babylon.d.txt 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  160. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Checks if the navigator object exists
  282. * @returns true if the navigator object exists
  283. */
  284. static IsNavigatorAvailable(): boolean;
  285. /**
  286. * Extracts text content from a DOM element hierarchy
  287. * @param element defines the root element
  288. * @returns a string
  289. */
  290. static GetDOMTextContent(element: HTMLElement): string;
  291. }
  292. }
  293. declare module BABYLON {
  294. /**
  295. * Logger used througouht the application to allow configuration of
  296. * the log level required for the messages.
  297. */
  298. export class Logger {
  299. /**
  300. * No log
  301. */
  302. static readonly NoneLogLevel: number;
  303. /**
  304. * Only message logs
  305. */
  306. static readonly MessageLogLevel: number;
  307. /**
  308. * Only warning logs
  309. */
  310. static readonly WarningLogLevel: number;
  311. /**
  312. * Only error logs
  313. */
  314. static readonly ErrorLogLevel: number;
  315. /**
  316. * All logs
  317. */
  318. static readonly AllLogLevel: number;
  319. private static _LogCache;
  320. /**
  321. * Gets a value indicating the number of loading errors
  322. * @ignorenaming
  323. */
  324. static errorsCount: number;
  325. /**
  326. * Callback called when a new log is added
  327. */
  328. static OnNewCacheEntry: (entry: string) => void;
  329. private static _AddLogEntry;
  330. private static _FormatMessage;
  331. private static _LogDisabled;
  332. private static _LogEnabled;
  333. private static _WarnDisabled;
  334. private static _WarnEnabled;
  335. private static _ErrorDisabled;
  336. private static _ErrorEnabled;
  337. /**
  338. * Log a message to the console
  339. */
  340. static Log: (message: string) => void;
  341. /**
  342. * Write a warning message to the console
  343. */
  344. static Warn: (message: string) => void;
  345. /**
  346. * Write an error message to the console
  347. */
  348. static Error: (message: string) => void;
  349. /**
  350. * Gets current log cache (list of logs)
  351. */
  352. static readonly LogCache: string;
  353. /**
  354. * Clears the log cache
  355. */
  356. static ClearLogCache(): void;
  357. /**
  358. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  359. */
  360. static LogLevels: number;
  361. }
  362. }
  363. declare module BABYLON {
  364. /** @hidden */
  365. export class _TypeStore {
  366. /** @hidden */
  367. static RegisteredTypes: {
  368. [key: string]: Object;
  369. };
  370. /** @hidden */
  371. static GetClass(fqdn: string): any;
  372. }
  373. }
  374. declare module BABYLON {
  375. /**
  376. * Class containing a set of static utilities functions for deep copy.
  377. */
  378. export class DeepCopier {
  379. /**
  380. * Tries to copy an object by duplicating every property
  381. * @param source defines the source object
  382. * @param destination defines the target object
  383. * @param doNotCopyList defines a list of properties to avoid
  384. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  385. */
  386. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  387. }
  388. }
  389. declare module BABYLON {
  390. /**
  391. * Class containing a set of static utilities functions for precision date
  392. */
  393. export class PrecisionDate {
  394. /**
  395. * Gets either window.performance.now() if supported or Date.now() else
  396. */
  397. static readonly Now: number;
  398. }
  399. }
  400. declare module BABYLON {
  401. /** @hidden */
  402. export class _DevTools {
  403. static WarnImport(name: string): string;
  404. }
  405. }
  406. declare module BABYLON {
  407. /**
  408. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  409. */
  410. export class WebRequest {
  411. private _xhr;
  412. /**
  413. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  414. * i.e. when loading files, where the server/service expects an Authorization header
  415. */
  416. static CustomRequestHeaders: {
  417. [key: string]: string;
  418. };
  419. /**
  420. * Add callback functions in this array to update all the requests before they get sent to the network
  421. */
  422. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  423. private _injectCustomRequestHeaders;
  424. /**
  425. * Gets or sets a function to be called when loading progress changes
  426. */
  427. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  428. /**
  429. * Returns client's state
  430. */
  431. readonly readyState: number;
  432. /**
  433. * Returns client's status
  434. */
  435. readonly status: number;
  436. /**
  437. * Returns client's status as a text
  438. */
  439. readonly statusText: string;
  440. /**
  441. * Returns client's response
  442. */
  443. readonly response: any;
  444. /**
  445. * Returns client's response url
  446. */
  447. readonly responseURL: string;
  448. /**
  449. * Returns client's response as text
  450. */
  451. readonly responseText: string;
  452. /**
  453. * Gets or sets the expected response type
  454. */
  455. responseType: XMLHttpRequestResponseType;
  456. /** @hidden */
  457. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  458. /** @hidden */
  459. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  460. /**
  461. * Cancels any network activity
  462. */
  463. abort(): void;
  464. /**
  465. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  466. * @param body defines an optional request body
  467. */
  468. send(body?: Document | BodyInit | null): void;
  469. /**
  470. * Sets the request method, request URL
  471. * @param method defines the method to use (GET, POST, etc..)
  472. * @param url defines the url to connect with
  473. */
  474. open(method: string, url: string): void;
  475. }
  476. }
  477. declare module BABYLON {
  478. /**
  479. * File request interface
  480. */
  481. export interface IFileRequest {
  482. /**
  483. * Raised when the request is complete (success or error).
  484. */
  485. onCompleteObservable: Observable<IFileRequest>;
  486. /**
  487. * Aborts the request for a file.
  488. */
  489. abort: () => void;
  490. }
  491. }
  492. declare module BABYLON {
  493. /**
  494. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  495. */
  496. export class PerformanceMonitor {
  497. private _enabled;
  498. private _rollingFrameTime;
  499. private _lastFrameTimeMs;
  500. /**
  501. * constructor
  502. * @param frameSampleSize The number of samples required to saturate the sliding window
  503. */
  504. constructor(frameSampleSize?: number);
  505. /**
  506. * Samples current frame
  507. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  508. */
  509. sampleFrame(timeMs?: number): void;
  510. /**
  511. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTime: number;
  514. /**
  515. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  516. */
  517. readonly averageFrameTimeVariance: number;
  518. /**
  519. * Returns the frame time of the most recent frame
  520. */
  521. readonly instantaneousFrameTime: number;
  522. /**
  523. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  524. */
  525. readonly averageFPS: number;
  526. /**
  527. * Returns the average framerate in frames per second using the most recent frame time
  528. */
  529. readonly instantaneousFPS: number;
  530. /**
  531. * Returns true if enough samples have been taken to completely fill the sliding window
  532. */
  533. readonly isSaturated: boolean;
  534. /**
  535. * Enables contributions to the sliding window sample set
  536. */
  537. enable(): void;
  538. /**
  539. * Disables contributions to the sliding window sample set
  540. * Samples will not be interpolated over the disabled period
  541. */
  542. disable(): void;
  543. /**
  544. * Returns true if sampling is enabled
  545. */
  546. readonly isEnabled: boolean;
  547. /**
  548. * Resets performance monitor
  549. */
  550. reset(): void;
  551. }
  552. /**
  553. * RollingAverage
  554. *
  555. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  556. */
  557. export class RollingAverage {
  558. /**
  559. * Current average
  560. */
  561. average: number;
  562. /**
  563. * Current variance
  564. */
  565. variance: number;
  566. protected _samples: Array<number>;
  567. protected _sampleCount: number;
  568. protected _pos: number;
  569. protected _m2: number;
  570. /**
  571. * constructor
  572. * @param length The number of samples required to saturate the sliding window
  573. */
  574. constructor(length: number);
  575. /**
  576. * Adds a sample to the sample set
  577. * @param v The sample value
  578. */
  579. add(v: number): void;
  580. /**
  581. * Returns previously added values or null if outside of history or outside the sliding window domain
  582. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  583. * @return Value previously recorded with add() or null if outside of range
  584. */
  585. history(i: number): number;
  586. /**
  587. * Returns true if enough samples have been taken to completely fill the sliding window
  588. * @return true if sample-set saturated
  589. */
  590. isSaturated(): boolean;
  591. /**
  592. * Resets the rolling average (equivalent to 0 samples taken so far)
  593. */
  594. reset(): void;
  595. /**
  596. * Wraps a value around the sample range boundaries
  597. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  598. * @return Wrapped position in sample range
  599. */
  600. protected _wrapPosition(i: number): number;
  601. }
  602. }
  603. declare module BABYLON {
  604. /**
  605. * This class implement a typical dictionary using a string as key and the generic type T as value.
  606. * The underlying implementation relies on an associative array to ensure the best performances.
  607. * The value can be anything including 'null' but except 'undefined'
  608. */
  609. export class StringDictionary<T> {
  610. /**
  611. * This will clear this dictionary and copy the content from the 'source' one.
  612. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  613. * @param source the dictionary to take the content from and copy to this dictionary
  614. */
  615. copyFrom(source: StringDictionary<T>): void;
  616. /**
  617. * Get a value based from its key
  618. * @param key the given key to get the matching value from
  619. * @return the value if found, otherwise undefined is returned
  620. */
  621. get(key: string): T | undefined;
  622. /**
  623. * Get a value from its key or add it if it doesn't exist.
  624. * This method will ensure you that a given key/data will be present in the dictionary.
  625. * @param key the given key to get the matching value from
  626. * @param factory the factory that will create the value if the key is not present in the dictionary.
  627. * The factory will only be invoked if there's no data for the given key.
  628. * @return the value corresponding to the key.
  629. */
  630. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  631. /**
  632. * Get a value from its key if present in the dictionary otherwise add it
  633. * @param key the key to get the value from
  634. * @param val if there's no such key/value pair in the dictionary add it with this value
  635. * @return the value corresponding to the key
  636. */
  637. getOrAdd(key: string, val: T): T;
  638. /**
  639. * Check if there's a given key in the dictionary
  640. * @param key the key to check for
  641. * @return true if the key is present, false otherwise
  642. */
  643. contains(key: string): boolean;
  644. /**
  645. * Add a new key and its corresponding value
  646. * @param key the key to add
  647. * @param value the value corresponding to the key
  648. * @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
  649. */
  650. add(key: string, value: T): boolean;
  651. /**
  652. * Update a specific value associated to a key
  653. * @param key defines the key to use
  654. * @param value defines the value to store
  655. * @returns true if the value was updated (or false if the key was not found)
  656. */
  657. set(key: string, value: T): boolean;
  658. /**
  659. * Get the element of the given key and remove it from the dictionary
  660. * @param key defines the key to search
  661. * @returns the value associated with the key or null if not found
  662. */
  663. getAndRemove(key: string): Nullable<T>;
  664. /**
  665. * Remove a key/value from the dictionary.
  666. * @param key the key to remove
  667. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  668. */
  669. remove(key: string): boolean;
  670. /**
  671. * Clear the whole content of the dictionary
  672. */
  673. clear(): void;
  674. /**
  675. * Gets the current count
  676. */
  677. readonly count: number;
  678. /**
  679. * Execute a callback on each key/val of the dictionary.
  680. * Note that you can remove any element in this dictionary in the callback implementation
  681. * @param callback the callback to execute on a given key/value pair
  682. */
  683. forEach(callback: (key: string, val: T) => void): void;
  684. /**
  685. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  686. * If the callback returns null or undefined the method will iterate to the next key/value pair
  687. * Note that you can remove any element in this dictionary in the callback implementation
  688. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  689. * @returns the first item
  690. */
  691. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  692. private _count;
  693. private _data;
  694. }
  695. }
  696. declare module BABYLON {
  697. /**
  698. * Class used to store gfx data (like WebGLBuffer)
  699. */
  700. export class DataBuffer {
  701. /**
  702. * Gets or sets the number of objects referencing this buffer
  703. */
  704. references: number;
  705. /** Gets or sets the size of the underlying buffer */
  706. capacity: number;
  707. /**
  708. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  709. */
  710. is32Bits: boolean;
  711. /**
  712. * Gets the underlying buffer
  713. */
  714. readonly underlyingResource: any;
  715. }
  716. }
  717. declare module BABYLON {
  718. /**
  719. * Class used to store data that will be store in GPU memory
  720. */
  721. export class Buffer {
  722. private _engine;
  723. private _buffer;
  724. /** @hidden */ private _data: Nullable<DataArray>;
  725. private _updatable;
  726. private _instanced;
  727. /**
  728. * Gets the byte stride.
  729. */
  730. readonly byteStride: number;
  731. /**
  732. * Constructor
  733. * @param engine the engine
  734. * @param data the data to use for this buffer
  735. * @param updatable whether the data is updatable
  736. * @param stride the stride (optional)
  737. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  738. * @param instanced whether the buffer is instanced (optional)
  739. * @param useBytes set to true if the stride in in bytes (optional)
  740. */
  741. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  742. /**
  743. * Create a new VertexBuffer based on the current buffer
  744. * @param kind defines the vertex buffer kind (position, normal, etc.)
  745. * @param offset defines offset in the buffer (0 by default)
  746. * @param size defines the size in floats of attributes (position is 3 for instance)
  747. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  748. * @param instanced defines if the vertex buffer contains indexed data
  749. * @param useBytes defines if the offset and stride are in bytes
  750. * @returns the new vertex buffer
  751. */
  752. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  753. /**
  754. * Gets a boolean indicating if the Buffer is updatable?
  755. * @returns true if the buffer is updatable
  756. */
  757. isUpdatable(): boolean;
  758. /**
  759. * Gets current buffer's data
  760. * @returns a DataArray or null
  761. */
  762. getData(): Nullable<DataArray>;
  763. /**
  764. * Gets underlying native buffer
  765. * @returns underlying native buffer
  766. */
  767. getBuffer(): Nullable<DataBuffer>;
  768. /**
  769. * Gets the stride in float32 units (i.e. byte stride / 4).
  770. * May not be an integer if the byte stride is not divisible by 4.
  771. * DEPRECATED. Use byteStride instead.
  772. * @returns the stride in float32 units
  773. */
  774. getStrideSize(): number;
  775. /**
  776. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  777. * @param data defines the data to store
  778. */
  779. create(data?: Nullable<DataArray>): void;
  780. /** @hidden */ private _rebuild(): void;
  781. /**
  782. * Update current buffer data
  783. * @param data defines the data to store
  784. */
  785. update(data: DataArray): void;
  786. /**
  787. * Updates the data directly.
  788. * @param data the new data
  789. * @param offset the new offset
  790. * @param vertexCount the vertex count (optional)
  791. * @param useBytes set to true if the offset is in bytes
  792. */
  793. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  794. /**
  795. * Release all resources
  796. */
  797. dispose(): void;
  798. }
  799. /**
  800. * Specialized buffer used to store vertex data
  801. */
  802. export class VertexBuffer {
  803. /** @hidden */ private _buffer: Buffer;
  804. private _kind;
  805. private _size;
  806. private _ownsBuffer;
  807. private _instanced;
  808. private _instanceDivisor;
  809. /**
  810. * The byte type.
  811. */
  812. static readonly BYTE: number;
  813. /**
  814. * The unsigned byte type.
  815. */
  816. static readonly UNSIGNED_BYTE: number;
  817. /**
  818. * The short type.
  819. */
  820. static readonly SHORT: number;
  821. /**
  822. * The unsigned short type.
  823. */
  824. static readonly UNSIGNED_SHORT: number;
  825. /**
  826. * The integer type.
  827. */
  828. static readonly INT: number;
  829. /**
  830. * The unsigned integer type.
  831. */
  832. static readonly UNSIGNED_INT: number;
  833. /**
  834. * The float type.
  835. */
  836. static readonly FLOAT: number;
  837. /**
  838. * Gets or sets the instance divisor when in instanced mode
  839. */
  840. instanceDivisor: number;
  841. /**
  842. * Gets the byte stride.
  843. */
  844. readonly byteStride: number;
  845. /**
  846. * Gets the byte offset.
  847. */
  848. readonly byteOffset: number;
  849. /**
  850. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  851. */
  852. readonly normalized: boolean;
  853. /**
  854. * Gets the data type of each component in the array.
  855. */
  856. readonly type: number;
  857. /**
  858. * Constructor
  859. * @param engine the engine
  860. * @param data the data to use for this vertex buffer
  861. * @param kind the vertex buffer kind
  862. * @param updatable whether the data is updatable
  863. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  864. * @param stride the stride (optional)
  865. * @param instanced whether the buffer is instanced (optional)
  866. * @param offset the offset of the data (optional)
  867. * @param size the number of components (optional)
  868. * @param type the type of the component (optional)
  869. * @param normalized whether the data contains normalized data (optional)
  870. * @param useBytes set to true if stride and offset are in bytes (optional)
  871. */
  872. 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);
  873. /** @hidden */ private _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2379. /**
  2380. * Unproject from screen space to object space
  2381. * @param source defines the screen space Vector3 to use
  2382. * @param viewportWidth defines the current width of the viewport
  2383. * @param viewportHeight defines the current height of the viewport
  2384. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2385. * @param transform defines the transform (view x projection) matrix to use
  2386. * @returns the new Vector3
  2387. */
  2388. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2389. /**
  2390. * Unproject from screen space to object space
  2391. * @param source defines the screen space Vector3 to use
  2392. * @param viewportWidth defines the current width of the viewport
  2393. * @param viewportHeight defines the current height of the viewport
  2394. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2395. * @param view defines the view matrix to use
  2396. * @param projection defines the projection matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @param result defines the Vector3 where to store the result
  2409. */
  2410. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param sourceX defines the screen space x coordinate to use
  2414. * @param sourceY defines the screen space y coordinate to use
  2415. * @param sourceZ defines the screen space z coordinate to use
  2416. * @param viewportWidth defines the current width of the viewport
  2417. * @param viewportHeight defines the current height of the viewport
  2418. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2419. * @param view defines the view matrix to use
  2420. * @param projection defines the projection matrix to use
  2421. * @param result defines the Vector3 where to store the result
  2422. */
  2423. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2424. /**
  2425. * Gets the minimal coordinate values between two Vector3
  2426. * @param left defines the first operand
  2427. * @param right defines the second operand
  2428. * @returns the new Vector3
  2429. */
  2430. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Gets the maximal coordinate values between two Vector3
  2433. * @param left defines the first operand
  2434. * @param right defines the second operand
  2435. * @returns the new Vector3
  2436. */
  2437. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2438. /**
  2439. * Returns the distance between the vectors "value1" and "value2"
  2440. * @param value1 defines the first operand
  2441. * @param value2 defines the second operand
  2442. * @returns the distance
  2443. */
  2444. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2445. /**
  2446. * Returns the squared distance between the vectors "value1" and "value2"
  2447. * @param value1 defines the first operand
  2448. * @param value2 defines the second operand
  2449. * @returns the squared distance
  2450. */
  2451. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2452. /**
  2453. * Returns a new Vector3 located at the center between "value1" and "value2"
  2454. * @param value1 defines the first operand
  2455. * @param value2 defines the second operand
  2456. * @returns the new Vector3
  2457. */
  2458. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2459. /**
  2460. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2461. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2462. * to something in order to rotate it from its local system to the given target system
  2463. * Note: axis1, axis2 and axis3 are normalized during this operation
  2464. * @param axis1 defines the first axis
  2465. * @param axis2 defines the second axis
  2466. * @param axis3 defines the third axis
  2467. * @returns a new Vector3
  2468. */
  2469. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2472. * @param axis1 defines the first axis
  2473. * @param axis2 defines the second axis
  2474. * @param axis3 defines the third axis
  2475. * @param ref defines the Vector3 where to store the result
  2476. */
  2477. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2478. }
  2479. /**
  2480. * Vector4 class created for EulerAngle class conversion to Quaternion
  2481. */
  2482. export class Vector4 {
  2483. /** x value of the vector */
  2484. x: number;
  2485. /** y value of the vector */
  2486. y: number;
  2487. /** z value of the vector */
  2488. z: number;
  2489. /** w value of the vector */
  2490. w: number;
  2491. /**
  2492. * Creates a Vector4 object from the given floats.
  2493. * @param x x value of the vector
  2494. * @param y y value of the vector
  2495. * @param z z value of the vector
  2496. * @param w w value of the vector
  2497. */
  2498. constructor(
  2499. /** x value of the vector */
  2500. x: number,
  2501. /** y value of the vector */
  2502. y: number,
  2503. /** z value of the vector */
  2504. z: number,
  2505. /** w value of the vector */
  2506. w: number);
  2507. /**
  2508. * Returns the string with the Vector4 coordinates.
  2509. * @returns a string containing all the vector values
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Returns the string "Vector4".
  2514. * @returns "Vector4"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Returns the Vector4 hash code.
  2519. * @returns a unique hash code
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2524. * @returns the resulting array
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array from the given index with the Vector4 coordinates.
  2529. * @param array array to populate
  2530. * @param index index of the array to start at (default: 0)
  2531. * @returns the Vector4.
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector4;
  2534. /**
  2535. * Adds the given vector to the current Vector4.
  2536. * @param otherVector the vector to add
  2537. * @returns the updated Vector4.
  2538. */
  2539. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2540. /**
  2541. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2542. * @param otherVector the vector to add
  2543. * @returns the resulting vector
  2544. */
  2545. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2546. /**
  2547. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2548. * @param otherVector the vector to add
  2549. * @param result the vector to store the result
  2550. * @returns the current Vector4.
  2551. */
  2552. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2553. /**
  2554. * Subtract in place the given vector from the current Vector4.
  2555. * @param otherVector the vector to subtract
  2556. * @returns the updated Vector4.
  2557. */
  2558. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2559. /**
  2560. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2561. * @param otherVector the vector to add
  2562. * @returns the new vector with the result
  2563. */
  2564. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2567. * @param otherVector the vector to subtract
  2568. * @param result the vector to store the result
  2569. * @returns the current Vector4.
  2570. */
  2571. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2572. /**
  2573. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2574. */
  2575. /**
  2576. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2577. * @param x value to subtract
  2578. * @param y value to subtract
  2579. * @param z value to subtract
  2580. * @param w value to subtract
  2581. * @returns new vector containing the result
  2582. */
  2583. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2584. /**
  2585. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2586. * @param x value to subtract
  2587. * @param y value to subtract
  2588. * @param z value to subtract
  2589. * @param w value to subtract
  2590. * @param result the vector to store the result in
  2591. * @returns the current Vector4.
  2592. */
  2593. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2594. /**
  2595. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2596. * @returns a new vector with the negated values
  2597. */
  2598. negate(): Vector4;
  2599. /**
  2600. * Multiplies the current Vector4 coordinates by scale (float).
  2601. * @param scale the number to scale with
  2602. * @returns the updated Vector4.
  2603. */
  2604. scaleInPlace(scale: number): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2607. * @param scale the number to scale with
  2608. * @returns a new vector with the result
  2609. */
  2610. scale(scale: number): Vector4;
  2611. /**
  2612. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2613. * @param scale the number to scale with
  2614. * @param result a vector to store the result in
  2615. * @returns the current Vector4.
  2616. */
  2617. scaleToRef(scale: number, result: Vector4): Vector4;
  2618. /**
  2619. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2620. * @param scale defines the scale factor
  2621. * @param result defines the Vector4 object where to store the result
  2622. * @returns the unmodified current Vector4
  2623. */
  2624. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2625. /**
  2626. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2627. * @param otherVector the vector to compare against
  2628. * @returns true if they are equal
  2629. */
  2630. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2631. /**
  2632. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2633. * @param otherVector vector to compare against
  2634. * @param epsilon (Default: very small number)
  2635. * @returns true if they are equal
  2636. */
  2637. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2638. /**
  2639. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2640. * @param x x value to compare against
  2641. * @param y y value to compare against
  2642. * @param z z value to compare against
  2643. * @param w w value to compare against
  2644. * @returns true if equal
  2645. */
  2646. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2647. /**
  2648. * Multiplies in place the current Vector4 by the given one.
  2649. * @param otherVector vector to multiple with
  2650. * @returns the updated Vector4.
  2651. */
  2652. multiplyInPlace(otherVector: Vector4): Vector4;
  2653. /**
  2654. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2655. * @param otherVector vector to multiple with
  2656. * @returns resulting new vector
  2657. */
  2658. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2659. /**
  2660. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2661. * @param otherVector vector to multiple with
  2662. * @param result vector to store the result
  2663. * @returns the current Vector4.
  2664. */
  2665. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2666. /**
  2667. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2668. * @param x x value multiply with
  2669. * @param y y value multiply with
  2670. * @param z z value multiply with
  2671. * @param w w value multiply with
  2672. * @returns resulting new vector
  2673. */
  2674. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2675. /**
  2676. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2677. * @param otherVector vector to devide with
  2678. * @returns resulting new vector
  2679. */
  2680. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2681. /**
  2682. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2683. * @param otherVector vector to devide with
  2684. * @param result vector to store the result
  2685. * @returns the current Vector4.
  2686. */
  2687. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones.
  2690. * @param otherVector vector to devide with
  2691. * @returns the updated Vector3.
  2692. */
  2693. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2694. /**
  2695. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2696. * @param other defines the second operand
  2697. * @returns the current updated Vector4
  2698. */
  2699. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2700. /**
  2701. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2702. * @param other defines the second operand
  2703. * @returns the current updated Vector4
  2704. */
  2705. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2706. /**
  2707. * Gets a new Vector4 from current Vector4 floored values
  2708. * @returns a new Vector4
  2709. */
  2710. floor(): Vector4;
  2711. /**
  2712. * Gets a new Vector4 from current Vector3 floored values
  2713. * @returns a new Vector4
  2714. */
  2715. fract(): Vector4;
  2716. /**
  2717. * Returns the Vector4 length (float).
  2718. * @returns the length
  2719. */
  2720. length(): number;
  2721. /**
  2722. * Returns the Vector4 squared length (float).
  2723. * @returns the length squared
  2724. */
  2725. lengthSquared(): number;
  2726. /**
  2727. * Normalizes in place the Vector4.
  2728. * @returns the updated Vector4.
  2729. */
  2730. normalize(): Vector4;
  2731. /**
  2732. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2733. * @returns this converted to a new vector3
  2734. */
  2735. toVector3(): Vector3;
  2736. /**
  2737. * Returns a new Vector4 copied from the current one.
  2738. * @returns the new cloned vector
  2739. */
  2740. clone(): Vector4;
  2741. /**
  2742. * Updates the current Vector4 with the given one coordinates.
  2743. * @param source the source vector to copy from
  2744. * @returns the updated Vector4.
  2745. */
  2746. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2747. /**
  2748. * Updates the current Vector4 coordinates with the given floats.
  2749. * @param x float to copy from
  2750. * @param y float to copy from
  2751. * @param z float to copy from
  2752. * @param w float to copy from
  2753. * @returns the updated Vector4.
  2754. */
  2755. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2756. /**
  2757. * Updates the current Vector4 coordinates with the given floats.
  2758. * @param x float to set from
  2759. * @param y float to set from
  2760. * @param z float to set from
  2761. * @param w float to set from
  2762. * @returns the updated Vector4.
  2763. */
  2764. set(x: number, y: number, z: number, w: number): Vector4;
  2765. /**
  2766. * Copies the given float to the current Vector3 coordinates
  2767. * @param v defines the x, y, z and w coordinates of the operand
  2768. * @returns the current updated Vector3
  2769. */
  2770. setAll(v: number): Vector4;
  2771. /**
  2772. * Returns a new Vector4 set from the starting index of the given array.
  2773. * @param array the array to pull values from
  2774. * @param offset the offset into the array to start at
  2775. * @returns the new vector
  2776. */
  2777. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2778. /**
  2779. * Updates the given vector "result" from the starting index of the given array.
  2780. * @param array the array to pull values from
  2781. * @param offset the offset into the array to start at
  2782. * @param result the vector to store the result in
  2783. */
  2784. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2785. /**
  2786. * Updates the given vector "result" from the starting index of the given Float32Array.
  2787. * @param array the array to pull values from
  2788. * @param offset the offset into the array to start at
  2789. * @param result the vector to store the result in
  2790. */
  2791. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2792. /**
  2793. * Updates the given vector "result" coordinates from the given floats.
  2794. * @param x float to set from
  2795. * @param y float to set from
  2796. * @param z float to set from
  2797. * @param w float to set from
  2798. * @param result the vector to the floats in
  2799. */
  2800. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2801. /**
  2802. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2803. * @returns the new vector
  2804. */
  2805. static Zero(): Vector4;
  2806. /**
  2807. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2808. * @returns the new vector
  2809. */
  2810. static One(): Vector4;
  2811. /**
  2812. * Returns a new normalized Vector4 from the given one.
  2813. * @param vector the vector to normalize
  2814. * @returns the vector
  2815. */
  2816. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2817. /**
  2818. * Updates the given vector "result" from the normalization of the given one.
  2819. * @param vector the vector to normalize
  2820. * @param result the vector to store the result in
  2821. */
  2822. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2823. /**
  2824. * Returns a vector with the minimum values from the left and right vectors
  2825. * @param left left vector to minimize
  2826. * @param right right vector to minimize
  2827. * @returns a new vector with the minimum of the left and right vector values
  2828. */
  2829. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2830. /**
  2831. * Returns a vector with the maximum values from the left and right vectors
  2832. * @param left left vector to maximize
  2833. * @param right right vector to maximize
  2834. * @returns a new vector with the maximum of the left and right vector values
  2835. */
  2836. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2837. /**
  2838. * Returns the distance (float) between the vectors "value1" and "value2".
  2839. * @param value1 value to calulate the distance between
  2840. * @param value2 value to calulate the distance between
  2841. * @return the distance between the two vectors
  2842. */
  2843. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2844. /**
  2845. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2846. * @param value1 value to calulate the distance between
  2847. * @param value2 value to calulate the distance between
  2848. * @return the distance between the two vectors squared
  2849. */
  2850. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2851. /**
  2852. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2853. * @param value1 value to calulate the center between
  2854. * @param value2 value to calulate the center between
  2855. * @return the center between the two vectors
  2856. */
  2857. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2858. /**
  2859. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2860. * This methods computes transformed normalized direction vectors only.
  2861. * @param vector the vector to transform
  2862. * @param transformation the transformation matrix to apply
  2863. * @returns the new vector
  2864. */
  2865. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2866. /**
  2867. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2868. * This methods computes transformed normalized direction vectors only.
  2869. * @param vector the vector to transform
  2870. * @param transformation the transformation matrix to apply
  2871. * @param result the vector to store the result in
  2872. */
  2873. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2874. /**
  2875. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2876. * This methods computes transformed normalized direction vectors only.
  2877. * @param x value to transform
  2878. * @param y value to transform
  2879. * @param z value to transform
  2880. * @param w value to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the results in
  2883. */
  2884. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Creates a new Vector4 from a Vector3
  2887. * @param source defines the source data
  2888. * @param w defines the 4th component (default is 0)
  2889. * @returns a new Vector4
  2890. */
  2891. static FromVector3(source: Vector3, w?: number): Vector4;
  2892. }
  2893. /**
  2894. * Class used to store quaternion data
  2895. * @see https://en.wikipedia.org/wiki/Quaternion
  2896. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2897. */
  2898. export class Quaternion {
  2899. /** defines the first component (0 by default) */
  2900. x: number;
  2901. /** defines the second component (0 by default) */
  2902. y: number;
  2903. /** defines the third component (0 by default) */
  2904. z: number;
  2905. /** defines the fourth component (1.0 by default) */
  2906. w: number;
  2907. /**
  2908. * Creates a new Quaternion from the given floats
  2909. * @param x defines the first component (0 by default)
  2910. * @param y defines the second component (0 by default)
  2911. * @param z defines the third component (0 by default)
  2912. * @param w defines the fourth component (1.0 by default)
  2913. */
  2914. constructor(
  2915. /** defines the first component (0 by default) */
  2916. x?: number,
  2917. /** defines the second component (0 by default) */
  2918. y?: number,
  2919. /** defines the third component (0 by default) */
  2920. z?: number,
  2921. /** defines the fourth component (1.0 by default) */
  2922. w?: number);
  2923. /**
  2924. * Gets a string representation for the current quaternion
  2925. * @returns a string with the Quaternion coordinates
  2926. */
  2927. toString(): string;
  2928. /**
  2929. * Gets the class name of the quaternion
  2930. * @returns the string "Quaternion"
  2931. */
  2932. getClassName(): string;
  2933. /**
  2934. * Gets a hash code for this quaternion
  2935. * @returns the quaternion hash code
  2936. */
  2937. getHashCode(): number;
  2938. /**
  2939. * Copy the quaternion to an array
  2940. * @returns a new array populated with 4 elements from the quaternion coordinates
  2941. */
  2942. asArray(): number[];
  2943. /**
  2944. * Check if two quaternions are equals
  2945. * @param otherQuaternion defines the second operand
  2946. * @return true if the current quaternion and the given one coordinates are strictly equals
  2947. */
  2948. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2949. /**
  2950. * Clone the current quaternion
  2951. * @returns a new quaternion copied from the current one
  2952. */
  2953. clone(): Quaternion;
  2954. /**
  2955. * Copy a quaternion to the current one
  2956. * @param other defines the other quaternion
  2957. * @returns the updated current quaternion
  2958. */
  2959. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2960. /**
  2961. * Updates the current quaternion with the given float coordinates
  2962. * @param x defines the x coordinate
  2963. * @param y defines the y coordinate
  2964. * @param z defines the z coordinate
  2965. * @param w defines the w coordinate
  2966. * @returns the updated current quaternion
  2967. */
  2968. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2969. /**
  2970. * Updates the current quaternion from the given float coordinates
  2971. * @param x defines the x coordinate
  2972. * @param y defines the y coordinate
  2973. * @param z defines the z coordinate
  2974. * @param w defines the w coordinate
  2975. * @returns the updated current quaternion
  2976. */
  2977. set(x: number, y: number, z: number, w: number): Quaternion;
  2978. /**
  2979. * Adds two quaternions
  2980. * @param other defines the second operand
  2981. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2982. */
  2983. add(other: DeepImmutable<Quaternion>): Quaternion;
  2984. /**
  2985. * Add a quaternion to the current one
  2986. * @param other defines the quaternion to add
  2987. * @returns the current quaternion
  2988. */
  2989. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2990. /**
  2991. * Subtract two quaternions
  2992. * @param other defines the second operand
  2993. * @returns a new quaternion as the subtraction result of the given one from the current one
  2994. */
  2995. subtract(other: Quaternion): Quaternion;
  2996. /**
  2997. * Multiplies the current quaternion by a scale factor
  2998. * @param value defines the scale factor
  2999. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3000. */
  3001. scale(value: number): Quaternion;
  3002. /**
  3003. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3004. * @param scale defines the scale factor
  3005. * @param result defines the Quaternion object where to store the result
  3006. * @returns the unmodified current quaternion
  3007. */
  3008. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3009. /**
  3010. * Multiplies in place the current quaternion by a scale factor
  3011. * @param value defines the scale factor
  3012. * @returns the current modified quaternion
  3013. */
  3014. scaleInPlace(value: number): Quaternion;
  3015. /**
  3016. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3017. * @param scale defines the scale factor
  3018. * @param result defines the Quaternion object where to store the result
  3019. * @returns the unmodified current quaternion
  3020. */
  3021. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3022. /**
  3023. * Multiplies two quaternions
  3024. * @param q1 defines the second operand
  3025. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3026. */
  3027. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3028. /**
  3029. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3030. * @param q1 defines the second operand
  3031. * @param result defines the target quaternion
  3032. * @returns the current quaternion
  3033. */
  3034. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3035. /**
  3036. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3037. * @param q1 defines the second operand
  3038. * @returns the currentupdated quaternion
  3039. */
  3040. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3041. /**
  3042. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3043. * @param ref defines the target quaternion
  3044. * @returns the current quaternion
  3045. */
  3046. conjugateToRef(ref: Quaternion): Quaternion;
  3047. /**
  3048. * Conjugates in place (1-q) the current quaternion
  3049. * @returns the current updated quaternion
  3050. */
  3051. conjugateInPlace(): Quaternion;
  3052. /**
  3053. * Conjugates in place (1-q) the current quaternion
  3054. * @returns a new quaternion
  3055. */
  3056. conjugate(): Quaternion;
  3057. /**
  3058. * Gets length of current quaternion
  3059. * @returns the quaternion length (float)
  3060. */
  3061. length(): number;
  3062. /**
  3063. * Normalize in place the current quaternion
  3064. * @returns the current updated quaternion
  3065. */
  3066. normalize(): Quaternion;
  3067. /**
  3068. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3069. * @param order is a reserved parameter and is ignore for now
  3070. * @returns a new Vector3 containing the Euler angles
  3071. */
  3072. toEulerAngles(order?: string): Vector3;
  3073. /**
  3074. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3075. * @param result defines the vector which will be filled with the Euler angles
  3076. * @param order is a reserved parameter and is ignore for now
  3077. * @returns the current unchanged quaternion
  3078. */
  3079. toEulerAnglesToRef(result: Vector3): Quaternion;
  3080. /**
  3081. * Updates the given rotation matrix with the current quaternion values
  3082. * @param result defines the target matrix
  3083. * @returns the current unchanged quaternion
  3084. */
  3085. toRotationMatrix(result: Matrix): Quaternion;
  3086. /**
  3087. * Updates the current quaternion from the given rotation matrix values
  3088. * @param matrix defines the source matrix
  3089. * @returns the current updated quaternion
  3090. */
  3091. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3092. /**
  3093. * Creates a new quaternion from a rotation matrix
  3094. * @param matrix defines the source matrix
  3095. * @returns a new quaternion created from the given rotation matrix values
  3096. */
  3097. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3098. /**
  3099. * Updates the given quaternion with the given rotation matrix values
  3100. * @param matrix defines the source matrix
  3101. * @param result defines the target quaternion
  3102. */
  3103. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3104. /**
  3105. * Returns the dot product (float) between the quaternions "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the dot product
  3109. */
  3110. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3111. /**
  3112. * Checks if the two quaternions are close to each other
  3113. * @param quat0 defines the first quaternion to check
  3114. * @param quat1 defines the second quaternion to check
  3115. * @returns true if the two quaternions are close to each other
  3116. */
  3117. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3118. /**
  3119. * Creates an empty quaternion
  3120. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3121. */
  3122. static Zero(): Quaternion;
  3123. /**
  3124. * Inverse a given quaternion
  3125. * @param q defines the source quaternion
  3126. * @returns a new quaternion as the inverted current quaternion
  3127. */
  3128. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3129. /**
  3130. * Inverse a given quaternion
  3131. * @param q defines the source quaternion
  3132. * @param result the quaternion the result will be stored in
  3133. * @returns the result quaternion
  3134. */
  3135. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3136. /**
  3137. * Creates an identity quaternion
  3138. * @returns the identity quaternion
  3139. */
  3140. static Identity(): Quaternion;
  3141. /**
  3142. * Gets a boolean indicating if the given quaternion is identity
  3143. * @param quaternion defines the quaternion to check
  3144. * @returns true if the quaternion is identity
  3145. */
  3146. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3147. /**
  3148. * Creates a quaternion from a rotation around an axis
  3149. * @param axis defines the axis to use
  3150. * @param angle defines the angle to use
  3151. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3152. */
  3153. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3154. /**
  3155. * Creates a rotation around an axis and stores it into the given quaternion
  3156. * @param axis defines the axis to use
  3157. * @param angle defines the angle to use
  3158. * @param result defines the target quaternion
  3159. * @returns the target quaternion
  3160. */
  3161. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3162. /**
  3163. * Creates a new quaternion from data stored into an array
  3164. * @param array defines the data source
  3165. * @param offset defines the offset in the source array where the data starts
  3166. * @returns a new quaternion
  3167. */
  3168. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3169. /**
  3170. * Create a quaternion from Euler rotation angles
  3171. * @param x Pitch
  3172. * @param y Yaw
  3173. * @param z Roll
  3174. * @returns the new Quaternion
  3175. */
  3176. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3177. /**
  3178. * Updates a quaternion from Euler rotation angles
  3179. * @param x Pitch
  3180. * @param y Yaw
  3181. * @param z Roll
  3182. * @param result the quaternion to store the result
  3183. * @returns the updated quaternion
  3184. */
  3185. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3186. /**
  3187. * Create a quaternion from Euler rotation vector
  3188. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3189. * @returns the new Quaternion
  3190. */
  3191. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3192. /**
  3193. * Updates a quaternion from Euler rotation vector
  3194. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3195. * @param result the quaternion to store the result
  3196. * @returns the updated quaternion
  3197. */
  3198. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3199. /**
  3200. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3201. * @param yaw defines the rotation around Y axis
  3202. * @param pitch defines the rotation around X axis
  3203. * @param roll defines the rotation around Z axis
  3204. * @returns the new quaternion
  3205. */
  3206. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3207. /**
  3208. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3209. * @param yaw defines the rotation around Y axis
  3210. * @param pitch defines the rotation around X axis
  3211. * @param roll defines the rotation around Z axis
  3212. * @param result defines the target quaternion
  3213. */
  3214. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3215. /**
  3216. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3217. * @param alpha defines the rotation around first axis
  3218. * @param beta defines the rotation around second axis
  3219. * @param gamma defines the rotation around third axis
  3220. * @returns the new quaternion
  3221. */
  3222. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3223. /**
  3224. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3225. * @param alpha defines the rotation around first axis
  3226. * @param beta defines the rotation around second axis
  3227. * @param gamma defines the rotation around third axis
  3228. * @param result defines the target quaternion
  3229. */
  3230. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3231. /**
  3232. * 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)
  3233. * @param axis1 defines the first axis
  3234. * @param axis2 defines the second axis
  3235. * @param axis3 defines the third axis
  3236. * @returns the new quaternion
  3237. */
  3238. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3239. /**
  3240. * 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
  3241. * @param axis1 defines the first axis
  3242. * @param axis2 defines the second axis
  3243. * @param axis3 defines the third axis
  3244. * @param ref defines the target quaternion
  3245. */
  3246. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3247. /**
  3248. * Interpolates between two quaternions
  3249. * @param left defines first quaternion
  3250. * @param right defines second quaternion
  3251. * @param amount defines the gradient to use
  3252. * @returns the new interpolated quaternion
  3253. */
  3254. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3255. /**
  3256. * Interpolates between two quaternions and stores it into a target quaternion
  3257. * @param left defines first quaternion
  3258. * @param right defines second quaternion
  3259. * @param amount defines the gradient to use
  3260. * @param result defines the target quaternion
  3261. */
  3262. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3263. /**
  3264. * Interpolate between two quaternions using Hermite interpolation
  3265. * @param value1 defines first quaternion
  3266. * @param tangent1 defines the incoming tangent
  3267. * @param value2 defines second quaternion
  3268. * @param tangent2 defines the outgoing tangent
  3269. * @param amount defines the target quaternion
  3270. * @returns the new interpolated quaternion
  3271. */
  3272. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3273. }
  3274. /**
  3275. * Class used to store matrix data (4x4)
  3276. */
  3277. export class Matrix {
  3278. private static _updateFlagSeed;
  3279. private static _identityReadOnly;
  3280. private _isIdentity;
  3281. private _isIdentityDirty;
  3282. private _isIdentity3x2;
  3283. private _isIdentity3x2Dirty;
  3284. /**
  3285. * Gets the update flag of the matrix which is an unique number for the matrix.
  3286. * It will be incremented every time the matrix data change.
  3287. * You can use it to speed the comparison between two versions of the same matrix.
  3288. */
  3289. updateFlag: number;
  3290. private readonly _m;
  3291. /**
  3292. * Gets the internal data of the matrix
  3293. */
  3294. readonly m: DeepImmutable<Float32Array>;
  3295. /** @hidden */ private _markAsUpdated(): void;
  3296. /** @hidden */
  3297. private _updateIdentityStatus;
  3298. /**
  3299. * Creates an empty matrix (filled with zeros)
  3300. */
  3301. constructor();
  3302. /**
  3303. * Check if the current matrix is identity
  3304. * @returns true is the matrix is the identity matrix
  3305. */
  3306. isIdentity(): boolean;
  3307. /**
  3308. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3309. * @returns true is the matrix is the identity matrix
  3310. */
  3311. isIdentityAs3x2(): boolean;
  3312. /**
  3313. * Gets the determinant of the matrix
  3314. * @returns the matrix determinant
  3315. */
  3316. determinant(): number;
  3317. /**
  3318. * Returns the matrix as a Float32Array
  3319. * @returns the matrix underlying array
  3320. */
  3321. toArray(): DeepImmutable<Float32Array>;
  3322. /**
  3323. * Returns the matrix as a Float32Array
  3324. * @returns the matrix underlying array.
  3325. */
  3326. asArray(): DeepImmutable<Float32Array>;
  3327. /**
  3328. * Inverts the current matrix in place
  3329. * @returns the current inverted matrix
  3330. */
  3331. invert(): Matrix;
  3332. /**
  3333. * Sets all the matrix elements to zero
  3334. * @returns the current matrix
  3335. */
  3336. reset(): Matrix;
  3337. /**
  3338. * Adds the current matrix with a second one
  3339. * @param other defines the matrix to add
  3340. * @returns a new matrix as the addition of the current matrix and the given one
  3341. */
  3342. add(other: DeepImmutable<Matrix>): Matrix;
  3343. /**
  3344. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3345. * @param other defines the matrix to add
  3346. * @param result defines the target matrix
  3347. * @returns the current matrix
  3348. */
  3349. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3350. /**
  3351. * Adds in place the given matrix to the current matrix
  3352. * @param other defines the second operand
  3353. * @returns the current updated matrix
  3354. */
  3355. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3356. /**
  3357. * Sets the given matrix to the current inverted Matrix
  3358. * @param other defines the target matrix
  3359. * @returns the unmodified current matrix
  3360. */
  3361. invertToRef(other: Matrix): Matrix;
  3362. /**
  3363. * add a value at the specified position in the current Matrix
  3364. * @param index the index of the value within the matrix. between 0 and 15.
  3365. * @param value the value to be added
  3366. * @returns the current updated matrix
  3367. */
  3368. addAtIndex(index: number, value: number): Matrix;
  3369. /**
  3370. * mutiply the specified position in the current Matrix by a value
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. multiplyAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * Inserts the translation vector (using 3 floats) in the current matrix
  3378. * @param x defines the 1st component of the translation
  3379. * @param y defines the 2nd component of the translation
  3380. * @param z defines the 3rd component of the translation
  3381. * @returns the current updated matrix
  3382. */
  3383. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3384. /**
  3385. * Adds the translation vector (using 3 floats) in the current matrix
  3386. * @param x defines the 1st component of the translation
  3387. * @param y defines the 2nd component of the translation
  3388. * @param z defines the 3rd component of the translation
  3389. * @returns the current updated matrix
  3390. */
  3391. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3392. /**
  3393. * Inserts the translation vector in the current matrix
  3394. * @param vector3 defines the translation to insert
  3395. * @returns the current updated matrix
  3396. */
  3397. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3398. /**
  3399. * Gets the translation value of the current matrix
  3400. * @returns a new Vector3 as the extracted translation from the matrix
  3401. */
  3402. getTranslation(): Vector3;
  3403. /**
  3404. * Fill a Vector3 with the extracted translation from the matrix
  3405. * @param result defines the Vector3 where to store the translation
  3406. * @returns the current matrix
  3407. */
  3408. getTranslationToRef(result: Vector3): Matrix;
  3409. /**
  3410. * Remove rotation and scaling part from the matrix
  3411. * @returns the updated matrix
  3412. */
  3413. removeRotationAndScaling(): Matrix;
  3414. /**
  3415. * Multiply two matrices
  3416. * @param other defines the second operand
  3417. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3418. */
  3419. multiply(other: DeepImmutable<Matrix>): Matrix;
  3420. /**
  3421. * Copy the current matrix from the given one
  3422. * @param other defines the source matrix
  3423. * @returns the current updated matrix
  3424. */
  3425. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3426. /**
  3427. * Populates the given array from the starting index with the current matrix values
  3428. * @param array defines the target array
  3429. * @param offset defines the offset in the target array where to start storing values
  3430. * @returns the current matrix
  3431. */
  3432. copyToArray(array: Float32Array, offset?: number): Matrix;
  3433. /**
  3434. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3435. * @param other defines the second operand
  3436. * @param result defines the matrix where to store the multiplication
  3437. * @returns the current matrix
  3438. */
  3439. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3440. /**
  3441. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the array where to store the multiplication
  3444. * @param offset defines the offset in the target array where to start storing values
  3445. * @returns the current matrix
  3446. */
  3447. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3448. /**
  3449. * Check equality between this matrix and a second one
  3450. * @param value defines the second matrix to compare
  3451. * @returns true is the current matrix and the given one values are strictly equal
  3452. */
  3453. equals(value: DeepImmutable<Matrix>): boolean;
  3454. /**
  3455. * Clone the current matrix
  3456. * @returns a new matrix from the current matrix
  3457. */
  3458. clone(): Matrix;
  3459. /**
  3460. * Returns the name of the current matrix class
  3461. * @returns the string "Matrix"
  3462. */
  3463. getClassName(): string;
  3464. /**
  3465. * Gets the hash code of the current matrix
  3466. * @returns the hash code
  3467. */
  3468. getHashCode(): number;
  3469. /**
  3470. * Decomposes the current Matrix into a translation, rotation and scaling components
  3471. * @param scale defines the scale vector3 given as a reference to update
  3472. * @param rotation defines the rotation quaternion given as a reference to update
  3473. * @param translation defines the translation vector3 given as a reference to update
  3474. * @returns true if operation was successful
  3475. */
  3476. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3477. /**
  3478. * Gets specific row of the matrix
  3479. * @param index defines the number of the row to get
  3480. * @returns the index-th row of the current matrix as a new Vector4
  3481. */
  3482. getRow(index: number): Nullable<Vector4>;
  3483. /**
  3484. * Sets the index-th row of the current matrix to the vector4 values
  3485. * @param index defines the number of the row to set
  3486. * @param row defines the target vector4
  3487. * @returns the updated current matrix
  3488. */
  3489. setRow(index: number, row: Vector4): Matrix;
  3490. /**
  3491. * Compute the transpose of the matrix
  3492. * @returns the new transposed matrix
  3493. */
  3494. transpose(): Matrix;
  3495. /**
  3496. * Compute the transpose of the matrix and store it in a given matrix
  3497. * @param result defines the target matrix
  3498. * @returns the current matrix
  3499. */
  3500. transposeToRef(result: Matrix): Matrix;
  3501. /**
  3502. * Sets the index-th row of the current matrix with the given 4 x float values
  3503. * @param index defines the row index
  3504. * @param x defines the x component to set
  3505. * @param y defines the y component to set
  3506. * @param z defines the z component to set
  3507. * @param w defines the w component to set
  3508. * @returns the updated current matrix
  3509. */
  3510. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3511. /**
  3512. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3513. * @param scale defines the scale factor
  3514. * @returns a new matrix
  3515. */
  3516. scale(scale: number): Matrix;
  3517. /**
  3518. * Scale the current matrix values by a factor to a given result matrix
  3519. * @param scale defines the scale factor
  3520. * @param result defines the matrix to store the result
  3521. * @returns the current matrix
  3522. */
  3523. scaleToRef(scale: number, result: Matrix): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor and add the result to a given matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the Matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3533. * @param ref matrix to store the result
  3534. */
  3535. toNormalMatrix(ref: Matrix): void;
  3536. /**
  3537. * Gets only rotation part of the current matrix
  3538. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3539. */
  3540. getRotationMatrix(): Matrix;
  3541. /**
  3542. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3543. * @param result defines the target matrix to store data to
  3544. * @returns the current matrix
  3545. */
  3546. getRotationMatrixToRef(result: Matrix): Matrix;
  3547. /**
  3548. * Toggles model matrix from being right handed to left handed in place and vice versa
  3549. */
  3550. toggleModelMatrixHandInPlace(): void;
  3551. /**
  3552. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3553. */
  3554. toggleProjectionMatrixHandInPlace(): void;
  3555. /**
  3556. * Creates a matrix from an array
  3557. * @param array defines the source array
  3558. * @param offset defines an offset in the source array
  3559. * @returns a new Matrix set from the starting index of the given array
  3560. */
  3561. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3562. /**
  3563. * Copy the content of an array into a given matrix
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @param result defines the target matrix
  3567. */
  3568. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3569. /**
  3570. * Stores an array into a matrix after having multiplied each component by a given factor
  3571. * @param array defines the source array
  3572. * @param offset defines the offset in the source array
  3573. * @param scale defines the scaling factor
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3577. /**
  3578. * Gets an identity matrix that must not be updated
  3579. */
  3580. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3581. /**
  3582. * Stores a list of values (16) inside a given matrix
  3583. * @param initialM11 defines 1st value of 1st row
  3584. * @param initialM12 defines 2nd value of 1st row
  3585. * @param initialM13 defines 3rd value of 1st row
  3586. * @param initialM14 defines 4th value of 1st row
  3587. * @param initialM21 defines 1st value of 2nd row
  3588. * @param initialM22 defines 2nd value of 2nd row
  3589. * @param initialM23 defines 3rd value of 2nd row
  3590. * @param initialM24 defines 4th value of 2nd row
  3591. * @param initialM31 defines 1st value of 3rd row
  3592. * @param initialM32 defines 2nd value of 3rd row
  3593. * @param initialM33 defines 3rd value of 3rd row
  3594. * @param initialM34 defines 4th value of 3rd row
  3595. * @param initialM41 defines 1st value of 4th row
  3596. * @param initialM42 defines 2nd value of 4th row
  3597. * @param initialM43 defines 3rd value of 4th row
  3598. * @param initialM44 defines 4th value of 4th row
  3599. * @param result defines the target matrix
  3600. */
  3601. 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;
  3602. /**
  3603. * Creates new matrix from a list of values (16)
  3604. * @param initialM11 defines 1st value of 1st row
  3605. * @param initialM12 defines 2nd value of 1st row
  3606. * @param initialM13 defines 3rd value of 1st row
  3607. * @param initialM14 defines 4th value of 1st row
  3608. * @param initialM21 defines 1st value of 2nd row
  3609. * @param initialM22 defines 2nd value of 2nd row
  3610. * @param initialM23 defines 3rd value of 2nd row
  3611. * @param initialM24 defines 4th value of 2nd row
  3612. * @param initialM31 defines 1st value of 3rd row
  3613. * @param initialM32 defines 2nd value of 3rd row
  3614. * @param initialM33 defines 3rd value of 3rd row
  3615. * @param initialM34 defines 4th value of 3rd row
  3616. * @param initialM41 defines 1st value of 4th row
  3617. * @param initialM42 defines 2nd value of 4th row
  3618. * @param initialM43 defines 3rd value of 4th row
  3619. * @param initialM44 defines 4th value of 4th row
  3620. * @returns the new matrix
  3621. */
  3622. 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;
  3623. /**
  3624. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3625. * @param scale defines the scale vector3
  3626. * @param rotation defines the rotation quaternion
  3627. * @param translation defines the translation vector3
  3628. * @returns a new matrix
  3629. */
  3630. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3631. /**
  3632. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3633. * @param scale defines the scale vector3
  3634. * @param rotation defines the rotation quaternion
  3635. * @param translation defines the translation vector3
  3636. * @param result defines the target matrix
  3637. */
  3638. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3639. /**
  3640. * Creates a new identity matrix
  3641. * @returns a new identity matrix
  3642. */
  3643. static Identity(): Matrix;
  3644. /**
  3645. * Creates a new identity matrix and stores the result in a given matrix
  3646. * @param result defines the target matrix
  3647. */
  3648. static IdentityToRef(result: Matrix): void;
  3649. /**
  3650. * Creates a new zero matrix
  3651. * @returns a new zero matrix
  3652. */
  3653. static Zero(): Matrix;
  3654. /**
  3655. * Creates a new rotation matrix for "angle" radians around the X axis
  3656. * @param angle defines the angle (in radians) to use
  3657. * @return the new matrix
  3658. */
  3659. static RotationX(angle: number): Matrix;
  3660. /**
  3661. * Creates a new matrix as the invert of a given matrix
  3662. * @param source defines the source matrix
  3663. * @returns the new matrix
  3664. */
  3665. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3668. * @param angle defines the angle (in radians) to use
  3669. * @param result defines the target matrix
  3670. */
  3671. static RotationXToRef(angle: number, result: Matrix): void;
  3672. /**
  3673. * Creates a new rotation matrix for "angle" radians around the Y axis
  3674. * @param angle defines the angle (in radians) to use
  3675. * @return the new matrix
  3676. */
  3677. static RotationY(angle: number): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationYToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Z axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationZ(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationZToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the given axis
  3698. * @param axis defines the axis to use
  3699. * @param angle defines the angle (in radians) to use
  3700. * @return the new matrix
  3701. */
  3702. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @param result defines the target matrix
  3708. */
  3709. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3710. /**
  3711. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3712. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3713. * @param from defines the vector to align
  3714. * @param to defines the vector to align to
  3715. * @param result defines the target matrix
  3716. */
  3717. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3718. /**
  3719. * Creates a rotation matrix
  3720. * @param yaw defines the yaw angle in radians (Y axis)
  3721. * @param pitch defines the pitch angle in radians (X axis)
  3722. * @param roll defines the roll angle in radians (X axis)
  3723. * @returns the new rotation matrix
  3724. */
  3725. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3726. /**
  3727. * Creates a rotation matrix and stores it in a given matrix
  3728. * @param yaw defines the yaw angle in radians (Y axis)
  3729. * @param pitch defines the pitch angle in radians (X axis)
  3730. * @param roll defines the roll angle in radians (X axis)
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3734. /**
  3735. * Creates a scaling matrix
  3736. * @param x defines the scale factor on X axis
  3737. * @param y defines the scale factor on Y axis
  3738. * @param z defines the scale factor on Z axis
  3739. * @returns the new matrix
  3740. */
  3741. static Scaling(x: number, y: number, z: number): Matrix;
  3742. /**
  3743. * Creates a scaling matrix and stores it in a given matrix
  3744. * @param x defines the scale factor on X axis
  3745. * @param y defines the scale factor on Y axis
  3746. * @param z defines the scale factor on Z axis
  3747. * @param result defines the target matrix
  3748. */
  3749. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3750. /**
  3751. * Creates a translation matrix
  3752. * @param x defines the translation on X axis
  3753. * @param y defines the translation on Y axis
  3754. * @param z defines the translationon Z axis
  3755. * @returns the new matrix
  3756. */
  3757. static Translation(x: number, y: number, z: number): Matrix;
  3758. /**
  3759. * Creates a translation matrix and stores it in a given matrix
  3760. * @param x defines the translation on X axis
  3761. * @param y defines the translation on Y axis
  3762. * @param z defines the translationon Z axis
  3763. * @param result defines the target matrix
  3764. */
  3765. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3766. /**
  3767. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3768. * @param startValue defines the start value
  3769. * @param endValue defines the end value
  3770. * @param gradient defines the gradient factor
  3771. * @returns the new matrix
  3772. */
  3773. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3774. /**
  3775. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3776. * @param startValue defines the start value
  3777. * @param endValue defines the end value
  3778. * @param gradient defines the gradient factor
  3779. * @param result defines the Matrix object where to store data
  3780. */
  3781. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3782. /**
  3783. * Builds a new matrix whose values are computed by:
  3784. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3785. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3786. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3787. * @param startValue defines the first matrix
  3788. * @param endValue defines the second matrix
  3789. * @param gradient defines the gradient between the two matrices
  3790. * @returns the new matrix
  3791. */
  3792. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3793. /**
  3794. * Update a matrix to values which are computed by:
  3795. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3796. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3797. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3798. * @param startValue defines the first matrix
  3799. * @param endValue defines the second matrix
  3800. * @param gradient defines the gradient between the two matrices
  3801. * @param result defines the target matrix
  3802. */
  3803. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3804. /**
  3805. * 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"
  3806. * This function works in left handed mode
  3807. * @param eye defines the final position of the entity
  3808. * @param target defines where the entity should look at
  3809. * @param up defines the up vector for the entity
  3810. * @returns the new matrix
  3811. */
  3812. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3813. /**
  3814. * 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".
  3815. * This function works in left handed mode
  3816. * @param eye defines the final position of the entity
  3817. * @param target defines where the entity should look at
  3818. * @param up defines the up vector for the entity
  3819. * @param result defines the target matrix
  3820. */
  3821. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3822. /**
  3823. * 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"
  3824. * This function works in right handed mode
  3825. * @param eye defines the final position of the entity
  3826. * @param target defines where the entity should look at
  3827. * @param up defines the up vector for the entity
  3828. * @returns the new matrix
  3829. */
  3830. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3831. /**
  3832. * 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".
  3833. * This function works in right handed mode
  3834. * @param eye defines the final position of the entity
  3835. * @param target defines where the entity should look at
  3836. * @param up defines the up vector for the entity
  3837. * @param result defines the target matrix
  3838. */
  3839. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3840. /**
  3841. * Create a left-handed orthographic projection matrix
  3842. * @param width defines the viewport width
  3843. * @param height defines the viewport height
  3844. * @param znear defines the near clip plane
  3845. * @param zfar defines the far clip plane
  3846. * @returns a new matrix as a left-handed orthographic projection matrix
  3847. */
  3848. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3849. /**
  3850. * Store a left-handed orthographic projection to a given matrix
  3851. * @param width defines the viewport width
  3852. * @param height defines the viewport height
  3853. * @param znear defines the near clip plane
  3854. * @param zfar defines the far clip plane
  3855. * @param result defines the target matrix
  3856. */
  3857. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3858. /**
  3859. * Create a left-handed orthographic projection matrix
  3860. * @param left defines the viewport left coordinate
  3861. * @param right defines the viewport right coordinate
  3862. * @param bottom defines the viewport bottom coordinate
  3863. * @param top defines the viewport top coordinate
  3864. * @param znear defines the near clip plane
  3865. * @param zfar defines the far clip plane
  3866. * @returns a new matrix as a left-handed orthographic projection matrix
  3867. */
  3868. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3869. /**
  3870. * Stores a left-handed orthographic projection into a given matrix
  3871. * @param left defines the viewport left coordinate
  3872. * @param right defines the viewport right coordinate
  3873. * @param bottom defines the viewport bottom coordinate
  3874. * @param top defines the viewport top coordinate
  3875. * @param znear defines the near clip plane
  3876. * @param zfar defines the far clip plane
  3877. * @param result defines the target matrix
  3878. */
  3879. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3880. /**
  3881. * Creates a right-handed orthographic projection matrix
  3882. * @param left defines the viewport left coordinate
  3883. * @param right defines the viewport right coordinate
  3884. * @param bottom defines the viewport bottom coordinate
  3885. * @param top defines the viewport top coordinate
  3886. * @param znear defines the near clip plane
  3887. * @param zfar defines the far clip plane
  3888. * @returns a new matrix as a right-handed orthographic projection matrix
  3889. */
  3890. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3891. /**
  3892. * Stores a right-handed orthographic projection into a given matrix
  3893. * @param left defines the viewport left coordinate
  3894. * @param right defines the viewport right coordinate
  3895. * @param bottom defines the viewport bottom coordinate
  3896. * @param top defines the viewport top coordinate
  3897. * @param znear defines the near clip plane
  3898. * @param zfar defines the far clip plane
  3899. * @param result defines the target matrix
  3900. */
  3901. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3902. /**
  3903. * Creates a left-handed perspective projection matrix
  3904. * @param width defines the viewport width
  3905. * @param height defines the viewport height
  3906. * @param znear defines the near clip plane
  3907. * @param zfar defines the far clip plane
  3908. * @returns a new matrix as a left-handed perspective projection matrix
  3909. */
  3910. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3911. /**
  3912. * Creates a left-handed perspective projection matrix
  3913. * @param fov defines the horizontal field of view
  3914. * @param aspect defines the aspect ratio
  3915. * @param znear defines the near clip plane
  3916. * @param zfar defines the far clip plane
  3917. * @returns a new matrix as a left-handed perspective projection matrix
  3918. */
  3919. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3920. /**
  3921. * Stores a left-handed perspective projection into a given matrix
  3922. * @param fov defines the horizontal field of view
  3923. * @param aspect defines the aspect ratio
  3924. * @param znear defines the near clip plane
  3925. * @param zfar defines the far clip plane
  3926. * @param result defines the target matrix
  3927. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3928. */
  3929. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3930. /**
  3931. * Creates a right-handed perspective projection matrix
  3932. * @param fov defines the horizontal field of view
  3933. * @param aspect defines the aspect ratio
  3934. * @param znear defines the near clip plane
  3935. * @param zfar defines the far clip plane
  3936. * @returns a new matrix as a right-handed perspective projection matrix
  3937. */
  3938. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3939. /**
  3940. * Stores a right-handed perspective projection into a given matrix
  3941. * @param fov defines the horizontal field of view
  3942. * @param aspect defines the aspect ratio
  3943. * @param znear defines the near clip plane
  3944. * @param zfar defines the far clip plane
  3945. * @param result defines the target matrix
  3946. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3947. */
  3948. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3949. /**
  3950. * Stores a perspective projection for WebVR info a given matrix
  3951. * @param fov defines the field of view
  3952. * @param znear defines the near clip plane
  3953. * @param zfar defines the far clip plane
  3954. * @param result defines the target matrix
  3955. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3956. */
  3957. static PerspectiveFovWebVRToRef(fov: {
  3958. upDegrees: number;
  3959. downDegrees: number;
  3960. leftDegrees: number;
  3961. rightDegrees: number;
  3962. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3963. /**
  3964. * Computes a complete transformation matrix
  3965. * @param viewport defines the viewport to use
  3966. * @param world defines the world matrix
  3967. * @param view defines the view matrix
  3968. * @param projection defines the projection matrix
  3969. * @param zmin defines the near clip plane
  3970. * @param zmax defines the far clip plane
  3971. * @returns the transformation matrix
  3972. */
  3973. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3974. /**
  3975. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3976. * @param matrix defines the matrix to use
  3977. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3978. */
  3979. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3980. /**
  3981. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3982. * @param matrix defines the matrix to use
  3983. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3984. */
  3985. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3986. /**
  3987. * Compute the transpose of a given matrix
  3988. * @param matrix defines the matrix to transpose
  3989. * @returns the new matrix
  3990. */
  3991. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3992. /**
  3993. * Compute the transpose of a matrix and store it in a target matrix
  3994. * @param matrix defines the matrix to transpose
  3995. * @param result defines the target matrix
  3996. */
  3997. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3998. /**
  3999. * Computes a reflection matrix from a plane
  4000. * @param plane defines the reflection plane
  4001. * @returns a new matrix
  4002. */
  4003. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4004. /**
  4005. * Computes a reflection matrix from a plane
  4006. * @param plane defines the reflection plane
  4007. * @param result defines the target matrix
  4008. */
  4009. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4010. /**
  4011. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4012. * @param xaxis defines the value of the 1st axis
  4013. * @param yaxis defines the value of the 2nd axis
  4014. * @param zaxis defines the value of the 3rd axis
  4015. * @param result defines the target matrix
  4016. */
  4017. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4018. /**
  4019. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4020. * @param quat defines the quaternion to use
  4021. * @param result defines the target matrix
  4022. */
  4023. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4024. }
  4025. /**
  4026. * @hidden
  4027. */
  4028. export class TmpVectors {
  4029. static Vector2: Vector2[];
  4030. static Vector3: Vector3[];
  4031. static Vector4: Vector4[];
  4032. static Quaternion: Quaternion[];
  4033. static Matrix: Matrix[];
  4034. }
  4035. }
  4036. declare module BABYLON {
  4037. /** Defines the cross module used constants to avoid circular dependncies */
  4038. export class Constants {
  4039. /** Defines that alpha blending is disabled */
  4040. static readonly ALPHA_DISABLE: number;
  4041. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4042. static readonly ALPHA_ADD: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4044. static readonly ALPHA_COMBINE: number;
  4045. /** Defines that alpha blending to DEST - SRC * DEST */
  4046. static readonly ALPHA_SUBTRACT: number;
  4047. /** Defines that alpha blending to SRC * DEST */
  4048. static readonly ALPHA_MULTIPLY: number;
  4049. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4050. static readonly ALPHA_MAXIMIZED: number;
  4051. /** Defines that alpha blending to SRC + DEST */
  4052. static readonly ALPHA_ONEONE: number;
  4053. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4054. static readonly ALPHA_PREMULTIPLIED: number;
  4055. /**
  4056. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4057. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4058. */
  4059. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4060. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4061. static readonly ALPHA_INTERPOLATE: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4064. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_SCREENMODE: number;
  4067. /** Defines that the ressource is not delayed*/
  4068. static readonly DELAYLOADSTATE_NONE: number;
  4069. /** Defines that the ressource was successfully delay loaded */
  4070. static readonly DELAYLOADSTATE_LOADED: number;
  4071. /** Defines that the ressource is currently delay loading */
  4072. static readonly DELAYLOADSTATE_LOADING: number;
  4073. /** Defines that the ressource is delayed and has not started loading */
  4074. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4076. static readonly NEVER: number;
  4077. /** 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 */
  4078. static readonly ALWAYS: number;
  4079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4080. static readonly LESS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4082. static readonly EQUAL: number;
  4083. /** 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 */
  4084. static readonly LEQUAL: number;
  4085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4086. static readonly GREATER: number;
  4087. /** 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 */
  4088. static readonly GEQUAL: number;
  4089. /** 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 */
  4090. static readonly NOTEQUAL: number;
  4091. /** Passed to stencilOperation to specify that stencil value must be kept */
  4092. static readonly KEEP: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4094. static readonly REPLACE: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4096. static readonly INCR: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4098. static readonly DECR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4100. static readonly INVERT: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4102. static readonly INCR_WRAP: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4104. static readonly DECR_WRAP: number;
  4105. /** Texture is not repeating outside of 0..1 UVs */
  4106. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4107. /** Texture is repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4109. /** Texture is repeating and mirrored */
  4110. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4111. /** ALPHA */
  4112. static readonly TEXTUREFORMAT_ALPHA: number;
  4113. /** LUMINANCE */
  4114. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4115. /** LUMINANCE_ALPHA */
  4116. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4117. /** RGB */
  4118. static readonly TEXTUREFORMAT_RGB: number;
  4119. /** RGBA */
  4120. static readonly TEXTUREFORMAT_RGBA: number;
  4121. /** RED */
  4122. static readonly TEXTUREFORMAT_RED: number;
  4123. /** RED (2nd reference) */
  4124. static readonly TEXTUREFORMAT_R: number;
  4125. /** RG */
  4126. static readonly TEXTUREFORMAT_RG: number;
  4127. /** RED_INTEGER */
  4128. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4129. /** RED_INTEGER (2nd reference) */
  4130. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4131. /** RG_INTEGER */
  4132. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4133. /** RGB_INTEGER */
  4134. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4135. /** RGBA_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4137. /** UNSIGNED_BYTE */
  4138. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4139. /** UNSIGNED_BYTE (2nd reference) */
  4140. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4141. /** FLOAT */
  4142. static readonly TEXTURETYPE_FLOAT: number;
  4143. /** HALF_FLOAT */
  4144. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4145. /** BYTE */
  4146. static readonly TEXTURETYPE_BYTE: number;
  4147. /** SHORT */
  4148. static readonly TEXTURETYPE_SHORT: number;
  4149. /** UNSIGNED_SHORT */
  4150. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4151. /** INT */
  4152. static readonly TEXTURETYPE_INT: number;
  4153. /** UNSIGNED_INT */
  4154. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4155. /** UNSIGNED_SHORT_4_4_4_4 */
  4156. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4157. /** UNSIGNED_SHORT_5_5_5_1 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4159. /** UNSIGNED_SHORT_5_6_5 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4161. /** UNSIGNED_INT_2_10_10_10_REV */
  4162. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4163. /** UNSIGNED_INT_24_8 */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4165. /** UNSIGNED_INT_10F_11F_11F_REV */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4167. /** UNSIGNED_INT_5_9_9_9_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4169. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4170. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4171. /** nearest is mag = nearest and min = nearest and mip = linear */
  4172. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4173. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4174. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4175. /** Trilinear is mag = linear and min = linear and mip = linear */
  4176. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4177. /** nearest is mag = nearest and min = nearest and mip = linear */
  4178. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4179. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4180. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4181. /** Trilinear is mag = linear and min = linear and mip = linear */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4183. /** mag = nearest and min = nearest and mip = nearest */
  4184. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4185. /** mag = nearest and min = linear and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = linear */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4189. /** mag = nearest and min = linear and mip = none */
  4190. static readonly TEXTURE_NEAREST_LINEAR: number;
  4191. /** mag = nearest and min = nearest and mip = none */
  4192. static readonly TEXTURE_NEAREST_NEAREST: number;
  4193. /** mag = linear and min = nearest and mip = nearest */
  4194. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4195. /** mag = linear and min = nearest and mip = linear */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4197. /** mag = linear and min = linear and mip = none */
  4198. static readonly TEXTURE_LINEAR_LINEAR: number;
  4199. /** mag = linear and min = nearest and mip = none */
  4200. static readonly TEXTURE_LINEAR_NEAREST: number;
  4201. /** Explicit coordinates mode */
  4202. static readonly TEXTURE_EXPLICIT_MODE: number;
  4203. /** Spherical coordinates mode */
  4204. static readonly TEXTURE_SPHERICAL_MODE: number;
  4205. /** Planar coordinates mode */
  4206. static readonly TEXTURE_PLANAR_MODE: number;
  4207. /** Cubic coordinates mode */
  4208. static readonly TEXTURE_CUBIC_MODE: number;
  4209. /** Projection coordinates mode */
  4210. static readonly TEXTURE_PROJECTION_MODE: number;
  4211. /** Skybox coordinates mode */
  4212. static readonly TEXTURE_SKYBOX_MODE: number;
  4213. /** Inverse Cubic coordinates mode */
  4214. static readonly TEXTURE_INVCUBIC_MODE: number;
  4215. /** Equirectangular coordinates mode */
  4216. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4217. /** Equirectangular Fixed coordinates mode */
  4218. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed Mirrored coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4221. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4222. static readonly SCALEMODE_FLOOR: number;
  4223. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4224. static readonly SCALEMODE_NEAREST: number;
  4225. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4226. static readonly SCALEMODE_CEILING: number;
  4227. /**
  4228. * The dirty texture flag value
  4229. */
  4230. static readonly MATERIAL_TextureDirtyFlag: number;
  4231. /**
  4232. * The dirty light flag value
  4233. */
  4234. static readonly MATERIAL_LightDirtyFlag: number;
  4235. /**
  4236. * The dirty fresnel flag value
  4237. */
  4238. static readonly MATERIAL_FresnelDirtyFlag: number;
  4239. /**
  4240. * The dirty attribute flag value
  4241. */
  4242. static readonly MATERIAL_AttributesDirtyFlag: number;
  4243. /**
  4244. * The dirty misc flag value
  4245. */
  4246. static readonly MATERIAL_MiscDirtyFlag: number;
  4247. /**
  4248. * The all dirty flag value
  4249. */
  4250. static readonly MATERIAL_AllDirtyFlag: number;
  4251. /**
  4252. * Returns the triangle fill mode
  4253. */
  4254. static readonly MATERIAL_TriangleFillMode: number;
  4255. /**
  4256. * Returns the wireframe mode
  4257. */
  4258. static readonly MATERIAL_WireFrameFillMode: number;
  4259. /**
  4260. * Returns the point fill mode
  4261. */
  4262. static readonly MATERIAL_PointFillMode: number;
  4263. /**
  4264. * Returns the point list draw mode
  4265. */
  4266. static readonly MATERIAL_PointListDrawMode: number;
  4267. /**
  4268. * Returns the line list draw mode
  4269. */
  4270. static readonly MATERIAL_LineListDrawMode: number;
  4271. /**
  4272. * Returns the line loop draw mode
  4273. */
  4274. static readonly MATERIAL_LineLoopDrawMode: number;
  4275. /**
  4276. * Returns the line strip draw mode
  4277. */
  4278. static readonly MATERIAL_LineStripDrawMode: number;
  4279. /**
  4280. * Returns the triangle strip draw mode
  4281. */
  4282. static readonly MATERIAL_TriangleStripDrawMode: number;
  4283. /**
  4284. * Returns the triangle fan draw mode
  4285. */
  4286. static readonly MATERIAL_TriangleFanDrawMode: number;
  4287. /**
  4288. * Stores the clock-wise side orientation
  4289. */
  4290. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4291. /**
  4292. * Stores the counter clock-wise side orientation
  4293. */
  4294. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4295. /**
  4296. * Nothing
  4297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4298. */
  4299. static readonly ACTION_NothingTrigger: number;
  4300. /**
  4301. * On pick
  4302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4303. */
  4304. static readonly ACTION_OnPickTrigger: number;
  4305. /**
  4306. * On left pick
  4307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4308. */
  4309. static readonly ACTION_OnLeftPickTrigger: number;
  4310. /**
  4311. * On right pick
  4312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4313. */
  4314. static readonly ACTION_OnRightPickTrigger: number;
  4315. /**
  4316. * On center pick
  4317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4318. */
  4319. static readonly ACTION_OnCenterPickTrigger: number;
  4320. /**
  4321. * On pick down
  4322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4323. */
  4324. static readonly ACTION_OnPickDownTrigger: number;
  4325. /**
  4326. * On double pick
  4327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4328. */
  4329. static readonly ACTION_OnDoublePickTrigger: number;
  4330. /**
  4331. * On pick up
  4332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4333. */
  4334. static readonly ACTION_OnPickUpTrigger: number;
  4335. /**
  4336. * On pick out.
  4337. * This trigger will only be raised if you also declared a OnPickDown
  4338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4339. */
  4340. static readonly ACTION_OnPickOutTrigger: number;
  4341. /**
  4342. * On long press
  4343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4344. */
  4345. static readonly ACTION_OnLongPressTrigger: number;
  4346. /**
  4347. * On pointer over
  4348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4349. */
  4350. static readonly ACTION_OnPointerOverTrigger: number;
  4351. /**
  4352. * On pointer out
  4353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4354. */
  4355. static readonly ACTION_OnPointerOutTrigger: number;
  4356. /**
  4357. * On every frame
  4358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4359. */
  4360. static readonly ACTION_OnEveryFrameTrigger: number;
  4361. /**
  4362. * On intersection enter
  4363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4364. */
  4365. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4366. /**
  4367. * On intersection exit
  4368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4369. */
  4370. static readonly ACTION_OnIntersectionExitTrigger: number;
  4371. /**
  4372. * On key down
  4373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4374. */
  4375. static readonly ACTION_OnKeyDownTrigger: number;
  4376. /**
  4377. * On key up
  4378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4379. */
  4380. static readonly ACTION_OnKeyUpTrigger: number;
  4381. /**
  4382. * Billboard mode will only apply to Y axis
  4383. */
  4384. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4385. /**
  4386. * Billboard mode will apply to all axes
  4387. */
  4388. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4389. /**
  4390. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4391. */
  4392. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4393. /**
  4394. * Gets or sets base Assets URL
  4395. */
  4396. static PARTICLES_BaseAssetsUrl: string;
  4397. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4398. * Test order :
  4399. * Is the bounding sphere outside the frustum ?
  4400. * If not, are the bounding box vertices outside the frustum ?
  4401. * It not, then the cullable object is in the frustum.
  4402. */
  4403. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4404. /** Culling strategy : Bounding Sphere Only.
  4405. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4406. * It's also less accurate than the standard because some not visible objects can still be selected.
  4407. * Test : is the bounding sphere outside the frustum ?
  4408. * If not, then the cullable object is in the frustum.
  4409. */
  4410. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4411. /** Culling strategy : Optimistic Inclusion.
  4412. * This in an inclusion test first, then the standard exclusion test.
  4413. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4414. * 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.
  4415. * Anyway, it's as accurate as the standard strategy.
  4416. * Test :
  4417. * Is the cullable object bounding sphere center in the frustum ?
  4418. * If not, apply the default culling strategy.
  4419. */
  4420. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4421. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4422. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4423. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4424. * 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.
  4425. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4426. * Test :
  4427. * Is the cullable object bounding sphere center in the frustum ?
  4428. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4429. */
  4430. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4431. /**
  4432. * No logging while loading
  4433. */
  4434. static readonly SCENELOADER_NO_LOGGING: number;
  4435. /**
  4436. * Minimal logging while loading
  4437. */
  4438. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4439. /**
  4440. * Summary logging while loading
  4441. */
  4442. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4443. /**
  4444. * Detailled logging while loading
  4445. */
  4446. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4447. }
  4448. }
  4449. declare module BABYLON {
  4450. /**
  4451. * Class used to store and describe the pipeline context associated with an effect
  4452. */
  4453. export interface IPipelineContext {
  4454. /**
  4455. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4456. */
  4457. isAsync: boolean;
  4458. /**
  4459. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4460. */
  4461. isReady: boolean;
  4462. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4463. }
  4464. }
  4465. declare module BABYLON {
  4466. /** @hidden */
  4467. export interface IShaderProcessor {
  4468. attributeProcessor?: (attribute: string) => string;
  4469. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4470. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4471. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4472. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4473. lineProcessor?: (line: string, isFragment: boolean) => string;
  4474. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4475. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4476. }
  4477. }
  4478. declare module BABYLON {
  4479. /** @hidden */
  4480. export interface ProcessingOptions {
  4481. defines: string[];
  4482. indexParameters: any;
  4483. isFragment: boolean;
  4484. shouldUseHighPrecisionShader: boolean;
  4485. supportsUniformBuffers: boolean;
  4486. shadersRepository: string;
  4487. includesShadersStore: {
  4488. [key: string]: string;
  4489. };
  4490. processor?: IShaderProcessor;
  4491. version: string;
  4492. platformName: string;
  4493. lookForClosingBracketForUniformBuffer?: boolean;
  4494. }
  4495. }
  4496. declare module BABYLON {
  4497. /**
  4498. * Helper to manipulate strings
  4499. */
  4500. export class StringTools {
  4501. /**
  4502. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4503. * @param str Source string
  4504. * @param suffix Suffix to search for in the source string
  4505. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4506. */
  4507. static EndsWith(str: string, suffix: string): boolean;
  4508. /**
  4509. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4510. * @param str Source string
  4511. * @param suffix Suffix to search for in the source string
  4512. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4513. */
  4514. static StartsWith(str: string, suffix: string): boolean;
  4515. }
  4516. }
  4517. declare module BABYLON {
  4518. /** @hidden */
  4519. export class ShaderCodeNode {
  4520. line: string;
  4521. children: ShaderCodeNode[];
  4522. additionalDefineKey?: string;
  4523. additionalDefineValue?: string;
  4524. isValid(preprocessors: {
  4525. [key: string]: string;
  4526. }): boolean;
  4527. process(preprocessors: {
  4528. [key: string]: string;
  4529. }, options: ProcessingOptions): string;
  4530. }
  4531. }
  4532. declare module BABYLON {
  4533. /** @hidden */
  4534. export class ShaderCodeCursor {
  4535. private _lines;
  4536. lineIndex: number;
  4537. readonly currentLine: string;
  4538. readonly canRead: boolean;
  4539. lines: string[];
  4540. }
  4541. }
  4542. declare module BABYLON {
  4543. /** @hidden */
  4544. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4545. process(preprocessors: {
  4546. [key: string]: string;
  4547. }, options: ProcessingOptions): string;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /** @hidden */
  4552. export class ShaderDefineExpression {
  4553. isTrue(preprocessors: {
  4554. [key: string]: string;
  4555. }): boolean;
  4556. }
  4557. }
  4558. declare module BABYLON {
  4559. /** @hidden */
  4560. export class ShaderCodeTestNode extends ShaderCodeNode {
  4561. testExpression: ShaderDefineExpression;
  4562. isValid(preprocessors: {
  4563. [key: string]: string;
  4564. }): boolean;
  4565. }
  4566. }
  4567. declare module BABYLON {
  4568. /** @hidden */
  4569. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4570. define: string;
  4571. not: boolean;
  4572. constructor(define: string, not?: boolean);
  4573. isTrue(preprocessors: {
  4574. [key: string]: string;
  4575. }): boolean;
  4576. }
  4577. }
  4578. declare module BABYLON {
  4579. /** @hidden */
  4580. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4581. leftOperand: ShaderDefineExpression;
  4582. rightOperand: ShaderDefineExpression;
  4583. isTrue(preprocessors: {
  4584. [key: string]: string;
  4585. }): boolean;
  4586. }
  4587. }
  4588. declare module BABYLON {
  4589. /** @hidden */
  4590. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4591. leftOperand: ShaderDefineExpression;
  4592. rightOperand: ShaderDefineExpression;
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module BABYLON {
  4599. /** @hidden */
  4600. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4601. define: string;
  4602. operand: string;
  4603. testValue: string;
  4604. constructor(define: string, operand: string, testValue: string);
  4605. isTrue(preprocessors: {
  4606. [key: string]: string;
  4607. }): boolean;
  4608. }
  4609. }
  4610. declare module BABYLON {
  4611. /**
  4612. * @ignore
  4613. * Application error to support additional information when loading a file
  4614. */
  4615. export class LoadFileError extends Error {
  4616. /** defines the optional web request */
  4617. request?: WebRequest | undefined;
  4618. private static _setPrototypeOf;
  4619. /**
  4620. * Creates a new LoadFileError
  4621. * @param message defines the message of the error
  4622. * @param request defines the optional web request
  4623. */
  4624. constructor(message: string,
  4625. /** defines the optional web request */
  4626. request?: WebRequest | undefined);
  4627. }
  4628. }
  4629. declare module BABYLON {
  4630. /**
  4631. * Class used to enable access to offline support
  4632. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4633. */
  4634. export interface IOfflineProvider {
  4635. /**
  4636. * Gets a boolean indicating if scene must be saved in the database
  4637. */
  4638. enableSceneOffline: boolean;
  4639. /**
  4640. * Gets a boolean indicating if textures must be saved in the database
  4641. */
  4642. enableTexturesOffline: boolean;
  4643. /**
  4644. * Open the offline support and make it available
  4645. * @param successCallback defines the callback to call on success
  4646. * @param errorCallback defines the callback to call on error
  4647. */
  4648. open(successCallback: () => void, errorCallback: () => void): void;
  4649. /**
  4650. * Loads an image from the offline support
  4651. * @param url defines the url to load from
  4652. * @param image defines the target DOM image
  4653. */
  4654. loadImage(url: string, image: HTMLImageElement): void;
  4655. /**
  4656. * Loads a file from offline support
  4657. * @param url defines the URL to load from
  4658. * @param sceneLoaded defines a callback to call on success
  4659. * @param progressCallBack defines a callback to call when progress changed
  4660. * @param errorCallback defines a callback to call on error
  4661. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4662. */
  4663. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4664. }
  4665. }
  4666. declare module BABYLON {
  4667. /**
  4668. * Class used to help managing file picking and drag'n'drop
  4669. * File Storage
  4670. */
  4671. export class FilesInputStore {
  4672. /**
  4673. * List of files ready to be loaded
  4674. */
  4675. static FilesToLoad: {
  4676. [key: string]: File;
  4677. };
  4678. }
  4679. }
  4680. declare module BABYLON {
  4681. /**
  4682. * Class used to define a retry strategy when error happens while loading assets
  4683. */
  4684. export class RetryStrategy {
  4685. /**
  4686. * Function used to defines an exponential back off strategy
  4687. * @param maxRetries defines the maximum number of retries (3 by default)
  4688. * @param baseInterval defines the interval between retries
  4689. * @returns the strategy function to use
  4690. */
  4691. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4692. }
  4693. }
  4694. declare module BABYLON {
  4695. /**
  4696. * @hidden
  4697. */
  4698. export class FileTools {
  4699. /**
  4700. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4701. */
  4702. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4703. /**
  4704. * Gets or sets the base URL to use to load assets
  4705. */
  4706. static BaseUrl: string;
  4707. /**
  4708. * Default behaviour for cors in the application.
  4709. * It can be a string if the expected behavior is identical in the entire app.
  4710. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4711. */
  4712. static CorsBehavior: string | ((url: string | string[]) => string);
  4713. /**
  4714. * Gets or sets a function used to pre-process url before using them to load assets
  4715. */
  4716. static PreprocessUrl: (url: string) => string;
  4717. /**
  4718. * Removes unwanted characters from an url
  4719. * @param url defines the url to clean
  4720. * @returns the cleaned url
  4721. */
  4722. private static _CleanUrl;
  4723. /**
  4724. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4725. * @param url define the url we are trying
  4726. * @param element define the dom element where to configure the cors policy
  4727. */
  4728. static SetCorsBehavior(url: string | string[], element: {
  4729. crossOrigin: string | null;
  4730. }): void;
  4731. /**
  4732. * Loads an image as an HTMLImageElement.
  4733. * @param input url string, ArrayBuffer, or Blob to load
  4734. * @param onLoad callback called when the image successfully loads
  4735. * @param onError callback called when the image fails to load
  4736. * @param offlineProvider offline provider for caching
  4737. * @returns the HTMLImageElement of the loaded image
  4738. */
  4739. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4740. /**
  4741. * Loads a file
  4742. * @param fileToLoad defines the file to load
  4743. * @param callback defines the callback to call when data is loaded
  4744. * @param progressCallBack defines the callback to call during loading process
  4745. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4746. * @returns a file request object
  4747. */
  4748. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4749. /**
  4750. * Loads a file
  4751. * @param url url string, ArrayBuffer, or Blob to load
  4752. * @param onSuccess callback called when the file successfully loads
  4753. * @param onProgress callback called while file is loading (if the server supports this mode)
  4754. * @param offlineProvider defines the offline provider for caching
  4755. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4756. * @param onError callback called when the file fails to load
  4757. * @returns a file request object
  4758. */
  4759. 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;
  4760. /**
  4761. * Checks if the loaded document was accessed via `file:`-Protocol.
  4762. * @returns boolean
  4763. */
  4764. static IsFileURL(): boolean;
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. /** @hidden */
  4769. export class ShaderProcessor {
  4770. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4771. private static _ProcessPrecision;
  4772. private static _ExtractOperation;
  4773. private static _BuildSubExpression;
  4774. private static _BuildExpression;
  4775. private static _MoveCursorWithinIf;
  4776. private static _MoveCursor;
  4777. private static _EvaluatePreProcessors;
  4778. private static _PreparePreProcessors;
  4779. private static _ProcessShaderConversion;
  4780. private static _ProcessIncludes;
  4781. }
  4782. }
  4783. declare module BABYLON {
  4784. /**
  4785. * Class used to hold a RBG color
  4786. */
  4787. export class Color3 {
  4788. /**
  4789. * Defines the red component (between 0 and 1, default is 0)
  4790. */
  4791. r: number;
  4792. /**
  4793. * Defines the green component (between 0 and 1, default is 0)
  4794. */
  4795. g: number;
  4796. /**
  4797. * Defines the blue component (between 0 and 1, default is 0)
  4798. */
  4799. b: number;
  4800. /**
  4801. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4802. * @param r defines the red component (between 0 and 1, default is 0)
  4803. * @param g defines the green component (between 0 and 1, default is 0)
  4804. * @param b defines the blue component (between 0 and 1, default is 0)
  4805. */
  4806. constructor(
  4807. /**
  4808. * Defines the red component (between 0 and 1, default is 0)
  4809. */
  4810. r?: number,
  4811. /**
  4812. * Defines the green component (between 0 and 1, default is 0)
  4813. */
  4814. g?: number,
  4815. /**
  4816. * Defines the blue component (between 0 and 1, default is 0)
  4817. */
  4818. b?: number);
  4819. /**
  4820. * Creates a string with the Color3 current values
  4821. * @returns the string representation of the Color3 object
  4822. */
  4823. toString(): string;
  4824. /**
  4825. * Returns the string "Color3"
  4826. * @returns "Color3"
  4827. */
  4828. getClassName(): string;
  4829. /**
  4830. * Compute the Color3 hash code
  4831. * @returns an unique number that can be used to hash Color3 objects
  4832. */
  4833. getHashCode(): number;
  4834. /**
  4835. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4836. * @param array defines the array where to store the r,g,b components
  4837. * @param index defines an optional index in the target array to define where to start storing values
  4838. * @returns the current Color3 object
  4839. */
  4840. toArray(array: FloatArray, index?: number): Color3;
  4841. /**
  4842. * Returns a new Color4 object from the current Color3 and the given alpha
  4843. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4844. * @returns a new Color4 object
  4845. */
  4846. toColor4(alpha?: number): Color4;
  4847. /**
  4848. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4849. * @returns the new array
  4850. */
  4851. asArray(): number[];
  4852. /**
  4853. * Returns the luminance value
  4854. * @returns a float value
  4855. */
  4856. toLuminance(): number;
  4857. /**
  4858. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4859. * @param otherColor defines the second operand
  4860. * @returns the new Color3 object
  4861. */
  4862. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4863. /**
  4864. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4865. * @param otherColor defines the second operand
  4866. * @param result defines the Color3 object where to store the result
  4867. * @returns the current Color3
  4868. */
  4869. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4870. /**
  4871. * Determines equality between Color3 objects
  4872. * @param otherColor defines the second operand
  4873. * @returns true if the rgb values are equal to the given ones
  4874. */
  4875. equals(otherColor: DeepImmutable<Color3>): boolean;
  4876. /**
  4877. * Determines equality between the current Color3 object and a set of r,b,g values
  4878. * @param r defines the red component to check
  4879. * @param g defines the green component to check
  4880. * @param b defines the blue component to check
  4881. * @returns true if the rgb values are equal to the given ones
  4882. */
  4883. equalsFloats(r: number, g: number, b: number): boolean;
  4884. /**
  4885. * Multiplies in place each rgb value by scale
  4886. * @param scale defines the scaling factor
  4887. * @returns the updated Color3
  4888. */
  4889. scale(scale: number): Color3;
  4890. /**
  4891. * Multiplies the rgb values by scale and stores the result into "result"
  4892. * @param scale defines the scaling factor
  4893. * @param result defines the Color3 object where to store the result
  4894. * @returns the unmodified current Color3
  4895. */
  4896. scaleToRef(scale: number, result: Color3): Color3;
  4897. /**
  4898. * Scale the current Color3 values by a factor and add the result to a given Color3
  4899. * @param scale defines the scale factor
  4900. * @param result defines color to store the result into
  4901. * @returns the unmodified current Color3
  4902. */
  4903. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4904. /**
  4905. * Clamps the rgb values by the min and max values and stores the result into "result"
  4906. * @param min defines minimum clamping value (default is 0)
  4907. * @param max defines maximum clamping value (default is 1)
  4908. * @param result defines color to store the result into
  4909. * @returns the original Color3
  4910. */
  4911. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4912. /**
  4913. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4914. * @param otherColor defines the second operand
  4915. * @returns the new Color3
  4916. */
  4917. add(otherColor: DeepImmutable<Color3>): Color3;
  4918. /**
  4919. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4920. * @param otherColor defines the second operand
  4921. * @param result defines Color3 object to store the result into
  4922. * @returns the unmodified current Color3
  4923. */
  4924. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4925. /**
  4926. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4927. * @param otherColor defines the second operand
  4928. * @returns the new Color3
  4929. */
  4930. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4931. /**
  4932. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4933. * @param otherColor defines the second operand
  4934. * @param result defines Color3 object to store the result into
  4935. * @returns the unmodified current Color3
  4936. */
  4937. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4938. /**
  4939. * Copy the current object
  4940. * @returns a new Color3 copied the current one
  4941. */
  4942. clone(): Color3;
  4943. /**
  4944. * Copies the rgb values from the source in the current Color3
  4945. * @param source defines the source Color3 object
  4946. * @returns the updated Color3 object
  4947. */
  4948. copyFrom(source: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Updates the Color3 rgb values from the given floats
  4951. * @param r defines the red component to read from
  4952. * @param g defines the green component to read from
  4953. * @param b defines the blue component to read from
  4954. * @returns the current Color3 object
  4955. */
  4956. copyFromFloats(r: number, g: number, b: number): Color3;
  4957. /**
  4958. * Updates the Color3 rgb values from the given floats
  4959. * @param r defines the red component to read from
  4960. * @param g defines the green component to read from
  4961. * @param b defines the blue component to read from
  4962. * @returns the current Color3 object
  4963. */
  4964. set(r: number, g: number, b: number): Color3;
  4965. /**
  4966. * Compute the Color3 hexadecimal code as a string
  4967. * @returns a string containing the hexadecimal representation of the Color3 object
  4968. */
  4969. toHexString(): string;
  4970. /**
  4971. * Computes a new Color3 converted from the current one to linear space
  4972. * @returns a new Color3 object
  4973. */
  4974. toLinearSpace(): Color3;
  4975. /**
  4976. * Converts current color in rgb space to HSV values
  4977. * @returns a new color3 representing the HSV values
  4978. */
  4979. toHSV(): Color3;
  4980. /**
  4981. * Converts current color in rgb space to HSV values
  4982. * @param result defines the Color3 where to store the HSV values
  4983. */
  4984. toHSVToRef(result: Color3): void;
  4985. /**
  4986. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4987. * @param convertedColor defines the Color3 object where to store the linear space version
  4988. * @returns the unmodified Color3
  4989. */
  4990. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4991. /**
  4992. * Computes a new Color3 converted from the current one to gamma space
  4993. * @returns a new Color3 object
  4994. */
  4995. toGammaSpace(): Color3;
  4996. /**
  4997. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  4998. * @param convertedColor defines the Color3 object where to store the gamma space version
  4999. * @returns the unmodified Color3
  5000. */
  5001. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5002. private static _BlackReadOnly;
  5003. /**
  5004. * Convert Hue, saturation and value to a Color3 (RGB)
  5005. * @param hue defines the hue
  5006. * @param saturation defines the saturation
  5007. * @param value defines the value
  5008. * @param result defines the Color3 where to store the RGB values
  5009. */
  5010. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5011. /**
  5012. * Creates a new Color3 from the string containing valid hexadecimal values
  5013. * @param hex defines a string containing valid hexadecimal values
  5014. * @returns a new Color3 object
  5015. */
  5016. static FromHexString(hex: string): Color3;
  5017. /**
  5018. * Creates a new Color3 from the starting index of the given array
  5019. * @param array defines the source array
  5020. * @param offset defines an offset in the source array
  5021. * @returns a new Color3 object
  5022. */
  5023. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5024. /**
  5025. * Creates a new Color3 from integer values (< 256)
  5026. * @param r defines the red component to read from (value between 0 and 255)
  5027. * @param g defines the green component to read from (value between 0 and 255)
  5028. * @param b defines the blue component to read from (value between 0 and 255)
  5029. * @returns a new Color3 object
  5030. */
  5031. static FromInts(r: number, g: number, b: number): Color3;
  5032. /**
  5033. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5034. * @param start defines the start Color3 value
  5035. * @param end defines the end Color3 value
  5036. * @param amount defines the gradient value between start and end
  5037. * @returns a new Color3 object
  5038. */
  5039. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5040. /**
  5041. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5042. * @param left defines the start value
  5043. * @param right defines the end value
  5044. * @param amount defines the gradient factor
  5045. * @param result defines the Color3 object where to store the result
  5046. */
  5047. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5048. /**
  5049. * Returns a Color3 value containing a red color
  5050. * @returns a new Color3 object
  5051. */
  5052. static Red(): Color3;
  5053. /**
  5054. * Returns a Color3 value containing a green color
  5055. * @returns a new Color3 object
  5056. */
  5057. static Green(): Color3;
  5058. /**
  5059. * Returns a Color3 value containing a blue color
  5060. * @returns a new Color3 object
  5061. */
  5062. static Blue(): Color3;
  5063. /**
  5064. * Returns a Color3 value containing a black color
  5065. * @returns a new Color3 object
  5066. */
  5067. static Black(): Color3;
  5068. /**
  5069. * Gets a Color3 value containing a black color that must not be updated
  5070. */
  5071. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5072. /**
  5073. * Returns a Color3 value containing a white color
  5074. * @returns a new Color3 object
  5075. */
  5076. static White(): Color3;
  5077. /**
  5078. * Returns a Color3 value containing a purple color
  5079. * @returns a new Color3 object
  5080. */
  5081. static Purple(): Color3;
  5082. /**
  5083. * Returns a Color3 value containing a magenta color
  5084. * @returns a new Color3 object
  5085. */
  5086. static Magenta(): Color3;
  5087. /**
  5088. * Returns a Color3 value containing a yellow color
  5089. * @returns a new Color3 object
  5090. */
  5091. static Yellow(): Color3;
  5092. /**
  5093. * Returns a Color3 value containing a gray color
  5094. * @returns a new Color3 object
  5095. */
  5096. static Gray(): Color3;
  5097. /**
  5098. * Returns a Color3 value containing a teal color
  5099. * @returns a new Color3 object
  5100. */
  5101. static Teal(): Color3;
  5102. /**
  5103. * Returns a Color3 value containing a random color
  5104. * @returns a new Color3 object
  5105. */
  5106. static Random(): Color3;
  5107. }
  5108. /**
  5109. * Class used to hold a RBGA color
  5110. */
  5111. export class Color4 {
  5112. /**
  5113. * Defines the red component (between 0 and 1, default is 0)
  5114. */
  5115. r: number;
  5116. /**
  5117. * Defines the green component (between 0 and 1, default is 0)
  5118. */
  5119. g: number;
  5120. /**
  5121. * Defines the blue component (between 0 and 1, default is 0)
  5122. */
  5123. b: number;
  5124. /**
  5125. * Defines the alpha component (between 0 and 1, default is 1)
  5126. */
  5127. a: number;
  5128. /**
  5129. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5130. * @param r defines the red component (between 0 and 1, default is 0)
  5131. * @param g defines the green component (between 0 and 1, default is 0)
  5132. * @param b defines the blue component (between 0 and 1, default is 0)
  5133. * @param a defines the alpha component (between 0 and 1, default is 1)
  5134. */
  5135. constructor(
  5136. /**
  5137. * Defines the red component (between 0 and 1, default is 0)
  5138. */
  5139. r?: number,
  5140. /**
  5141. * Defines the green component (between 0 and 1, default is 0)
  5142. */
  5143. g?: number,
  5144. /**
  5145. * Defines the blue component (between 0 and 1, default is 0)
  5146. */
  5147. b?: number,
  5148. /**
  5149. * Defines the alpha component (between 0 and 1, default is 1)
  5150. */
  5151. a?: number);
  5152. /**
  5153. * Adds in place the given Color4 values to the current Color4 object
  5154. * @param right defines the second operand
  5155. * @returns the current updated Color4 object
  5156. */
  5157. addInPlace(right: DeepImmutable<Color4>): Color4;
  5158. /**
  5159. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5160. * @returns the new array
  5161. */
  5162. asArray(): number[];
  5163. /**
  5164. * Stores from the starting index in the given array the Color4 successive values
  5165. * @param array defines the array where to store the r,g,b components
  5166. * @param index defines an optional index in the target array to define where to start storing values
  5167. * @returns the current Color4 object
  5168. */
  5169. toArray(array: number[], index?: number): Color4;
  5170. /**
  5171. * Determines equality between Color4 objects
  5172. * @param otherColor defines the second operand
  5173. * @returns true if the rgba values are equal to the given ones
  5174. */
  5175. equals(otherColor: DeepImmutable<Color4>): boolean;
  5176. /**
  5177. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5178. * @param right defines the second operand
  5179. * @returns a new Color4 object
  5180. */
  5181. add(right: DeepImmutable<Color4>): Color4;
  5182. /**
  5183. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5184. * @param right defines the second operand
  5185. * @returns a new Color4 object
  5186. */
  5187. subtract(right: DeepImmutable<Color4>): Color4;
  5188. /**
  5189. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5190. * @param right defines the second operand
  5191. * @param result defines the Color4 object where to store the result
  5192. * @returns the current Color4 object
  5193. */
  5194. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5195. /**
  5196. * Creates a new Color4 with the current Color4 values multiplied by scale
  5197. * @param scale defines the scaling factor to apply
  5198. * @returns a new Color4 object
  5199. */
  5200. scale(scale: number): Color4;
  5201. /**
  5202. * Multiplies the current Color4 values by scale and stores the result in "result"
  5203. * @param scale defines the scaling factor to apply
  5204. * @param result defines the Color4 object where to store the result
  5205. * @returns the current unmodified Color4
  5206. */
  5207. scaleToRef(scale: number, result: Color4): Color4;
  5208. /**
  5209. * Scale the current Color4 values by a factor and add the result to a given Color4
  5210. * @param scale defines the scale factor
  5211. * @param result defines the Color4 object where to store the result
  5212. * @returns the unmodified current Color4
  5213. */
  5214. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5215. /**
  5216. * Clamps the rgb values by the min and max values and stores the result into "result"
  5217. * @param min defines minimum clamping value (default is 0)
  5218. * @param max defines maximum clamping value (default is 1)
  5219. * @param result defines color to store the result into.
  5220. * @returns the cuurent Color4
  5221. */
  5222. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5223. /**
  5224. * Multipy an Color4 value by another and return a new Color4 object
  5225. * @param color defines the Color4 value to multiply by
  5226. * @returns a new Color4 object
  5227. */
  5228. multiply(color: Color4): Color4;
  5229. /**
  5230. * Multipy a Color4 value by another and push the result in a reference value
  5231. * @param color defines the Color4 value to multiply by
  5232. * @param result defines the Color4 to fill the result in
  5233. * @returns the result Color4
  5234. */
  5235. multiplyToRef(color: Color4, result: Color4): Color4;
  5236. /**
  5237. * Creates a string with the Color4 current values
  5238. * @returns the string representation of the Color4 object
  5239. */
  5240. toString(): string;
  5241. /**
  5242. * Returns the string "Color4"
  5243. * @returns "Color4"
  5244. */
  5245. getClassName(): string;
  5246. /**
  5247. * Compute the Color4 hash code
  5248. * @returns an unique number that can be used to hash Color4 objects
  5249. */
  5250. getHashCode(): number;
  5251. /**
  5252. * Creates a new Color4 copied from the current one
  5253. * @returns a new Color4 object
  5254. */
  5255. clone(): Color4;
  5256. /**
  5257. * Copies the given Color4 values into the current one
  5258. * @param source defines the source Color4 object
  5259. * @returns the current updated Color4 object
  5260. */
  5261. copyFrom(source: Color4): Color4;
  5262. /**
  5263. * Copies the given float values into the current one
  5264. * @param r defines the red component to read from
  5265. * @param g defines the green component to read from
  5266. * @param b defines the blue component to read from
  5267. * @param a defines the alpha component to read from
  5268. * @returns the current updated Color4 object
  5269. */
  5270. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5271. /**
  5272. * Copies the given float values into the current one
  5273. * @param r defines the red component to read from
  5274. * @param g defines the green component to read from
  5275. * @param b defines the blue component to read from
  5276. * @param a defines the alpha component to read from
  5277. * @returns the current updated Color4 object
  5278. */
  5279. set(r: number, g: number, b: number, a: number): Color4;
  5280. /**
  5281. * Compute the Color4 hexadecimal code as a string
  5282. * @returns a string containing the hexadecimal representation of the Color4 object
  5283. */
  5284. toHexString(): string;
  5285. /**
  5286. * Computes a new Color4 converted from the current one to linear space
  5287. * @returns a new Color4 object
  5288. */
  5289. toLinearSpace(): Color4;
  5290. /**
  5291. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5292. * @param convertedColor defines the Color4 object where to store the linear space version
  5293. * @returns the unmodified Color4
  5294. */
  5295. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5296. /**
  5297. * Computes a new Color4 converted from the current one to gamma space
  5298. * @returns a new Color4 object
  5299. */
  5300. toGammaSpace(): Color4;
  5301. /**
  5302. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5303. * @param convertedColor defines the Color4 object where to store the gamma space version
  5304. * @returns the unmodified Color4
  5305. */
  5306. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5307. /**
  5308. * Creates a new Color4 from the string containing valid hexadecimal values
  5309. * @param hex defines a string containing valid hexadecimal values
  5310. * @returns a new Color4 object
  5311. */
  5312. static FromHexString(hex: string): Color4;
  5313. /**
  5314. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5315. * @param left defines the start value
  5316. * @param right defines the end value
  5317. * @param amount defines the gradient factor
  5318. * @returns a new Color4 object
  5319. */
  5320. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5321. /**
  5322. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5323. * @param left defines the start value
  5324. * @param right defines the end value
  5325. * @param amount defines the gradient factor
  5326. * @param result defines the Color4 object where to store data
  5327. */
  5328. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5329. /**
  5330. * Creates a new Color4 from a Color3 and an alpha value
  5331. * @param color3 defines the source Color3 to read from
  5332. * @param alpha defines the alpha component (1.0 by default)
  5333. * @returns a new Color4 object
  5334. */
  5335. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5336. /**
  5337. * Creates a new Color4 from the starting index element of the given array
  5338. * @param array defines the source array to read from
  5339. * @param offset defines the offset in the source array
  5340. * @returns a new Color4 object
  5341. */
  5342. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5343. /**
  5344. * Creates a new Color3 from integer values (< 256)
  5345. * @param r defines the red component to read from (value between 0 and 255)
  5346. * @param g defines the green component to read from (value between 0 and 255)
  5347. * @param b defines the blue component to read from (value between 0 and 255)
  5348. * @param a defines the alpha component to read from (value between 0 and 255)
  5349. * @returns a new Color3 object
  5350. */
  5351. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5352. /**
  5353. * Check the content of a given array and convert it to an array containing RGBA data
  5354. * If the original array was already containing count * 4 values then it is returned directly
  5355. * @param colors defines the array to check
  5356. * @param count defines the number of RGBA data to expect
  5357. * @returns an array containing count * 4 values (RGBA)
  5358. */
  5359. static CheckColors4(colors: number[], count: number): number[];
  5360. }
  5361. /**
  5362. * @hidden
  5363. */
  5364. export class TmpColors {
  5365. static Color3: Color3[];
  5366. static Color4: Color4[];
  5367. }
  5368. }
  5369. declare module BABYLON {
  5370. /**
  5371. * Class representing spherical harmonics coefficients to the 3rd degree
  5372. */
  5373. export class SphericalHarmonics {
  5374. /**
  5375. * Defines whether or not the harmonics have been prescaled for rendering.
  5376. */
  5377. preScaled: boolean;
  5378. /**
  5379. * The l0,0 coefficients of the spherical harmonics
  5380. */
  5381. l00: Vector3;
  5382. /**
  5383. * The l1,-1 coefficients of the spherical harmonics
  5384. */
  5385. l1_1: Vector3;
  5386. /**
  5387. * The l1,0 coefficients of the spherical harmonics
  5388. */
  5389. l10: Vector3;
  5390. /**
  5391. * The l1,1 coefficients of the spherical harmonics
  5392. */
  5393. l11: Vector3;
  5394. /**
  5395. * The l2,-2 coefficients of the spherical harmonics
  5396. */
  5397. l2_2: Vector3;
  5398. /**
  5399. * The l2,-1 coefficients of the spherical harmonics
  5400. */
  5401. l2_1: Vector3;
  5402. /**
  5403. * The l2,0 coefficients of the spherical harmonics
  5404. */
  5405. l20: Vector3;
  5406. /**
  5407. * The l2,1 coefficients of the spherical harmonics
  5408. */
  5409. l21: Vector3;
  5410. /**
  5411. * The l2,2 coefficients of the spherical harmonics
  5412. */
  5413. l22: Vector3;
  5414. /**
  5415. * Adds a light to the spherical harmonics
  5416. * @param direction the direction of the light
  5417. * @param color the color of the light
  5418. * @param deltaSolidAngle the delta solid angle of the light
  5419. */
  5420. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5421. /**
  5422. * Scales the spherical harmonics by the given amount
  5423. * @param scale the amount to scale
  5424. */
  5425. scaleInPlace(scale: number): void;
  5426. /**
  5427. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5428. *
  5429. * ```
  5430. * E_lm = A_l * L_lm
  5431. * ```
  5432. *
  5433. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5434. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5435. * the scaling factors are given in equation 9.
  5436. */
  5437. convertIncidentRadianceToIrradiance(): void;
  5438. /**
  5439. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5440. *
  5441. * ```
  5442. * L = (1/pi) * E * rho
  5443. * ```
  5444. *
  5445. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5446. */
  5447. convertIrradianceToLambertianRadiance(): void;
  5448. /**
  5449. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5450. * required operations at run time.
  5451. *
  5452. * This is simply done by scaling back the SH with Ylm constants parameter.
  5453. * The trigonometric part being applied by the shader at run time.
  5454. */
  5455. preScaleForRendering(): void;
  5456. /**
  5457. * Constructs a spherical harmonics from an array.
  5458. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5459. * @returns the spherical harmonics
  5460. */
  5461. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5462. /**
  5463. * Gets the spherical harmonics from polynomial
  5464. * @param polynomial the spherical polynomial
  5465. * @returns the spherical harmonics
  5466. */
  5467. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5468. }
  5469. /**
  5470. * Class representing spherical polynomial coefficients to the 3rd degree
  5471. */
  5472. export class SphericalPolynomial {
  5473. private _harmonics;
  5474. /**
  5475. * The spherical harmonics used to create the polynomials.
  5476. */
  5477. readonly preScaledHarmonics: SphericalHarmonics;
  5478. /**
  5479. * The x coefficients of the spherical polynomial
  5480. */
  5481. x: Vector3;
  5482. /**
  5483. * The y coefficients of the spherical polynomial
  5484. */
  5485. y: Vector3;
  5486. /**
  5487. * The z coefficients of the spherical polynomial
  5488. */
  5489. z: Vector3;
  5490. /**
  5491. * The xx coefficients of the spherical polynomial
  5492. */
  5493. xx: Vector3;
  5494. /**
  5495. * The yy coefficients of the spherical polynomial
  5496. */
  5497. yy: Vector3;
  5498. /**
  5499. * The zz coefficients of the spherical polynomial
  5500. */
  5501. zz: Vector3;
  5502. /**
  5503. * The xy coefficients of the spherical polynomial
  5504. */
  5505. xy: Vector3;
  5506. /**
  5507. * The yz coefficients of the spherical polynomial
  5508. */
  5509. yz: Vector3;
  5510. /**
  5511. * The zx coefficients of the spherical polynomial
  5512. */
  5513. zx: Vector3;
  5514. /**
  5515. * Adds an ambient color to the spherical polynomial
  5516. * @param color the color to add
  5517. */
  5518. addAmbient(color: Color3): void;
  5519. /**
  5520. * Scales the spherical polynomial by the given amount
  5521. * @param scale the amount to scale
  5522. */
  5523. scaleInPlace(scale: number): void;
  5524. /**
  5525. * Gets the spherical polynomial from harmonics
  5526. * @param harmonics the spherical harmonics
  5527. * @returns the spherical polynomial
  5528. */
  5529. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5530. /**
  5531. * Constructs a spherical polynomial from an array.
  5532. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5533. * @returns the spherical polynomial
  5534. */
  5535. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5536. }
  5537. }
  5538. declare module BABYLON {
  5539. /**
  5540. * Define options used to create a render target texture
  5541. */
  5542. export class RenderTargetCreationOptions {
  5543. /**
  5544. * Specifies is mipmaps must be generated
  5545. */
  5546. generateMipMaps?: boolean;
  5547. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5548. generateDepthBuffer?: boolean;
  5549. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5550. generateStencilBuffer?: boolean;
  5551. /** Defines texture type (int by default) */
  5552. type?: number;
  5553. /** Defines sampling mode (trilinear by default) */
  5554. samplingMode?: number;
  5555. /** Defines format (RGBA by default) */
  5556. format?: number;
  5557. }
  5558. }
  5559. declare module BABYLON {
  5560. /**
  5561. * @hidden
  5562. **/
  5563. export class _AlphaState {
  5564. private _isAlphaBlendDirty;
  5565. private _isBlendFunctionParametersDirty;
  5566. private _isBlendEquationParametersDirty;
  5567. private _isBlendConstantsDirty;
  5568. private _alphaBlend;
  5569. private _blendFunctionParameters;
  5570. private _blendEquationParameters;
  5571. private _blendConstants;
  5572. /**
  5573. * Initializes the state.
  5574. */
  5575. constructor();
  5576. readonly isDirty: boolean;
  5577. alphaBlend: boolean;
  5578. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5579. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5580. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5581. reset(): void;
  5582. apply(gl: WebGLRenderingContext): void;
  5583. }
  5584. }
  5585. declare module BABYLON {
  5586. /**
  5587. * @hidden
  5588. **/
  5589. export class _DepthCullingState {
  5590. private _isDepthTestDirty;
  5591. private _isDepthMaskDirty;
  5592. private _isDepthFuncDirty;
  5593. private _isCullFaceDirty;
  5594. private _isCullDirty;
  5595. private _isZOffsetDirty;
  5596. private _isFrontFaceDirty;
  5597. private _depthTest;
  5598. private _depthMask;
  5599. private _depthFunc;
  5600. private _cull;
  5601. private _cullFace;
  5602. private _zOffset;
  5603. private _frontFace;
  5604. /**
  5605. * Initializes the state.
  5606. */
  5607. constructor();
  5608. readonly isDirty: boolean;
  5609. zOffset: number;
  5610. cullFace: Nullable<number>;
  5611. cull: Nullable<boolean>;
  5612. depthFunc: Nullable<number>;
  5613. depthMask: boolean;
  5614. depthTest: boolean;
  5615. frontFace: Nullable<number>;
  5616. reset(): void;
  5617. apply(gl: WebGLRenderingContext): void;
  5618. }
  5619. }
  5620. declare module BABYLON {
  5621. /**
  5622. * @hidden
  5623. **/
  5624. export class _StencilState {
  5625. /** 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 */
  5626. static readonly ALWAYS: number;
  5627. /** Passed to stencilOperation to specify that stencil value must be kept */
  5628. static readonly KEEP: number;
  5629. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5630. static readonly REPLACE: number;
  5631. private _isStencilTestDirty;
  5632. private _isStencilMaskDirty;
  5633. private _isStencilFuncDirty;
  5634. private _isStencilOpDirty;
  5635. private _stencilTest;
  5636. private _stencilMask;
  5637. private _stencilFunc;
  5638. private _stencilFuncRef;
  5639. private _stencilFuncMask;
  5640. private _stencilOpStencilFail;
  5641. private _stencilOpDepthFail;
  5642. private _stencilOpStencilDepthPass;
  5643. readonly isDirty: boolean;
  5644. stencilFunc: number;
  5645. stencilFuncRef: number;
  5646. stencilFuncMask: number;
  5647. stencilOpStencilFail: number;
  5648. stencilOpDepthFail: number;
  5649. stencilOpStencilDepthPass: number;
  5650. stencilMask: number;
  5651. stencilTest: boolean;
  5652. constructor();
  5653. reset(): void;
  5654. apply(gl: WebGLRenderingContext): void;
  5655. }
  5656. }
  5657. declare module BABYLON {
  5658. /**
  5659. * @hidden
  5660. **/
  5661. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  5662. }
  5663. }
  5664. declare module BABYLON {
  5665. /**
  5666. * Class used to evalaute queries containing `and` and `or` operators
  5667. */
  5668. export class AndOrNotEvaluator {
  5669. /**
  5670. * Evaluate a query
  5671. * @param query defines the query to evaluate
  5672. * @param evaluateCallback defines the callback used to filter result
  5673. * @returns true if the query matches
  5674. */
  5675. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5676. private static _HandleParenthesisContent;
  5677. private static _SimplifyNegation;
  5678. }
  5679. }
  5680. declare module BABYLON {
  5681. /**
  5682. * Class used to store custom tags
  5683. */
  5684. export class Tags {
  5685. /**
  5686. * Adds support for tags on the given object
  5687. * @param obj defines the object to use
  5688. */
  5689. static EnableFor(obj: any): void;
  5690. /**
  5691. * Removes tags support
  5692. * @param obj defines the object to use
  5693. */
  5694. static DisableFor(obj: any): void;
  5695. /**
  5696. * Gets a boolean indicating if the given object has tags
  5697. * @param obj defines the object to use
  5698. * @returns a boolean
  5699. */
  5700. static HasTags(obj: any): boolean;
  5701. /**
  5702. * Gets the tags available on a given object
  5703. * @param obj defines the object to use
  5704. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5705. * @returns the tags
  5706. */
  5707. static GetTags(obj: any, asString?: boolean): any;
  5708. /**
  5709. * Adds tags to an object
  5710. * @param obj defines the object to use
  5711. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5712. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5713. */
  5714. static AddTagsTo(obj: any, tagsString: string): void;
  5715. /**
  5716. * @hidden
  5717. */ private static _AddTagTo(obj: any, tag: string): void;
  5718. /**
  5719. * Removes specific tags from a specific object
  5720. * @param obj defines the object to use
  5721. * @param tagsString defines the tags to remove
  5722. */
  5723. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5724. /**
  5725. * @hidden
  5726. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5727. /**
  5728. * Defines if tags hosted on an object match a given query
  5729. * @param obj defines the object to use
  5730. * @param tagsQuery defines the tag query
  5731. * @returns a boolean
  5732. */
  5733. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5734. }
  5735. }
  5736. declare module BABYLON {
  5737. /**
  5738. * Defines potential orientation for back face culling
  5739. */
  5740. export enum Orientation {
  5741. /**
  5742. * Clockwise
  5743. */
  5744. CW = 0,
  5745. /** Counter clockwise */
  5746. CCW = 1
  5747. }
  5748. /** Class used to represent a Bezier curve */
  5749. export class BezierCurve {
  5750. /**
  5751. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5752. * @param t defines the time
  5753. * @param x1 defines the left coordinate on X axis
  5754. * @param y1 defines the left coordinate on Y axis
  5755. * @param x2 defines the right coordinate on X axis
  5756. * @param y2 defines the right coordinate on Y axis
  5757. * @returns the interpolated value
  5758. */
  5759. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5760. }
  5761. /**
  5762. * Defines angle representation
  5763. */
  5764. export class Angle {
  5765. private _radians;
  5766. /**
  5767. * Creates an Angle object of "radians" radians (float).
  5768. * @param radians the angle in radians
  5769. */
  5770. constructor(radians: number);
  5771. /**
  5772. * Get value in degrees
  5773. * @returns the Angle value in degrees (float)
  5774. */
  5775. degrees(): number;
  5776. /**
  5777. * Get value in radians
  5778. * @returns the Angle value in radians (float)
  5779. */
  5780. radians(): number;
  5781. /**
  5782. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5783. * @param a defines first vector
  5784. * @param b defines second vector
  5785. * @returns a new Angle
  5786. */
  5787. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5788. /**
  5789. * Gets a new Angle object from the given float in radians
  5790. * @param radians defines the angle value in radians
  5791. * @returns a new Angle
  5792. */
  5793. static FromRadians(radians: number): Angle;
  5794. /**
  5795. * Gets a new Angle object from the given float in degrees
  5796. * @param degrees defines the angle value in degrees
  5797. * @returns a new Angle
  5798. */
  5799. static FromDegrees(degrees: number): Angle;
  5800. }
  5801. /**
  5802. * This represents an arc in a 2d space.
  5803. */
  5804. export class Arc2 {
  5805. /** Defines the start point of the arc */
  5806. startPoint: Vector2;
  5807. /** Defines the mid point of the arc */
  5808. midPoint: Vector2;
  5809. /** Defines the end point of the arc */
  5810. endPoint: Vector2;
  5811. /**
  5812. * Defines the center point of the arc.
  5813. */
  5814. centerPoint: Vector2;
  5815. /**
  5816. * Defines the radius of the arc.
  5817. */
  5818. radius: number;
  5819. /**
  5820. * Defines the angle of the arc (from mid point to end point).
  5821. */
  5822. angle: Angle;
  5823. /**
  5824. * Defines the start angle of the arc (from start point to middle point).
  5825. */
  5826. startAngle: Angle;
  5827. /**
  5828. * Defines the orientation of the arc (clock wise/counter clock wise).
  5829. */
  5830. orientation: Orientation;
  5831. /**
  5832. * Creates an Arc object from the three given points : start, middle and end.
  5833. * @param startPoint Defines the start point of the arc
  5834. * @param midPoint Defines the midlle point of the arc
  5835. * @param endPoint Defines the end point of the arc
  5836. */
  5837. constructor(
  5838. /** Defines the start point of the arc */
  5839. startPoint: Vector2,
  5840. /** Defines the mid point of the arc */
  5841. midPoint: Vector2,
  5842. /** Defines the end point of the arc */
  5843. endPoint: Vector2);
  5844. }
  5845. /**
  5846. * Represents a 2D path made up of multiple 2D points
  5847. */
  5848. export class Path2 {
  5849. private _points;
  5850. private _length;
  5851. /**
  5852. * If the path start and end point are the same
  5853. */
  5854. closed: boolean;
  5855. /**
  5856. * Creates a Path2 object from the starting 2D coordinates x and y.
  5857. * @param x the starting points x value
  5858. * @param y the starting points y value
  5859. */
  5860. constructor(x: number, y: number);
  5861. /**
  5862. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5863. * @param x the added points x value
  5864. * @param y the added points y value
  5865. * @returns the updated Path2.
  5866. */
  5867. addLineTo(x: number, y: number): Path2;
  5868. /**
  5869. * 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.
  5870. * @param midX middle point x value
  5871. * @param midY middle point y value
  5872. * @param endX end point x value
  5873. * @param endY end point y value
  5874. * @param numberOfSegments (default: 36)
  5875. * @returns the updated Path2.
  5876. */
  5877. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5878. /**
  5879. * Closes the Path2.
  5880. * @returns the Path2.
  5881. */
  5882. close(): Path2;
  5883. /**
  5884. * Gets the sum of the distance between each sequential point in the path
  5885. * @returns the Path2 total length (float).
  5886. */
  5887. length(): number;
  5888. /**
  5889. * Gets the points which construct the path
  5890. * @returns the Path2 internal array of points.
  5891. */
  5892. getPoints(): Vector2[];
  5893. /**
  5894. * Retreives the point at the distance aways from the starting point
  5895. * @param normalizedLengthPosition the length along the path to retreive the point from
  5896. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5897. */
  5898. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5899. /**
  5900. * Creates a new path starting from an x and y position
  5901. * @param x starting x value
  5902. * @param y starting y value
  5903. * @returns a new Path2 starting at the coordinates (x, y).
  5904. */
  5905. static StartingAt(x: number, y: number): Path2;
  5906. }
  5907. /**
  5908. * Represents a 3D path made up of multiple 3D points
  5909. */
  5910. export class Path3D {
  5911. /**
  5912. * an array of Vector3, the curve axis of the Path3D
  5913. */
  5914. path: Vector3[];
  5915. private _curve;
  5916. private _distances;
  5917. private _tangents;
  5918. private _normals;
  5919. private _binormals;
  5920. private _raw;
  5921. /**
  5922. * new Path3D(path, normal, raw)
  5923. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5924. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5925. * @param path an array of Vector3, the curve axis of the Path3D
  5926. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5927. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5928. */
  5929. constructor(
  5930. /**
  5931. * an array of Vector3, the curve axis of the Path3D
  5932. */
  5933. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5934. /**
  5935. * Returns the Path3D array of successive Vector3 designing its curve.
  5936. * @returns the Path3D array of successive Vector3 designing its curve.
  5937. */
  5938. getCurve(): Vector3[];
  5939. /**
  5940. * Returns an array populated with tangent vectors on each Path3D curve point.
  5941. * @returns an array populated with tangent vectors on each Path3D curve point.
  5942. */
  5943. getTangents(): Vector3[];
  5944. /**
  5945. * Returns an array populated with normal vectors on each Path3D curve point.
  5946. * @returns an array populated with normal vectors on each Path3D curve point.
  5947. */
  5948. getNormals(): Vector3[];
  5949. /**
  5950. * Returns an array populated with binormal vectors on each Path3D curve point.
  5951. * @returns an array populated with binormal vectors on each Path3D curve point.
  5952. */
  5953. getBinormals(): Vector3[];
  5954. /**
  5955. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5956. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5957. */
  5958. getDistances(): number[];
  5959. /**
  5960. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5961. * @param path path which all values are copied into the curves points
  5962. * @param firstNormal which should be projected onto the curve
  5963. * @returns the same object updated.
  5964. */
  5965. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5966. private _compute;
  5967. private _getFirstNonNullVector;
  5968. private _getLastNonNullVector;
  5969. private _normalVector;
  5970. }
  5971. /**
  5972. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5973. * A Curve3 is designed from a series of successive Vector3.
  5974. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5975. */
  5976. export class Curve3 {
  5977. private _points;
  5978. private _length;
  5979. /**
  5980. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5981. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5982. * @param v1 (Vector3) the control point
  5983. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5984. * @param nbPoints (integer) the wanted number of points in the curve
  5985. * @returns the created Curve3
  5986. */
  5987. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5988. /**
  5989. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5991. * @param v1 (Vector3) the first control point
  5992. * @param v2 (Vector3) the second control point
  5993. * @param v3 (Vector3) the end point of the Cubic Bezier
  5994. * @param nbPoints (integer) the wanted number of points in the curve
  5995. * @returns the created Curve3
  5996. */
  5997. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5998. /**
  5999. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6000. * @param p1 (Vector3) the origin point of the Hermite Spline
  6001. * @param t1 (Vector3) the tangent vector at the origin point
  6002. * @param p2 (Vector3) the end point of the Hermite Spline
  6003. * @param t2 (Vector3) the tangent vector at the end point
  6004. * @param nbPoints (integer) the wanted number of points in the curve
  6005. * @returns the created Curve3
  6006. */
  6007. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6008. /**
  6009. * Returns a Curve3 object along a CatmullRom Spline curve :
  6010. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6011. * @param nbPoints (integer) the wanted number of points between each curve control points
  6012. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6013. * @returns the created Curve3
  6014. */
  6015. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6016. /**
  6017. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6018. * A Curve3 is designed from a series of successive Vector3.
  6019. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6020. * @param points points which make up the curve
  6021. */
  6022. constructor(points: Vector3[]);
  6023. /**
  6024. * @returns the Curve3 stored array of successive Vector3
  6025. */
  6026. getPoints(): Vector3[];
  6027. /**
  6028. * @returns the computed length (float) of the curve.
  6029. */
  6030. length(): number;
  6031. /**
  6032. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6033. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6034. * curveA and curveB keep unchanged.
  6035. * @param curve the curve to continue from this curve
  6036. * @returns the newly constructed curve
  6037. */
  6038. continue(curve: DeepImmutable<Curve3>): Curve3;
  6039. private _computeLength;
  6040. }
  6041. }
  6042. declare module BABYLON {
  6043. /**
  6044. * This represents the main contract an easing function should follow.
  6045. * Easing functions are used throughout the animation system.
  6046. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6047. */
  6048. export interface IEasingFunction {
  6049. /**
  6050. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6051. * of the easing function.
  6052. * The link below provides some of the most common examples of easing functions.
  6053. * @see https://easings.net/
  6054. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6055. * @returns the corresponding value on the curve defined by the easing function
  6056. */
  6057. ease(gradient: number): number;
  6058. }
  6059. /**
  6060. * Base class used for every default easing function.
  6061. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6062. */
  6063. export class EasingFunction implements IEasingFunction {
  6064. /**
  6065. * Interpolation follows the mathematical formula associated with the easing function.
  6066. */
  6067. static readonly EASINGMODE_EASEIN: number;
  6068. /**
  6069. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6070. */
  6071. static readonly EASINGMODE_EASEOUT: number;
  6072. /**
  6073. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6074. */
  6075. static readonly EASINGMODE_EASEINOUT: number;
  6076. private _easingMode;
  6077. /**
  6078. * Sets the easing mode of the current function.
  6079. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6080. */
  6081. setEasingMode(easingMode: number): void;
  6082. /**
  6083. * Gets the current easing mode.
  6084. * @returns the easing mode
  6085. */
  6086. getEasingMode(): number;
  6087. /**
  6088. * @hidden
  6089. */
  6090. easeInCore(gradient: number): number;
  6091. /**
  6092. * Given an input gradient between 0 and 1, this returns the corresponding value
  6093. * of the easing function.
  6094. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6095. * @returns the corresponding value on the curve defined by the easing function
  6096. */
  6097. ease(gradient: number): number;
  6098. }
  6099. /**
  6100. * Easing function with a circle shape (see link below).
  6101. * @see https://easings.net/#easeInCirc
  6102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6103. */
  6104. export class CircleEase extends EasingFunction implements IEasingFunction {
  6105. /** @hidden */
  6106. easeInCore(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a ease back shape (see link below).
  6110. * @see https://easings.net/#easeInBack
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class BackEase extends EasingFunction implements IEasingFunction {
  6114. /** Defines the amplitude of the function */
  6115. amplitude: number;
  6116. /**
  6117. * Instantiates a back ease easing
  6118. * @see https://easings.net/#easeInBack
  6119. * @param amplitude Defines the amplitude of the function
  6120. */
  6121. constructor(
  6122. /** Defines the amplitude of the function */
  6123. amplitude?: number);
  6124. /** @hidden */
  6125. easeInCore(gradient: number): number;
  6126. }
  6127. /**
  6128. * Easing function with a bouncing shape (see link below).
  6129. * @see https://easings.net/#easeInBounce
  6130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6131. */
  6132. export class BounceEase extends EasingFunction implements IEasingFunction {
  6133. /** Defines the number of bounces */
  6134. bounces: number;
  6135. /** Defines the amplitude of the bounce */
  6136. bounciness: number;
  6137. /**
  6138. * Instantiates a bounce easing
  6139. * @see https://easings.net/#easeInBounce
  6140. * @param bounces Defines the number of bounces
  6141. * @param bounciness Defines the amplitude of the bounce
  6142. */
  6143. constructor(
  6144. /** Defines the number of bounces */
  6145. bounces?: number,
  6146. /** Defines the amplitude of the bounce */
  6147. bounciness?: number);
  6148. /** @hidden */
  6149. easeInCore(gradient: number): number;
  6150. }
  6151. /**
  6152. * Easing function with a power of 3 shape (see link below).
  6153. * @see https://easings.net/#easeInCubic
  6154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6155. */
  6156. export class CubicEase extends EasingFunction implements IEasingFunction {
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with an elastic shape (see link below).
  6162. * @see https://easings.net/#easeInElastic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6166. /** Defines the number of oscillations*/
  6167. oscillations: number;
  6168. /** Defines the amplitude of the oscillations*/
  6169. springiness: number;
  6170. /**
  6171. * Instantiates an elastic easing function
  6172. * @see https://easings.net/#easeInElastic
  6173. * @param oscillations Defines the number of oscillations
  6174. * @param springiness Defines the amplitude of the oscillations
  6175. */
  6176. constructor(
  6177. /** Defines the number of oscillations*/
  6178. oscillations?: number,
  6179. /** Defines the amplitude of the oscillations*/
  6180. springiness?: number);
  6181. /** @hidden */
  6182. easeInCore(gradient: number): number;
  6183. }
  6184. /**
  6185. * Easing function with an exponential shape (see link below).
  6186. * @see https://easings.net/#easeInExpo
  6187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6188. */
  6189. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6190. /** Defines the exponent of the function */
  6191. exponent: number;
  6192. /**
  6193. * Instantiates an exponential easing function
  6194. * @see https://easings.net/#easeInExpo
  6195. * @param exponent Defines the exponent of the function
  6196. */
  6197. constructor(
  6198. /** Defines the exponent of the function */
  6199. exponent?: number);
  6200. /** @hidden */
  6201. easeInCore(gradient: number): number;
  6202. }
  6203. /**
  6204. * Easing function with a power shape (see link below).
  6205. * @see https://easings.net/#easeInQuad
  6206. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6207. */
  6208. export class PowerEase extends EasingFunction implements IEasingFunction {
  6209. /** Defines the power of the function */
  6210. power: number;
  6211. /**
  6212. * Instantiates an power base easing function
  6213. * @see https://easings.net/#easeInQuad
  6214. * @param power Defines the power of the function
  6215. */
  6216. constructor(
  6217. /** Defines the power of the function */
  6218. power?: number);
  6219. /** @hidden */
  6220. easeInCore(gradient: number): number;
  6221. }
  6222. /**
  6223. * Easing function with a power of 2 shape (see link below).
  6224. * @see https://easings.net/#easeInQuad
  6225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6226. */
  6227. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 4 shape (see link below).
  6233. * @see https://easings.net/#easeInQuart
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 5 shape (see link below).
  6242. * @see https://easings.net/#easeInQuint
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a sin shape (see link below).
  6251. * @see https://easings.net/#easeInSine
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class SineEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a bezier shape (see link below).
  6260. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6264. /** Defines the x component of the start tangent in the bezier curve */
  6265. x1: number;
  6266. /** Defines the y component of the start tangent in the bezier curve */
  6267. y1: number;
  6268. /** Defines the x component of the end tangent in the bezier curve */
  6269. x2: number;
  6270. /** Defines the y component of the end tangent in the bezier curve */
  6271. y2: number;
  6272. /**
  6273. * Instantiates a bezier function
  6274. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6275. * @param x1 Defines the x component of the start tangent in the bezier curve
  6276. * @param y1 Defines the y component of the start tangent in the bezier curve
  6277. * @param x2 Defines the x component of the end tangent in the bezier curve
  6278. * @param y2 Defines the y component of the end tangent in the bezier curve
  6279. */
  6280. constructor(
  6281. /** Defines the x component of the start tangent in the bezier curve */
  6282. x1?: number,
  6283. /** Defines the y component of the start tangent in the bezier curve */
  6284. y1?: number,
  6285. /** Defines the x component of the end tangent in the bezier curve */
  6286. x2?: number,
  6287. /** Defines the y component of the end tangent in the bezier curve */
  6288. y2?: number);
  6289. /** @hidden */
  6290. easeInCore(gradient: number): number;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. /**
  6295. * Defines an interface which represents an animation key frame
  6296. */
  6297. export interface IAnimationKey {
  6298. /**
  6299. * Frame of the key frame
  6300. */
  6301. frame: number;
  6302. /**
  6303. * Value at the specifies key frame
  6304. */
  6305. value: any;
  6306. /**
  6307. * The input tangent for the cubic hermite spline
  6308. */
  6309. inTangent?: any;
  6310. /**
  6311. * The output tangent for the cubic hermite spline
  6312. */
  6313. outTangent?: any;
  6314. /**
  6315. * The animation interpolation type
  6316. */
  6317. interpolation?: AnimationKeyInterpolation;
  6318. }
  6319. /**
  6320. * Enum for the animation key frame interpolation type
  6321. */
  6322. export enum AnimationKeyInterpolation {
  6323. /**
  6324. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6325. */
  6326. STEP = 1
  6327. }
  6328. }
  6329. declare module BABYLON {
  6330. /**
  6331. * Represents the range of an animation
  6332. */
  6333. export class AnimationRange {
  6334. /**The name of the animation range**/
  6335. name: string;
  6336. /**The starting frame of the animation */
  6337. from: number;
  6338. /**The ending frame of the animation*/
  6339. to: number;
  6340. /**
  6341. * Initializes the range of an animation
  6342. * @param name The name of the animation range
  6343. * @param from The starting frame of the animation
  6344. * @param to The ending frame of the animation
  6345. */
  6346. constructor(
  6347. /**The name of the animation range**/
  6348. name: string,
  6349. /**The starting frame of the animation */
  6350. from: number,
  6351. /**The ending frame of the animation*/
  6352. to: number);
  6353. /**
  6354. * Makes a copy of the animation range
  6355. * @returns A copy of the animation range
  6356. */
  6357. clone(): AnimationRange;
  6358. }
  6359. }
  6360. declare module BABYLON {
  6361. /**
  6362. * Composed of a frame, and an action function
  6363. */
  6364. export class AnimationEvent {
  6365. /** The frame for which the event is triggered **/
  6366. frame: number;
  6367. /** The event to perform when triggered **/
  6368. action: (currentFrame: number) => void;
  6369. /** Specifies if the event should be triggered only once**/
  6370. onlyOnce?: boolean | undefined;
  6371. /**
  6372. * Specifies if the animation event is done
  6373. */
  6374. isDone: boolean;
  6375. /**
  6376. * Initializes the animation event
  6377. * @param frame The frame for which the event is triggered
  6378. * @param action The event to perform when triggered
  6379. * @param onlyOnce Specifies if the event should be triggered only once
  6380. */
  6381. constructor(
  6382. /** The frame for which the event is triggered **/
  6383. frame: number,
  6384. /** The event to perform when triggered **/
  6385. action: (currentFrame: number) => void,
  6386. /** Specifies if the event should be triggered only once**/
  6387. onlyOnce?: boolean | undefined);
  6388. /** @hidden */ private _clone(): AnimationEvent;
  6389. }
  6390. }
  6391. declare module BABYLON {
  6392. /**
  6393. * Interface used to define a behavior
  6394. */
  6395. export interface Behavior<T> {
  6396. /** gets or sets behavior's name */
  6397. name: string;
  6398. /**
  6399. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6400. */
  6401. init(): void;
  6402. /**
  6403. * Called when the behavior is attached to a target
  6404. * @param target defines the target where the behavior is attached to
  6405. */
  6406. attach(target: T): void;
  6407. /**
  6408. * Called when the behavior is detached from its target
  6409. */
  6410. detach(): void;
  6411. }
  6412. /**
  6413. * Interface implemented by classes supporting behaviors
  6414. */
  6415. export interface IBehaviorAware<T> {
  6416. /**
  6417. * Attach a behavior
  6418. * @param behavior defines the behavior to attach
  6419. * @returns the current host
  6420. */
  6421. addBehavior(behavior: Behavior<T>): T;
  6422. /**
  6423. * Remove a behavior from the current object
  6424. * @param behavior defines the behavior to detach
  6425. * @returns the current host
  6426. */
  6427. removeBehavior(behavior: Behavior<T>): T;
  6428. /**
  6429. * Gets a behavior using its name to search
  6430. * @param name defines the name to search
  6431. * @returns the behavior or null if not found
  6432. */
  6433. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6434. }
  6435. }
  6436. declare module BABYLON {
  6437. /**
  6438. * Defines an array and its length.
  6439. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6440. */
  6441. export interface ISmartArrayLike<T> {
  6442. /**
  6443. * The data of the array.
  6444. */
  6445. data: Array<T>;
  6446. /**
  6447. * The active length of the array.
  6448. */
  6449. length: number;
  6450. }
  6451. /**
  6452. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6453. */
  6454. export class SmartArray<T> implements ISmartArrayLike<T> {
  6455. /**
  6456. * The full set of data from the array.
  6457. */
  6458. data: Array<T>;
  6459. /**
  6460. * The active length of the array.
  6461. */
  6462. length: number;
  6463. protected _id: number;
  6464. /**
  6465. * Instantiates a Smart Array.
  6466. * @param capacity defines the default capacity of the array.
  6467. */
  6468. constructor(capacity: number);
  6469. /**
  6470. * Pushes a value at the end of the active data.
  6471. * @param value defines the object to push in the array.
  6472. */
  6473. push(value: T): void;
  6474. /**
  6475. * Iterates over the active data and apply the lambda to them.
  6476. * @param func defines the action to apply on each value.
  6477. */
  6478. forEach(func: (content: T) => void): void;
  6479. /**
  6480. * Sorts the full sets of data.
  6481. * @param compareFn defines the comparison function to apply.
  6482. */
  6483. sort(compareFn: (a: T, b: T) => number): void;
  6484. /**
  6485. * Resets the active data to an empty array.
  6486. */
  6487. reset(): void;
  6488. /**
  6489. * Releases all the data from the array as well as the array.
  6490. */
  6491. dispose(): void;
  6492. /**
  6493. * Concats the active data with a given array.
  6494. * @param array defines the data to concatenate with.
  6495. */
  6496. concat(array: any): void;
  6497. /**
  6498. * Returns the position of a value in the active data.
  6499. * @param value defines the value to find the index for
  6500. * @returns the index if found in the active data otherwise -1
  6501. */
  6502. indexOf(value: T): number;
  6503. /**
  6504. * Returns whether an element is part of the active data.
  6505. * @param value defines the value to look for
  6506. * @returns true if found in the active data otherwise false
  6507. */
  6508. contains(value: T): boolean;
  6509. private static _GlobalId;
  6510. }
  6511. /**
  6512. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6513. * The data in this array can only be present once
  6514. */
  6515. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6516. private _duplicateId;
  6517. /**
  6518. * Pushes a value at the end of the active data.
  6519. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6520. * @param value defines the object to push in the array.
  6521. */
  6522. push(value: T): void;
  6523. /**
  6524. * Pushes a value at the end of the active data.
  6525. * If the data is already present, it won t be added again
  6526. * @param value defines the object to push in the array.
  6527. * @returns true if added false if it was already present
  6528. */
  6529. pushNoDuplicate(value: T): boolean;
  6530. /**
  6531. * Resets the active data to an empty array.
  6532. */
  6533. reset(): void;
  6534. /**
  6535. * Concats the active data with a given array.
  6536. * This ensures no dupplicate will be present in the result.
  6537. * @param array defines the data to concatenate with.
  6538. */
  6539. concatWithNoDuplicate(array: any): void;
  6540. }
  6541. }
  6542. declare module BABYLON {
  6543. /**
  6544. * @ignore
  6545. * This is a list of all the different input types that are available in the application.
  6546. * Fo instance: ArcRotateCameraGamepadInput...
  6547. */
  6548. export var CameraInputTypes: {};
  6549. /**
  6550. * This is the contract to implement in order to create a new input class.
  6551. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6552. */
  6553. export interface ICameraInput<TCamera extends Camera> {
  6554. /**
  6555. * Defines the camera the input is attached to.
  6556. */
  6557. camera: Nullable<TCamera>;
  6558. /**
  6559. * Gets the class name of the current intput.
  6560. * @returns the class name
  6561. */
  6562. getClassName(): string;
  6563. /**
  6564. * Get the friendly name associated with the input class.
  6565. * @returns the input friendly name
  6566. */
  6567. getSimpleName(): string;
  6568. /**
  6569. * Attach the input controls to a specific dom element to get the input from.
  6570. * @param element Defines the element the controls should be listened from
  6571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6572. */
  6573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6574. /**
  6575. * Detach the current controls from the specified dom element.
  6576. * @param element Defines the element to stop listening the inputs from
  6577. */
  6578. detachControl(element: Nullable<HTMLElement>): void;
  6579. /**
  6580. * Update the current camera state depending on the inputs that have been used this frame.
  6581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6582. */
  6583. checkInputs?: () => void;
  6584. }
  6585. /**
  6586. * Represents a map of input types to input instance or input index to input instance.
  6587. */
  6588. export interface CameraInputsMap<TCamera extends Camera> {
  6589. /**
  6590. * Accessor to the input by input type.
  6591. */
  6592. [name: string]: ICameraInput<TCamera>;
  6593. /**
  6594. * Accessor to the input by input index.
  6595. */
  6596. [idx: number]: ICameraInput<TCamera>;
  6597. }
  6598. /**
  6599. * This represents the input manager used within a camera.
  6600. * It helps dealing with all the different kind of input attached to a camera.
  6601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6602. */
  6603. export class CameraInputsManager<TCamera extends Camera> {
  6604. /**
  6605. * Defines the list of inputs attahed to the camera.
  6606. */
  6607. attached: CameraInputsMap<TCamera>;
  6608. /**
  6609. * Defines the dom element the camera is collecting inputs from.
  6610. * This is null if the controls have not been attached.
  6611. */
  6612. attachedElement: Nullable<HTMLElement>;
  6613. /**
  6614. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6615. */
  6616. noPreventDefault: boolean;
  6617. /**
  6618. * Defined the camera the input manager belongs to.
  6619. */
  6620. camera: TCamera;
  6621. /**
  6622. * Update the current camera state depending on the inputs that have been used this frame.
  6623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6624. */
  6625. checkInputs: () => void;
  6626. /**
  6627. * Instantiate a new Camera Input Manager.
  6628. * @param camera Defines the camera the input manager blongs to
  6629. */
  6630. constructor(camera: TCamera);
  6631. /**
  6632. * Add an input method to a camera
  6633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6634. * @param input camera input method
  6635. */
  6636. add(input: ICameraInput<TCamera>): void;
  6637. /**
  6638. * Remove a specific input method from a camera
  6639. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6640. * @param inputToRemove camera input method
  6641. */
  6642. remove(inputToRemove: ICameraInput<TCamera>): void;
  6643. /**
  6644. * Remove a specific input type from a camera
  6645. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6646. * @param inputType the type of the input to remove
  6647. */
  6648. removeByType(inputType: string): void;
  6649. private _addCheckInputs;
  6650. /**
  6651. * Attach the input controls to the currently attached dom element to listen the events from.
  6652. * @param input Defines the input to attach
  6653. */
  6654. attachInput(input: ICameraInput<TCamera>): void;
  6655. /**
  6656. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6657. * @param element Defines the dom element to collect the events from
  6658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6659. */
  6660. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6661. /**
  6662. * Detach the current manager inputs controls from a specific dom element.
  6663. * @param element Defines the dom element to collect the events from
  6664. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6665. */
  6666. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6667. /**
  6668. * Rebuild the dynamic inputCheck function from the current list of
  6669. * defined inputs in the manager.
  6670. */
  6671. rebuildInputCheck(): void;
  6672. /**
  6673. * Remove all attached input methods from a camera
  6674. */
  6675. clear(): void;
  6676. /**
  6677. * Serialize the current input manager attached to a camera.
  6678. * This ensures than once parsed,
  6679. * the input associated to the camera will be identical to the current ones
  6680. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6681. */
  6682. serialize(serializedCamera: any): void;
  6683. /**
  6684. * Parses an input manager serialized JSON to restore the previous list of inputs
  6685. * and states associated to a camera.
  6686. * @param parsedCamera Defines the JSON to parse
  6687. */
  6688. parse(parsedCamera: any): void;
  6689. }
  6690. }
  6691. declare module BABYLON {
  6692. /**
  6693. * @hidden
  6694. */
  6695. export class IntersectionInfo {
  6696. bu: Nullable<number>;
  6697. bv: Nullable<number>;
  6698. distance: number;
  6699. faceId: number;
  6700. subMeshId: number;
  6701. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6702. }
  6703. }
  6704. declare module BABYLON {
  6705. /**
  6706. * Represens a plane by the equation ax + by + cz + d = 0
  6707. */
  6708. export class Plane {
  6709. private static _TmpMatrix;
  6710. /**
  6711. * Normal of the plane (a,b,c)
  6712. */
  6713. normal: Vector3;
  6714. /**
  6715. * d component of the plane
  6716. */
  6717. d: number;
  6718. /**
  6719. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6720. * @param a a component of the plane
  6721. * @param b b component of the plane
  6722. * @param c c component of the plane
  6723. * @param d d component of the plane
  6724. */
  6725. constructor(a: number, b: number, c: number, d: number);
  6726. /**
  6727. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6728. */
  6729. asArray(): number[];
  6730. /**
  6731. * @returns a new plane copied from the current Plane.
  6732. */
  6733. clone(): Plane;
  6734. /**
  6735. * @returns the string "Plane".
  6736. */
  6737. getClassName(): string;
  6738. /**
  6739. * @returns the Plane hash code.
  6740. */
  6741. getHashCode(): number;
  6742. /**
  6743. * Normalize the current Plane in place.
  6744. * @returns the updated Plane.
  6745. */
  6746. normalize(): Plane;
  6747. /**
  6748. * Applies a transformation the plane and returns the result
  6749. * @param transformation the transformation matrix to be applied to the plane
  6750. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6751. */
  6752. transform(transformation: DeepImmutable<Matrix>): Plane;
  6753. /**
  6754. * Calcualtte the dot product between the point and the plane normal
  6755. * @param point point to calculate the dot product with
  6756. * @returns the dot product (float) of the point coordinates and the plane normal.
  6757. */
  6758. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6759. /**
  6760. * Updates the current Plane from the plane defined by the three given points.
  6761. * @param point1 one of the points used to contruct the plane
  6762. * @param point2 one of the points used to contruct the plane
  6763. * @param point3 one of the points used to contruct the plane
  6764. * @returns the updated Plane.
  6765. */
  6766. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6767. /**
  6768. * Checks if the plane is facing a given direction
  6769. * @param direction the direction to check if the plane is facing
  6770. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6771. * @returns True is the vector "direction" is the same side than the plane normal.
  6772. */
  6773. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6774. /**
  6775. * Calculates the distance to a point
  6776. * @param point point to calculate distance to
  6777. * @returns the signed distance (float) from the given point to the Plane.
  6778. */
  6779. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6780. /**
  6781. * Creates a plane from an array
  6782. * @param array the array to create a plane from
  6783. * @returns a new Plane from the given array.
  6784. */
  6785. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6786. /**
  6787. * Creates a plane from three points
  6788. * @param point1 point used to create the plane
  6789. * @param point2 point used to create the plane
  6790. * @param point3 point used to create the plane
  6791. * @returns a new Plane defined by the three given points.
  6792. */
  6793. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6794. /**
  6795. * Creates a plane from an origin point and a normal
  6796. * @param origin origin of the plane to be constructed
  6797. * @param normal normal of the plane to be constructed
  6798. * @returns a new Plane the normal vector to this plane at the given origin point.
  6799. * Note : the vector "normal" is updated because normalized.
  6800. */
  6801. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6802. /**
  6803. * Calculates the distance from a plane and a point
  6804. * @param origin origin of the plane to be constructed
  6805. * @param normal normal of the plane to be constructed
  6806. * @param point point to calculate distance to
  6807. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6808. */
  6809. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6810. }
  6811. }
  6812. declare module BABYLON {
  6813. /**
  6814. * Class used to store bounding sphere information
  6815. */
  6816. export class BoundingSphere {
  6817. /**
  6818. * Gets the center of the bounding sphere in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Radius of the bounding sphere in local space
  6823. */
  6824. radius: number;
  6825. /**
  6826. * Gets the center of the bounding sphere in world space
  6827. */
  6828. readonly centerWorld: Vector3;
  6829. /**
  6830. * Radius of the bounding sphere in world space
  6831. */
  6832. radiusWorld: number;
  6833. /**
  6834. * Gets the minimum vector in local space
  6835. */
  6836. readonly minimum: Vector3;
  6837. /**
  6838. * Gets the maximum vector in local space
  6839. */
  6840. readonly maximum: Vector3;
  6841. private _worldMatrix;
  6842. private static readonly TmpVector3;
  6843. /**
  6844. * Creates a new bounding sphere
  6845. * @param min defines the minimum vector (in local space)
  6846. * @param max defines the maximum vector (in local space)
  6847. * @param worldMatrix defines the new world matrix
  6848. */
  6849. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6850. /**
  6851. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6852. * @param min defines the new minimum vector (in local space)
  6853. * @param max defines the new maximum vector (in local space)
  6854. * @param worldMatrix defines the new world matrix
  6855. */
  6856. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6857. /**
  6858. * Scale the current bounding sphere by applying a scale factor
  6859. * @param factor defines the scale factor to apply
  6860. * @returns the current bounding box
  6861. */
  6862. scale(factor: number): BoundingSphere;
  6863. /**
  6864. * Gets the world matrix of the bounding box
  6865. * @returns a matrix
  6866. */
  6867. getWorldMatrix(): DeepImmutable<Matrix>;
  6868. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6869. /**
  6870. * Tests if the bounding sphere is intersecting the frustum planes
  6871. * @param frustumPlanes defines the frustum planes to test
  6872. * @returns true if there is an intersection
  6873. */
  6874. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6875. /**
  6876. * Tests if the bounding sphere center is in between the frustum planes.
  6877. * Used for optimistic fast inclusion.
  6878. * @param frustumPlanes defines the frustum planes to test
  6879. * @returns true if the sphere center is in between the frustum planes
  6880. */
  6881. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6882. /**
  6883. * Tests if a point is inside the bounding sphere
  6884. * @param point defines the point to test
  6885. * @returns true if the point is inside the bounding sphere
  6886. */
  6887. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6888. /**
  6889. * Checks if two sphere intersct
  6890. * @param sphere0 sphere 0
  6891. * @param sphere1 sphere 1
  6892. * @returns true if the speres intersect
  6893. */
  6894. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6895. }
  6896. }
  6897. declare module BABYLON {
  6898. /**
  6899. * Class used to store bounding box information
  6900. */
  6901. export class BoundingBox implements ICullable {
  6902. /**
  6903. * Gets the 8 vectors representing the bounding box in local space
  6904. */
  6905. readonly vectors: Vector3[];
  6906. /**
  6907. * Gets the center of the bounding box in local space
  6908. */
  6909. readonly center: Vector3;
  6910. /**
  6911. * Gets the center of the bounding box in world space
  6912. */
  6913. readonly centerWorld: Vector3;
  6914. /**
  6915. * Gets the extend size in local space
  6916. */
  6917. readonly extendSize: Vector3;
  6918. /**
  6919. * Gets the extend size in world space
  6920. */
  6921. readonly extendSizeWorld: Vector3;
  6922. /**
  6923. * Gets the OBB (object bounding box) directions
  6924. */
  6925. readonly directions: Vector3[];
  6926. /**
  6927. * Gets the 8 vectors representing the bounding box in world space
  6928. */
  6929. readonly vectorsWorld: Vector3[];
  6930. /**
  6931. * Gets the minimum vector in world space
  6932. */
  6933. readonly minimumWorld: Vector3;
  6934. /**
  6935. * Gets the maximum vector in world space
  6936. */
  6937. readonly maximumWorld: Vector3;
  6938. /**
  6939. * Gets the minimum vector in local space
  6940. */
  6941. readonly minimum: Vector3;
  6942. /**
  6943. * Gets the maximum vector in local space
  6944. */
  6945. readonly maximum: Vector3;
  6946. private _worldMatrix;
  6947. private static readonly TmpVector3;
  6948. /**
  6949. * @hidden
  6950. */ private _tag: number;
  6951. /**
  6952. * Creates a new bounding box
  6953. * @param min defines the minimum vector (in local space)
  6954. * @param max defines the maximum vector (in local space)
  6955. * @param worldMatrix defines the new world matrix
  6956. */
  6957. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6958. /**
  6959. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6960. * @param min defines the new minimum vector (in local space)
  6961. * @param max defines the new maximum vector (in local space)
  6962. * @param worldMatrix defines the new world matrix
  6963. */
  6964. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6965. /**
  6966. * Scale the current bounding box by applying a scale factor
  6967. * @param factor defines the scale factor to apply
  6968. * @returns the current bounding box
  6969. */
  6970. scale(factor: number): BoundingBox;
  6971. /**
  6972. * Gets the world matrix of the bounding box
  6973. * @returns a matrix
  6974. */
  6975. getWorldMatrix(): DeepImmutable<Matrix>;
  6976. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Tests if the bounding box is intersecting the frustum planes
  6979. * @param frustumPlanes defines the frustum planes to test
  6980. * @returns true if there is an intersection
  6981. */
  6982. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6983. /**
  6984. * Tests if the bounding box is entirely inside the frustum planes
  6985. * @param frustumPlanes defines the frustum planes to test
  6986. * @returns true if there is an inclusion
  6987. */
  6988. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6989. /**
  6990. * Tests if a point is inside the bounding box
  6991. * @param point defines the point to test
  6992. * @returns true if the point is inside the bounding box
  6993. */
  6994. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if the bounding box intersects with a bounding sphere
  6997. * @param sphere defines the sphere to test
  6998. * @returns true if there is an intersection
  6999. */
  7000. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7001. /**
  7002. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7003. * @param min defines the min vector to use
  7004. * @param max defines the max vector to use
  7005. * @returns true if there is an intersection
  7006. */
  7007. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if two bounding boxes are intersections
  7010. * @param box0 defines the first box to test
  7011. * @param box1 defines the second box to test
  7012. * @returns true if there is an intersection
  7013. */
  7014. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7015. /**
  7016. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7017. * @param minPoint defines the minimum vector of the bounding box
  7018. * @param maxPoint defines the maximum vector of the bounding box
  7019. * @param sphereCenter defines the sphere center
  7020. * @param sphereRadius defines the sphere radius
  7021. * @returns true if there is an intersection
  7022. */
  7023. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7024. /**
  7025. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7026. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @return true if there is an inclusion
  7029. */
  7030. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7033. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7034. * @param frustumPlanes defines the frustum planes to test
  7035. * @return true if there is an intersection
  7036. */
  7037. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /** @hidden */
  7042. export class Collider {
  7043. /** Define if a collision was found */
  7044. collisionFound: boolean;
  7045. /**
  7046. * Define last intersection point in local space
  7047. */
  7048. intersectionPoint: Vector3;
  7049. /**
  7050. * Define last collided mesh
  7051. */
  7052. collidedMesh: Nullable<AbstractMesh>;
  7053. private _collisionPoint;
  7054. private _planeIntersectionPoint;
  7055. private _tempVector;
  7056. private _tempVector2;
  7057. private _tempVector3;
  7058. private _tempVector4;
  7059. private _edge;
  7060. private _baseToVertex;
  7061. private _destinationPoint;
  7062. private _slidePlaneNormal;
  7063. private _displacementVector;
  7064. /** @hidden */ private _radius: Vector3;
  7065. /** @hidden */ private _retry: number;
  7066. private _velocity;
  7067. private _basePoint;
  7068. private _epsilon;
  7069. /** @hidden */ private _velocityWorldLength: number;
  7070. /** @hidden */ private _basePointWorld: Vector3;
  7071. private _velocityWorld;
  7072. private _normalizedVelocity;
  7073. /** @hidden */ private _initialVelocity: Vector3;
  7074. /** @hidden */ private _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. collisionMask: number;
  7078. /**
  7079. * Gets the plane normal used to compute the sliding response (in local space)
  7080. */
  7081. readonly slidePlaneNormal: Vector3;
  7082. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7083. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7084. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7085. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7086. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7087. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7088. }
  7089. }
  7090. declare module BABYLON {
  7091. /**
  7092. * Interface for cullable objects
  7093. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7094. */
  7095. export interface ICullable {
  7096. /**
  7097. * Checks if the object or part of the object is in the frustum
  7098. * @param frustumPlanes Camera near/planes
  7099. * @returns true if the object is in frustum otherwise false
  7100. */
  7101. isInFrustum(frustumPlanes: Plane[]): boolean;
  7102. /**
  7103. * Checks if a cullable object (mesh...) is in the camera frustum
  7104. * Unlike isInFrustum this cheks the full bounding box
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7109. }
  7110. /**
  7111. * Info for a bounding data of a mesh
  7112. */
  7113. export class BoundingInfo implements ICullable {
  7114. /**
  7115. * Bounding box for the mesh
  7116. */
  7117. readonly boundingBox: BoundingBox;
  7118. /**
  7119. * Bounding sphere for the mesh
  7120. */
  7121. readonly boundingSphere: BoundingSphere;
  7122. private _isLocked;
  7123. private static readonly TmpVector3;
  7124. /**
  7125. * Constructs bounding info
  7126. * @param minimum min vector of the bounding box/sphere
  7127. * @param maximum max vector of the bounding box/sphere
  7128. * @param worldMatrix defines the new world matrix
  7129. */
  7130. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7131. /**
  7132. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7133. * @param min defines the new minimum vector (in local space)
  7134. * @param max defines the new maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7138. /**
  7139. * min vector of the bounding box/sphere
  7140. */
  7141. readonly minimum: Vector3;
  7142. /**
  7143. * max vector of the bounding box/sphere
  7144. */
  7145. readonly maximum: Vector3;
  7146. /**
  7147. * If the info is locked and won't be updated to avoid perf overhead
  7148. */
  7149. isLocked: boolean;
  7150. /**
  7151. * Updates the bounding sphere and box
  7152. * @param world world matrix to be used to update
  7153. */
  7154. update(world: DeepImmutable<Matrix>): void;
  7155. /**
  7156. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7157. * @param center New center of the bounding info
  7158. * @param extend New extend of the bounding info
  7159. * @returns the current bounding info
  7160. */
  7161. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7162. /**
  7163. * Scale the current bounding info by applying a scale factor
  7164. * @param factor defines the scale factor to apply
  7165. * @returns the current bounding info
  7166. */
  7167. scale(factor: number): BoundingInfo;
  7168. /**
  7169. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7170. * @param frustumPlanes defines the frustum to test
  7171. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7172. * @returns true if the bounding info is in the frustum planes
  7173. */
  7174. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7175. /**
  7176. * Gets the world distance between the min and max points of the bounding box
  7177. */
  7178. readonly diagonalLength: number;
  7179. /**
  7180. * Checks if a cullable object (mesh...) is in the camera frustum
  7181. * Unlike isInFrustum this cheks the full bounding box
  7182. * @param frustumPlanes Camera near/planes
  7183. * @returns true if the object is in frustum otherwise false
  7184. */
  7185. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7186. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7187. /**
  7188. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7189. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7190. * @param point the point to check intersection with
  7191. * @returns if the point intersects
  7192. */
  7193. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7194. /**
  7195. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param boundingInfo the bounding info to check intersection with
  7198. * @param precise if the intersection should be done using OBB
  7199. * @returns if the bounding info intersects
  7200. */
  7201. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7202. }
  7203. }
  7204. declare module BABYLON {
  7205. /**
  7206. * Extracts minimum and maximum values from a list of indexed positions
  7207. * @param positions defines the positions to use
  7208. * @param indices defines the indices to the positions
  7209. * @param indexStart defines the start index
  7210. * @param indexCount defines the end index
  7211. * @param bias defines bias value to add to the result
  7212. * @return minimum and maximum values
  7213. */
  7214. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7215. minimum: Vector3;
  7216. maximum: Vector3;
  7217. };
  7218. /**
  7219. * Extracts minimum and maximum values from a list of positions
  7220. * @param positions defines the positions to use
  7221. * @param start defines the start index in the positions array
  7222. * @param count defines the number of positions to handle
  7223. * @param bias defines bias value to add to the result
  7224. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7225. * @return minimum and maximum values
  7226. */
  7227. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7228. minimum: Vector3;
  7229. maximum: Vector3;
  7230. };
  7231. }
  7232. declare module BABYLON {
  7233. /**
  7234. * Enum that determines the text-wrapping mode to use.
  7235. */
  7236. export enum InspectableType {
  7237. /**
  7238. * Checkbox for booleans
  7239. */
  7240. Checkbox = 0,
  7241. /**
  7242. * Sliders for numbers
  7243. */
  7244. Slider = 1,
  7245. /**
  7246. * Vector3
  7247. */
  7248. Vector3 = 2,
  7249. /**
  7250. * Quaternions
  7251. */
  7252. Quaternion = 3,
  7253. /**
  7254. * Color3
  7255. */
  7256. Color3 = 4,
  7257. /**
  7258. * String
  7259. */
  7260. String = 5
  7261. }
  7262. /**
  7263. * Interface used to define custom inspectable properties.
  7264. * This interface is used by the inspector to display custom property grids
  7265. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7266. */
  7267. export interface IInspectable {
  7268. /**
  7269. * Gets the label to display
  7270. */
  7271. label: string;
  7272. /**
  7273. * Gets the name of the property to edit
  7274. */
  7275. propertyName: string;
  7276. /**
  7277. * Gets the type of the editor to use
  7278. */
  7279. type: InspectableType;
  7280. /**
  7281. * Gets the minimum value of the property when using in "slider" mode
  7282. */
  7283. min?: number;
  7284. /**
  7285. * Gets the maximum value of the property when using in "slider" mode
  7286. */
  7287. max?: number;
  7288. /**
  7289. * Gets the setp to use when using in "slider" mode
  7290. */
  7291. step?: number;
  7292. }
  7293. }
  7294. declare module BABYLON {
  7295. /**
  7296. * Class used to provide helper for timing
  7297. */
  7298. export class TimingTools {
  7299. /**
  7300. * Polyfill for setImmediate
  7301. * @param action defines the action to execute after the current execution block
  7302. */
  7303. static SetImmediate(action: () => void): void;
  7304. }
  7305. }
  7306. declare module BABYLON {
  7307. /**
  7308. * Class used to enable instatition of objects by class name
  7309. */
  7310. export class InstantiationTools {
  7311. /**
  7312. * Use this object to register external classes like custom textures or material
  7313. * to allow the laoders to instantiate them
  7314. */
  7315. static RegisteredExternalClasses: {
  7316. [key: string]: Object;
  7317. };
  7318. /**
  7319. * Tries to instantiate a new object from a given class name
  7320. * @param className defines the class name to instantiate
  7321. * @returns the new object or null if the system was not able to do the instantiation
  7322. */
  7323. static Instantiate(className: string): any;
  7324. }
  7325. }
  7326. declare module BABYLON {
  7327. /**
  7328. * This represents the required contract to create a new type of texture loader.
  7329. */
  7330. export interface IInternalTextureLoader {
  7331. /**
  7332. * Defines wether the loader supports cascade loading the different faces.
  7333. */
  7334. supportCascades: boolean;
  7335. /**
  7336. * This returns if the loader support the current file information.
  7337. * @param extension defines the file extension of the file being loaded
  7338. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7339. * @param fallback defines the fallback internal texture if any
  7340. * @param isBase64 defines whether the texture is encoded as a base64
  7341. * @param isBuffer defines whether the texture data are stored as a buffer
  7342. * @returns true if the loader can load the specified file
  7343. */
  7344. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7345. /**
  7346. * Transform the url before loading if required.
  7347. * @param rootUrl the url of the texture
  7348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7349. * @returns the transformed texture
  7350. */
  7351. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7352. /**
  7353. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7354. * @param rootUrl the url of the texture
  7355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7356. * @returns the fallback texture
  7357. */
  7358. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7359. /**
  7360. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7361. * @param data contains the texture data
  7362. * @param texture defines the BabylonJS internal texture
  7363. * @param createPolynomials will be true if polynomials have been requested
  7364. * @param onLoad defines the callback to trigger once the texture is ready
  7365. * @param onError defines the callback to trigger in case of error
  7366. */
  7367. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7368. /**
  7369. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7370. * @param data contains the texture data
  7371. * @param texture defines the BabylonJS internal texture
  7372. * @param callback defines the method to call once ready to upload
  7373. */
  7374. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7375. }
  7376. }
  7377. declare module BABYLON {
  7378. interface Engine {
  7379. /**
  7380. * Creates a depth stencil cube texture.
  7381. * This is only available in WebGL 2.
  7382. * @param size The size of face edge in the cube texture.
  7383. * @param options The options defining the cube texture.
  7384. * @returns The cube texture
  7385. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7386. /**
  7387. * Creates a cube texture
  7388. * @param rootUrl defines the url where the files to load is located
  7389. * @param scene defines the current scene
  7390. * @param files defines the list of files to load (1 per face)
  7391. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7392. * @param onLoad defines an optional callback raised when the texture is loaded
  7393. * @param onError defines an optional callback raised if there is an issue to load the texture
  7394. * @param format defines the format of the data
  7395. * @param forcedExtension defines the extension to use to pick the right loader
  7396. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7397. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7398. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7399. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7400. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7401. * @returns the cube texture as an InternalTexture
  7402. */
  7403. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7404. /**
  7405. * Creates a cube texture
  7406. * @param rootUrl defines the url where the files to load is located
  7407. * @param scene defines the current scene
  7408. * @param files defines the list of files to load (1 per face)
  7409. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7410. * @param onLoad defines an optional callback raised when the texture is loaded
  7411. * @param onError defines an optional callback raised if there is an issue to load the texture
  7412. * @param format defines the format of the data
  7413. * @param forcedExtension defines the extension to use to pick the right loader
  7414. * @returns the cube texture as an InternalTexture
  7415. */
  7416. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7417. /**
  7418. * Creates a cube texture
  7419. * @param rootUrl defines the url where the files to load is located
  7420. * @param scene defines the current scene
  7421. * @param files defines the list of files to load (1 per face)
  7422. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7423. * @param onLoad defines an optional callback raised when the texture is loaded
  7424. * @param onError defines an optional callback raised if there is an issue to load the texture
  7425. * @param format defines the format of the data
  7426. * @param forcedExtension defines the extension to use to pick the right loader
  7427. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7428. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7429. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7430. * @returns the cube texture as an InternalTexture
  7431. */
  7432. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7433. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7434. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7435. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7436. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7437. }
  7438. }
  7439. declare module BABYLON {
  7440. /**
  7441. * Class for creating a cube texture
  7442. */
  7443. export class CubeTexture extends BaseTexture {
  7444. private _delayedOnLoad;
  7445. /**
  7446. * The url of the texture
  7447. */
  7448. url: string;
  7449. /**
  7450. * Gets or sets the center of the bounding box associated with the cube texture.
  7451. * It must define where the camera used to render the texture was set
  7452. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7453. */
  7454. boundingBoxPosition: Vector3;
  7455. private _boundingBoxSize;
  7456. /**
  7457. * Gets or sets the size of the bounding box associated with the cube texture
  7458. * When defined, the cubemap will switch to local mode
  7459. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7460. * @example https://www.babylonjs-playground.com/#RNASML
  7461. */
  7462. /**
  7463. * Returns the bounding box size
  7464. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7465. */
  7466. boundingBoxSize: Vector3;
  7467. protected _rotationY: number;
  7468. /**
  7469. * Sets texture matrix rotation angle around Y axis in radians.
  7470. */
  7471. /**
  7472. * Gets texture matrix rotation angle around Y axis radians.
  7473. */
  7474. rotationY: number;
  7475. /**
  7476. * Are mip maps generated for this texture or not.
  7477. */
  7478. readonly noMipmap: boolean;
  7479. private _noMipmap;
  7480. private _files;
  7481. private _extensions;
  7482. private _textureMatrix;
  7483. private _format;
  7484. private _createPolynomials;
  7485. /** @hidden */ private _prefiltered: boolean;
  7486. /**
  7487. * Creates a cube texture from an array of image urls
  7488. * @param files defines an array of image urls
  7489. * @param scene defines the hosting scene
  7490. * @param noMipmap specifies if mip maps are not used
  7491. * @returns a cube texture
  7492. */
  7493. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7494. /**
  7495. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7496. * @param url defines the url of the prefiltered texture
  7497. * @param scene defines the scene the texture is attached to
  7498. * @param forcedExtension defines the extension of the file if different from the url
  7499. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7500. * @return the prefiltered texture
  7501. */
  7502. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7503. /**
  7504. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7505. * as prefiltered data.
  7506. * @param rootUrl defines the url of the texture or the root name of the six images
  7507. * @param scene defines the scene the texture is attached to
  7508. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7509. * @param noMipmap defines if mipmaps should be created or not
  7510. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7511. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7512. * @param onError defines a callback triggered in case of error during load
  7513. * @param format defines the internal format to use for the texture once loaded
  7514. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7515. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7516. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7519. * @return the cube texture
  7520. */
  7521. 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);
  7522. /**
  7523. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7524. */
  7525. readonly isPrefiltered: boolean;
  7526. /**
  7527. * Get the current class name of the texture useful for serialization or dynamic coding.
  7528. * @returns "CubeTexture"
  7529. */
  7530. getClassName(): string;
  7531. /**
  7532. * Update the url (and optional buffer) of this texture if url was null during construction.
  7533. * @param url the url of the texture
  7534. * @param forcedExtension defines the extension to use
  7535. * @param onLoad callback called when the texture is loaded (defaults to null)
  7536. */
  7537. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7538. /**
  7539. * Delays loading of the cube texture
  7540. * @param forcedExtension defines the extension to use
  7541. */
  7542. delayLoad(forcedExtension?: string): void;
  7543. /**
  7544. * Returns the reflection texture matrix
  7545. * @returns the reflection texture matrix
  7546. */
  7547. getReflectionTextureMatrix(): Matrix;
  7548. /**
  7549. * Sets the reflection texture matrix
  7550. * @param value Reflection texture matrix
  7551. */
  7552. setReflectionTextureMatrix(value: Matrix): void;
  7553. /**
  7554. * Parses text to create a cube texture
  7555. * @param parsedTexture define the serialized text to read from
  7556. * @param scene defines the hosting scene
  7557. * @param rootUrl defines the root url of the cube texture
  7558. * @returns a cube texture
  7559. */
  7560. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7561. /**
  7562. * Makes a clone, or deep copy, of the cube texture
  7563. * @returns a new cube texture
  7564. */
  7565. clone(): CubeTexture;
  7566. }
  7567. }
  7568. declare module BABYLON {
  7569. /**
  7570. * Manages the defines for the Material
  7571. */
  7572. export class MaterialDefines {
  7573. /** @hidden */
  7574. protected _keys: string[];
  7575. private _isDirty;
  7576. /** @hidden */ private _renderId: number;
  7577. /** @hidden */ private _areLightsDirty: boolean;
  7578. /** @hidden */ private _areLightsDisposed: boolean;
  7579. /** @hidden */ private _areAttributesDirty: boolean;
  7580. /** @hidden */ private _areTexturesDirty: boolean;
  7581. /** @hidden */ private _areFresnelDirty: boolean;
  7582. /** @hidden */ private _areMiscDirty: boolean;
  7583. /** @hidden */ private _areImageProcessingDirty: boolean;
  7584. /** @hidden */ private _normals: boolean;
  7585. /** @hidden */ private _uvs: boolean;
  7586. /** @hidden */ private _needNormals: boolean;
  7587. /** @hidden */ private _needUVs: boolean;
  7588. [id: string]: any;
  7589. /**
  7590. * Specifies if the material needs to be re-calculated
  7591. */
  7592. readonly isDirty: boolean;
  7593. /**
  7594. * Marks the material to indicate that it has been re-calculated
  7595. */
  7596. markAsProcessed(): void;
  7597. /**
  7598. * Marks the material to indicate that it needs to be re-calculated
  7599. */
  7600. markAsUnprocessed(): void;
  7601. /**
  7602. * Marks the material to indicate all of its defines need to be re-calculated
  7603. */
  7604. markAllAsDirty(): void;
  7605. /**
  7606. * Marks the material to indicate that image processing needs to be re-calculated
  7607. */
  7608. markAsImageProcessingDirty(): void;
  7609. /**
  7610. * Marks the material to indicate the lights need to be re-calculated
  7611. * @param disposed Defines whether the light is dirty due to dispose or not
  7612. */
  7613. markAsLightDirty(disposed?: boolean): void;
  7614. /**
  7615. * Marks the attribute state as changed
  7616. */
  7617. markAsAttributesDirty(): void;
  7618. /**
  7619. * Marks the texture state as changed
  7620. */
  7621. markAsTexturesDirty(): void;
  7622. /**
  7623. * Marks the fresnel state as changed
  7624. */
  7625. markAsFresnelDirty(): void;
  7626. /**
  7627. * Marks the misc state as changed
  7628. */
  7629. markAsMiscDirty(): void;
  7630. /**
  7631. * Rebuilds the material defines
  7632. */
  7633. rebuild(): void;
  7634. /**
  7635. * Specifies if two material defines are equal
  7636. * @param other - A material define instance to compare to
  7637. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7638. */
  7639. isEqual(other: MaterialDefines): boolean;
  7640. /**
  7641. * Clones this instance's defines to another instance
  7642. * @param other - material defines to clone values to
  7643. */
  7644. cloneTo(other: MaterialDefines): void;
  7645. /**
  7646. * Resets the material define values
  7647. */
  7648. reset(): void;
  7649. /**
  7650. * Converts the material define values to a string
  7651. * @returns - String of material define information
  7652. */
  7653. toString(): string;
  7654. }
  7655. }
  7656. declare module BABYLON {
  7657. /**
  7658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7660. * 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;
  7661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7662. */
  7663. export class ColorCurves {
  7664. private _dirty;
  7665. private _tempColor;
  7666. private _globalCurve;
  7667. private _highlightsCurve;
  7668. private _midtonesCurve;
  7669. private _shadowsCurve;
  7670. private _positiveCurve;
  7671. private _negativeCurve;
  7672. private _globalHue;
  7673. private _globalDensity;
  7674. private _globalSaturation;
  7675. private _globalExposure;
  7676. /**
  7677. * Gets the global Hue value.
  7678. * 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).
  7679. */
  7680. /**
  7681. * Sets the global Hue value.
  7682. * 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).
  7683. */
  7684. globalHue: number;
  7685. /**
  7686. * Gets the global Density value.
  7687. * 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.
  7688. * Values less than zero provide a filter of opposite hue.
  7689. */
  7690. /**
  7691. * Sets the global Density value.
  7692. * 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.
  7693. * Values less than zero provide a filter of opposite hue.
  7694. */
  7695. globalDensity: number;
  7696. /**
  7697. * Gets the global Saturation value.
  7698. * 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.
  7699. */
  7700. /**
  7701. * Sets the global Saturation value.
  7702. * 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.
  7703. */
  7704. globalSaturation: number;
  7705. /**
  7706. * Gets the global Exposure value.
  7707. * 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.
  7708. */
  7709. /**
  7710. * Sets the global Exposure value.
  7711. * 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.
  7712. */
  7713. globalExposure: number;
  7714. private _highlightsHue;
  7715. private _highlightsDensity;
  7716. private _highlightsSaturation;
  7717. private _highlightsExposure;
  7718. /**
  7719. * Gets the highlights Hue value.
  7720. * 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).
  7721. */
  7722. /**
  7723. * Sets the highlights Hue value.
  7724. * 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).
  7725. */
  7726. highlightsHue: number;
  7727. /**
  7728. * Gets the highlights Density value.
  7729. * 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.
  7730. * Values less than zero provide a filter of opposite hue.
  7731. */
  7732. /**
  7733. * Sets the highlights Density value.
  7734. * 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.
  7735. * Values less than zero provide a filter of opposite hue.
  7736. */
  7737. highlightsDensity: number;
  7738. /**
  7739. * Gets the highlights Saturation value.
  7740. * 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.
  7741. */
  7742. /**
  7743. * Sets the highlights Saturation value.
  7744. * 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.
  7745. */
  7746. highlightsSaturation: number;
  7747. /**
  7748. * Gets the highlights Exposure value.
  7749. * 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.
  7750. */
  7751. /**
  7752. * Sets the highlights Exposure value.
  7753. * 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.
  7754. */
  7755. highlightsExposure: number;
  7756. private _midtonesHue;
  7757. private _midtonesDensity;
  7758. private _midtonesSaturation;
  7759. private _midtonesExposure;
  7760. /**
  7761. * Gets the midtones Hue value.
  7762. * 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).
  7763. */
  7764. /**
  7765. * Sets the midtones Hue value.
  7766. * 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).
  7767. */
  7768. midtonesHue: number;
  7769. /**
  7770. * Gets the midtones Density value.
  7771. * 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.
  7772. * Values less than zero provide a filter of opposite hue.
  7773. */
  7774. /**
  7775. * Sets the midtones Density value.
  7776. * 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.
  7777. * Values less than zero provide a filter of opposite hue.
  7778. */
  7779. midtonesDensity: number;
  7780. /**
  7781. * Gets the midtones Saturation value.
  7782. * 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.
  7783. */
  7784. /**
  7785. * Sets the midtones Saturation value.
  7786. * 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.
  7787. */
  7788. midtonesSaturation: number;
  7789. /**
  7790. * Gets the midtones Exposure value.
  7791. * 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.
  7792. */
  7793. /**
  7794. * Sets the midtones Exposure value.
  7795. * 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.
  7796. */
  7797. midtonesExposure: number;
  7798. private _shadowsHue;
  7799. private _shadowsDensity;
  7800. private _shadowsSaturation;
  7801. private _shadowsExposure;
  7802. /**
  7803. * Gets the shadows Hue value.
  7804. * 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).
  7805. */
  7806. /**
  7807. * Sets the shadows Hue value.
  7808. * 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).
  7809. */
  7810. shadowsHue: number;
  7811. /**
  7812. * Gets the shadows Density value.
  7813. * 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.
  7814. * Values less than zero provide a filter of opposite hue.
  7815. */
  7816. /**
  7817. * Sets the shadows Density value.
  7818. * 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.
  7819. * Values less than zero provide a filter of opposite hue.
  7820. */
  7821. shadowsDensity: number;
  7822. /**
  7823. * Gets the shadows Saturation value.
  7824. * 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.
  7825. */
  7826. /**
  7827. * Sets the shadows Saturation value.
  7828. * 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.
  7829. */
  7830. shadowsSaturation: number;
  7831. /**
  7832. * Gets the shadows Exposure value.
  7833. * 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.
  7834. */
  7835. /**
  7836. * Sets the shadows Exposure value.
  7837. * 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.
  7838. */
  7839. shadowsExposure: number;
  7840. /**
  7841. * Returns the class name
  7842. * @returns The class name
  7843. */
  7844. getClassName(): string;
  7845. /**
  7846. * Binds the color curves to the shader.
  7847. * @param colorCurves The color curve to bind
  7848. * @param effect The effect to bind to
  7849. * @param positiveUniform The positive uniform shader parameter
  7850. * @param neutralUniform The neutral uniform shader parameter
  7851. * @param negativeUniform The negative uniform shader parameter
  7852. */
  7853. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7854. /**
  7855. * Prepare the list of uniforms associated with the ColorCurves effects.
  7856. * @param uniformsList The list of uniforms used in the effect
  7857. */
  7858. static PrepareUniforms(uniformsList: string[]): void;
  7859. /**
  7860. * Returns color grading data based on a hue, density, saturation and exposure value.
  7861. * @param filterHue The hue of the color filter.
  7862. * @param filterDensity The density of the color filter.
  7863. * @param saturation The saturation.
  7864. * @param exposure The exposure.
  7865. * @param result The result data container.
  7866. */
  7867. private getColorGradingDataToRef;
  7868. /**
  7869. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7870. * @param value The input slider value in range [-100,100].
  7871. * @returns Adjusted value.
  7872. */
  7873. private static applyColorGradingSliderNonlinear;
  7874. /**
  7875. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7876. * @param hue The hue (H) input.
  7877. * @param saturation The saturation (S) input.
  7878. * @param brightness The brightness (B) input.
  7879. * @result An RGBA color represented as Vector4.
  7880. */
  7881. private static fromHSBToRef;
  7882. /**
  7883. * Returns a value clamped between min and max
  7884. * @param value The value to clamp
  7885. * @param min The minimum of value
  7886. * @param max The maximum of value
  7887. * @returns The clamped value.
  7888. */
  7889. private static clamp;
  7890. /**
  7891. * Clones the current color curve instance.
  7892. * @return The cloned curves
  7893. */
  7894. clone(): ColorCurves;
  7895. /**
  7896. * Serializes the current color curve instance to a json representation.
  7897. * @return a JSON representation
  7898. */
  7899. serialize(): any;
  7900. /**
  7901. * Parses the color curve from a json representation.
  7902. * @param source the JSON source to parse
  7903. * @return The parsed curves
  7904. */
  7905. static Parse(source: any): ColorCurves;
  7906. }
  7907. }
  7908. declare module BABYLON {
  7909. /**
  7910. * Interface to follow in your material defines to integrate easily the
  7911. * Image proccessing functions.
  7912. * @hidden
  7913. */
  7914. export interface IImageProcessingConfigurationDefines {
  7915. IMAGEPROCESSING: boolean;
  7916. VIGNETTE: boolean;
  7917. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7918. VIGNETTEBLENDMODEOPAQUE: boolean;
  7919. TONEMAPPING: boolean;
  7920. TONEMAPPING_ACES: boolean;
  7921. CONTRAST: boolean;
  7922. EXPOSURE: boolean;
  7923. COLORCURVES: boolean;
  7924. COLORGRADING: boolean;
  7925. COLORGRADING3D: boolean;
  7926. SAMPLER3DGREENDEPTH: boolean;
  7927. SAMPLER3DBGRMAP: boolean;
  7928. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7929. }
  7930. /**
  7931. * @hidden
  7932. */
  7933. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7934. IMAGEPROCESSING: boolean;
  7935. VIGNETTE: boolean;
  7936. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7937. VIGNETTEBLENDMODEOPAQUE: boolean;
  7938. TONEMAPPING: boolean;
  7939. TONEMAPPING_ACES: boolean;
  7940. CONTRAST: boolean;
  7941. COLORCURVES: boolean;
  7942. COLORGRADING: boolean;
  7943. COLORGRADING3D: boolean;
  7944. SAMPLER3DGREENDEPTH: boolean;
  7945. SAMPLER3DBGRMAP: boolean;
  7946. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7947. EXPOSURE: boolean;
  7948. constructor();
  7949. }
  7950. /**
  7951. * This groups together the common properties used for image processing either in direct forward pass
  7952. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7953. * or not.
  7954. */
  7955. export class ImageProcessingConfiguration {
  7956. /**
  7957. * Default tone mapping applied in BabylonJS.
  7958. */
  7959. static readonly TONEMAPPING_STANDARD: number;
  7960. /**
  7961. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7962. * to other engines rendering to increase portability.
  7963. */
  7964. static readonly TONEMAPPING_ACES: number;
  7965. /**
  7966. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7967. */
  7968. colorCurves: Nullable<ColorCurves>;
  7969. private _colorCurvesEnabled;
  7970. /**
  7971. * Gets wether the color curves effect is enabled.
  7972. */
  7973. /**
  7974. * Sets wether the color curves effect is enabled.
  7975. */
  7976. colorCurvesEnabled: boolean;
  7977. private _colorGradingTexture;
  7978. /**
  7979. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7980. */
  7981. /**
  7982. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7983. */
  7984. colorGradingTexture: Nullable<BaseTexture>;
  7985. private _colorGradingEnabled;
  7986. /**
  7987. * Gets wether the color grading effect is enabled.
  7988. */
  7989. /**
  7990. * Sets wether the color grading effect is enabled.
  7991. */
  7992. colorGradingEnabled: boolean;
  7993. private _colorGradingWithGreenDepth;
  7994. /**
  7995. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7996. */
  7997. /**
  7998. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7999. */
  8000. colorGradingWithGreenDepth: boolean;
  8001. private _colorGradingBGR;
  8002. /**
  8003. * Gets wether the color grading texture contains BGR values.
  8004. */
  8005. /**
  8006. * Sets wether the color grading texture contains BGR values.
  8007. */
  8008. colorGradingBGR: boolean;
  8009. /** @hidden */ private _exposure: number;
  8010. /**
  8011. * Gets the Exposure used in the effect.
  8012. */
  8013. /**
  8014. * Sets the Exposure used in the effect.
  8015. */
  8016. exposure: number;
  8017. private _toneMappingEnabled;
  8018. /**
  8019. * Gets wether the tone mapping effect is enabled.
  8020. */
  8021. /**
  8022. * Sets wether the tone mapping effect is enabled.
  8023. */
  8024. toneMappingEnabled: boolean;
  8025. private _toneMappingType;
  8026. /**
  8027. * Gets the type of tone mapping effect.
  8028. */
  8029. /**
  8030. * Sets the type of tone mapping effect used in BabylonJS.
  8031. */
  8032. toneMappingType: number;
  8033. protected _contrast: number;
  8034. /**
  8035. * Gets the contrast used in the effect.
  8036. */
  8037. /**
  8038. * Sets the contrast used in the effect.
  8039. */
  8040. contrast: number;
  8041. /**
  8042. * Vignette stretch size.
  8043. */
  8044. vignetteStretch: number;
  8045. /**
  8046. * Vignette centre X Offset.
  8047. */
  8048. vignetteCentreX: number;
  8049. /**
  8050. * Vignette centre Y Offset.
  8051. */
  8052. vignetteCentreY: number;
  8053. /**
  8054. * Vignette weight or intensity of the vignette effect.
  8055. */
  8056. vignetteWeight: number;
  8057. /**
  8058. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8059. * if vignetteEnabled is set to true.
  8060. */
  8061. vignetteColor: Color4;
  8062. /**
  8063. * Camera field of view used by the Vignette effect.
  8064. */
  8065. vignetteCameraFov: number;
  8066. private _vignetteBlendMode;
  8067. /**
  8068. * Gets the vignette blend mode allowing different kind of effect.
  8069. */
  8070. /**
  8071. * Sets the vignette blend mode allowing different kind of effect.
  8072. */
  8073. vignetteBlendMode: number;
  8074. private _vignetteEnabled;
  8075. /**
  8076. * Gets wether the vignette effect is enabled.
  8077. */
  8078. /**
  8079. * Sets wether the vignette effect is enabled.
  8080. */
  8081. vignetteEnabled: boolean;
  8082. private _applyByPostProcess;
  8083. /**
  8084. * Gets wether the image processing is applied through a post process or not.
  8085. */
  8086. /**
  8087. * Sets wether the image processing is applied through a post process or not.
  8088. */
  8089. applyByPostProcess: boolean;
  8090. private _isEnabled;
  8091. /**
  8092. * Gets wether the image processing is enabled or not.
  8093. */
  8094. /**
  8095. * Sets wether the image processing is enabled or not.
  8096. */
  8097. isEnabled: boolean;
  8098. /**
  8099. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8100. */
  8101. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8102. /**
  8103. * Method called each time the image processing information changes requires to recompile the effect.
  8104. */
  8105. protected _updateParameters(): void;
  8106. /**
  8107. * Gets the current class name.
  8108. * @return "ImageProcessingConfiguration"
  8109. */
  8110. getClassName(): string;
  8111. /**
  8112. * Prepare the list of uniforms associated with the Image Processing effects.
  8113. * @param uniforms The list of uniforms used in the effect
  8114. * @param defines the list of defines currently in use
  8115. */
  8116. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8117. /**
  8118. * Prepare the list of samplers associated with the Image Processing effects.
  8119. * @param samplersList The list of uniforms used in the effect
  8120. * @param defines the list of defines currently in use
  8121. */
  8122. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8123. /**
  8124. * Prepare the list of defines associated to the shader.
  8125. * @param defines the list of defines to complete
  8126. * @param forPostProcess Define if we are currently in post process mode or not
  8127. */
  8128. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8129. /**
  8130. * Returns true if all the image processing information are ready.
  8131. * @returns True if ready, otherwise, false
  8132. */
  8133. isReady(): boolean;
  8134. /**
  8135. * Binds the image processing to the shader.
  8136. * @param effect The effect to bind to
  8137. * @param aspectRatio Define the current aspect ratio of the effect
  8138. */
  8139. bind(effect: Effect, aspectRatio?: number): void;
  8140. /**
  8141. * Clones the current image processing instance.
  8142. * @return The cloned image processing
  8143. */
  8144. clone(): ImageProcessingConfiguration;
  8145. /**
  8146. * Serializes the current image processing instance to a json representation.
  8147. * @return a JSON representation
  8148. */
  8149. serialize(): any;
  8150. /**
  8151. * Parses the image processing from a json representation.
  8152. * @param source the JSON source to parse
  8153. * @return The parsed image processing
  8154. */
  8155. static Parse(source: any): ImageProcessingConfiguration;
  8156. private static _VIGNETTEMODE_MULTIPLY;
  8157. private static _VIGNETTEMODE_OPAQUE;
  8158. /**
  8159. * Used to apply the vignette as a mix with the pixel color.
  8160. */
  8161. static readonly VIGNETTEMODE_MULTIPLY: number;
  8162. /**
  8163. * Used to apply the vignette as a replacement of the pixel color.
  8164. */
  8165. static readonly VIGNETTEMODE_OPAQUE: number;
  8166. }
  8167. }
  8168. declare module BABYLON {
  8169. /** @hidden */
  8170. export var postprocessVertexShader: {
  8171. name: string;
  8172. shader: string;
  8173. };
  8174. }
  8175. declare module BABYLON {
  8176. /** Defines supported spaces */
  8177. export enum Space {
  8178. /** Local (object) space */
  8179. LOCAL = 0,
  8180. /** World space */
  8181. WORLD = 1,
  8182. /** Bone space */
  8183. BONE = 2
  8184. }
  8185. /** Defines the 3 main axes */
  8186. export class Axis {
  8187. /** X axis */
  8188. static X: Vector3;
  8189. /** Y axis */
  8190. static Y: Vector3;
  8191. /** Z axis */
  8192. static Z: Vector3;
  8193. }
  8194. }
  8195. declare module BABYLON {
  8196. /**
  8197. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8198. * This is the base of the follow, arc rotate cameras and Free camera
  8199. * @see http://doc.babylonjs.com/features/cameras
  8200. */
  8201. export class TargetCamera extends Camera {
  8202. private static _RigCamTransformMatrix;
  8203. private static _TargetTransformMatrix;
  8204. private static _TargetFocalPoint;
  8205. /**
  8206. * Define the current direction the camera is moving to
  8207. */
  8208. cameraDirection: Vector3;
  8209. /**
  8210. * Define the current rotation the camera is rotating to
  8211. */
  8212. cameraRotation: Vector2;
  8213. /**
  8214. * When set, the up vector of the camera will be updated by the rotation of the camera
  8215. */
  8216. updateUpVectorFromRotation: boolean;
  8217. private _tmpQuaternion;
  8218. /**
  8219. * Define the current rotation of the camera
  8220. */
  8221. rotation: Vector3;
  8222. /**
  8223. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8224. */
  8225. rotationQuaternion: Quaternion;
  8226. /**
  8227. * Define the current speed of the camera
  8228. */
  8229. speed: number;
  8230. /**
  8231. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8232. * around all axis.
  8233. */
  8234. noRotationConstraint: boolean;
  8235. /**
  8236. * Define the current target of the camera as an object or a position.
  8237. */
  8238. lockedTarget: any;
  8239. /** @hidden */ private _currentTarget: Vector3;
  8240. /** @hidden */ private _initialFocalDistance: number;
  8241. /** @hidden */ private _viewMatrix: Matrix;
  8242. /** @hidden */ private _camMatrix: Matrix;
  8243. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8244. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8245. /** @hidden */ private _referencePoint: Vector3;
  8246. /** @hidden */ private _transformedReferencePoint: Vector3;
  8247. protected _globalCurrentTarget: Vector3;
  8248. protected _globalCurrentUpVector: Vector3;
  8249. /** @hidden */ private _reset: () => void;
  8250. private _defaultUp;
  8251. /**
  8252. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8253. * This is the base of the follow, arc rotate cameras and Free camera
  8254. * @see http://doc.babylonjs.com/features/cameras
  8255. * @param name Defines the name of the camera in the scene
  8256. * @param position Defines the start position of the camera in the scene
  8257. * @param scene Defines the scene the camera belongs to
  8258. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8259. */
  8260. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8261. /**
  8262. * Gets the position in front of the camera at a given distance.
  8263. * @param distance The distance from the camera we want the position to be
  8264. * @returns the position
  8265. */
  8266. getFrontPosition(distance: number): Vector3;
  8267. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8268. private _storedPosition;
  8269. private _storedRotation;
  8270. private _storedRotationQuaternion;
  8271. /**
  8272. * Store current camera state of the camera (fov, position, rotation, etc..)
  8273. * @returns the camera
  8274. */
  8275. storeState(): Camera;
  8276. /**
  8277. * Restored camera state. You must call storeState() first
  8278. * @returns whether it was successful or not
  8279. * @hidden
  8280. */ private _restoreStateValues(): boolean;
  8281. /** @hidden */ private _initCache(): void;
  8282. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8283. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8284. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8285. /**
  8286. * Defines the target the camera should look at.
  8287. * @param target Defines the new target as a Vector or a mesh
  8288. */
  8289. setTarget(target: Vector3): void;
  8290. /**
  8291. * Return the current target position of the camera. This value is expressed in local space.
  8292. * @returns the target position
  8293. */
  8294. getTarget(): Vector3;
  8295. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8296. /** @hidden */ private _updatePosition(): void;
  8297. /** @hidden */ private _checkInputs(): void;
  8298. protected _updateCameraRotationMatrix(): void;
  8299. /**
  8300. * 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)
  8301. * @returns the current camera
  8302. */
  8303. private _rotateUpVectorWithCameraRotationMatrix;
  8304. private _cachedRotationZ;
  8305. private _cachedQuaternionRotationZ;
  8306. /** @hidden */ private _getViewMatrix(): Matrix;
  8307. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8308. /**
  8309. * @hidden
  8310. */
  8311. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8312. /**
  8313. * @hidden
  8314. */ private _updateRigCameras(): void;
  8315. private _getRigCamPositionAndTarget;
  8316. /**
  8317. * Gets the current object class name.
  8318. * @return the class name
  8319. */
  8320. getClassName(): string;
  8321. }
  8322. }
  8323. declare module BABYLON {
  8324. /**
  8325. * Gather the list of keyboard event types as constants.
  8326. */
  8327. export class KeyboardEventTypes {
  8328. /**
  8329. * The keydown event is fired when a key becomes active (pressed).
  8330. */
  8331. static readonly KEYDOWN: number;
  8332. /**
  8333. * The keyup event is fired when a key has been released.
  8334. */
  8335. static readonly KEYUP: number;
  8336. }
  8337. /**
  8338. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8339. */
  8340. export class KeyboardInfo {
  8341. /**
  8342. * Defines the type of event (KeyboardEventTypes)
  8343. */
  8344. type: number;
  8345. /**
  8346. * Defines the related dom event
  8347. */
  8348. event: KeyboardEvent;
  8349. /**
  8350. * Instantiates a new keyboard info.
  8351. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8352. * @param type Defines the type of event (KeyboardEventTypes)
  8353. * @param event Defines the related dom event
  8354. */
  8355. constructor(
  8356. /**
  8357. * Defines the type of event (KeyboardEventTypes)
  8358. */
  8359. type: number,
  8360. /**
  8361. * Defines the related dom event
  8362. */
  8363. event: KeyboardEvent);
  8364. }
  8365. /**
  8366. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8367. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8368. */
  8369. export class KeyboardInfoPre extends KeyboardInfo {
  8370. /**
  8371. * Defines the type of event (KeyboardEventTypes)
  8372. */
  8373. type: number;
  8374. /**
  8375. * Defines the related dom event
  8376. */
  8377. event: KeyboardEvent;
  8378. /**
  8379. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8380. */
  8381. skipOnPointerObservable: boolean;
  8382. /**
  8383. * Instantiates a new keyboard pre info.
  8384. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8385. * @param type Defines the type of event (KeyboardEventTypes)
  8386. * @param event Defines the related dom event
  8387. */
  8388. constructor(
  8389. /**
  8390. * Defines the type of event (KeyboardEventTypes)
  8391. */
  8392. type: number,
  8393. /**
  8394. * Defines the related dom event
  8395. */
  8396. event: KeyboardEvent);
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /**
  8401. * Manage the keyboard inputs to control the movement of a free camera.
  8402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8403. */
  8404. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8405. /**
  8406. * Defines the camera the input is attached to.
  8407. */
  8408. camera: FreeCamera;
  8409. /**
  8410. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8411. */
  8412. keysUp: number[];
  8413. /**
  8414. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8415. */
  8416. keysDown: number[];
  8417. /**
  8418. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8419. */
  8420. keysLeft: number[];
  8421. /**
  8422. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8423. */
  8424. keysRight: number[];
  8425. private _keys;
  8426. private _onCanvasBlurObserver;
  8427. private _onKeyboardObserver;
  8428. private _engine;
  8429. private _scene;
  8430. /**
  8431. * Attach the input controls to a specific dom element to get the input from.
  8432. * @param element Defines the element the controls should be listened from
  8433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8434. */
  8435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8436. /**
  8437. * Detach the current controls from the specified dom element.
  8438. * @param element Defines the element to stop listening the inputs from
  8439. */
  8440. detachControl(element: Nullable<HTMLElement>): void;
  8441. /**
  8442. * Update the current camera state depending on the inputs that have been used this frame.
  8443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8444. */
  8445. checkInputs(): void;
  8446. /**
  8447. * Gets the class name of the current intput.
  8448. * @returns the class name
  8449. */
  8450. getClassName(): string;
  8451. /** @hidden */ private _onLostFocus(): void;
  8452. /**
  8453. * Get the friendly name associated with the input class.
  8454. * @returns the input friendly name
  8455. */
  8456. getSimpleName(): string;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /**
  8461. * Interface describing all the common properties and methods a shadow light needs to implement.
  8462. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8463. * as well as binding the different shadow properties to the effects.
  8464. */
  8465. export interface IShadowLight extends Light {
  8466. /**
  8467. * The light id in the scene (used in scene.findLighById for instance)
  8468. */
  8469. id: string;
  8470. /**
  8471. * The position the shdow will be casted from.
  8472. */
  8473. position: Vector3;
  8474. /**
  8475. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8476. */
  8477. direction: Vector3;
  8478. /**
  8479. * The transformed position. Position of the light in world space taking parenting in account.
  8480. */
  8481. transformedPosition: Vector3;
  8482. /**
  8483. * The transformed direction. Direction of the light in world space taking parenting in account.
  8484. */
  8485. transformedDirection: Vector3;
  8486. /**
  8487. * The friendly name of the light in the scene.
  8488. */
  8489. name: string;
  8490. /**
  8491. * Defines the shadow projection clipping minimum z value.
  8492. */
  8493. shadowMinZ: number;
  8494. /**
  8495. * Defines the shadow projection clipping maximum z value.
  8496. */
  8497. shadowMaxZ: number;
  8498. /**
  8499. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8500. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8501. */
  8502. computeTransformedInformation(): boolean;
  8503. /**
  8504. * Gets the scene the light belongs to.
  8505. * @returns The scene
  8506. */
  8507. getScene(): Scene;
  8508. /**
  8509. * Callback defining a custom Projection Matrix Builder.
  8510. * This can be used to override the default projection matrix computation.
  8511. */
  8512. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8513. /**
  8514. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8515. * @param matrix The materix to updated with the projection information
  8516. * @param viewMatrix The transform matrix of the light
  8517. * @param renderList The list of mesh to render in the map
  8518. * @returns The current light
  8519. */
  8520. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8521. /**
  8522. * Gets the current depth scale used in ESM.
  8523. * @returns The scale
  8524. */
  8525. getDepthScale(): number;
  8526. /**
  8527. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8528. * @returns true if a cube texture needs to be use
  8529. */
  8530. needCube(): boolean;
  8531. /**
  8532. * Detects if the projection matrix requires to be recomputed this frame.
  8533. * @returns true if it requires to be recomputed otherwise, false.
  8534. */
  8535. needProjectionMatrixCompute(): boolean;
  8536. /**
  8537. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8538. */
  8539. forceProjectionMatrixCompute(): void;
  8540. /**
  8541. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8542. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8543. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8544. */
  8545. getShadowDirection(faceIndex?: number): Vector3;
  8546. /**
  8547. * Gets the minZ used for shadow according to both the scene and the light.
  8548. * @param activeCamera The camera we are returning the min for
  8549. * @returns the depth min z
  8550. */
  8551. getDepthMinZ(activeCamera: Camera): number;
  8552. /**
  8553. * Gets the maxZ used for shadow according to both the scene and the light.
  8554. * @param activeCamera The camera we are returning the max for
  8555. * @returns the depth max z
  8556. */
  8557. getDepthMaxZ(activeCamera: Camera): number;
  8558. }
  8559. /**
  8560. * Base implementation IShadowLight
  8561. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8562. */
  8563. export abstract class ShadowLight extends Light implements IShadowLight {
  8564. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8565. protected _position: Vector3;
  8566. protected _setPosition(value: Vector3): void;
  8567. /**
  8568. * Sets the position the shadow will be casted from. Also use as the light position for both
  8569. * point and spot lights.
  8570. */
  8571. /**
  8572. * Sets the position the shadow will be casted from. Also use as the light position for both
  8573. * point and spot lights.
  8574. */
  8575. position: Vector3;
  8576. protected _direction: Vector3;
  8577. protected _setDirection(value: Vector3): void;
  8578. /**
  8579. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8580. * Also use as the light direction on spot and directional lights.
  8581. */
  8582. /**
  8583. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8584. * Also use as the light direction on spot and directional lights.
  8585. */
  8586. direction: Vector3;
  8587. private _shadowMinZ;
  8588. /**
  8589. * Gets the shadow projection clipping minimum z value.
  8590. */
  8591. /**
  8592. * Sets the shadow projection clipping minimum z value.
  8593. */
  8594. shadowMinZ: number;
  8595. private _shadowMaxZ;
  8596. /**
  8597. * Sets the shadow projection clipping maximum z value.
  8598. */
  8599. /**
  8600. * Gets the shadow projection clipping maximum z value.
  8601. */
  8602. shadowMaxZ: number;
  8603. /**
  8604. * Callback defining a custom Projection Matrix Builder.
  8605. * This can be used to override the default projection matrix computation.
  8606. */
  8607. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8608. /**
  8609. * The transformed position. Position of the light in world space taking parenting in account.
  8610. */
  8611. transformedPosition: Vector3;
  8612. /**
  8613. * The transformed direction. Direction of the light in world space taking parenting in account.
  8614. */
  8615. transformedDirection: Vector3;
  8616. private _needProjectionMatrixCompute;
  8617. /**
  8618. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8619. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8620. */
  8621. computeTransformedInformation(): boolean;
  8622. /**
  8623. * Return the depth scale used for the shadow map.
  8624. * @returns the depth scale.
  8625. */
  8626. getDepthScale(): number;
  8627. /**
  8628. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8629. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8630. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8631. */
  8632. getShadowDirection(faceIndex?: number): Vector3;
  8633. /**
  8634. * Returns the ShadowLight absolute position in the World.
  8635. * @returns the position vector in world space
  8636. */
  8637. getAbsolutePosition(): Vector3;
  8638. /**
  8639. * Sets the ShadowLight direction toward the passed target.
  8640. * @param target The point to target in local space
  8641. * @returns the updated ShadowLight direction
  8642. */
  8643. setDirectionToTarget(target: Vector3): Vector3;
  8644. /**
  8645. * Returns the light rotation in euler definition.
  8646. * @returns the x y z rotation in local space.
  8647. */
  8648. getRotation(): Vector3;
  8649. /**
  8650. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8651. * @returns true if a cube texture needs to be use
  8652. */
  8653. needCube(): boolean;
  8654. /**
  8655. * Detects if the projection matrix requires to be recomputed this frame.
  8656. * @returns true if it requires to be recomputed otherwise, false.
  8657. */
  8658. needProjectionMatrixCompute(): boolean;
  8659. /**
  8660. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8661. */
  8662. forceProjectionMatrixCompute(): void;
  8663. /** @hidden */ private _initCache(): void;
  8664. /** @hidden */ private _isSynchronized(): boolean;
  8665. /**
  8666. * Computes the world matrix of the node
  8667. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8668. * @returns the world matrix
  8669. */
  8670. computeWorldMatrix(force?: boolean): Matrix;
  8671. /**
  8672. * Gets the minZ used for shadow according to both the scene and the light.
  8673. * @param activeCamera The camera we are returning the min for
  8674. * @returns the depth min z
  8675. */
  8676. getDepthMinZ(activeCamera: Camera): number;
  8677. /**
  8678. * Gets the maxZ used for shadow according to both the scene and the light.
  8679. * @param activeCamera The camera we are returning the max for
  8680. * @returns the depth max z
  8681. */
  8682. getDepthMaxZ(activeCamera: Camera): number;
  8683. /**
  8684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8685. * @param matrix The materix to updated with the projection information
  8686. * @param viewMatrix The transform matrix of the light
  8687. * @param renderList The list of mesh to render in the map
  8688. * @returns The current light
  8689. */
  8690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8691. }
  8692. }
  8693. declare module BABYLON {
  8694. /**
  8695. * "Static Class" containing the most commonly used helper while dealing with material for
  8696. * rendering purpose.
  8697. *
  8698. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8699. *
  8700. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8701. */
  8702. export class MaterialHelper {
  8703. /**
  8704. * Bind the current view position to an effect.
  8705. * @param effect The effect to be bound
  8706. * @param scene The scene the eyes position is used from
  8707. */
  8708. static BindEyePosition(effect: Effect, scene: Scene): void;
  8709. /**
  8710. * Helps preparing the defines values about the UVs in used in the effect.
  8711. * UVs are shared as much as we can accross channels in the shaders.
  8712. * @param texture The texture we are preparing the UVs for
  8713. * @param defines The defines to update
  8714. * @param key The channel key "diffuse", "specular"... used in the shader
  8715. */
  8716. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8717. /**
  8718. * Binds a texture matrix value to its corrsponding uniform
  8719. * @param texture The texture to bind the matrix for
  8720. * @param uniformBuffer The uniform buffer receivin the data
  8721. * @param key The channel key "diffuse", "specular"... used in the shader
  8722. */
  8723. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8724. /**
  8725. * Gets the current status of the fog (should it be enabled?)
  8726. * @param mesh defines the mesh to evaluate for fog support
  8727. * @param scene defines the hosting scene
  8728. * @returns true if fog must be enabled
  8729. */
  8730. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8731. /**
  8732. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8733. * @param mesh defines the current mesh
  8734. * @param scene defines the current scene
  8735. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8736. * @param pointsCloud defines if point cloud rendering has to be turned on
  8737. * @param fogEnabled defines if fog has to be turned on
  8738. * @param alphaTest defines if alpha testing has to be turned on
  8739. * @param defines defines the current list of defines
  8740. */
  8741. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8742. /**
  8743. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8744. * @param scene defines the current scene
  8745. * @param engine defines the current engine
  8746. * @param defines specifies the list of active defines
  8747. * @param useInstances defines if instances have to be turned on
  8748. * @param useClipPlane defines if clip plane have to be turned on
  8749. */
  8750. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8751. /**
  8752. * Prepares the defines for bones
  8753. * @param mesh The mesh containing the geometry data we will draw
  8754. * @param defines The defines to update
  8755. */
  8756. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8757. /**
  8758. * Prepares the defines for morph targets
  8759. * @param mesh The mesh containing the geometry data we will draw
  8760. * @param defines The defines to update
  8761. */
  8762. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8763. /**
  8764. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8765. * @param mesh The mesh containing the geometry data we will draw
  8766. * @param defines The defines to update
  8767. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8768. * @param useBones Precise whether bones should be used or not (override mesh info)
  8769. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8770. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8771. * @returns false if defines are considered not dirty and have not been checked
  8772. */
  8773. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8774. /**
  8775. * Prepares the defines related to multiview
  8776. * @param scene The scene we are intending to draw
  8777. * @param defines The defines to update
  8778. */
  8779. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8780. /**
  8781. * Prepares the defines related to the light information passed in parameter
  8782. * @param scene The scene we are intending to draw
  8783. * @param mesh The mesh the effect is compiling for
  8784. * @param light The light the effect is compiling for
  8785. * @param lightIndex The index of the light
  8786. * @param defines The defines to update
  8787. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8788. * @param state Defines the current state regarding what is needed (normals, etc...)
  8789. */
  8790. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8791. needNormals: boolean;
  8792. needRebuild: boolean;
  8793. shadowEnabled: boolean;
  8794. specularEnabled: boolean;
  8795. lightmapMode: boolean;
  8796. }): void;
  8797. /**
  8798. * Prepares the defines related to the light information passed in parameter
  8799. * @param scene The scene we are intending to draw
  8800. * @param mesh The mesh the effect is compiling for
  8801. * @param defines The defines to update
  8802. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8803. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8804. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8805. * @returns true if normals will be required for the rest of the effect
  8806. */
  8807. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8808. /**
  8809. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8810. * @param lightIndex defines the light index
  8811. * @param uniformsList The uniform list
  8812. * @param samplersList The sampler list
  8813. * @param projectedLightTexture defines if projected texture must be used
  8814. * @param uniformBuffersList defines an optional list of uniform buffers
  8815. */
  8816. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8817. /**
  8818. * Prepares the uniforms and samplers list to be used in the effect
  8819. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8820. * @param samplersList The sampler list
  8821. * @param defines The defines helping in the list generation
  8822. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8823. */
  8824. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8825. /**
  8826. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8827. * @param defines The defines to update while falling back
  8828. * @param fallbacks The authorized effect fallbacks
  8829. * @param maxSimultaneousLights The maximum number of lights allowed
  8830. * @param rank the current rank of the Effect
  8831. * @returns The newly affected rank
  8832. */
  8833. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8834. private static _TmpMorphInfluencers;
  8835. /**
  8836. * Prepares the list of attributes required for morph targets according to the effect defines.
  8837. * @param attribs The current list of supported attribs
  8838. * @param mesh The mesh to prepare the morph targets attributes for
  8839. * @param influencers The number of influencers
  8840. */
  8841. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8842. /**
  8843. * Prepares the list of attributes required for morph targets according to the effect defines.
  8844. * @param attribs The current list of supported attribs
  8845. * @param mesh The mesh to prepare the morph targets attributes for
  8846. * @param defines The current Defines of the effect
  8847. */
  8848. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8849. /**
  8850. * Prepares the list of attributes required for bones according to the effect defines.
  8851. * @param attribs The current list of supported attribs
  8852. * @param mesh The mesh to prepare the bones attributes for
  8853. * @param defines The current Defines of the effect
  8854. * @param fallbacks The current efffect fallback strategy
  8855. */
  8856. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8857. /**
  8858. * Check and prepare the list of attributes required for instances according to the effect defines.
  8859. * @param attribs The current list of supported attribs
  8860. * @param defines The current MaterialDefines of the effect
  8861. */
  8862. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8863. /**
  8864. * Add the list of attributes required for instances to the attribs array.
  8865. * @param attribs The current list of supported attribs
  8866. */
  8867. static PushAttributesForInstances(attribs: string[]): void;
  8868. /**
  8869. * Binds the light shadow information to the effect for the given mesh.
  8870. * @param light The light containing the generator
  8871. * @param scene The scene the lights belongs to
  8872. * @param mesh The mesh we are binding the information to render
  8873. * @param lightIndex The light index in the effect used to render the mesh
  8874. * @param effect The effect we are binding the data to
  8875. */
  8876. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8877. /**
  8878. * Binds the light information to the effect.
  8879. * @param light The light containing the generator
  8880. * @param effect The effect we are binding the data to
  8881. * @param lightIndex The light index in the effect used to render
  8882. */
  8883. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8884. /**
  8885. * Binds the lights information from the scene to the effect for the given mesh.
  8886. * @param light Light to bind
  8887. * @param lightIndex Light index
  8888. * @param scene The scene where the light belongs to
  8889. * @param mesh The mesh we are binding the information to render
  8890. * @param effect The effect we are binding the data to
  8891. * @param useSpecular Defines if specular is supported
  8892. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8893. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8894. */
  8895. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8896. /**
  8897. * Binds the lights information from the scene to the effect for the given mesh.
  8898. * @param scene The scene the lights belongs to
  8899. * @param mesh The mesh we are binding the information to render
  8900. * @param effect The effect we are binding the data to
  8901. * @param defines The generated defines for the effect
  8902. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8903. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8904. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8905. */
  8906. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8907. private static _tempFogColor;
  8908. /**
  8909. * Binds the fog information from the scene to the effect for the given mesh.
  8910. * @param scene The scene the lights belongs to
  8911. * @param mesh The mesh we are binding the information to render
  8912. * @param effect The effect we are binding the data to
  8913. * @param linearSpace Defines if the fog effect is applied in linear space
  8914. */
  8915. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8916. /**
  8917. * Binds the bones information from the mesh to the effect.
  8918. * @param mesh The mesh we are binding the information to render
  8919. * @param effect The effect we are binding the data to
  8920. */
  8921. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8922. /**
  8923. * Binds the morph targets information from the mesh to the effect.
  8924. * @param abstractMesh The mesh we are binding the information to render
  8925. * @param effect The effect we are binding the data to
  8926. */
  8927. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8928. /**
  8929. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8930. * @param defines The generated defines used in the effect
  8931. * @param effect The effect we are binding the data to
  8932. * @param scene The scene we are willing to render with logarithmic scale for
  8933. */
  8934. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8935. /**
  8936. * Binds the clip plane information from the scene to the effect.
  8937. * @param scene The scene the clip plane information are extracted from
  8938. * @param effect The effect we are binding the data to
  8939. */
  8940. static BindClipPlane(effect: Effect, scene: Scene): void;
  8941. }
  8942. }
  8943. declare module BABYLON {
  8944. /** @hidden */
  8945. export var packingFunctions: {
  8946. name: string;
  8947. shader: string;
  8948. };
  8949. }
  8950. declare module BABYLON {
  8951. /** @hidden */
  8952. export var shadowMapPixelShader: {
  8953. name: string;
  8954. shader: string;
  8955. };
  8956. }
  8957. declare module BABYLON {
  8958. /** @hidden */
  8959. export var bonesDeclaration: {
  8960. name: string;
  8961. shader: string;
  8962. };
  8963. }
  8964. declare module BABYLON {
  8965. /** @hidden */
  8966. export var morphTargetsVertexGlobalDeclaration: {
  8967. name: string;
  8968. shader: string;
  8969. };
  8970. }
  8971. declare module BABYLON {
  8972. /** @hidden */
  8973. export var morphTargetsVertexDeclaration: {
  8974. name: string;
  8975. shader: string;
  8976. };
  8977. }
  8978. declare module BABYLON {
  8979. /** @hidden */
  8980. export var instancesDeclaration: {
  8981. name: string;
  8982. shader: string;
  8983. };
  8984. }
  8985. declare module BABYLON {
  8986. /** @hidden */
  8987. export var helperFunctions: {
  8988. name: string;
  8989. shader: string;
  8990. };
  8991. }
  8992. declare module BABYLON {
  8993. /** @hidden */
  8994. export var morphTargetsVertex: {
  8995. name: string;
  8996. shader: string;
  8997. };
  8998. }
  8999. declare module BABYLON {
  9000. /** @hidden */
  9001. export var instancesVertex: {
  9002. name: string;
  9003. shader: string;
  9004. };
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var bonesVertex: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapVertexShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var depthBoxBlurPixelShader: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /**
  9029. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9030. */
  9031. export interface ICustomShaderOptions {
  9032. /**
  9033. * Gets or sets the custom shader name to use
  9034. */
  9035. shaderName: string;
  9036. /**
  9037. * The list of attribute names used in the shader
  9038. */
  9039. attributes?: string[];
  9040. /**
  9041. * The list of unifrom names used in the shader
  9042. */
  9043. uniforms?: string[];
  9044. /**
  9045. * The list of sampler names used in the shader
  9046. */
  9047. samplers?: string[];
  9048. /**
  9049. * The list of defines used in the shader
  9050. */
  9051. defines?: string[];
  9052. }
  9053. /**
  9054. * Interface to implement to create a shadow generator compatible with BJS.
  9055. */
  9056. export interface IShadowGenerator {
  9057. /**
  9058. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9059. * @returns The render target texture if present otherwise, null
  9060. */
  9061. getShadowMap(): Nullable<RenderTargetTexture>;
  9062. /**
  9063. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9064. * @returns The render target texture if the shadow map is present otherwise, null
  9065. */
  9066. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9067. /**
  9068. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9069. * @param subMesh The submesh we want to render in the shadow map
  9070. * @param useInstances Defines wether will draw in the map using instances
  9071. * @returns true if ready otherwise, false
  9072. */
  9073. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9074. /**
  9075. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9076. * @param defines Defines of the material we want to update
  9077. * @param lightIndex Index of the light in the enabled light list of the material
  9078. */
  9079. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9080. /**
  9081. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9082. * defined in the generator but impacting the effect).
  9083. * It implies the unifroms available on the materials are the standard BJS ones.
  9084. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9085. * @param effect The effect we are binfing the information for
  9086. */
  9087. bindShadowLight(lightIndex: string, effect: Effect): void;
  9088. /**
  9089. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9090. * (eq to shadow prjection matrix * light transform matrix)
  9091. * @returns The transform matrix used to create the shadow map
  9092. */
  9093. getTransformMatrix(): Matrix;
  9094. /**
  9095. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9096. * Cube and 2D textures for instance.
  9097. */
  9098. recreateShadowMap(): void;
  9099. /**
  9100. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9101. * @param onCompiled Callback triggered at the and of the effects compilation
  9102. * @param options Sets of optional options forcing the compilation with different modes
  9103. */
  9104. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9105. useInstances: boolean;
  9106. }>): void;
  9107. /**
  9108. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9109. * @param options Sets of optional options forcing the compilation with different modes
  9110. * @returns A promise that resolves when the compilation completes
  9111. */
  9112. forceCompilationAsync(options?: Partial<{
  9113. useInstances: boolean;
  9114. }>): Promise<void>;
  9115. /**
  9116. * Serializes the shadow generator setup to a json object.
  9117. * @returns The serialized JSON object
  9118. */
  9119. serialize(): any;
  9120. /**
  9121. * Disposes the Shadow map and related Textures and effects.
  9122. */
  9123. dispose(): void;
  9124. }
  9125. /**
  9126. * Default implementation IShadowGenerator.
  9127. * This is the main object responsible of generating shadows in the framework.
  9128. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9129. */
  9130. export class ShadowGenerator implements IShadowGenerator {
  9131. /**
  9132. * Shadow generator mode None: no filtering applied.
  9133. */
  9134. static readonly FILTER_NONE: number;
  9135. /**
  9136. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9137. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9138. */
  9139. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9140. /**
  9141. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9142. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9143. */
  9144. static readonly FILTER_POISSONSAMPLING: number;
  9145. /**
  9146. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9147. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9148. */
  9149. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9150. /**
  9151. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9152. * edge artifacts on steep falloff.
  9153. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9154. */
  9155. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9156. /**
  9157. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9158. * edge artifacts on steep falloff.
  9159. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9160. */
  9161. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9162. /**
  9163. * Shadow generator mode PCF: Percentage Closer Filtering
  9164. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9165. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9166. */
  9167. static readonly FILTER_PCF: number;
  9168. /**
  9169. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9170. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9171. * Contact Hardening
  9172. */
  9173. static readonly FILTER_PCSS: number;
  9174. /**
  9175. * Reserved for PCF and PCSS
  9176. * Highest Quality.
  9177. *
  9178. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9179. *
  9180. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9181. */
  9182. static readonly QUALITY_HIGH: number;
  9183. /**
  9184. * Reserved for PCF and PCSS
  9185. * Good tradeoff for quality/perf cross devices
  9186. *
  9187. * Execute PCF on a 3*3 kernel.
  9188. *
  9189. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9190. */
  9191. static readonly QUALITY_MEDIUM: number;
  9192. /**
  9193. * Reserved for PCF and PCSS
  9194. * The lowest quality but the fastest.
  9195. *
  9196. * Execute PCF on a 1*1 kernel.
  9197. *
  9198. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9199. */
  9200. static readonly QUALITY_LOW: number;
  9201. /** Gets or sets the custom shader name to use */
  9202. customShaderOptions: ICustomShaderOptions;
  9203. /**
  9204. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9205. */
  9206. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9207. /**
  9208. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9209. */
  9210. onAfterShadowMapRenderObservable: Observable<Effect>;
  9211. /**
  9212. * Observable triggered before a mesh is rendered in the shadow map.
  9213. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9214. */
  9215. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9216. /**
  9217. * Observable triggered after a mesh is rendered in the shadow map.
  9218. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9219. */
  9220. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9221. private _bias;
  9222. /**
  9223. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9224. */
  9225. /**
  9226. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9227. */
  9228. bias: number;
  9229. private _normalBias;
  9230. /**
  9231. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9232. */
  9233. /**
  9234. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9235. */
  9236. normalBias: number;
  9237. private _blurBoxOffset;
  9238. /**
  9239. * Gets the blur box offset: offset applied during the blur pass.
  9240. * Only useful if useKernelBlur = false
  9241. */
  9242. /**
  9243. * Sets the blur box offset: offset applied during the blur pass.
  9244. * Only useful if useKernelBlur = false
  9245. */
  9246. blurBoxOffset: number;
  9247. private _blurScale;
  9248. /**
  9249. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9250. * 2 means half of the size.
  9251. */
  9252. /**
  9253. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9254. * 2 means half of the size.
  9255. */
  9256. blurScale: number;
  9257. private _blurKernel;
  9258. /**
  9259. * Gets the blur kernel: kernel size of the blur pass.
  9260. * Only useful if useKernelBlur = true
  9261. */
  9262. /**
  9263. * Sets the blur kernel: kernel size of the blur pass.
  9264. * Only useful if useKernelBlur = true
  9265. */
  9266. blurKernel: number;
  9267. private _useKernelBlur;
  9268. /**
  9269. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9270. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9271. */
  9272. /**
  9273. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9274. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9275. */
  9276. useKernelBlur: boolean;
  9277. private _depthScale;
  9278. /**
  9279. * Gets the depth scale used in ESM mode.
  9280. */
  9281. /**
  9282. * Sets the depth scale used in ESM mode.
  9283. * This can override the scale stored on the light.
  9284. */
  9285. depthScale: number;
  9286. private _filter;
  9287. /**
  9288. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9289. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9290. */
  9291. /**
  9292. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9293. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9294. */
  9295. filter: number;
  9296. /**
  9297. * Gets if the current filter is set to Poisson Sampling.
  9298. */
  9299. /**
  9300. * Sets the current filter to Poisson Sampling.
  9301. */
  9302. usePoissonSampling: boolean;
  9303. /**
  9304. * Gets if the current filter is set to ESM.
  9305. */
  9306. /**
  9307. * Sets the current filter is to ESM.
  9308. */
  9309. useExponentialShadowMap: boolean;
  9310. /**
  9311. * Gets if the current filter is set to filtered ESM.
  9312. */
  9313. /**
  9314. * Gets if the current filter is set to filtered ESM.
  9315. */
  9316. useBlurExponentialShadowMap: boolean;
  9317. /**
  9318. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9319. * exponential to prevent steep falloff artifacts).
  9320. */
  9321. /**
  9322. * Sets the current filter to "close ESM" (using the inverse of the
  9323. * exponential to prevent steep falloff artifacts).
  9324. */
  9325. useCloseExponentialShadowMap: boolean;
  9326. /**
  9327. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9328. * exponential to prevent steep falloff artifacts).
  9329. */
  9330. /**
  9331. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9332. * exponential to prevent steep falloff artifacts).
  9333. */
  9334. useBlurCloseExponentialShadowMap: boolean;
  9335. /**
  9336. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9337. */
  9338. /**
  9339. * Sets the current filter to "PCF" (percentage closer filtering).
  9340. */
  9341. usePercentageCloserFiltering: boolean;
  9342. private _filteringQuality;
  9343. /**
  9344. * Gets the PCF or PCSS Quality.
  9345. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9346. */
  9347. /**
  9348. * Sets the PCF or PCSS Quality.
  9349. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9350. */
  9351. filteringQuality: number;
  9352. /**
  9353. * Gets if the current filter is set to "PCSS" (contact hardening).
  9354. */
  9355. /**
  9356. * Sets the current filter to "PCSS" (contact hardening).
  9357. */
  9358. useContactHardeningShadow: boolean;
  9359. private _contactHardeningLightSizeUVRatio;
  9360. /**
  9361. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9362. * Using a ratio helps keeping shape stability independently of the map size.
  9363. *
  9364. * It does not account for the light projection as it was having too much
  9365. * instability during the light setup or during light position changes.
  9366. *
  9367. * Only valid if useContactHardeningShadow is true.
  9368. */
  9369. /**
  9370. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9371. * Using a ratio helps keeping shape stability independently of the map size.
  9372. *
  9373. * It does not account for the light projection as it was having too much
  9374. * instability during the light setup or during light position changes.
  9375. *
  9376. * Only valid if useContactHardeningShadow is true.
  9377. */
  9378. contactHardeningLightSizeUVRatio: number;
  9379. private _darkness;
  9380. /** Gets or sets the actual darkness of a shadow */
  9381. darkness: number;
  9382. /**
  9383. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9384. * 0 means strongest and 1 would means no shadow.
  9385. * @returns the darkness.
  9386. */
  9387. getDarkness(): number;
  9388. /**
  9389. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9390. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9391. * @returns the shadow generator allowing fluent coding.
  9392. */
  9393. setDarkness(darkness: number): ShadowGenerator;
  9394. private _transparencyShadow;
  9395. /** Gets or sets the ability to have transparent shadow */
  9396. transparencyShadow: boolean;
  9397. /**
  9398. * Sets the ability to have transparent shadow (boolean).
  9399. * @param transparent True if transparent else False
  9400. * @returns the shadow generator allowing fluent coding
  9401. */
  9402. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9403. private _shadowMap;
  9404. private _shadowMap2;
  9405. /**
  9406. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9407. * @returns The render target texture if present otherwise, null
  9408. */
  9409. getShadowMap(): Nullable<RenderTargetTexture>;
  9410. /**
  9411. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9412. * @returns The render target texture if the shadow map is present otherwise, null
  9413. */
  9414. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9415. /**
  9416. * Gets the class name of that object
  9417. * @returns "ShadowGenerator"
  9418. */
  9419. getClassName(): string;
  9420. /**
  9421. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9422. * @param mesh Mesh to add
  9423. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9424. * @returns the Shadow Generator itself
  9425. */
  9426. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9427. /**
  9428. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9429. * @param mesh Mesh to remove
  9430. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9431. * @returns the Shadow Generator itself
  9432. */
  9433. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9434. /**
  9435. * Controls the extent to which the shadows fade out at the edge of the frustum
  9436. * Used only by directionals and spots
  9437. */
  9438. frustumEdgeFalloff: number;
  9439. private _light;
  9440. /**
  9441. * Returns the associated light object.
  9442. * @returns the light generating the shadow
  9443. */
  9444. getLight(): IShadowLight;
  9445. /**
  9446. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9447. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9448. * It might on the other hand introduce peter panning.
  9449. */
  9450. forceBackFacesOnly: boolean;
  9451. private _scene;
  9452. private _lightDirection;
  9453. private _effect;
  9454. private _viewMatrix;
  9455. private _projectionMatrix;
  9456. private _transformMatrix;
  9457. private _cachedPosition;
  9458. private _cachedDirection;
  9459. private _cachedDefines;
  9460. private _currentRenderID;
  9461. private _boxBlurPostprocess;
  9462. private _kernelBlurXPostprocess;
  9463. private _kernelBlurYPostprocess;
  9464. private _blurPostProcesses;
  9465. private _mapSize;
  9466. private _currentFaceIndex;
  9467. private _currentFaceIndexCache;
  9468. private _textureType;
  9469. private _defaultTextureMatrix;
  9470. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9471. /**
  9472. * Creates a ShadowGenerator object.
  9473. * A ShadowGenerator is the required tool to use the shadows.
  9474. * Each light casting shadows needs to use its own ShadowGenerator.
  9475. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9476. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9477. * @param light The light object generating the shadows.
  9478. * @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.
  9479. */
  9480. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9481. private _initializeGenerator;
  9482. private _initializeShadowMap;
  9483. private _initializeBlurRTTAndPostProcesses;
  9484. private _renderForShadowMap;
  9485. private _renderSubMeshForShadowMap;
  9486. private _applyFilterValues;
  9487. /**
  9488. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9489. * @param onCompiled Callback triggered at the and of the effects compilation
  9490. * @param options Sets of optional options forcing the compilation with different modes
  9491. */
  9492. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9493. useInstances: boolean;
  9494. }>): void;
  9495. /**
  9496. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9497. * @param options Sets of optional options forcing the compilation with different modes
  9498. * @returns A promise that resolves when the compilation completes
  9499. */
  9500. forceCompilationAsync(options?: Partial<{
  9501. useInstances: boolean;
  9502. }>): Promise<void>;
  9503. /**
  9504. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9505. * @param subMesh The submesh we want to render in the shadow map
  9506. * @param useInstances Defines wether will draw in the map using instances
  9507. * @returns true if ready otherwise, false
  9508. */
  9509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9510. /**
  9511. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9512. * @param defines Defines of the material we want to update
  9513. * @param lightIndex Index of the light in the enabled light list of the material
  9514. */
  9515. prepareDefines(defines: any, lightIndex: number): void;
  9516. /**
  9517. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9518. * defined in the generator but impacting the effect).
  9519. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9520. * @param effect The effect we are binfing the information for
  9521. */
  9522. bindShadowLight(lightIndex: string, effect: Effect): void;
  9523. /**
  9524. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9525. * (eq to shadow prjection matrix * light transform matrix)
  9526. * @returns The transform matrix used to create the shadow map
  9527. */
  9528. getTransformMatrix(): Matrix;
  9529. /**
  9530. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9531. * Cube and 2D textures for instance.
  9532. */
  9533. recreateShadowMap(): void;
  9534. private _disposeBlurPostProcesses;
  9535. private _disposeRTTandPostProcesses;
  9536. /**
  9537. * Disposes the ShadowGenerator.
  9538. * Returns nothing.
  9539. */
  9540. dispose(): void;
  9541. /**
  9542. * Serializes the shadow generator setup to a json object.
  9543. * @returns The serialized JSON object
  9544. */
  9545. serialize(): any;
  9546. /**
  9547. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9548. * @param parsedShadowGenerator The JSON object to parse
  9549. * @param scene The scene to create the shadow map for
  9550. * @returns The parsed shadow generator
  9551. */
  9552. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9553. }
  9554. }
  9555. declare module BABYLON {
  9556. /**
  9557. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9558. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9559. * 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.
  9560. */
  9561. export abstract class Light extends Node {
  9562. /**
  9563. * Falloff Default: light is falling off following the material specification:
  9564. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9565. */
  9566. static readonly FALLOFF_DEFAULT: number;
  9567. /**
  9568. * Falloff Physical: light is falling off following the inverse squared distance law.
  9569. */
  9570. static readonly FALLOFF_PHYSICAL: number;
  9571. /**
  9572. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9573. * to enhance interoperability with other engines.
  9574. */
  9575. static readonly FALLOFF_GLTF: number;
  9576. /**
  9577. * Falloff Standard: light is falling off like in the standard material
  9578. * to enhance interoperability with other materials.
  9579. */
  9580. static readonly FALLOFF_STANDARD: number;
  9581. /**
  9582. * If every light affecting the material is in this lightmapMode,
  9583. * material.lightmapTexture adds or multiplies
  9584. * (depends on material.useLightmapAsShadowmap)
  9585. * after every other light calculations.
  9586. */
  9587. static readonly LIGHTMAP_DEFAULT: number;
  9588. /**
  9589. * material.lightmapTexture as only diffuse lighting from this light
  9590. * adds only specular lighting from this light
  9591. * adds dynamic shadows
  9592. */
  9593. static readonly LIGHTMAP_SPECULAR: number;
  9594. /**
  9595. * material.lightmapTexture as only lighting
  9596. * no light calculation from this light
  9597. * only adds dynamic shadows from this light
  9598. */
  9599. static readonly LIGHTMAP_SHADOWSONLY: number;
  9600. /**
  9601. * Each light type uses the default quantity according to its type:
  9602. * point/spot lights use luminous intensity
  9603. * directional lights use illuminance
  9604. */
  9605. static readonly INTENSITYMODE_AUTOMATIC: number;
  9606. /**
  9607. * lumen (lm)
  9608. */
  9609. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9610. /**
  9611. * candela (lm/sr)
  9612. */
  9613. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9614. /**
  9615. * lux (lm/m^2)
  9616. */
  9617. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9618. /**
  9619. * nit (cd/m^2)
  9620. */
  9621. static readonly INTENSITYMODE_LUMINANCE: number;
  9622. /**
  9623. * Light type const id of the point light.
  9624. */
  9625. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9626. /**
  9627. * Light type const id of the directional light.
  9628. */
  9629. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9630. /**
  9631. * Light type const id of the spot light.
  9632. */
  9633. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9634. /**
  9635. * Light type const id of the hemispheric light.
  9636. */
  9637. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9638. /**
  9639. * Diffuse gives the basic color to an object.
  9640. */
  9641. diffuse: Color3;
  9642. /**
  9643. * Specular produces a highlight color on an object.
  9644. * Note: This is note affecting PBR materials.
  9645. */
  9646. specular: Color3;
  9647. /**
  9648. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9649. * falling off base on range or angle.
  9650. * This can be set to any values in Light.FALLOFF_x.
  9651. *
  9652. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9653. * other types of materials.
  9654. */
  9655. falloffType: number;
  9656. /**
  9657. * Strength of the light.
  9658. * Note: By default it is define in the framework own unit.
  9659. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9660. */
  9661. intensity: number;
  9662. private _range;
  9663. protected _inverseSquaredRange: number;
  9664. /**
  9665. * Defines how far from the source the light is impacting in scene units.
  9666. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9667. */
  9668. /**
  9669. * Defines how far from the source the light is impacting in scene units.
  9670. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9671. */
  9672. range: number;
  9673. /**
  9674. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9675. * of light.
  9676. */
  9677. private _photometricScale;
  9678. private _intensityMode;
  9679. /**
  9680. * Gets the photometric scale used to interpret the intensity.
  9681. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9682. */
  9683. /**
  9684. * Sets the photometric scale used to interpret the intensity.
  9685. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9686. */
  9687. intensityMode: number;
  9688. private _radius;
  9689. /**
  9690. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9691. */
  9692. /**
  9693. * sets the light radius used by PBR Materials to simulate soft area lights.
  9694. */
  9695. radius: number;
  9696. private _renderPriority;
  9697. /**
  9698. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9699. * exceeding the number allowed of the materials.
  9700. */
  9701. renderPriority: number;
  9702. private _shadowEnabled;
  9703. /**
  9704. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9705. * the current shadow generator.
  9706. */
  9707. /**
  9708. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9709. * the current shadow generator.
  9710. */
  9711. shadowEnabled: boolean;
  9712. private _includedOnlyMeshes;
  9713. /**
  9714. * Gets the only meshes impacted by this light.
  9715. */
  9716. /**
  9717. * Sets the only meshes impacted by this light.
  9718. */
  9719. includedOnlyMeshes: AbstractMesh[];
  9720. private _excludedMeshes;
  9721. /**
  9722. * Gets the meshes not impacted by this light.
  9723. */
  9724. /**
  9725. * Sets the meshes not impacted by this light.
  9726. */
  9727. excludedMeshes: AbstractMesh[];
  9728. private _excludeWithLayerMask;
  9729. /**
  9730. * Gets the layer id use to find what meshes are not impacted by the light.
  9731. * Inactive if 0
  9732. */
  9733. /**
  9734. * Sets the layer id use to find what meshes are not impacted by the light.
  9735. * Inactive if 0
  9736. */
  9737. excludeWithLayerMask: number;
  9738. private _includeOnlyWithLayerMask;
  9739. /**
  9740. * Gets the layer id use to find what meshes are impacted by the light.
  9741. * Inactive if 0
  9742. */
  9743. /**
  9744. * Sets the layer id use to find what meshes are impacted by the light.
  9745. * Inactive if 0
  9746. */
  9747. includeOnlyWithLayerMask: number;
  9748. private _lightmapMode;
  9749. /**
  9750. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9751. */
  9752. /**
  9753. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9754. */
  9755. lightmapMode: number;
  9756. /**
  9757. * Shadow generator associted to the light.
  9758. * @hidden Internal use only.
  9759. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9760. /**
  9761. * @hidden Internal use only.
  9762. */ private _excludedMeshesIds: string[];
  9763. /**
  9764. * @hidden Internal use only.
  9765. */ private _includedOnlyMeshesIds: string[];
  9766. /**
  9767. * The current light unifom buffer.
  9768. * @hidden Internal use only.
  9769. */ private _uniformBuffer: UniformBuffer;
  9770. /**
  9771. * Creates a Light object in the scene.
  9772. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9773. * @param name The firendly name of the light
  9774. * @param scene The scene the light belongs too
  9775. */
  9776. constructor(name: string, scene: Scene);
  9777. protected abstract _buildUniformLayout(): void;
  9778. /**
  9779. * Sets the passed Effect "effect" with the Light information.
  9780. * @param effect The effect to update
  9781. * @param lightIndex The index of the light in the effect to update
  9782. * @returns The light
  9783. */
  9784. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9785. /**
  9786. * Sets the passed Effect "effect" with the Light information.
  9787. * @param effect The effect to update
  9788. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9789. * @returns The light
  9790. */
  9791. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9792. /**
  9793. * Returns the string "Light".
  9794. * @returns the class name
  9795. */
  9796. getClassName(): string;
  9797. /** @hidden */ protected readonly _isLight: boolean;
  9798. /**
  9799. * Converts the light information to a readable string for debug purpose.
  9800. * @param fullDetails Supports for multiple levels of logging within scene loading
  9801. * @returns the human readable light info
  9802. */
  9803. toString(fullDetails?: boolean): string;
  9804. /** @hidden */
  9805. protected _syncParentEnabledState(): void;
  9806. /**
  9807. * Set the enabled state of this node.
  9808. * @param value - the new enabled state
  9809. */
  9810. setEnabled(value: boolean): void;
  9811. /**
  9812. * Returns the Light associated shadow generator if any.
  9813. * @return the associated shadow generator.
  9814. */
  9815. getShadowGenerator(): Nullable<IShadowGenerator>;
  9816. /**
  9817. * Returns a Vector3, the absolute light position in the World.
  9818. * @returns the world space position of the light
  9819. */
  9820. getAbsolutePosition(): Vector3;
  9821. /**
  9822. * Specifies if the light will affect the passed mesh.
  9823. * @param mesh The mesh to test against the light
  9824. * @return true the mesh is affected otherwise, false.
  9825. */
  9826. canAffectMesh(mesh: AbstractMesh): boolean;
  9827. /**
  9828. * Sort function to order lights for rendering.
  9829. * @param a First Light object to compare to second.
  9830. * @param b Second Light object to compare first.
  9831. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9832. */
  9833. static CompareLightsPriority(a: Light, b: Light): number;
  9834. /**
  9835. * Releases resources associated with this node.
  9836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9838. */
  9839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9840. /**
  9841. * Returns the light type ID (integer).
  9842. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9843. */
  9844. getTypeID(): number;
  9845. /**
  9846. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9847. * @returns the scaled intensity in intensity mode unit
  9848. */
  9849. getScaledIntensity(): number;
  9850. /**
  9851. * Returns a new Light object, named "name", from the current one.
  9852. * @param name The name of the cloned light
  9853. * @returns the new created light
  9854. */
  9855. clone(name: string): Nullable<Light>;
  9856. /**
  9857. * Serializes the current light into a Serialization object.
  9858. * @returns the serialized object.
  9859. */
  9860. serialize(): any;
  9861. /**
  9862. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9863. * This new light is named "name" and added to the passed scene.
  9864. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9865. * @param name The friendly name of the light
  9866. * @param scene The scene the new light will belong to
  9867. * @returns the constructor function
  9868. */
  9869. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9870. /**
  9871. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9872. * @param parsedLight The JSON representation of the light
  9873. * @param scene The scene to create the parsed light in
  9874. * @returns the created light after parsing
  9875. */
  9876. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9877. private _hookArrayForExcluded;
  9878. private _hookArrayForIncludedOnly;
  9879. private _resyncMeshes;
  9880. /**
  9881. * Forces the meshes to update their light related information in their rendering used effects
  9882. * @hidden Internal Use Only
  9883. */ private _markMeshesAsLightDirty(): void;
  9884. /**
  9885. * Recomputes the cached photometric scale if needed.
  9886. */
  9887. private _computePhotometricScale;
  9888. /**
  9889. * Returns the Photometric Scale according to the light type and intensity mode.
  9890. */
  9891. private _getPhotometricScale;
  9892. /**
  9893. * Reorder the light in the scene according to their defined priority.
  9894. * @hidden Internal Use Only
  9895. */ private _reorderLightsInScene(): void;
  9896. /**
  9897. * Prepares the list of defines specific to the light type.
  9898. * @param defines the list of defines
  9899. * @param lightIndex defines the index of the light for the effect
  9900. */
  9901. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9902. }
  9903. }
  9904. declare module BABYLON {
  9905. /**
  9906. * Interface used to define Action
  9907. */
  9908. export interface IAction {
  9909. /**
  9910. * Trigger for the action
  9911. */
  9912. trigger: number;
  9913. /** Options of the trigger */
  9914. triggerOptions: any;
  9915. /**
  9916. * Gets the trigger parameters
  9917. * @returns the trigger parameters
  9918. */
  9919. getTriggerParameter(): any;
  9920. /**
  9921. * Internal only - executes current action event
  9922. * @hidden
  9923. */ private _executeCurrent(evt?: ActionEvent): void;
  9924. /**
  9925. * Serialize placeholder for child classes
  9926. * @param parent of child
  9927. * @returns the serialized object
  9928. */
  9929. serialize(parent: any): any;
  9930. /**
  9931. * Internal only
  9932. * @hidden
  9933. */ private _prepare(): void;
  9934. /**
  9935. * Internal only - manager for action
  9936. * @hidden
  9937. */ private _actionManager: AbstractActionManager;
  9938. /**
  9939. * Adds action to chain of actions, may be a DoNothingAction
  9940. * @param action defines the next action to execute
  9941. * @returns The action passed in
  9942. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9943. */
  9944. then(action: IAction): IAction;
  9945. }
  9946. /**
  9947. * The action to be carried out following a trigger
  9948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9949. */
  9950. export class Action implements IAction {
  9951. /** the trigger, with or without parameters, for the action */
  9952. triggerOptions: any;
  9953. /**
  9954. * Trigger for the action
  9955. */
  9956. trigger: number;
  9957. /**
  9958. * Internal only - manager for action
  9959. * @hidden
  9960. */ private _actionManager: ActionManager;
  9961. private _nextActiveAction;
  9962. private _child;
  9963. private _condition?;
  9964. private _triggerParameter;
  9965. /**
  9966. * An event triggered prior to action being executed.
  9967. */
  9968. onBeforeExecuteObservable: Observable<Action>;
  9969. /**
  9970. * Creates a new Action
  9971. * @param triggerOptions the trigger, with or without parameters, for the action
  9972. * @param condition an optional determinant of action
  9973. */
  9974. constructor(
  9975. /** the trigger, with or without parameters, for the action */
  9976. triggerOptions: any, condition?: Condition);
  9977. /**
  9978. * Internal only
  9979. * @hidden
  9980. */ private _prepare(): void;
  9981. /**
  9982. * Gets the trigger parameters
  9983. * @returns the trigger parameters
  9984. */
  9985. getTriggerParameter(): any;
  9986. /**
  9987. * Internal only - executes current action event
  9988. * @hidden
  9989. */ private _executeCurrent(evt?: ActionEvent): void;
  9990. /**
  9991. * Execute placeholder for child classes
  9992. * @param evt optional action event
  9993. */
  9994. execute(evt?: ActionEvent): void;
  9995. /**
  9996. * Skips to next active action
  9997. */
  9998. skipToNextActiveAction(): void;
  9999. /**
  10000. * Adds action to chain of actions, may be a DoNothingAction
  10001. * @param action defines the next action to execute
  10002. * @returns The action passed in
  10003. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10004. */
  10005. then(action: Action): Action;
  10006. /**
  10007. * Internal only
  10008. * @hidden
  10009. */ private _getProperty(propertyPath: string): string;
  10010. /**
  10011. * Internal only
  10012. * @hidden
  10013. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10014. /**
  10015. * Serialize placeholder for child classes
  10016. * @param parent of child
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. /**
  10021. * Internal only called by serialize
  10022. * @hidden
  10023. */
  10024. protected _serialize(serializedAction: any, parent?: any): any;
  10025. /**
  10026. * Internal only
  10027. * @hidden
  10028. */ private static _SerializeValueAsString: (value: any) => string;
  10029. /**
  10030. * Internal only
  10031. * @hidden
  10032. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10033. name: string;
  10034. targetType: string;
  10035. value: string;
  10036. };
  10037. }
  10038. }
  10039. declare module BABYLON {
  10040. /**
  10041. * A Condition applied to an Action
  10042. */
  10043. export class Condition {
  10044. /**
  10045. * Internal only - manager for action
  10046. * @hidden
  10047. */ private _actionManager: ActionManager;
  10048. /**
  10049. * Internal only
  10050. * @hidden
  10051. */ private _evaluationId: number;
  10052. /**
  10053. * Internal only
  10054. * @hidden
  10055. */ private _currentResult: boolean;
  10056. /**
  10057. * Creates a new Condition
  10058. * @param actionManager the manager of the action the condition is applied to
  10059. */
  10060. constructor(actionManager: ActionManager);
  10061. /**
  10062. * Check if the current condition is valid
  10063. * @returns a boolean
  10064. */
  10065. isValid(): boolean;
  10066. /**
  10067. * Internal only
  10068. * @hidden
  10069. */ private _getProperty(propertyPath: string): string;
  10070. /**
  10071. * Internal only
  10072. * @hidden
  10073. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10074. /**
  10075. * Serialize placeholder for child classes
  10076. * @returns the serialized object
  10077. */
  10078. serialize(): any;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. protected _serialize(serializedCondition: any): any;
  10084. }
  10085. /**
  10086. * Defines specific conditional operators as extensions of Condition
  10087. */
  10088. export class ValueCondition extends Condition {
  10089. /** path to specify the property of the target the conditional operator uses */
  10090. propertyPath: string;
  10091. /** the value compared by the conditional operator against the current value of the property */
  10092. value: any;
  10093. /** the conditional operator, default ValueCondition.IsEqual */
  10094. operator: number;
  10095. /**
  10096. * Internal only
  10097. * @hidden
  10098. */
  10099. private static _IsEqual;
  10100. /**
  10101. * Internal only
  10102. * @hidden
  10103. */
  10104. private static _IsDifferent;
  10105. /**
  10106. * Internal only
  10107. * @hidden
  10108. */
  10109. private static _IsGreater;
  10110. /**
  10111. * Internal only
  10112. * @hidden
  10113. */
  10114. private static _IsLesser;
  10115. /**
  10116. * returns the number for IsEqual
  10117. */
  10118. static readonly IsEqual: number;
  10119. /**
  10120. * Returns the number for IsDifferent
  10121. */
  10122. static readonly IsDifferent: number;
  10123. /**
  10124. * Returns the number for IsGreater
  10125. */
  10126. static readonly IsGreater: number;
  10127. /**
  10128. * Returns the number for IsLesser
  10129. */
  10130. static readonly IsLesser: number;
  10131. /**
  10132. * Internal only The action manager for the condition
  10133. * @hidden
  10134. */ private _actionManager: ActionManager;
  10135. /**
  10136. * Internal only
  10137. * @hidden
  10138. */
  10139. private _target;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. private _effectiveTarget;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. private _property;
  10150. /**
  10151. * Creates a new ValueCondition
  10152. * @param actionManager manager for the action the condition applies to
  10153. * @param target for the action
  10154. * @param propertyPath path to specify the property of the target the conditional operator uses
  10155. * @param value the value compared by the conditional operator against the current value of the property
  10156. * @param operator the conditional operator, default ValueCondition.IsEqual
  10157. */
  10158. constructor(actionManager: ActionManager, target: any,
  10159. /** path to specify the property of the target the conditional operator uses */
  10160. propertyPath: string,
  10161. /** the value compared by the conditional operator against the current value of the property */
  10162. value: any,
  10163. /** the conditional operator, default ValueCondition.IsEqual */
  10164. operator?: number);
  10165. /**
  10166. * Compares the given value with the property value for the specified conditional operator
  10167. * @returns the result of the comparison
  10168. */
  10169. isValid(): boolean;
  10170. /**
  10171. * Serialize the ValueCondition into a JSON compatible object
  10172. * @returns serialization object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Gets the name of the conditional operator for the ValueCondition
  10177. * @param operator the conditional operator
  10178. * @returns the name
  10179. */
  10180. static GetOperatorName(operator: number): string;
  10181. }
  10182. /**
  10183. * Defines a predicate condition as an extension of Condition
  10184. */
  10185. export class PredicateCondition extends Condition {
  10186. /** defines the predicate function used to validate the condition */
  10187. predicate: () => boolean;
  10188. /**
  10189. * Internal only - manager for action
  10190. * @hidden
  10191. */ private _actionManager: ActionManager;
  10192. /**
  10193. * Creates a new PredicateCondition
  10194. * @param actionManager manager for the action the condition applies to
  10195. * @param predicate defines the predicate function used to validate the condition
  10196. */
  10197. constructor(actionManager: ActionManager,
  10198. /** defines the predicate function used to validate the condition */
  10199. predicate: () => boolean);
  10200. /**
  10201. * @returns the validity of the predicate condition
  10202. */
  10203. isValid(): boolean;
  10204. }
  10205. /**
  10206. * Defines a state condition as an extension of Condition
  10207. */
  10208. export class StateCondition extends Condition {
  10209. /** Value to compare with target state */
  10210. value: string;
  10211. /**
  10212. * Internal only - manager for action
  10213. * @hidden
  10214. */ private _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Creates a new StateCondition
  10222. * @param actionManager manager for the action the condition applies to
  10223. * @param target of the condition
  10224. * @param value to compare with target state
  10225. */
  10226. constructor(actionManager: ActionManager, target: any,
  10227. /** Value to compare with target state */
  10228. value: string);
  10229. /**
  10230. * Gets a boolean indicating if the current condition is met
  10231. * @returns the validity of the state
  10232. */
  10233. isValid(): boolean;
  10234. /**
  10235. * Serialize the StateCondition into a JSON compatible object
  10236. * @returns serialization object
  10237. */
  10238. serialize(): any;
  10239. }
  10240. }
  10241. declare module BABYLON {
  10242. /**
  10243. * This defines an action responsible to toggle a boolean once triggered.
  10244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10245. */
  10246. export class SwitchBooleanAction extends Action {
  10247. /**
  10248. * The path to the boolean property in the target object
  10249. */
  10250. propertyPath: string;
  10251. private _target;
  10252. private _effectiveTarget;
  10253. private _property;
  10254. /**
  10255. * Instantiate the action
  10256. * @param triggerOptions defines the trigger options
  10257. * @param target defines the object containing the boolean
  10258. * @param propertyPath defines the path to the boolean property in the target object
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10262. /** @hidden */ private _prepare(): void;
  10263. /**
  10264. * Execute the action toggle the boolean value.
  10265. */
  10266. execute(): void;
  10267. /**
  10268. * Serializes the actions and its related information.
  10269. * @param parent defines the object to serialize in
  10270. * @returns the serialized object
  10271. */
  10272. serialize(parent: any): any;
  10273. }
  10274. /**
  10275. * This defines an action responsible to set a the state field of the target
  10276. * to a desired value once triggered.
  10277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10278. */
  10279. export class SetStateAction extends Action {
  10280. /**
  10281. * The value to store in the state field.
  10282. */
  10283. value: string;
  10284. private _target;
  10285. /**
  10286. * Instantiate the action
  10287. * @param triggerOptions defines the trigger options
  10288. * @param target defines the object containing the state property
  10289. * @param value defines the value to store in the state field
  10290. * @param condition defines the trigger related conditions
  10291. */
  10292. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10293. /**
  10294. * Execute the action and store the value on the target state property.
  10295. */
  10296. execute(): void;
  10297. /**
  10298. * Serializes the actions and its related information.
  10299. * @param parent defines the object to serialize in
  10300. * @returns the serialized object
  10301. */
  10302. serialize(parent: any): any;
  10303. }
  10304. /**
  10305. * This defines an action responsible to set a property of the target
  10306. * to a desired value once triggered.
  10307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10308. */
  10309. export class SetValueAction extends Action {
  10310. /**
  10311. * The path of the property to set in the target.
  10312. */
  10313. propertyPath: string;
  10314. /**
  10315. * The value to set in the property
  10316. */
  10317. value: any;
  10318. private _target;
  10319. private _effectiveTarget;
  10320. private _property;
  10321. /**
  10322. * Instantiate the action
  10323. * @param triggerOptions defines the trigger options
  10324. * @param target defines the object containing the property
  10325. * @param propertyPath defines the path of the property to set in the target
  10326. * @param value defines the value to set in the property
  10327. * @param condition defines the trigger related conditions
  10328. */
  10329. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10330. /** @hidden */ private _prepare(): void;
  10331. /**
  10332. * Execute the action and set the targetted property to the desired value.
  10333. */
  10334. execute(): void;
  10335. /**
  10336. * Serializes the actions and its related information.
  10337. * @param parent defines the object to serialize in
  10338. * @returns the serialized object
  10339. */
  10340. serialize(parent: any): any;
  10341. }
  10342. /**
  10343. * This defines an action responsible to increment the target value
  10344. * to a desired value once triggered.
  10345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10346. */
  10347. export class IncrementValueAction extends Action {
  10348. /**
  10349. * The path of the property to increment in the target.
  10350. */
  10351. propertyPath: string;
  10352. /**
  10353. * The value we should increment the property by.
  10354. */
  10355. value: any;
  10356. private _target;
  10357. private _effectiveTarget;
  10358. private _property;
  10359. /**
  10360. * Instantiate the action
  10361. * @param triggerOptions defines the trigger options
  10362. * @param target defines the object containing the property
  10363. * @param propertyPath defines the path of the property to increment in the target
  10364. * @param value defines the value value we should increment the property by
  10365. * @param condition defines the trigger related conditions
  10366. */
  10367. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10368. /** @hidden */ private _prepare(): void;
  10369. /**
  10370. * Execute the action and increment the target of the value amount.
  10371. */
  10372. execute(): void;
  10373. /**
  10374. * Serializes the actions and its related information.
  10375. * @param parent defines the object to serialize in
  10376. * @returns the serialized object
  10377. */
  10378. serialize(parent: any): any;
  10379. }
  10380. /**
  10381. * This defines an action responsible to start an animation once triggered.
  10382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10383. */
  10384. export class PlayAnimationAction extends Action {
  10385. /**
  10386. * Where the animation should start (animation frame)
  10387. */
  10388. from: number;
  10389. /**
  10390. * Where the animation should stop (animation frame)
  10391. */
  10392. to: number;
  10393. /**
  10394. * Define if the animation should loop or stop after the first play.
  10395. */
  10396. loop?: boolean;
  10397. private _target;
  10398. /**
  10399. * Instantiate the action
  10400. * @param triggerOptions defines the trigger options
  10401. * @param target defines the target animation or animation name
  10402. * @param from defines from where the animation should start (animation frame)
  10403. * @param end defines where the animation should stop (animation frame)
  10404. * @param loop defines if the animation should loop or stop after the first play
  10405. * @param condition defines the trigger related conditions
  10406. */
  10407. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10408. /** @hidden */ private _prepare(): void;
  10409. /**
  10410. * Execute the action and play the animation.
  10411. */
  10412. execute(): void;
  10413. /**
  10414. * Serializes the actions and its related information.
  10415. * @param parent defines the object to serialize in
  10416. * @returns the serialized object
  10417. */
  10418. serialize(parent: any): any;
  10419. }
  10420. /**
  10421. * This defines an action responsible to stop an animation once triggered.
  10422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10423. */
  10424. export class StopAnimationAction extends Action {
  10425. private _target;
  10426. /**
  10427. * Instantiate the action
  10428. * @param triggerOptions defines the trigger options
  10429. * @param target defines the target animation or animation name
  10430. * @param condition defines the trigger related conditions
  10431. */
  10432. constructor(triggerOptions: any, target: any, condition?: Condition);
  10433. /** @hidden */ private _prepare(): void;
  10434. /**
  10435. * Execute the action and stop the animation.
  10436. */
  10437. execute(): void;
  10438. /**
  10439. * Serializes the actions and its related information.
  10440. * @param parent defines the object to serialize in
  10441. * @returns the serialized object
  10442. */
  10443. serialize(parent: any): any;
  10444. }
  10445. /**
  10446. * This defines an action responsible that does nothing once triggered.
  10447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10448. */
  10449. export class DoNothingAction extends Action {
  10450. /**
  10451. * Instantiate the action
  10452. * @param triggerOptions defines the trigger options
  10453. * @param condition defines the trigger related conditions
  10454. */
  10455. constructor(triggerOptions?: any, condition?: Condition);
  10456. /**
  10457. * Execute the action and do nothing.
  10458. */
  10459. execute(): void;
  10460. /**
  10461. * Serializes the actions and its related information.
  10462. * @param parent defines the object to serialize in
  10463. * @returns the serialized object
  10464. */
  10465. serialize(parent: any): any;
  10466. }
  10467. /**
  10468. * This defines an action responsible to trigger several actions once triggered.
  10469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10470. */
  10471. export class CombineAction extends Action {
  10472. /**
  10473. * The list of aggregated animations to run.
  10474. */
  10475. children: Action[];
  10476. /**
  10477. * Instantiate the action
  10478. * @param triggerOptions defines the trigger options
  10479. * @param children defines the list of aggregated animations to run
  10480. * @param condition defines the trigger related conditions
  10481. */
  10482. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10483. /** @hidden */ private _prepare(): void;
  10484. /**
  10485. * Execute the action and executes all the aggregated actions.
  10486. */
  10487. execute(evt: ActionEvent): void;
  10488. /**
  10489. * Serializes the actions and its related information.
  10490. * @param parent defines the object to serialize in
  10491. * @returns the serialized object
  10492. */
  10493. serialize(parent: any): any;
  10494. }
  10495. /**
  10496. * This defines an action responsible to run code (external event) once triggered.
  10497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10498. */
  10499. export class ExecuteCodeAction extends Action {
  10500. /**
  10501. * The callback function to run.
  10502. */
  10503. func: (evt: ActionEvent) => void;
  10504. /**
  10505. * Instantiate the action
  10506. * @param triggerOptions defines the trigger options
  10507. * @param func defines the callback function to run
  10508. * @param condition defines the trigger related conditions
  10509. */
  10510. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10511. /**
  10512. * Execute the action and run the attached code.
  10513. */
  10514. execute(evt: ActionEvent): void;
  10515. }
  10516. /**
  10517. * This defines an action responsible to set the parent property of the target once triggered.
  10518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10519. */
  10520. export class SetParentAction extends Action {
  10521. private _parent;
  10522. private _target;
  10523. /**
  10524. * Instantiate the action
  10525. * @param triggerOptions defines the trigger options
  10526. * @param target defines the target containing the parent property
  10527. * @param parent defines from where the animation should start (animation frame)
  10528. * @param condition defines the trigger related conditions
  10529. */
  10530. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10531. /** @hidden */ private _prepare(): void;
  10532. /**
  10533. * Execute the action and set the parent property.
  10534. */
  10535. execute(): void;
  10536. /**
  10537. * Serializes the actions and its related information.
  10538. * @param parent defines the object to serialize in
  10539. * @returns the serialized object
  10540. */
  10541. serialize(parent: any): any;
  10542. }
  10543. }
  10544. declare module BABYLON {
  10545. /**
  10546. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10547. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10549. */
  10550. export class ActionManager extends AbstractActionManager {
  10551. /**
  10552. * Nothing
  10553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10554. */
  10555. static readonly NothingTrigger: number;
  10556. /**
  10557. * On pick
  10558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10559. */
  10560. static readonly OnPickTrigger: number;
  10561. /**
  10562. * On left pick
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10564. */
  10565. static readonly OnLeftPickTrigger: number;
  10566. /**
  10567. * On right pick
  10568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10569. */
  10570. static readonly OnRightPickTrigger: number;
  10571. /**
  10572. * On center pick
  10573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10574. */
  10575. static readonly OnCenterPickTrigger: number;
  10576. /**
  10577. * On pick down
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10579. */
  10580. static readonly OnPickDownTrigger: number;
  10581. /**
  10582. * On double pick
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10584. */
  10585. static readonly OnDoublePickTrigger: number;
  10586. /**
  10587. * On pick up
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10589. */
  10590. static readonly OnPickUpTrigger: number;
  10591. /**
  10592. * On pick out.
  10593. * This trigger will only be raised if you also declared a OnPickDown
  10594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10595. */
  10596. static readonly OnPickOutTrigger: number;
  10597. /**
  10598. * On long press
  10599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10600. */
  10601. static readonly OnLongPressTrigger: number;
  10602. /**
  10603. * On pointer over
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10605. */
  10606. static readonly OnPointerOverTrigger: number;
  10607. /**
  10608. * On pointer out
  10609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10610. */
  10611. static readonly OnPointerOutTrigger: number;
  10612. /**
  10613. * On every frame
  10614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10615. */
  10616. static readonly OnEveryFrameTrigger: number;
  10617. /**
  10618. * On intersection enter
  10619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10620. */
  10621. static readonly OnIntersectionEnterTrigger: number;
  10622. /**
  10623. * On intersection exit
  10624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10625. */
  10626. static readonly OnIntersectionExitTrigger: number;
  10627. /**
  10628. * On key down
  10629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10630. */
  10631. static readonly OnKeyDownTrigger: number;
  10632. /**
  10633. * On key up
  10634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10635. */
  10636. static readonly OnKeyUpTrigger: number;
  10637. private _scene;
  10638. /**
  10639. * Creates a new action manager
  10640. * @param scene defines the hosting scene
  10641. */
  10642. constructor(scene: Scene);
  10643. /**
  10644. * Releases all associated resources
  10645. */
  10646. dispose(): void;
  10647. /**
  10648. * Gets hosting scene
  10649. * @returns the hosting scene
  10650. */
  10651. getScene(): Scene;
  10652. /**
  10653. * Does this action manager handles actions of any of the given triggers
  10654. * @param triggers defines the triggers to be tested
  10655. * @return a boolean indicating whether one (or more) of the triggers is handled
  10656. */
  10657. hasSpecificTriggers(triggers: number[]): boolean;
  10658. /**
  10659. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10660. * speed.
  10661. * @param triggerA defines the trigger to be tested
  10662. * @param triggerB defines the trigger to be tested
  10663. * @return a boolean indicating whether one (or more) of the triggers is handled
  10664. */
  10665. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10666. /**
  10667. * Does this action manager handles actions of a given trigger
  10668. * @param trigger defines the trigger to be tested
  10669. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10670. * @return whether the trigger is handled
  10671. */
  10672. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10673. /**
  10674. * Does this action manager has pointer triggers
  10675. */
  10676. readonly hasPointerTriggers: boolean;
  10677. /**
  10678. * Does this action manager has pick triggers
  10679. */
  10680. readonly hasPickTriggers: boolean;
  10681. /**
  10682. * Registers an action to this action manager
  10683. * @param action defines the action to be registered
  10684. * @return the action amended (prepared) after registration
  10685. */
  10686. registerAction(action: IAction): Nullable<IAction>;
  10687. /**
  10688. * Unregisters an action to this action manager
  10689. * @param action defines the action to be unregistered
  10690. * @return a boolean indicating whether the action has been unregistered
  10691. */
  10692. unregisterAction(action: IAction): Boolean;
  10693. /**
  10694. * Process a specific trigger
  10695. * @param trigger defines the trigger to process
  10696. * @param evt defines the event details to be processed
  10697. */
  10698. processTrigger(trigger: number, evt?: IActionEvent): void;
  10699. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10700. /** @hidden */ private _getProperty(propertyPath: string): string;
  10701. /**
  10702. * Serialize this manager to a JSON object
  10703. * @param name defines the property name to store this manager
  10704. * @returns a JSON representation of this manager
  10705. */
  10706. serialize(name: string): any;
  10707. /**
  10708. * Creates a new ActionManager from a JSON data
  10709. * @param parsedActions defines the JSON data to read from
  10710. * @param object defines the hosting mesh
  10711. * @param scene defines the hosting scene
  10712. */
  10713. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10714. /**
  10715. * Get a trigger name by index
  10716. * @param trigger defines the trigger index
  10717. * @returns a trigger name
  10718. */
  10719. static GetTriggerName(trigger: number): string;
  10720. }
  10721. }
  10722. declare module BABYLON {
  10723. /**
  10724. * Class representing a ray with position and direction
  10725. */
  10726. export class Ray {
  10727. /** origin point */
  10728. origin: Vector3;
  10729. /** direction */
  10730. direction: Vector3;
  10731. /** length of the ray */
  10732. length: number;
  10733. private static readonly TmpVector3;
  10734. private _tmpRay;
  10735. /**
  10736. * Creates a new ray
  10737. * @param origin origin point
  10738. * @param direction direction
  10739. * @param length length of the ray
  10740. */
  10741. constructor(
  10742. /** origin point */
  10743. origin: Vector3,
  10744. /** direction */
  10745. direction: Vector3,
  10746. /** length of the ray */
  10747. length?: number);
  10748. /**
  10749. * Checks if the ray intersects a box
  10750. * @param minimum bound of the box
  10751. * @param maximum bound of the box
  10752. * @param intersectionTreshold extra extend to be added to the box in all direction
  10753. * @returns if the box was hit
  10754. */
  10755. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10756. /**
  10757. * Checks if the ray intersects a box
  10758. * @param box the bounding box to check
  10759. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10760. * @returns if the box was hit
  10761. */
  10762. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10763. /**
  10764. * If the ray hits a sphere
  10765. * @param sphere the bounding sphere to check
  10766. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10767. * @returns true if it hits the sphere
  10768. */
  10769. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10770. /**
  10771. * If the ray hits a triange
  10772. * @param vertex0 triangle vertex
  10773. * @param vertex1 triangle vertex
  10774. * @param vertex2 triangle vertex
  10775. * @returns intersection information if hit
  10776. */
  10777. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10778. /**
  10779. * Checks if ray intersects a plane
  10780. * @param plane the plane to check
  10781. * @returns the distance away it was hit
  10782. */
  10783. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10784. /**
  10785. * Calculate the intercept of a ray on a given axis
  10786. * @param axis to check 'x' | 'y' | 'z'
  10787. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10788. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10789. */
  10790. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10791. /**
  10792. * Checks if ray intersects a mesh
  10793. * @param mesh the mesh to check
  10794. * @param fastCheck if only the bounding box should checked
  10795. * @returns picking info of the intersecton
  10796. */
  10797. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10798. /**
  10799. * Checks if ray intersects a mesh
  10800. * @param meshes the meshes to check
  10801. * @param fastCheck if only the bounding box should checked
  10802. * @param results array to store result in
  10803. * @returns Array of picking infos
  10804. */
  10805. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10806. private _comparePickingInfo;
  10807. private static smallnum;
  10808. private static rayl;
  10809. /**
  10810. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10811. * @param sega the first point of the segment to test the intersection against
  10812. * @param segb the second point of the segment to test the intersection against
  10813. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10814. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10815. */
  10816. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10817. /**
  10818. * Update the ray from viewport position
  10819. * @param x position
  10820. * @param y y position
  10821. * @param viewportWidth viewport width
  10822. * @param viewportHeight viewport height
  10823. * @param world world matrix
  10824. * @param view view matrix
  10825. * @param projection projection matrix
  10826. * @returns this ray updated
  10827. */
  10828. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10829. /**
  10830. * Creates a ray with origin and direction of 0,0,0
  10831. * @returns the new ray
  10832. */
  10833. static Zero(): Ray;
  10834. /**
  10835. * Creates a new ray from screen space and viewport
  10836. * @param x position
  10837. * @param y y position
  10838. * @param viewportWidth viewport width
  10839. * @param viewportHeight viewport height
  10840. * @param world world matrix
  10841. * @param view view matrix
  10842. * @param projection projection matrix
  10843. * @returns new ray
  10844. */
  10845. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10846. /**
  10847. * 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
  10848. * transformed to the given world matrix.
  10849. * @param origin The origin point
  10850. * @param end The end point
  10851. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10852. * @returns the new ray
  10853. */
  10854. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10855. /**
  10856. * Transforms a ray by a matrix
  10857. * @param ray ray to transform
  10858. * @param matrix matrix to apply
  10859. * @returns the resulting new ray
  10860. */
  10861. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10862. /**
  10863. * Transforms a ray by a matrix
  10864. * @param ray ray to transform
  10865. * @param matrix matrix to apply
  10866. * @param result ray to store result in
  10867. */
  10868. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10869. /**
  10870. * Unproject a ray from screen space to object space
  10871. * @param sourceX defines the screen space x coordinate to use
  10872. * @param sourceY defines the screen space y coordinate to use
  10873. * @param viewportWidth defines the current width of the viewport
  10874. * @param viewportHeight defines the current height of the viewport
  10875. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10876. * @param view defines the view matrix to use
  10877. * @param projection defines the projection matrix to use
  10878. */
  10879. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10880. }
  10881. /**
  10882. * Type used to define predicate used to select faces when a mesh intersection is detected
  10883. */
  10884. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10885. interface Scene {
  10886. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10887. /** @hidden */ private _cachedRayForTransform: Ray;
  10888. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10889. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10890. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10891. }
  10892. }
  10893. declare module BABYLON {
  10894. /**
  10895. * Groups all the scene component constants in one place to ease maintenance.
  10896. * @hidden
  10897. */
  10898. export class SceneComponentConstants {
  10899. static readonly NAME_EFFECTLAYER: string;
  10900. static readonly NAME_LAYER: string;
  10901. static readonly NAME_LENSFLARESYSTEM: string;
  10902. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10903. static readonly NAME_PARTICLESYSTEM: string;
  10904. static readonly NAME_GAMEPAD: string;
  10905. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10906. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10907. static readonly NAME_DEPTHRENDERER: string;
  10908. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10909. static readonly NAME_SPRITE: string;
  10910. static readonly NAME_OUTLINERENDERER: string;
  10911. static readonly NAME_PROCEDURALTEXTURE: string;
  10912. static readonly NAME_SHADOWGENERATOR: string;
  10913. static readonly NAME_OCTREE: string;
  10914. static readonly NAME_PHYSICSENGINE: string;
  10915. static readonly NAME_AUDIO: string;
  10916. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10917. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10918. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10919. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10920. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10921. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10922. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10923. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10924. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10925. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10926. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10927. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10928. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10929. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10930. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10931. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10932. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10933. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10934. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10935. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10936. static readonly STEP_AFTERRENDER_AUDIO: number;
  10937. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10938. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10939. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10940. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10941. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10942. static readonly STEP_POINTERMOVE_SPRITE: number;
  10943. static readonly STEP_POINTERDOWN_SPRITE: number;
  10944. static readonly STEP_POINTERUP_SPRITE: number;
  10945. }
  10946. /**
  10947. * This represents a scene component.
  10948. *
  10949. * This is used to decouple the dependency the scene is having on the different workloads like
  10950. * layers, post processes...
  10951. */
  10952. export interface ISceneComponent {
  10953. /**
  10954. * The name of the component. Each component must have a unique name.
  10955. */
  10956. name: string;
  10957. /**
  10958. * The scene the component belongs to.
  10959. */
  10960. scene: Scene;
  10961. /**
  10962. * Register the component to one instance of a scene.
  10963. */
  10964. register(): void;
  10965. /**
  10966. * Rebuilds the elements related to this component in case of
  10967. * context lost for instance.
  10968. */
  10969. rebuild(): void;
  10970. /**
  10971. * Disposes the component and the associated ressources.
  10972. */
  10973. dispose(): void;
  10974. }
  10975. /**
  10976. * This represents a SERIALIZABLE scene component.
  10977. *
  10978. * This extends Scene Component to add Serialization methods on top.
  10979. */
  10980. export interface ISceneSerializableComponent extends ISceneComponent {
  10981. /**
  10982. * Adds all the elements from the container to the scene
  10983. * @param container the container holding the elements
  10984. */
  10985. addFromContainer(container: AbstractScene): void;
  10986. /**
  10987. * Removes all the elements in the container from the scene
  10988. * @param container contains the elements to remove
  10989. * @param dispose if the removed element should be disposed (default: false)
  10990. */
  10991. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10992. /**
  10993. * Serializes the component data to the specified json object
  10994. * @param serializationObject The object to serialize to
  10995. */
  10996. serialize(serializationObject: any): void;
  10997. }
  10998. /**
  10999. * Strong typing of a Mesh related stage step action
  11000. */
  11001. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11002. /**
  11003. * Strong typing of a Evaluate Sub Mesh related stage step action
  11004. */
  11005. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11006. /**
  11007. * Strong typing of a Active Mesh related stage step action
  11008. */
  11009. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11010. /**
  11011. * Strong typing of a Camera related stage step action
  11012. */
  11013. export type CameraStageAction = (camera: Camera) => void;
  11014. /**
  11015. * Strong typing of a Camera Frame buffer related stage step action
  11016. */
  11017. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11018. /**
  11019. * Strong typing of a Render Target related stage step action
  11020. */
  11021. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11022. /**
  11023. * Strong typing of a RenderingGroup related stage step action
  11024. */
  11025. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11026. /**
  11027. * Strong typing of a Mesh Render related stage step action
  11028. */
  11029. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11030. /**
  11031. * Strong typing of a simple stage step action
  11032. */
  11033. export type SimpleStageAction = () => void;
  11034. /**
  11035. * Strong typing of a render target action.
  11036. */
  11037. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11038. /**
  11039. * Strong typing of a pointer move action.
  11040. */
  11041. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11042. /**
  11043. * Strong typing of a pointer up/down action.
  11044. */
  11045. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11046. /**
  11047. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11048. * @hidden
  11049. */
  11050. export class Stage<T extends Function> extends Array<{
  11051. index: number;
  11052. component: ISceneComponent;
  11053. action: T;
  11054. }> {
  11055. /**
  11056. * Hide ctor from the rest of the world.
  11057. * @param items The items to add.
  11058. */
  11059. private constructor();
  11060. /**
  11061. * Creates a new Stage.
  11062. * @returns A new instance of a Stage
  11063. */
  11064. static Create<T extends Function>(): Stage<T>;
  11065. /**
  11066. * Registers a step in an ordered way in the targeted stage.
  11067. * @param index Defines the position to register the step in
  11068. * @param component Defines the component attached to the step
  11069. * @param action Defines the action to launch during the step
  11070. */
  11071. registerStep(index: number, component: ISceneComponent, action: T): void;
  11072. /**
  11073. * Clears all the steps from the stage.
  11074. */
  11075. clear(): void;
  11076. }
  11077. }
  11078. declare module BABYLON {
  11079. interface Scene {
  11080. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11081. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11082. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11083. /**
  11084. * All of the sprite managers added to this scene
  11085. * @see http://doc.babylonjs.com/babylon101/sprites
  11086. */
  11087. spriteManagers: Array<ISpriteManager>;
  11088. /**
  11089. * An event triggered when sprites rendering is about to start
  11090. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11091. */
  11092. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11093. /**
  11094. * An event triggered when sprites rendering is done
  11095. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11096. */
  11097. onAfterSpritesRenderingObservable: Observable<Scene>;
  11098. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11099. /** Launch a ray to try to pick a sprite in the scene
  11100. * @param x position on screen
  11101. * @param y position on screen
  11102. * @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
  11103. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11104. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11105. * @returns a PickingInfo
  11106. */
  11107. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11108. /** Use the given ray to pick a sprite in the scene
  11109. * @param ray The ray (in world space) to use to pick meshes
  11110. * @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
  11111. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11112. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11113. * @returns a PickingInfo
  11114. */
  11115. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11116. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11117. /** Launch a ray to try to pick sprites in the scene
  11118. * @param x position on screen
  11119. * @param y position on screen
  11120. * @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
  11121. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11122. * @returns a PickingInfo array
  11123. */
  11124. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11125. /** Use the given ray to pick sprites in the scene
  11126. * @param ray The ray (in world space) to use to pick meshes
  11127. * @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
  11128. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11129. * @returns a PickingInfo array
  11130. */
  11131. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11132. /**
  11133. * Force the sprite under the pointer
  11134. * @param sprite defines the sprite to use
  11135. */
  11136. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11137. /**
  11138. * Gets the sprite under the pointer
  11139. * @returns a Sprite or null if no sprite is under the pointer
  11140. */
  11141. getPointerOverSprite(): Nullable<Sprite>;
  11142. }
  11143. /**
  11144. * Defines the sprite scene component responsible to manage sprites
  11145. * in a given scene.
  11146. */
  11147. export class SpriteSceneComponent implements ISceneComponent {
  11148. /**
  11149. * The component name helpfull to identify the component in the list of scene components.
  11150. */
  11151. readonly name: string;
  11152. /**
  11153. * The scene the component belongs to.
  11154. */
  11155. scene: Scene;
  11156. /** @hidden */
  11157. private _spritePredicate;
  11158. /**
  11159. * Creates a new instance of the component for the given scene
  11160. * @param scene Defines the scene to register the component in
  11161. */
  11162. constructor(scene: Scene);
  11163. /**
  11164. * Registers the component in a given scene
  11165. */
  11166. register(): void;
  11167. /**
  11168. * Rebuilds the elements related to this component in case of
  11169. * context lost for instance.
  11170. */
  11171. rebuild(): void;
  11172. /**
  11173. * Disposes the component and the associated ressources.
  11174. */
  11175. dispose(): void;
  11176. private _pickSpriteButKeepRay;
  11177. private _pointerMove;
  11178. private _pointerDown;
  11179. private _pointerUp;
  11180. }
  11181. }
  11182. declare module BABYLON {
  11183. /** @hidden */
  11184. export var fogFragmentDeclaration: {
  11185. name: string;
  11186. shader: string;
  11187. };
  11188. }
  11189. declare module BABYLON {
  11190. /** @hidden */
  11191. export var fogFragment: {
  11192. name: string;
  11193. shader: string;
  11194. };
  11195. }
  11196. declare module BABYLON {
  11197. /** @hidden */
  11198. export var spritesPixelShader: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module BABYLON {
  11204. /** @hidden */
  11205. export var fogVertexDeclaration: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module BABYLON {
  11211. /** @hidden */
  11212. export var spritesVertexShader: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module BABYLON {
  11218. /**
  11219. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11220. */
  11221. export interface ISpriteManager extends IDisposable {
  11222. /**
  11223. * Restricts the camera to viewing objects with the same layerMask.
  11224. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11225. */
  11226. layerMask: number;
  11227. /**
  11228. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11229. */
  11230. isPickable: boolean;
  11231. /**
  11232. * Specifies the rendering group id for this mesh (0 by default)
  11233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11234. */
  11235. renderingGroupId: number;
  11236. /**
  11237. * Defines the list of sprites managed by the manager.
  11238. */
  11239. sprites: Array<Sprite>;
  11240. /**
  11241. * Tests the intersection of a sprite with a specific ray.
  11242. * @param ray The ray we are sending to test the collision
  11243. * @param camera The camera space we are sending rays in
  11244. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11245. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11246. * @returns picking info or null.
  11247. */
  11248. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11249. /**
  11250. * Intersects the sprites with a ray
  11251. * @param ray defines the ray to intersect with
  11252. * @param camera defines the current active camera
  11253. * @param predicate defines a predicate used to select candidate sprites
  11254. * @returns null if no hit or a PickingInfo array
  11255. */
  11256. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11257. /**
  11258. * Renders the list of sprites on screen.
  11259. */
  11260. render(): void;
  11261. }
  11262. /**
  11263. * Class used to manage multiple sprites on the same spritesheet
  11264. * @see http://doc.babylonjs.com/babylon101/sprites
  11265. */
  11266. export class SpriteManager implements ISpriteManager {
  11267. /** defines the manager's name */
  11268. name: string;
  11269. /** Gets the list of sprites */
  11270. sprites: Sprite[];
  11271. /** Gets or sets the rendering group id (0 by default) */
  11272. renderingGroupId: number;
  11273. /** Gets or sets camera layer mask */
  11274. layerMask: number;
  11275. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11276. fogEnabled: boolean;
  11277. /** Gets or sets a boolean indicating if the sprites are pickable */
  11278. isPickable: boolean;
  11279. /** Defines the default width of a cell in the spritesheet */
  11280. cellWidth: number;
  11281. /** Defines the default height of a cell in the spritesheet */
  11282. cellHeight: number;
  11283. /** Associative array from JSON sprite data file */
  11284. private _cellData;
  11285. /** Array of sprite names from JSON sprite data file */
  11286. private _spriteMap;
  11287. /** True when packed cell data from JSON file is ready*/
  11288. private _packedAndReady;
  11289. /**
  11290. * An event triggered when the manager is disposed.
  11291. */
  11292. onDisposeObservable: Observable<SpriteManager>;
  11293. private _onDisposeObserver;
  11294. /**
  11295. * Callback called when the manager is disposed
  11296. */
  11297. onDispose: () => void;
  11298. private _capacity;
  11299. private _fromPacked;
  11300. private _spriteTexture;
  11301. private _epsilon;
  11302. private _scene;
  11303. private _vertexData;
  11304. private _buffer;
  11305. private _vertexBuffers;
  11306. private _indexBuffer;
  11307. private _effectBase;
  11308. private _effectFog;
  11309. /**
  11310. * Gets or sets the spritesheet texture
  11311. */
  11312. texture: Texture;
  11313. /**
  11314. * Creates a new sprite manager
  11315. * @param name defines the manager's name
  11316. * @param imgUrl defines the sprite sheet url
  11317. * @param capacity defines the maximum allowed number of sprites
  11318. * @param cellSize defines the size of a sprite cell
  11319. * @param scene defines the hosting scene
  11320. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11321. * @param samplingMode defines the smapling mode to use with spritesheet
  11322. * @param fromPacked set to false; do not alter
  11323. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11324. */
  11325. constructor(
  11326. /** defines the manager's name */
  11327. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11328. private _makePacked;
  11329. private _appendSpriteVertex;
  11330. /**
  11331. * Intersects the sprites with a ray
  11332. * @param ray defines the ray to intersect with
  11333. * @param camera defines the current active camera
  11334. * @param predicate defines a predicate used to select candidate sprites
  11335. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11336. * @returns null if no hit or a PickingInfo
  11337. */
  11338. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11339. /**
  11340. * Intersects the sprites with a ray
  11341. * @param ray defines the ray to intersect with
  11342. * @param camera defines the current active camera
  11343. * @param predicate defines a predicate used to select candidate sprites
  11344. * @returns null if no hit or a PickingInfo array
  11345. */
  11346. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11347. /**
  11348. * Render all child sprites
  11349. */
  11350. render(): void;
  11351. /**
  11352. * Release associated resources
  11353. */
  11354. dispose(): void;
  11355. }
  11356. }
  11357. declare module BABYLON {
  11358. /**
  11359. * Class used to represent a sprite
  11360. * @see http://doc.babylonjs.com/babylon101/sprites
  11361. */
  11362. export class Sprite {
  11363. /** defines the name */
  11364. name: string;
  11365. /** Gets or sets the current world position */
  11366. position: Vector3;
  11367. /** Gets or sets the main color */
  11368. color: Color4;
  11369. /** Gets or sets the width */
  11370. width: number;
  11371. /** Gets or sets the height */
  11372. height: number;
  11373. /** Gets or sets rotation angle */
  11374. angle: number;
  11375. /** Gets or sets the cell index in the sprite sheet */
  11376. cellIndex: number;
  11377. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11378. cellRef: string;
  11379. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11380. invertU: number;
  11381. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11382. invertV: number;
  11383. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11384. disposeWhenFinishedAnimating: boolean;
  11385. /** Gets the list of attached animations */
  11386. animations: Animation[];
  11387. /** Gets or sets a boolean indicating if the sprite can be picked */
  11388. isPickable: boolean;
  11389. /**
  11390. * Gets or sets the associated action manager
  11391. */
  11392. actionManager: Nullable<ActionManager>;
  11393. private _animationStarted;
  11394. private _loopAnimation;
  11395. private _fromIndex;
  11396. private _toIndex;
  11397. private _delay;
  11398. private _direction;
  11399. private _manager;
  11400. private _time;
  11401. private _onAnimationEnd;
  11402. /**
  11403. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11404. */
  11405. isVisible: boolean;
  11406. /**
  11407. * Gets or sets the sprite size
  11408. */
  11409. size: number;
  11410. /**
  11411. * Creates a new Sprite
  11412. * @param name defines the name
  11413. * @param manager defines the manager
  11414. */
  11415. constructor(
  11416. /** defines the name */
  11417. name: string, manager: ISpriteManager);
  11418. /**
  11419. * Starts an animation
  11420. * @param from defines the initial key
  11421. * @param to defines the end key
  11422. * @param loop defines if the animation must loop
  11423. * @param delay defines the start delay (in ms)
  11424. * @param onAnimationEnd defines a callback to call when animation ends
  11425. */
  11426. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11427. /** Stops current animation (if any) */
  11428. stopAnimation(): void;
  11429. /** @hidden */ private _animate(deltaTime: number): void;
  11430. /** Release associated resources */
  11431. dispose(): void;
  11432. }
  11433. }
  11434. declare module BABYLON {
  11435. /**
  11436. * Information about the result of picking within a scene
  11437. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11438. */
  11439. export class PickingInfo {
  11440. /** @hidden */ private _pickingUnavailable: boolean;
  11441. /**
  11442. * If the pick collided with an object
  11443. */
  11444. hit: boolean;
  11445. /**
  11446. * Distance away where the pick collided
  11447. */
  11448. distance: number;
  11449. /**
  11450. * The location of pick collision
  11451. */
  11452. pickedPoint: Nullable<Vector3>;
  11453. /**
  11454. * The mesh corresponding the the pick collision
  11455. */
  11456. pickedMesh: Nullable<AbstractMesh>;
  11457. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11458. bu: number;
  11459. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11460. bv: number;
  11461. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11462. faceId: number;
  11463. /** Id of the the submesh that was picked */
  11464. subMeshId: number;
  11465. /** If a sprite was picked, this will be the sprite the pick collided with */
  11466. pickedSprite: Nullable<Sprite>;
  11467. /**
  11468. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11469. */
  11470. originMesh: Nullable<AbstractMesh>;
  11471. /**
  11472. * The ray that was used to perform the picking.
  11473. */
  11474. ray: Nullable<Ray>;
  11475. /**
  11476. * Gets the normal correspodning to the face the pick collided with
  11477. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11478. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11479. * @returns The normal correspodning to the face the pick collided with
  11480. */
  11481. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11482. /**
  11483. * Gets the texture coordinates of where the pick occured
  11484. * @returns the vector containing the coordnates of the texture
  11485. */
  11486. getTextureCoordinates(): Nullable<Vector2>;
  11487. }
  11488. }
  11489. declare module BABYLON {
  11490. /**
  11491. * Gather the list of pointer event types as constants.
  11492. */
  11493. export class PointerEventTypes {
  11494. /**
  11495. * 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.
  11496. */
  11497. static readonly POINTERDOWN: number;
  11498. /**
  11499. * The pointerup event is fired when a pointer is no longer active.
  11500. */
  11501. static readonly POINTERUP: number;
  11502. /**
  11503. * The pointermove event is fired when a pointer changes coordinates.
  11504. */
  11505. static readonly POINTERMOVE: number;
  11506. /**
  11507. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11508. */
  11509. static readonly POINTERWHEEL: number;
  11510. /**
  11511. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11512. */
  11513. static readonly POINTERPICK: number;
  11514. /**
  11515. * The pointertap event is fired when a the object has been touched and released without drag.
  11516. */
  11517. static readonly POINTERTAP: number;
  11518. /**
  11519. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11520. */
  11521. static readonly POINTERDOUBLETAP: number;
  11522. }
  11523. /**
  11524. * Base class of pointer info types.
  11525. */
  11526. export class PointerInfoBase {
  11527. /**
  11528. * Defines the type of event (PointerEventTypes)
  11529. */
  11530. type: number;
  11531. /**
  11532. * Defines the related dom event
  11533. */
  11534. event: PointerEvent | MouseWheelEvent;
  11535. /**
  11536. * Instantiates the base class of pointers info.
  11537. * @param type Defines the type of event (PointerEventTypes)
  11538. * @param event Defines the related dom event
  11539. */
  11540. constructor(
  11541. /**
  11542. * Defines the type of event (PointerEventTypes)
  11543. */
  11544. type: number,
  11545. /**
  11546. * Defines the related dom event
  11547. */
  11548. event: PointerEvent | MouseWheelEvent);
  11549. }
  11550. /**
  11551. * This class is used to store pointer related info for the onPrePointerObservable event.
  11552. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11553. */
  11554. export class PointerInfoPre extends PointerInfoBase {
  11555. /**
  11556. * Ray from a pointer if availible (eg. 6dof controller)
  11557. */
  11558. ray: Nullable<Ray>;
  11559. /**
  11560. * Defines the local position of the pointer on the canvas.
  11561. */
  11562. localPosition: Vector2;
  11563. /**
  11564. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11565. */
  11566. skipOnPointerObservable: boolean;
  11567. /**
  11568. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11569. * @param type Defines the type of event (PointerEventTypes)
  11570. * @param event Defines the related dom event
  11571. * @param localX Defines the local x coordinates of the pointer when the event occured
  11572. * @param localY Defines the local y coordinates of the pointer when the event occured
  11573. */
  11574. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11575. }
  11576. /**
  11577. * This type contains all the data related to a pointer event in Babylon.js.
  11578. * 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.
  11579. */
  11580. export class PointerInfo extends PointerInfoBase {
  11581. /**
  11582. * Defines the picking info associated to the info (if any)\
  11583. */
  11584. pickInfo: Nullable<PickingInfo>;
  11585. /**
  11586. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11587. * @param type Defines the type of event (PointerEventTypes)
  11588. * @param event Defines the related dom event
  11589. * @param pickInfo Defines the picking info associated to the info (if any)\
  11590. */
  11591. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11592. /**
  11593. * Defines the picking info associated to the info (if any)\
  11594. */
  11595. pickInfo: Nullable<PickingInfo>);
  11596. }
  11597. /**
  11598. * Data relating to a touch event on the screen.
  11599. */
  11600. export interface PointerTouch {
  11601. /**
  11602. * X coordinate of touch.
  11603. */
  11604. x: number;
  11605. /**
  11606. * Y coordinate of touch.
  11607. */
  11608. y: number;
  11609. /**
  11610. * Id of touch. Unique for each finger.
  11611. */
  11612. pointerId: number;
  11613. /**
  11614. * Event type passed from DOM.
  11615. */
  11616. type: any;
  11617. }
  11618. }
  11619. declare module BABYLON {
  11620. /**
  11621. * Manage the mouse inputs to control the movement of a free camera.
  11622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11623. */
  11624. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11625. /**
  11626. * Define if touch is enabled in the mouse input
  11627. */
  11628. touchEnabled: boolean;
  11629. /**
  11630. * Defines the camera the input is attached to.
  11631. */
  11632. camera: FreeCamera;
  11633. /**
  11634. * Defines the buttons associated with the input to handle camera move.
  11635. */
  11636. buttons: number[];
  11637. /**
  11638. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11639. */
  11640. angularSensibility: number;
  11641. private _pointerInput;
  11642. private _onMouseMove;
  11643. private _observer;
  11644. private previousPosition;
  11645. /**
  11646. * Observable for when a pointer move event occurs containing the move offset
  11647. */
  11648. onPointerMovedObservable: Observable<{
  11649. offsetX: number;
  11650. offsetY: number;
  11651. }>;
  11652. /**
  11653. * @hidden
  11654. * If the camera should be rotated automatically based on pointer movement
  11655. */ private _allowCameraRotation: boolean;
  11656. /**
  11657. * Manage the mouse inputs to control the movement of a free camera.
  11658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11659. * @param touchEnabled Defines if touch is enabled or not
  11660. */
  11661. constructor(
  11662. /**
  11663. * Define if touch is enabled in the mouse input
  11664. */
  11665. touchEnabled?: boolean);
  11666. /**
  11667. * Attach the input controls to a specific dom element to get the input from.
  11668. * @param element Defines the element the controls should be listened from
  11669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11670. */
  11671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11672. /**
  11673. * Called on JS contextmenu event.
  11674. * Override this method to provide functionality.
  11675. */
  11676. protected onContextMenu(evt: PointerEvent): void;
  11677. /**
  11678. * Detach the current controls from the specified dom element.
  11679. * @param element Defines the element to stop listening the inputs from
  11680. */
  11681. detachControl(element: Nullable<HTMLElement>): void;
  11682. /**
  11683. * Gets the class name of the current intput.
  11684. * @returns the class name
  11685. */
  11686. getClassName(): string;
  11687. /**
  11688. * Get the friendly name associated with the input class.
  11689. * @returns the input friendly name
  11690. */
  11691. getSimpleName(): string;
  11692. }
  11693. }
  11694. declare module BABYLON {
  11695. /**
  11696. * Manage the touch inputs to control the movement of a free camera.
  11697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11698. */
  11699. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11700. /**
  11701. * Defines the camera the input is attached to.
  11702. */
  11703. camera: FreeCamera;
  11704. /**
  11705. * Defines the touch sensibility for rotation.
  11706. * The higher the faster.
  11707. */
  11708. touchAngularSensibility: number;
  11709. /**
  11710. * Defines the touch sensibility for move.
  11711. * The higher the faster.
  11712. */
  11713. touchMoveSensibility: number;
  11714. private _offsetX;
  11715. private _offsetY;
  11716. private _pointerPressed;
  11717. private _pointerInput;
  11718. private _observer;
  11719. private _onLostFocus;
  11720. /**
  11721. * Attach the input controls to a specific dom element to get the input from.
  11722. * @param element Defines the element the controls should be listened from
  11723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11724. */
  11725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11726. /**
  11727. * Detach the current controls from the specified dom element.
  11728. * @param element Defines the element to stop listening the inputs from
  11729. */
  11730. detachControl(element: Nullable<HTMLElement>): void;
  11731. /**
  11732. * Update the current camera state depending on the inputs that have been used this frame.
  11733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11734. */
  11735. checkInputs(): void;
  11736. /**
  11737. * Gets the class name of the current intput.
  11738. * @returns the class name
  11739. */
  11740. getClassName(): string;
  11741. /**
  11742. * Get the friendly name associated with the input class.
  11743. * @returns the input friendly name
  11744. */
  11745. getSimpleName(): string;
  11746. }
  11747. }
  11748. declare module BABYLON {
  11749. /**
  11750. * Default Inputs manager for the FreeCamera.
  11751. * It groups all the default supported inputs for ease of use.
  11752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11753. */
  11754. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11755. /**
  11756. * @hidden
  11757. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11758. /**
  11759. * Instantiates a new FreeCameraInputsManager.
  11760. * @param camera Defines the camera the inputs belong to
  11761. */
  11762. constructor(camera: FreeCamera);
  11763. /**
  11764. * Add keyboard input support to the input manager.
  11765. * @returns the current input manager
  11766. */
  11767. addKeyboard(): FreeCameraInputsManager;
  11768. /**
  11769. * Add mouse input support to the input manager.
  11770. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11771. * @returns the current input manager
  11772. */
  11773. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11774. /**
  11775. * Removes the mouse input support from the manager
  11776. * @returns the current input manager
  11777. */
  11778. removeMouse(): FreeCameraInputsManager;
  11779. /**
  11780. * Add touch input support to the input manager.
  11781. * @returns the current input manager
  11782. */
  11783. addTouch(): FreeCameraInputsManager;
  11784. /**
  11785. * Remove all attached input methods from a camera
  11786. */
  11787. clear(): void;
  11788. }
  11789. }
  11790. declare module BABYLON {
  11791. /**
  11792. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11793. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11795. */
  11796. export class FreeCamera extends TargetCamera {
  11797. /**
  11798. * Define the collision ellipsoid of the camera.
  11799. * This is helpful to simulate a camera body like the player body around the camera
  11800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11801. */
  11802. ellipsoid: Vector3;
  11803. /**
  11804. * Define an offset for the position of the ellipsoid around the camera.
  11805. * This can be helpful to determine the center of the body near the gravity center of the body
  11806. * instead of its head.
  11807. */
  11808. ellipsoidOffset: Vector3;
  11809. /**
  11810. * Enable or disable collisions of the camera with the rest of the scene objects.
  11811. */
  11812. checkCollisions: boolean;
  11813. /**
  11814. * Enable or disable gravity on the camera.
  11815. */
  11816. applyGravity: boolean;
  11817. /**
  11818. * Define the input manager associated to the camera.
  11819. */
  11820. inputs: FreeCameraInputsManager;
  11821. /**
  11822. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11823. * Higher values reduce sensitivity.
  11824. */
  11825. /**
  11826. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11827. * Higher values reduce sensitivity.
  11828. */
  11829. angularSensibility: number;
  11830. /**
  11831. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11832. */
  11833. keysUp: number[];
  11834. /**
  11835. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11836. */
  11837. keysDown: number[];
  11838. /**
  11839. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11840. */
  11841. keysLeft: number[];
  11842. /**
  11843. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11844. */
  11845. keysRight: number[];
  11846. /**
  11847. * Event raised when the camera collide with a mesh in the scene.
  11848. */
  11849. onCollide: (collidedMesh: AbstractMesh) => void;
  11850. private _collider;
  11851. private _needMoveForGravity;
  11852. private _oldPosition;
  11853. private _diffPosition;
  11854. private _newPosition;
  11855. /** @hidden */ private _localDirection: Vector3;
  11856. /** @hidden */ private _transformedDirection: Vector3;
  11857. /**
  11858. * Instantiates a Free Camera.
  11859. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11860. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11862. * @param name Define the name of the camera in the scene
  11863. * @param position Define the start position of the camera in the scene
  11864. * @param scene Define the scene the camera belongs to
  11865. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11866. */
  11867. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11868. /**
  11869. * Attached controls to the current camera.
  11870. * @param element Defines the element the controls should be listened from
  11871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11872. */
  11873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11874. /**
  11875. * Detach the current controls from the camera.
  11876. * The camera will stop reacting to inputs.
  11877. * @param element Defines the element to stop listening the inputs from
  11878. */
  11879. detachControl(element: HTMLElement): void;
  11880. private _collisionMask;
  11881. /**
  11882. * Define a collision mask to limit the list of object the camera can collide with
  11883. */
  11884. collisionMask: number;
  11885. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11886. private _onCollisionPositionChange;
  11887. /** @hidden */ private _checkInputs(): void;
  11888. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11889. /** @hidden */ private _updatePosition(): void;
  11890. /**
  11891. * Destroy the camera and release the current resources hold by it.
  11892. */
  11893. dispose(): void;
  11894. /**
  11895. * Gets the current object class name.
  11896. * @return the class name
  11897. */
  11898. getClassName(): string;
  11899. }
  11900. }
  11901. declare module BABYLON {
  11902. /**
  11903. * Represents a gamepad control stick position
  11904. */
  11905. export class StickValues {
  11906. /**
  11907. * The x component of the control stick
  11908. */
  11909. x: number;
  11910. /**
  11911. * The y component of the control stick
  11912. */
  11913. y: number;
  11914. /**
  11915. * Initializes the gamepad x and y control stick values
  11916. * @param x The x component of the gamepad control stick value
  11917. * @param y The y component of the gamepad control stick value
  11918. */
  11919. constructor(
  11920. /**
  11921. * The x component of the control stick
  11922. */
  11923. x: number,
  11924. /**
  11925. * The y component of the control stick
  11926. */
  11927. y: number);
  11928. }
  11929. /**
  11930. * An interface which manages callbacks for gamepad button changes
  11931. */
  11932. export interface GamepadButtonChanges {
  11933. /**
  11934. * Called when a gamepad has been changed
  11935. */
  11936. changed: boolean;
  11937. /**
  11938. * Called when a gamepad press event has been triggered
  11939. */
  11940. pressChanged: boolean;
  11941. /**
  11942. * Called when a touch event has been triggered
  11943. */
  11944. touchChanged: boolean;
  11945. /**
  11946. * Called when a value has changed
  11947. */
  11948. valueChanged: boolean;
  11949. }
  11950. /**
  11951. * Represents a gamepad
  11952. */
  11953. export class Gamepad {
  11954. /**
  11955. * The id of the gamepad
  11956. */
  11957. id: string;
  11958. /**
  11959. * The index of the gamepad
  11960. */
  11961. index: number;
  11962. /**
  11963. * The browser gamepad
  11964. */
  11965. browserGamepad: any;
  11966. /**
  11967. * Specifies what type of gamepad this represents
  11968. */
  11969. type: number;
  11970. private _leftStick;
  11971. private _rightStick;
  11972. /** @hidden */ private _isConnected: boolean;
  11973. private _leftStickAxisX;
  11974. private _leftStickAxisY;
  11975. private _rightStickAxisX;
  11976. private _rightStickAxisY;
  11977. /**
  11978. * Triggered when the left control stick has been changed
  11979. */
  11980. private _onleftstickchanged;
  11981. /**
  11982. * Triggered when the right control stick has been changed
  11983. */
  11984. private _onrightstickchanged;
  11985. /**
  11986. * Represents a gamepad controller
  11987. */
  11988. static GAMEPAD: number;
  11989. /**
  11990. * Represents a generic controller
  11991. */
  11992. static GENERIC: number;
  11993. /**
  11994. * Represents an XBox controller
  11995. */
  11996. static XBOX: number;
  11997. /**
  11998. * Represents a pose-enabled controller
  11999. */
  12000. static POSE_ENABLED: number;
  12001. /**
  12002. * Represents an Dual Shock controller
  12003. */
  12004. static DUALSHOCK: number;
  12005. /**
  12006. * Specifies whether the left control stick should be Y-inverted
  12007. */
  12008. protected _invertLeftStickY: boolean;
  12009. /**
  12010. * Specifies if the gamepad has been connected
  12011. */
  12012. readonly isConnected: boolean;
  12013. /**
  12014. * Initializes the gamepad
  12015. * @param id The id of the gamepad
  12016. * @param index The index of the gamepad
  12017. * @param browserGamepad The browser gamepad
  12018. * @param leftStickX The x component of the left joystick
  12019. * @param leftStickY The y component of the left joystick
  12020. * @param rightStickX The x component of the right joystick
  12021. * @param rightStickY The y component of the right joystick
  12022. */
  12023. constructor(
  12024. /**
  12025. * The id of the gamepad
  12026. */
  12027. id: string,
  12028. /**
  12029. * The index of the gamepad
  12030. */
  12031. index: number,
  12032. /**
  12033. * The browser gamepad
  12034. */
  12035. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12036. /**
  12037. * Callback triggered when the left joystick has changed
  12038. * @param callback
  12039. */
  12040. onleftstickchanged(callback: (values: StickValues) => void): void;
  12041. /**
  12042. * Callback triggered when the right joystick has changed
  12043. * @param callback
  12044. */
  12045. onrightstickchanged(callback: (values: StickValues) => void): void;
  12046. /**
  12047. * Gets the left joystick
  12048. */
  12049. /**
  12050. * Sets the left joystick values
  12051. */
  12052. leftStick: StickValues;
  12053. /**
  12054. * Gets the right joystick
  12055. */
  12056. /**
  12057. * Sets the right joystick value
  12058. */
  12059. rightStick: StickValues;
  12060. /**
  12061. * Updates the gamepad joystick positions
  12062. */
  12063. update(): void;
  12064. /**
  12065. * Disposes the gamepad
  12066. */
  12067. dispose(): void;
  12068. }
  12069. /**
  12070. * Represents a generic gamepad
  12071. */
  12072. export class GenericPad extends Gamepad {
  12073. private _buttons;
  12074. private _onbuttondown;
  12075. private _onbuttonup;
  12076. /**
  12077. * Observable triggered when a button has been pressed
  12078. */
  12079. onButtonDownObservable: Observable<number>;
  12080. /**
  12081. * Observable triggered when a button has been released
  12082. */
  12083. onButtonUpObservable: Observable<number>;
  12084. /**
  12085. * Callback triggered when a button has been pressed
  12086. * @param callback Called when a button has been pressed
  12087. */
  12088. onbuttondown(callback: (buttonPressed: number) => void): void;
  12089. /**
  12090. * Callback triggered when a button has been released
  12091. * @param callback Called when a button has been released
  12092. */
  12093. onbuttonup(callback: (buttonReleased: number) => void): void;
  12094. /**
  12095. * Initializes the generic gamepad
  12096. * @param id The id of the generic gamepad
  12097. * @param index The index of the generic gamepad
  12098. * @param browserGamepad The browser gamepad
  12099. */
  12100. constructor(id: string, index: number, browserGamepad: any);
  12101. private _setButtonValue;
  12102. /**
  12103. * Updates the generic gamepad
  12104. */
  12105. update(): void;
  12106. /**
  12107. * Disposes the generic gamepad
  12108. */
  12109. dispose(): void;
  12110. }
  12111. }
  12112. declare module BABYLON {
  12113. interface Engine {
  12114. /**
  12115. * Creates a raw texture
  12116. * @param data defines the data to store in the texture
  12117. * @param width defines the width of the texture
  12118. * @param height defines the height of the texture
  12119. * @param format defines the format of the data
  12120. * @param generateMipMaps defines if the engine should generate the mip levels
  12121. * @param invertY defines if data must be stored with Y axis inverted
  12122. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12123. * @param compression defines the compression used (null by default)
  12124. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12125. * @returns the raw texture inside an InternalTexture
  12126. */
  12127. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12128. /**
  12129. * Update a raw texture
  12130. * @param texture defines the texture to update
  12131. * @param data defines the data to store in the texture
  12132. * @param format defines the format of the data
  12133. * @param invertY defines if data must be stored with Y axis inverted
  12134. */
  12135. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12136. /**
  12137. * Update a raw texture
  12138. * @param texture defines the texture to update
  12139. * @param data defines the data to store in the texture
  12140. * @param format defines the format of the data
  12141. * @param invertY defines if data must be stored with Y axis inverted
  12142. * @param compression defines the compression used (null by default)
  12143. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12144. */
  12145. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12146. /**
  12147. * Creates a new raw cube texture
  12148. * @param data defines the array of data to use to create each face
  12149. * @param size defines the size of the textures
  12150. * @param format defines the format of the data
  12151. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12152. * @param generateMipMaps defines if the engine should generate the mip levels
  12153. * @param invertY defines if data must be stored with Y axis inverted
  12154. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12155. * @param compression defines the compression used (null by default)
  12156. * @returns the cube texture as an InternalTexture
  12157. */
  12158. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12159. /**
  12160. * Update a raw cube texture
  12161. * @param texture defines the texture to udpdate
  12162. * @param data defines the data to store
  12163. * @param format defines the data format
  12164. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12165. * @param invertY defines if data must be stored with Y axis inverted
  12166. */
  12167. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12168. /**
  12169. * Update a raw cube texture
  12170. * @param texture defines the texture to udpdate
  12171. * @param data defines the data to store
  12172. * @param format defines the data format
  12173. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12174. * @param invertY defines if data must be stored with Y axis inverted
  12175. * @param compression defines the compression used (null by default)
  12176. */
  12177. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12178. /**
  12179. * Update a raw cube texture
  12180. * @param texture defines the texture to udpdate
  12181. * @param data defines the data to store
  12182. * @param format defines the data format
  12183. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12184. * @param invertY defines if data must be stored with Y axis inverted
  12185. * @param compression defines the compression used (null by default)
  12186. * @param level defines which level of the texture to update
  12187. */
  12188. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12189. /**
  12190. * Creates a new raw cube texture from a specified url
  12191. * @param url defines the url where the data is located
  12192. * @param scene defines the current scene
  12193. * @param size defines the size of the textures
  12194. * @param format defines the format of the data
  12195. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12196. * @param noMipmap defines if the engine should avoid generating the mip levels
  12197. * @param callback defines a callback used to extract texture data from loaded data
  12198. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12199. * @param onLoad defines a callback called when texture is loaded
  12200. * @param onError defines a callback called if there is an error
  12201. * @returns the cube texture as an InternalTexture
  12202. */
  12203. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12204. /**
  12205. * Creates a new raw cube texture from a specified url
  12206. * @param url defines the url where the data is located
  12207. * @param scene defines the current scene
  12208. * @param size defines the size of the textures
  12209. * @param format defines the format of the data
  12210. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12211. * @param noMipmap defines if the engine should avoid generating the mip levels
  12212. * @param callback defines a callback used to extract texture data from loaded data
  12213. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12214. * @param onLoad defines a callback called when texture is loaded
  12215. * @param onError defines a callback called if there is an error
  12216. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12217. * @param invertY defines if data must be stored with Y axis inverted
  12218. * @returns the cube texture as an InternalTexture
  12219. */
  12220. 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;
  12221. /**
  12222. * Creates a new raw 3D texture
  12223. * @param data defines the data used to create the texture
  12224. * @param width defines the width of the texture
  12225. * @param height defines the height of the texture
  12226. * @param depth defines the depth of the texture
  12227. * @param format defines the format of the texture
  12228. * @param generateMipMaps defines if the engine must generate mip levels
  12229. * @param invertY defines if data must be stored with Y axis inverted
  12230. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12231. * @param compression defines the compressed used (can be null)
  12232. * @param textureType defines the compressed used (can be null)
  12233. * @returns a new raw 3D texture (stored in an InternalTexture)
  12234. */
  12235. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12236. /**
  12237. * Update a raw 3D texture
  12238. * @param texture defines the texture to update
  12239. * @param data defines the data to store
  12240. * @param format defines the data format
  12241. * @param invertY defines if data must be stored with Y axis inverted
  12242. */
  12243. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12244. /**
  12245. * Update a raw 3D texture
  12246. * @param texture defines the texture to update
  12247. * @param data defines the data to store
  12248. * @param format defines the data format
  12249. * @param invertY defines if data must be stored with Y axis inverted
  12250. * @param compression defines the used compression (can be null)
  12251. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12252. */
  12253. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12254. }
  12255. }
  12256. declare module BABYLON {
  12257. /**
  12258. * Raw texture can help creating a texture directly from an array of data.
  12259. * This can be super useful if you either get the data from an uncompressed source or
  12260. * if you wish to create your texture pixel by pixel.
  12261. */
  12262. export class RawTexture extends Texture {
  12263. /**
  12264. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12265. */
  12266. format: number;
  12267. private _engine;
  12268. /**
  12269. * Instantiates a new RawTexture.
  12270. * Raw texture can help creating a texture directly from an array of data.
  12271. * This can be super useful if you either get the data from an uncompressed source or
  12272. * if you wish to create your texture pixel by pixel.
  12273. * @param data define the array of data to use to create the texture
  12274. * @param width define the width of the texture
  12275. * @param height define the height of the texture
  12276. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12277. * @param scene define the scene the texture belongs to
  12278. * @param generateMipMaps define whether mip maps should be generated or not
  12279. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12280. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12281. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12282. */
  12283. constructor(data: ArrayBufferView, width: number, height: number,
  12284. /**
  12285. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12286. */
  12287. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12288. /**
  12289. * Updates the texture underlying data.
  12290. * @param data Define the new data of the texture
  12291. */
  12292. update(data: ArrayBufferView): void;
  12293. /**
  12294. * Creates a luminance texture from some data.
  12295. * @param data Define the texture data
  12296. * @param width Define the width of the texture
  12297. * @param height Define the height of the texture
  12298. * @param scene Define the scene the texture belongs to
  12299. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12302. * @returns the luminance texture
  12303. */
  12304. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12305. /**
  12306. * Creates a luminance alpha texture from some data.
  12307. * @param data Define the texture data
  12308. * @param width Define the width of the texture
  12309. * @param height Define the height of the texture
  12310. * @param scene Define the scene the texture belongs to
  12311. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12312. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12313. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12314. * @returns the luminance alpha texture
  12315. */
  12316. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12317. /**
  12318. * Creates an alpha texture from some data.
  12319. * @param data Define the texture data
  12320. * @param width Define the width of the texture
  12321. * @param height Define the height of the texture
  12322. * @param scene Define the scene the texture belongs to
  12323. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12324. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12325. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12326. * @returns the alpha texture
  12327. */
  12328. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12329. /**
  12330. * Creates a RGB texture from some data.
  12331. * @param data Define the texture data
  12332. * @param width Define the width of the texture
  12333. * @param height Define the height of the texture
  12334. * @param scene Define the scene the texture belongs to
  12335. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12336. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12337. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12338. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12339. * @returns the RGB alpha texture
  12340. */
  12341. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12342. /**
  12343. * Creates a RGBA texture from some data.
  12344. * @param data Define the texture data
  12345. * @param width Define the width of the texture
  12346. * @param height Define the height of the texture
  12347. * @param scene Define the scene the texture belongs to
  12348. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12349. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12350. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12351. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12352. * @returns the RGBA texture
  12353. */
  12354. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12355. /**
  12356. * Creates a R texture from some data.
  12357. * @param data Define the texture data
  12358. * @param width Define the width of the texture
  12359. * @param height Define the height of the texture
  12360. * @param scene Define the scene the texture belongs to
  12361. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12362. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12363. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12364. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12365. * @returns the R texture
  12366. */
  12367. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12368. }
  12369. }
  12370. declare module BABYLON {
  12371. /**
  12372. * Interface for the size containing width and height
  12373. */
  12374. export interface ISize {
  12375. /**
  12376. * Width
  12377. */
  12378. width: number;
  12379. /**
  12380. * Heighht
  12381. */
  12382. height: number;
  12383. }
  12384. /**
  12385. * Size containing widht and height
  12386. */
  12387. export class Size implements ISize {
  12388. /**
  12389. * Width
  12390. */
  12391. width: number;
  12392. /**
  12393. * Height
  12394. */
  12395. height: number;
  12396. /**
  12397. * Creates a Size object from the given width and height (floats).
  12398. * @param width width of the new size
  12399. * @param height height of the new size
  12400. */
  12401. constructor(width: number, height: number);
  12402. /**
  12403. * Returns a string with the Size width and height
  12404. * @returns a string with the Size width and height
  12405. */
  12406. toString(): string;
  12407. /**
  12408. * "Size"
  12409. * @returns the string "Size"
  12410. */
  12411. getClassName(): string;
  12412. /**
  12413. * Returns the Size hash code.
  12414. * @returns a hash code for a unique width and height
  12415. */
  12416. getHashCode(): number;
  12417. /**
  12418. * Updates the current size from the given one.
  12419. * @param src the given size
  12420. */
  12421. copyFrom(src: Size): void;
  12422. /**
  12423. * Updates in place the current Size from the given floats.
  12424. * @param width width of the new size
  12425. * @param height height of the new size
  12426. * @returns the updated Size.
  12427. */
  12428. copyFromFloats(width: number, height: number): Size;
  12429. /**
  12430. * Updates in place the current Size from the given floats.
  12431. * @param width width to set
  12432. * @param height height to set
  12433. * @returns the updated Size.
  12434. */
  12435. set(width: number, height: number): Size;
  12436. /**
  12437. * Multiplies the width and height by numbers
  12438. * @param w factor to multiple the width by
  12439. * @param h factor to multiple the height by
  12440. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12441. */
  12442. multiplyByFloats(w: number, h: number): Size;
  12443. /**
  12444. * Clones the size
  12445. * @returns a new Size copied from the given one.
  12446. */
  12447. clone(): Size;
  12448. /**
  12449. * True if the current Size and the given one width and height are strictly equal.
  12450. * @param other the other size to compare against
  12451. * @returns True if the current Size and the given one width and height are strictly equal.
  12452. */
  12453. equals(other: Size): boolean;
  12454. /**
  12455. * The surface of the Size : width * height (float).
  12456. */
  12457. readonly surface: number;
  12458. /**
  12459. * Create a new size of zero
  12460. * @returns a new Size set to (0.0, 0.0)
  12461. */
  12462. static Zero(): Size;
  12463. /**
  12464. * Sums the width and height of two sizes
  12465. * @param otherSize size to add to this size
  12466. * @returns a new Size set as the addition result of the current Size and the given one.
  12467. */
  12468. add(otherSize: Size): Size;
  12469. /**
  12470. * Subtracts the width and height of two
  12471. * @param otherSize size to subtract to this size
  12472. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12473. */
  12474. subtract(otherSize: Size): Size;
  12475. /**
  12476. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12477. * @param start starting size to lerp between
  12478. * @param end end size to lerp between
  12479. * @param amount amount to lerp between the start and end values
  12480. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12481. */
  12482. static Lerp(start: Size, end: Size, amount: number): Size;
  12483. }
  12484. }
  12485. declare module BABYLON {
  12486. /**
  12487. * Defines a runtime animation
  12488. */
  12489. export class RuntimeAnimation {
  12490. private _events;
  12491. /**
  12492. * The current frame of the runtime animation
  12493. */
  12494. private _currentFrame;
  12495. /**
  12496. * The animation used by the runtime animation
  12497. */
  12498. private _animation;
  12499. /**
  12500. * The target of the runtime animation
  12501. */
  12502. private _target;
  12503. /**
  12504. * The initiating animatable
  12505. */
  12506. private _host;
  12507. /**
  12508. * The original value of the runtime animation
  12509. */
  12510. private _originalValue;
  12511. /**
  12512. * The original blend value of the runtime animation
  12513. */
  12514. private _originalBlendValue;
  12515. /**
  12516. * The offsets cache of the runtime animation
  12517. */
  12518. private _offsetsCache;
  12519. /**
  12520. * The high limits cache of the runtime animation
  12521. */
  12522. private _highLimitsCache;
  12523. /**
  12524. * Specifies if the runtime animation has been stopped
  12525. */
  12526. private _stopped;
  12527. /**
  12528. * The blending factor of the runtime animation
  12529. */
  12530. private _blendingFactor;
  12531. /**
  12532. * The BabylonJS scene
  12533. */
  12534. private _scene;
  12535. /**
  12536. * The current value of the runtime animation
  12537. */
  12538. private _currentValue;
  12539. /** @hidden */ private _animationState: _IAnimationState;
  12540. /**
  12541. * The active target of the runtime animation
  12542. */
  12543. private _activeTargets;
  12544. private _currentActiveTarget;
  12545. private _directTarget;
  12546. /**
  12547. * The target path of the runtime animation
  12548. */
  12549. private _targetPath;
  12550. /**
  12551. * The weight of the runtime animation
  12552. */
  12553. private _weight;
  12554. /**
  12555. * The ratio offset of the runtime animation
  12556. */
  12557. private _ratioOffset;
  12558. /**
  12559. * The previous delay of the runtime animation
  12560. */
  12561. private _previousDelay;
  12562. /**
  12563. * The previous ratio of the runtime animation
  12564. */
  12565. private _previousRatio;
  12566. private _enableBlending;
  12567. private _keys;
  12568. private _minFrame;
  12569. private _maxFrame;
  12570. private _minValue;
  12571. private _maxValue;
  12572. private _targetIsArray;
  12573. /**
  12574. * Gets the current frame of the runtime animation
  12575. */
  12576. readonly currentFrame: number;
  12577. /**
  12578. * Gets the weight of the runtime animation
  12579. */
  12580. readonly weight: number;
  12581. /**
  12582. * Gets the current value of the runtime animation
  12583. */
  12584. readonly currentValue: any;
  12585. /**
  12586. * Gets the target path of the runtime animation
  12587. */
  12588. readonly targetPath: string;
  12589. /**
  12590. * Gets the actual target of the runtime animation
  12591. */
  12592. readonly target: any;
  12593. /** @hidden */ private _onLoop: () => void;
  12594. /**
  12595. * Create a new RuntimeAnimation object
  12596. * @param target defines the target of the animation
  12597. * @param animation defines the source animation object
  12598. * @param scene defines the hosting scene
  12599. * @param host defines the initiating Animatable
  12600. */
  12601. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12602. private _preparePath;
  12603. /**
  12604. * Gets the animation from the runtime animation
  12605. */
  12606. readonly animation: Animation;
  12607. /**
  12608. * Resets the runtime animation to the beginning
  12609. * @param restoreOriginal defines whether to restore the target property to the original value
  12610. */
  12611. reset(restoreOriginal?: boolean): void;
  12612. /**
  12613. * Specifies if the runtime animation is stopped
  12614. * @returns Boolean specifying if the runtime animation is stopped
  12615. */
  12616. isStopped(): boolean;
  12617. /**
  12618. * Disposes of the runtime animation
  12619. */
  12620. dispose(): void;
  12621. /**
  12622. * Apply the interpolated value to the target
  12623. * @param currentValue defines the value computed by the animation
  12624. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12625. */
  12626. setValue(currentValue: any, weight: number): void;
  12627. private _getOriginalValues;
  12628. private _setValue;
  12629. /**
  12630. * Gets the loop pmode of the runtime animation
  12631. * @returns Loop Mode
  12632. */
  12633. private _getCorrectLoopMode;
  12634. /**
  12635. * Move the current animation to a given frame
  12636. * @param frame defines the frame to move to
  12637. */
  12638. goToFrame(frame: number): void;
  12639. /**
  12640. * @hidden Internal use only
  12641. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12642. /**
  12643. * Execute the current animation
  12644. * @param delay defines the delay to add to the current frame
  12645. * @param from defines the lower bound of the animation range
  12646. * @param to defines the upper bound of the animation range
  12647. * @param loop defines if the current animation must loop
  12648. * @param speedRatio defines the current speed ratio
  12649. * @param weight defines the weight of the animation (default is -1 so no weight)
  12650. * @param onLoop optional callback called when animation loops
  12651. * @returns a boolean indicating if the animation is running
  12652. */
  12653. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12654. }
  12655. }
  12656. declare module BABYLON {
  12657. /**
  12658. * Class used to store an actual running animation
  12659. */
  12660. export class Animatable {
  12661. /** defines the target object */
  12662. target: any;
  12663. /** defines the starting frame number (default is 0) */
  12664. fromFrame: number;
  12665. /** defines the ending frame number (default is 100) */
  12666. toFrame: number;
  12667. /** defines if the animation must loop (default is false) */
  12668. loopAnimation: boolean;
  12669. /** defines a callback to call when animation ends if it is not looping */
  12670. onAnimationEnd?: (() => void) | null | undefined;
  12671. /** defines a callback to call when animation loops */
  12672. onAnimationLoop?: (() => void) | null | undefined;
  12673. private _localDelayOffset;
  12674. private _pausedDelay;
  12675. private _runtimeAnimations;
  12676. private _paused;
  12677. private _scene;
  12678. private _speedRatio;
  12679. private _weight;
  12680. private _syncRoot;
  12681. /**
  12682. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12683. * This will only apply for non looping animation (default is true)
  12684. */
  12685. disposeOnEnd: boolean;
  12686. /**
  12687. * Gets a boolean indicating if the animation has started
  12688. */
  12689. animationStarted: boolean;
  12690. /**
  12691. * Observer raised when the animation ends
  12692. */
  12693. onAnimationEndObservable: Observable<Animatable>;
  12694. /**
  12695. * Observer raised when the animation loops
  12696. */
  12697. onAnimationLoopObservable: Observable<Animatable>;
  12698. /**
  12699. * Gets the root Animatable used to synchronize and normalize animations
  12700. */
  12701. readonly syncRoot: Nullable<Animatable>;
  12702. /**
  12703. * Gets the current frame of the first RuntimeAnimation
  12704. * Used to synchronize Animatables
  12705. */
  12706. readonly masterFrame: number;
  12707. /**
  12708. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12709. */
  12710. weight: number;
  12711. /**
  12712. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12713. */
  12714. speedRatio: number;
  12715. /**
  12716. * Creates a new Animatable
  12717. * @param scene defines the hosting scene
  12718. * @param target defines the target object
  12719. * @param fromFrame defines the starting frame number (default is 0)
  12720. * @param toFrame defines the ending frame number (default is 100)
  12721. * @param loopAnimation defines if the animation must loop (default is false)
  12722. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12723. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12724. * @param animations defines a group of animation to add to the new Animatable
  12725. * @param onAnimationLoop defines a callback to call when animation loops
  12726. */
  12727. constructor(scene: Scene,
  12728. /** defines the target object */
  12729. target: any,
  12730. /** defines the starting frame number (default is 0) */
  12731. fromFrame?: number,
  12732. /** defines the ending frame number (default is 100) */
  12733. toFrame?: number,
  12734. /** defines if the animation must loop (default is false) */
  12735. loopAnimation?: boolean, speedRatio?: number,
  12736. /** defines a callback to call when animation ends if it is not looping */
  12737. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12738. /** defines a callback to call when animation loops */
  12739. onAnimationLoop?: (() => void) | null | undefined);
  12740. /**
  12741. * Synchronize and normalize current Animatable with a source Animatable
  12742. * This is useful when using animation weights and when animations are not of the same length
  12743. * @param root defines the root Animatable to synchronize with
  12744. * @returns the current Animatable
  12745. */
  12746. syncWith(root: Animatable): Animatable;
  12747. /**
  12748. * Gets the list of runtime animations
  12749. * @returns an array of RuntimeAnimation
  12750. */
  12751. getAnimations(): RuntimeAnimation[];
  12752. /**
  12753. * Adds more animations to the current animatable
  12754. * @param target defines the target of the animations
  12755. * @param animations defines the new animations to add
  12756. */
  12757. appendAnimations(target: any, animations: Animation[]): void;
  12758. /**
  12759. * Gets the source animation for a specific property
  12760. * @param property defines the propertyu to look for
  12761. * @returns null or the source animation for the given property
  12762. */
  12763. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12764. /**
  12765. * Gets the runtime animation for a specific property
  12766. * @param property defines the propertyu to look for
  12767. * @returns null or the runtime animation for the given property
  12768. */
  12769. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12770. /**
  12771. * Resets the animatable to its original state
  12772. */
  12773. reset(): void;
  12774. /**
  12775. * Allows the animatable to blend with current running animations
  12776. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12777. * @param blendingSpeed defines the blending speed to use
  12778. */
  12779. enableBlending(blendingSpeed: number): void;
  12780. /**
  12781. * Disable animation blending
  12782. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12783. */
  12784. disableBlending(): void;
  12785. /**
  12786. * Jump directly to a given frame
  12787. * @param frame defines the frame to jump to
  12788. */
  12789. goToFrame(frame: number): void;
  12790. /**
  12791. * Pause the animation
  12792. */
  12793. pause(): void;
  12794. /**
  12795. * Restart the animation
  12796. */
  12797. restart(): void;
  12798. private _raiseOnAnimationEnd;
  12799. /**
  12800. * Stop and delete the current animation
  12801. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12802. * @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)
  12803. */
  12804. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12805. /**
  12806. * Wait asynchronously for the animation to end
  12807. * @returns a promise which will be fullfilled when the animation ends
  12808. */
  12809. waitAsync(): Promise<Animatable>;
  12810. /** @hidden */ private _animate(delay: number): boolean;
  12811. }
  12812. interface Scene {
  12813. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12814. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12815. totalWeight: number;
  12816. animations: RuntimeAnimation[];
  12817. originalValue: Matrix;
  12818. }): any;
  12819. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12820. totalWeight: number;
  12821. animations: RuntimeAnimation[];
  12822. originalValue: Quaternion;
  12823. }, refQuaternion: Quaternion): Quaternion;
  12824. /** @hidden */ private _processLateAnimationBindings(): void;
  12825. /**
  12826. * Will start the animation sequence of a given target
  12827. * @param target defines the target
  12828. * @param from defines from which frame should animation start
  12829. * @param to defines until which frame should animation run.
  12830. * @param weight defines the weight to apply to the animation (1.0 by default)
  12831. * @param loop defines if the animation loops
  12832. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12833. * @param onAnimationEnd defines the function to be executed when the animation ends
  12834. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12835. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12836. * @param onAnimationLoop defines the callback to call when an animation loops
  12837. * @returns the animatable object created for this animation
  12838. */
  12839. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12840. /**
  12841. * Will start the animation sequence of a given target
  12842. * @param target defines the target
  12843. * @param from defines from which frame should animation start
  12844. * @param to defines until which frame should animation run.
  12845. * @param loop defines if the animation loops
  12846. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12847. * @param onAnimationEnd defines the function to be executed when the animation ends
  12848. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12849. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12850. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12851. * @param onAnimationLoop defines the callback to call when an animation loops
  12852. * @returns the animatable object created for this animation
  12853. */
  12854. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12855. /**
  12856. * Will start the animation sequence of a given target and its hierarchy
  12857. * @param target defines the target
  12858. * @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.
  12859. * @param from defines from which frame should animation start
  12860. * @param to defines until which frame should animation run.
  12861. * @param loop defines if the animation loops
  12862. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12863. * @param onAnimationEnd defines the function to be executed when the animation ends
  12864. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12865. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12866. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12867. * @param onAnimationLoop defines the callback to call when an animation loops
  12868. * @returns the list of created animatables
  12869. */
  12870. 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[];
  12871. /**
  12872. * Begin a new animation on a given node
  12873. * @param target defines the target where the animation will take place
  12874. * @param animations defines the list of animations to start
  12875. * @param from defines the initial value
  12876. * @param to defines the final value
  12877. * @param loop defines if you want animation to loop (off by default)
  12878. * @param speedRatio defines the speed ratio to apply to all animations
  12879. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12880. * @param onAnimationLoop defines the callback to call when an animation loops
  12881. * @returns the list of created animatables
  12882. */
  12883. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12884. /**
  12885. * Begin a new animation on a given node and its hierarchy
  12886. * @param target defines the root node where the animation will take place
  12887. * @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.
  12888. * @param animations defines the list of animations to start
  12889. * @param from defines the initial value
  12890. * @param to defines the final value
  12891. * @param loop defines if you want animation to loop (off by default)
  12892. * @param speedRatio defines the speed ratio to apply to all animations
  12893. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12894. * @param onAnimationLoop defines the callback to call when an animation loops
  12895. * @returns the list of animatables created for all nodes
  12896. */
  12897. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12898. /**
  12899. * Gets the animatable associated with a specific target
  12900. * @param target defines the target of the animatable
  12901. * @returns the required animatable if found
  12902. */
  12903. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12904. /**
  12905. * Gets all animatables associated with a given target
  12906. * @param target defines the target to look animatables for
  12907. * @returns an array of Animatables
  12908. */
  12909. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12910. /**
  12911. * Stops and removes all animations that have been applied to the scene
  12912. */
  12913. stopAllAnimations(): void;
  12914. }
  12915. interface Bone {
  12916. /**
  12917. * Copy an animation range from another bone
  12918. * @param source defines the source bone
  12919. * @param rangeName defines the range name to copy
  12920. * @param frameOffset defines the frame offset
  12921. * @param rescaleAsRequired defines if rescaling must be applied if required
  12922. * @param skelDimensionsRatio defines the scaling ratio
  12923. * @returns true if operation was successful
  12924. */
  12925. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12926. }
  12927. }
  12928. declare module BABYLON {
  12929. /**
  12930. * Class used to override all child animations of a given target
  12931. */
  12932. export class AnimationPropertiesOverride {
  12933. /**
  12934. * Gets or sets a value indicating if animation blending must be used
  12935. */
  12936. enableBlending: boolean;
  12937. /**
  12938. * Gets or sets the blending speed to use when enableBlending is true
  12939. */
  12940. blendingSpeed: number;
  12941. /**
  12942. * Gets or sets the default loop mode to use
  12943. */
  12944. loopMode: number;
  12945. }
  12946. }
  12947. declare module BABYLON {
  12948. /**
  12949. * Class used to handle skinning animations
  12950. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12951. */
  12952. export class Skeleton implements IAnimatable {
  12953. /** defines the skeleton name */
  12954. name: string;
  12955. /** defines the skeleton Id */
  12956. id: string;
  12957. /**
  12958. * Defines the list of child bones
  12959. */
  12960. bones: Bone[];
  12961. /**
  12962. * Defines an estimate of the dimension of the skeleton at rest
  12963. */
  12964. dimensionsAtRest: Vector3;
  12965. /**
  12966. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12967. */
  12968. needInitialSkinMatrix: boolean;
  12969. /**
  12970. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12971. */
  12972. overrideMesh: Nullable<AbstractMesh>;
  12973. /**
  12974. * Gets the list of animations attached to this skeleton
  12975. */
  12976. animations: Array<Animation>;
  12977. private _scene;
  12978. private _isDirty;
  12979. private _transformMatrices;
  12980. private _transformMatrixTexture;
  12981. private _meshesWithPoseMatrix;
  12982. private _animatables;
  12983. private _identity;
  12984. private _synchronizedWithMesh;
  12985. private _ranges;
  12986. private _lastAbsoluteTransformsUpdateId;
  12987. private _canUseTextureForBones;
  12988. private _uniqueId;
  12989. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  12990. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  12991. /**
  12992. * Specifies if the skeleton should be serialized
  12993. */
  12994. doNotSerialize: boolean;
  12995. private _useTextureToStoreBoneMatrices;
  12996. /**
  12997. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  12998. * Please note that this option is not available if the hardware does not support it
  12999. */
  13000. useTextureToStoreBoneMatrices: boolean;
  13001. private _animationPropertiesOverride;
  13002. /**
  13003. * Gets or sets the animation properties override
  13004. */
  13005. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13006. /**
  13007. * List of inspectable custom properties (used by the Inspector)
  13008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13009. */
  13010. inspectableCustomProperties: IInspectable[];
  13011. /**
  13012. * An observable triggered before computing the skeleton's matrices
  13013. */
  13014. onBeforeComputeObservable: Observable<Skeleton>;
  13015. /**
  13016. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13017. */
  13018. readonly isUsingTextureForMatrices: boolean;
  13019. /**
  13020. * Gets the unique ID of this skeleton
  13021. */
  13022. readonly uniqueId: number;
  13023. /**
  13024. * Creates a new skeleton
  13025. * @param name defines the skeleton name
  13026. * @param id defines the skeleton Id
  13027. * @param scene defines the hosting scene
  13028. */
  13029. constructor(
  13030. /** defines the skeleton name */
  13031. name: string,
  13032. /** defines the skeleton Id */
  13033. id: string, scene: Scene);
  13034. /**
  13035. * Gets the current object class name.
  13036. * @return the class name
  13037. */
  13038. getClassName(): string;
  13039. /**
  13040. * Returns an array containing the root bones
  13041. * @returns an array containing the root bones
  13042. */
  13043. getChildren(): Array<Bone>;
  13044. /**
  13045. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13046. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13047. * @returns a Float32Array containing matrices data
  13048. */
  13049. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13050. /**
  13051. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13052. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13053. * @returns a raw texture containing the data
  13054. */
  13055. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13056. /**
  13057. * Gets the current hosting scene
  13058. * @returns a scene object
  13059. */
  13060. getScene(): Scene;
  13061. /**
  13062. * Gets a string representing the current skeleton data
  13063. * @param fullDetails defines a boolean indicating if we want a verbose version
  13064. * @returns a string representing the current skeleton data
  13065. */
  13066. toString(fullDetails?: boolean): string;
  13067. /**
  13068. * Get bone's index searching by name
  13069. * @param name defines bone's name to search for
  13070. * @return the indice of the bone. Returns -1 if not found
  13071. */
  13072. getBoneIndexByName(name: string): number;
  13073. /**
  13074. * Creater a new animation range
  13075. * @param name defines the name of the range
  13076. * @param from defines the start key
  13077. * @param to defines the end key
  13078. */
  13079. createAnimationRange(name: string, from: number, to: number): void;
  13080. /**
  13081. * Delete a specific animation range
  13082. * @param name defines the name of the range
  13083. * @param deleteFrames defines if frames must be removed as well
  13084. */
  13085. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13086. /**
  13087. * Gets a specific animation range
  13088. * @param name defines the name of the range to look for
  13089. * @returns the requested animation range or null if not found
  13090. */
  13091. getAnimationRange(name: string): Nullable<AnimationRange>;
  13092. /**
  13093. * Gets the list of all animation ranges defined on this skeleton
  13094. * @returns an array
  13095. */
  13096. getAnimationRanges(): Nullable<AnimationRange>[];
  13097. /**
  13098. * Copy animation range from a source skeleton.
  13099. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13100. * @param source defines the source skeleton
  13101. * @param name defines the name of the range to copy
  13102. * @param rescaleAsRequired defines if rescaling must be applied if required
  13103. * @returns true if operation was successful
  13104. */
  13105. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13106. /**
  13107. * Forces the skeleton to go to rest pose
  13108. */
  13109. returnToRest(): void;
  13110. private _getHighestAnimationFrame;
  13111. /**
  13112. * Begin a specific animation range
  13113. * @param name defines the name of the range to start
  13114. * @param loop defines if looping must be turned on (false by default)
  13115. * @param speedRatio defines the speed ratio to apply (1 by default)
  13116. * @param onAnimationEnd defines a callback which will be called when animation will end
  13117. * @returns a new animatable
  13118. */
  13119. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13120. /** @hidden */ private _markAsDirty(): void;
  13121. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13122. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13123. private _computeTransformMatrices;
  13124. /**
  13125. * Build all resources required to render a skeleton
  13126. */
  13127. prepare(): void;
  13128. /**
  13129. * Gets the list of animatables currently running for this skeleton
  13130. * @returns an array of animatables
  13131. */
  13132. getAnimatables(): IAnimatable[];
  13133. /**
  13134. * Clone the current skeleton
  13135. * @param name defines the name of the new skeleton
  13136. * @param id defines the id of the new skeleton
  13137. * @returns the new skeleton
  13138. */
  13139. clone(name: string, id: string): Skeleton;
  13140. /**
  13141. * Enable animation blending for this skeleton
  13142. * @param blendingSpeed defines the blending speed to apply
  13143. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13144. */
  13145. enableBlending(blendingSpeed?: number): void;
  13146. /**
  13147. * Releases all resources associated with the current skeleton
  13148. */
  13149. dispose(): void;
  13150. /**
  13151. * Serialize the skeleton in a JSON object
  13152. * @returns a JSON object
  13153. */
  13154. serialize(): any;
  13155. /**
  13156. * Creates a new skeleton from serialized data
  13157. * @param parsedSkeleton defines the serialized data
  13158. * @param scene defines the hosting scene
  13159. * @returns a new skeleton
  13160. */
  13161. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13162. /**
  13163. * Compute all node absolute transforms
  13164. * @param forceUpdate defines if computation must be done even if cache is up to date
  13165. */
  13166. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13167. /**
  13168. * Gets the root pose matrix
  13169. * @returns a matrix
  13170. */
  13171. getPoseMatrix(): Nullable<Matrix>;
  13172. /**
  13173. * Sorts bones per internal index
  13174. */
  13175. sortBones(): void;
  13176. private _sortBones;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * Class used to store bone information
  13182. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13183. */
  13184. export class Bone extends Node {
  13185. /**
  13186. * defines the bone name
  13187. */
  13188. name: string;
  13189. private static _tmpVecs;
  13190. private static _tmpQuat;
  13191. private static _tmpMats;
  13192. /**
  13193. * Gets the list of child bones
  13194. */
  13195. children: Bone[];
  13196. /** Gets the animations associated with this bone */
  13197. animations: Animation[];
  13198. /**
  13199. * Gets or sets bone length
  13200. */
  13201. length: number;
  13202. /**
  13203. * @hidden Internal only
  13204. * Set this value to map this bone to a different index in the transform matrices
  13205. * Set this value to -1 to exclude the bone from the transform matrices
  13206. */ private _index: Nullable<number>;
  13207. private _skeleton;
  13208. private _localMatrix;
  13209. private _restPose;
  13210. private _baseMatrix;
  13211. private _absoluteTransform;
  13212. private _invertedAbsoluteTransform;
  13213. private _parent;
  13214. private _scalingDeterminant;
  13215. private _worldTransform;
  13216. private _localScaling;
  13217. private _localRotation;
  13218. private _localPosition;
  13219. private _needToDecompose;
  13220. private _needToCompose;
  13221. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13222. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13223. /** @hidden */
  13224. /** @hidden */ private _matrix: Matrix;
  13225. /**
  13226. * Create a new bone
  13227. * @param name defines the bone name
  13228. * @param skeleton defines the parent skeleton
  13229. * @param parentBone defines the parent (can be null if the bone is the root)
  13230. * @param localMatrix defines the local matrix
  13231. * @param restPose defines the rest pose matrix
  13232. * @param baseMatrix defines the base matrix
  13233. * @param index defines index of the bone in the hiearchy
  13234. */
  13235. constructor(
  13236. /**
  13237. * defines the bone name
  13238. */
  13239. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13240. /**
  13241. * Gets the current object class name.
  13242. * @return the class name
  13243. */
  13244. getClassName(): string;
  13245. /**
  13246. * Gets the parent skeleton
  13247. * @returns a skeleton
  13248. */
  13249. getSkeleton(): Skeleton;
  13250. /**
  13251. * Gets parent bone
  13252. * @returns a bone or null if the bone is the root of the bone hierarchy
  13253. */
  13254. getParent(): Nullable<Bone>;
  13255. /**
  13256. * Returns an array containing the root bones
  13257. * @returns an array containing the root bones
  13258. */
  13259. getChildren(): Array<Bone>;
  13260. /**
  13261. * Sets the parent bone
  13262. * @param parent defines the parent (can be null if the bone is the root)
  13263. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13264. */
  13265. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13266. /**
  13267. * Gets the local matrix
  13268. * @returns a matrix
  13269. */
  13270. getLocalMatrix(): Matrix;
  13271. /**
  13272. * Gets the base matrix (initial matrix which remains unchanged)
  13273. * @returns a matrix
  13274. */
  13275. getBaseMatrix(): Matrix;
  13276. /**
  13277. * Gets the rest pose matrix
  13278. * @returns a matrix
  13279. */
  13280. getRestPose(): Matrix;
  13281. /**
  13282. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13283. */
  13284. getWorldMatrix(): Matrix;
  13285. /**
  13286. * Sets the local matrix to rest pose matrix
  13287. */
  13288. returnToRest(): void;
  13289. /**
  13290. * Gets the inverse of the absolute transform matrix.
  13291. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13292. * @returns a matrix
  13293. */
  13294. getInvertedAbsoluteTransform(): Matrix;
  13295. /**
  13296. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13297. * @returns a matrix
  13298. */
  13299. getAbsoluteTransform(): Matrix;
  13300. /**
  13301. * Links with the given transform node.
  13302. * The local matrix of this bone is copied from the transform node every frame.
  13303. * @param transformNode defines the transform node to link to
  13304. */
  13305. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13306. /**
  13307. * Gets the node used to drive the bone's transformation
  13308. * @returns a transform node or null
  13309. */
  13310. getTransformNode(): Nullable<TransformNode>;
  13311. /** Gets or sets current position (in local space) */
  13312. position: Vector3;
  13313. /** Gets or sets current rotation (in local space) */
  13314. rotation: Vector3;
  13315. /** Gets or sets current rotation quaternion (in local space) */
  13316. rotationQuaternion: Quaternion;
  13317. /** Gets or sets current scaling (in local space) */
  13318. scaling: Vector3;
  13319. /**
  13320. * Gets the animation properties override
  13321. */
  13322. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13323. private _decompose;
  13324. private _compose;
  13325. /**
  13326. * Update the base and local matrices
  13327. * @param matrix defines the new base or local matrix
  13328. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13329. * @param updateLocalMatrix defines if the local matrix should be updated
  13330. */
  13331. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13332. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13333. /**
  13334. * Flag the bone as dirty (Forcing it to update everything)
  13335. */
  13336. markAsDirty(): void;
  13337. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13338. private _markAsDirtyAndDecompose;
  13339. /**
  13340. * Translate the bone in local or world space
  13341. * @param vec The amount to translate the bone
  13342. * @param space The space that the translation is in
  13343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13344. */
  13345. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13346. /**
  13347. * Set the postion of the bone in local or world space
  13348. * @param position The position to set the bone
  13349. * @param space The space that the position is in
  13350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13351. */
  13352. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13353. /**
  13354. * Set the absolute position of the bone (world space)
  13355. * @param position The position to set the bone
  13356. * @param mesh The mesh that this bone is attached to
  13357. */
  13358. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13359. /**
  13360. * Scale the bone on the x, y and z axes (in local space)
  13361. * @param x The amount to scale the bone on the x axis
  13362. * @param y The amount to scale the bone on the y axis
  13363. * @param z The amount to scale the bone on the z axis
  13364. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13365. */
  13366. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13367. /**
  13368. * Set the bone scaling in local space
  13369. * @param scale defines the scaling vector
  13370. */
  13371. setScale(scale: Vector3): void;
  13372. /**
  13373. * Gets the current scaling in local space
  13374. * @returns the current scaling vector
  13375. */
  13376. getScale(): Vector3;
  13377. /**
  13378. * Gets the current scaling in local space and stores it in a target vector
  13379. * @param result defines the target vector
  13380. */
  13381. getScaleToRef(result: Vector3): void;
  13382. /**
  13383. * Set the yaw, pitch, and roll of the bone in local or world space
  13384. * @param yaw The rotation of the bone on the y axis
  13385. * @param pitch The rotation of the bone on the x axis
  13386. * @param roll The rotation of the bone on the z axis
  13387. * @param space The space that the axes of rotation are in
  13388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13389. */
  13390. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13391. /**
  13392. * Add a rotation to the bone on an axis in local or world space
  13393. * @param axis The axis to rotate the bone on
  13394. * @param amount The amount to rotate the bone
  13395. * @param space The space that the axis is in
  13396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13397. */
  13398. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13399. /**
  13400. * Set the rotation of the bone to a particular axis angle in local or world space
  13401. * @param axis The axis to rotate the bone on
  13402. * @param angle The angle that the bone should be rotated to
  13403. * @param space The space that the axis is in
  13404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13405. */
  13406. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13407. /**
  13408. * Set the euler rotation of the bone in local of world space
  13409. * @param rotation The euler rotation that the bone should be set to
  13410. * @param space The space that the rotation is in
  13411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13412. */
  13413. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13414. /**
  13415. * Set the quaternion rotation of the bone in local of world space
  13416. * @param quat The quaternion rotation that the bone should be set to
  13417. * @param space The space that the rotation is in
  13418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13419. */
  13420. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13421. /**
  13422. * Set the rotation matrix of the bone in local of world space
  13423. * @param rotMat The rotation matrix that the bone should be set to
  13424. * @param space The space that the rotation is in
  13425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13426. */
  13427. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13428. private _rotateWithMatrix;
  13429. private _getNegativeRotationToRef;
  13430. /**
  13431. * Get the position of the bone in local or world space
  13432. * @param space The space that the returned position is in
  13433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13434. * @returns The position of the bone
  13435. */
  13436. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13437. /**
  13438. * Copy the position of the bone to a vector3 in local or world space
  13439. * @param space The space that the returned position is in
  13440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13441. * @param result The vector3 to copy the position to
  13442. */
  13443. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13444. /**
  13445. * Get the absolute position of the bone (world space)
  13446. * @param mesh The mesh that this bone is attached to
  13447. * @returns The absolute position of the bone
  13448. */
  13449. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13450. /**
  13451. * Copy the absolute position of the bone (world space) to the result param
  13452. * @param mesh The mesh that this bone is attached to
  13453. * @param result The vector3 to copy the absolute position to
  13454. */
  13455. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13456. /**
  13457. * Compute the absolute transforms of this bone and its children
  13458. */
  13459. computeAbsoluteTransforms(): void;
  13460. /**
  13461. * Get the world direction from an axis that is in the local space of the bone
  13462. * @param localAxis The local direction that is used to compute the world direction
  13463. * @param mesh The mesh that this bone is attached to
  13464. * @returns The world direction
  13465. */
  13466. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13467. /**
  13468. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13469. * @param localAxis The local direction that is used to compute the world direction
  13470. * @param mesh The mesh that this bone is attached to
  13471. * @param result The vector3 that the world direction will be copied to
  13472. */
  13473. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13474. /**
  13475. * Get the euler rotation of the bone in local or world space
  13476. * @param space The space that the rotation should be in
  13477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13478. * @returns The euler rotation
  13479. */
  13480. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13481. /**
  13482. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13483. * @param space The space that the rotation should be in
  13484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13485. * @param result The vector3 that the rotation should be copied to
  13486. */
  13487. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13488. /**
  13489. * Get the quaternion rotation of the bone in either local or world space
  13490. * @param space The space that the rotation should be in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. * @returns The quaternion rotation
  13493. */
  13494. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13495. /**
  13496. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13497. * @param space The space that the rotation should be in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. * @param result The quaternion that the rotation should be copied to
  13500. */
  13501. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13502. /**
  13503. * Get the rotation matrix of the bone in local or world space
  13504. * @param space The space that the rotation should be in
  13505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13506. * @returns The rotation matrix
  13507. */
  13508. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13509. /**
  13510. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13511. * @param space The space that the rotation should be in
  13512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13513. * @param result The quaternion that the rotation should be copied to
  13514. */
  13515. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13516. /**
  13517. * Get the world position of a point that is in the local space of the bone
  13518. * @param position The local position
  13519. * @param mesh The mesh that this bone is attached to
  13520. * @returns The world position
  13521. */
  13522. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13523. /**
  13524. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13525. * @param position The local position
  13526. * @param mesh The mesh that this bone is attached to
  13527. * @param result The vector3 that the world position should be copied to
  13528. */
  13529. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13530. /**
  13531. * Get the local position of a point that is in world space
  13532. * @param position The world position
  13533. * @param mesh The mesh that this bone is attached to
  13534. * @returns The local position
  13535. */
  13536. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13537. /**
  13538. * Get the local position of a point that is in world space and copy it to the result param
  13539. * @param position The world position
  13540. * @param mesh The mesh that this bone is attached to
  13541. * @param result The vector3 that the local position should be copied to
  13542. */
  13543. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13544. }
  13545. }
  13546. declare module BABYLON {
  13547. /**
  13548. * 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.
  13549. * @see https://doc.babylonjs.com/how_to/transformnode
  13550. */
  13551. export class TransformNode extends Node {
  13552. /**
  13553. * Object will not rotate to face the camera
  13554. */
  13555. static BILLBOARDMODE_NONE: number;
  13556. /**
  13557. * Object will rotate to face the camera but only on the x axis
  13558. */
  13559. static BILLBOARDMODE_X: number;
  13560. /**
  13561. * Object will rotate to face the camera but only on the y axis
  13562. */
  13563. static BILLBOARDMODE_Y: number;
  13564. /**
  13565. * Object will rotate to face the camera but only on the z axis
  13566. */
  13567. static BILLBOARDMODE_Z: number;
  13568. /**
  13569. * Object will rotate to face the camera
  13570. */
  13571. static BILLBOARDMODE_ALL: number;
  13572. /**
  13573. * Object will rotate to face the camera's position instead of orientation
  13574. */
  13575. static BILLBOARDMODE_USE_POSITION: number;
  13576. private _forward;
  13577. private _forwardInverted;
  13578. private _up;
  13579. private _right;
  13580. private _rightInverted;
  13581. private _position;
  13582. private _rotation;
  13583. private _rotationQuaternion;
  13584. protected _scaling: Vector3;
  13585. protected _isDirty: boolean;
  13586. private _transformToBoneReferal;
  13587. private _isAbsoluteSynced;
  13588. private _billboardMode;
  13589. /**
  13590. * Gets or sets the billboard mode. Default is 0.
  13591. *
  13592. * | Value | Type | Description |
  13593. * | --- | --- | --- |
  13594. * | 0 | BILLBOARDMODE_NONE | |
  13595. * | 1 | BILLBOARDMODE_X | |
  13596. * | 2 | BILLBOARDMODE_Y | |
  13597. * | 4 | BILLBOARDMODE_Z | |
  13598. * | 7 | BILLBOARDMODE_ALL | |
  13599. *
  13600. */
  13601. billboardMode: number;
  13602. private _preserveParentRotationForBillboard;
  13603. /**
  13604. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13605. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13606. */
  13607. preserveParentRotationForBillboard: boolean;
  13608. /**
  13609. * 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
  13610. */
  13611. scalingDeterminant: number;
  13612. private _infiniteDistance;
  13613. /**
  13614. * Gets or sets the distance of the object to max, often used by skybox
  13615. */
  13616. infiniteDistance: boolean;
  13617. /**
  13618. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13619. * By default the system will update normals to compensate
  13620. */
  13621. ignoreNonUniformScaling: boolean;
  13622. /**
  13623. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13624. */
  13625. reIntegrateRotationIntoRotationQuaternion: boolean;
  13626. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13627. /** @hidden */ private _localMatrix: Matrix;
  13628. private _usePivotMatrix;
  13629. private _absolutePosition;
  13630. private _absoluteScaling;
  13631. private _absoluteRotationQuaternion;
  13632. private _pivotMatrix;
  13633. private _pivotMatrixInverse;
  13634. protected _postMultiplyPivotMatrix: boolean;
  13635. protected _isWorldMatrixFrozen: boolean;
  13636. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13637. /**
  13638. * An event triggered after the world matrix is updated
  13639. */
  13640. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13641. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13642. /**
  13643. * Gets a string identifying the name of the class
  13644. * @returns "TransformNode" string
  13645. */
  13646. getClassName(): string;
  13647. /**
  13648. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13649. */
  13650. position: Vector3;
  13651. /**
  13652. * 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)).
  13653. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13654. */
  13655. rotation: Vector3;
  13656. /**
  13657. * 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)).
  13658. */
  13659. scaling: Vector3;
  13660. /**
  13661. * 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).
  13662. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13663. */
  13664. rotationQuaternion: Nullable<Quaternion>;
  13665. /**
  13666. * The forward direction of that transform in world space.
  13667. */
  13668. readonly forward: Vector3;
  13669. /**
  13670. * The up direction of that transform in world space.
  13671. */
  13672. readonly up: Vector3;
  13673. /**
  13674. * The right direction of that transform in world space.
  13675. */
  13676. readonly right: Vector3;
  13677. /**
  13678. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13679. * @param matrix the matrix to copy the pose from
  13680. * @returns this TransformNode.
  13681. */
  13682. updatePoseMatrix(matrix: Matrix): TransformNode;
  13683. /**
  13684. * Returns the mesh Pose matrix.
  13685. * @returns the pose matrix
  13686. */
  13687. getPoseMatrix(): Matrix;
  13688. /** @hidden */ private _isSynchronized(): boolean;
  13689. /** @hidden */ private _initCache(): void;
  13690. /**
  13691. * Flag the transform node as dirty (Forcing it to update everything)
  13692. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13693. * @returns this transform node
  13694. */
  13695. markAsDirty(property: string): TransformNode;
  13696. /**
  13697. * Returns the current mesh absolute position.
  13698. * Returns a Vector3.
  13699. */
  13700. readonly absolutePosition: Vector3;
  13701. /**
  13702. * Returns the current mesh absolute scaling.
  13703. * Returns a Vector3.
  13704. */
  13705. readonly absoluteScaling: Vector3;
  13706. /**
  13707. * Returns the current mesh absolute rotation.
  13708. * Returns a Quaternion.
  13709. */
  13710. readonly absoluteRotationQuaternion: Quaternion;
  13711. /**
  13712. * Sets a new matrix to apply before all other transformation
  13713. * @param matrix defines the transform matrix
  13714. * @returns the current TransformNode
  13715. */
  13716. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13717. /**
  13718. * Sets a new pivot matrix to the current node
  13719. * @param matrix defines the new pivot matrix to use
  13720. * @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
  13721. * @returns the current TransformNode
  13722. */
  13723. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13724. /**
  13725. * Returns the mesh pivot matrix.
  13726. * Default : Identity.
  13727. * @returns the matrix
  13728. */
  13729. getPivotMatrix(): Matrix;
  13730. /**
  13731. * Instantiate (when possible) or clone that node with its hierarchy
  13732. * @param newParent defines the new parent to use for the instance (or clone)
  13733. * @returns an instance (or a clone) of the current node with its hiearchy
  13734. */
  13735. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13736. /**
  13737. * Prevents the World matrix to be computed any longer
  13738. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13739. * @returns the TransformNode.
  13740. */
  13741. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13742. /**
  13743. * Allows back the World matrix computation.
  13744. * @returns the TransformNode.
  13745. */
  13746. unfreezeWorldMatrix(): this;
  13747. /**
  13748. * True if the World matrix has been frozen.
  13749. */
  13750. readonly isWorldMatrixFrozen: boolean;
  13751. /**
  13752. * Retuns the mesh absolute position in the World.
  13753. * @returns a Vector3.
  13754. */
  13755. getAbsolutePosition(): Vector3;
  13756. /**
  13757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13758. * @param absolutePosition the absolute position to set
  13759. * @returns the TransformNode.
  13760. */
  13761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13762. /**
  13763. * Sets the mesh position in its local space.
  13764. * @param vector3 the position to set in localspace
  13765. * @returns the TransformNode.
  13766. */
  13767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13768. /**
  13769. * Returns the mesh position in the local space from the current World matrix values.
  13770. * @returns a new Vector3.
  13771. */
  13772. getPositionExpressedInLocalSpace(): Vector3;
  13773. /**
  13774. * Translates the mesh along the passed Vector3 in its local space.
  13775. * @param vector3 the distance to translate in localspace
  13776. * @returns the TransformNode.
  13777. */
  13778. locallyTranslate(vector3: Vector3): TransformNode;
  13779. private static _lookAtVectorCache;
  13780. /**
  13781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13782. * @param targetPoint the position (must be in same space as current mesh) to look at
  13783. * @param yawCor optional yaw (y-axis) correction in radians
  13784. * @param pitchCor optional pitch (x-axis) correction in radians
  13785. * @param rollCor optional roll (z-axis) correction in radians
  13786. * @param space the choosen space of the target
  13787. * @returns the TransformNode.
  13788. */
  13789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13790. /**
  13791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13792. * This Vector3 is expressed in the World space.
  13793. * @param localAxis axis to rotate
  13794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13795. */
  13796. getDirection(localAxis: Vector3): Vector3;
  13797. /**
  13798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13799. * localAxis is expressed in the mesh local space.
  13800. * result is computed in the Wordl space from the mesh World matrix.
  13801. * @param localAxis axis to rotate
  13802. * @param result the resulting transformnode
  13803. * @returns this TransformNode.
  13804. */
  13805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13806. /**
  13807. * Sets this transform node rotation to the given local axis.
  13808. * @param localAxis the axis in local space
  13809. * @param yawCor optional yaw (y-axis) correction in radians
  13810. * @param pitchCor optional pitch (x-axis) correction in radians
  13811. * @param rollCor optional roll (z-axis) correction in radians
  13812. * @returns this TransformNode
  13813. */
  13814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13815. /**
  13816. * Sets a new pivot point to the current node
  13817. * @param point defines the new pivot point to use
  13818. * @param space defines if the point is in world or local space (local by default)
  13819. * @returns the current TransformNode
  13820. */
  13821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13822. /**
  13823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13824. * @returns the pivot point
  13825. */
  13826. getPivotPoint(): Vector3;
  13827. /**
  13828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13829. * @param result the vector3 to store the result
  13830. * @returns this TransformNode.
  13831. */
  13832. getPivotPointToRef(result: Vector3): TransformNode;
  13833. /**
  13834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13836. */
  13837. getAbsolutePivotPoint(): Vector3;
  13838. /**
  13839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13840. * @param result vector3 to store the result
  13841. * @returns this TransformNode.
  13842. */
  13843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13844. /**
  13845. * Defines the passed node as the parent of the current node.
  13846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13847. * @see https://doc.babylonjs.com/how_to/parenting
  13848. * @param node the node ot set as the parent
  13849. * @returns this TransformNode.
  13850. */
  13851. setParent(node: Nullable<Node>): TransformNode;
  13852. private _nonUniformScaling;
  13853. /**
  13854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13855. */
  13856. readonly nonUniformScaling: boolean;
  13857. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13858. /**
  13859. * Attach the current TransformNode to another TransformNode associated with a bone
  13860. * @param bone Bone affecting the TransformNode
  13861. * @param affectedTransformNode TransformNode associated with the bone
  13862. * @returns this object
  13863. */
  13864. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13865. /**
  13866. * Detach the transform node if its associated with a bone
  13867. * @returns this object
  13868. */
  13869. detachFromBone(): TransformNode;
  13870. private static _rotationAxisCache;
  13871. /**
  13872. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13873. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13874. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13875. * The passed axis is also normalized.
  13876. * @param axis the axis to rotate around
  13877. * @param amount the amount to rotate in radians
  13878. * @param space Space to rotate in (Default: local)
  13879. * @returns the TransformNode.
  13880. */
  13881. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13882. /**
  13883. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13884. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13885. * The passed axis is also normalized. .
  13886. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13887. * @param point the point to rotate around
  13888. * @param axis the axis to rotate around
  13889. * @param amount the amount to rotate in radians
  13890. * @returns the TransformNode
  13891. */
  13892. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13893. /**
  13894. * Translates the mesh along the axis vector for the passed distance in the given space.
  13895. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13896. * @param axis the axis to translate in
  13897. * @param distance the distance to translate
  13898. * @param space Space to rotate in (Default: local)
  13899. * @returns the TransformNode.
  13900. */
  13901. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13902. /**
  13903. * Adds a rotation step to the mesh current rotation.
  13904. * x, y, z are Euler angles expressed in radians.
  13905. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13906. * This means this rotation is made in the mesh local space only.
  13907. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13908. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13909. * ```javascript
  13910. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13911. * ```
  13912. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13913. * 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.
  13914. * @param x Rotation to add
  13915. * @param y Rotation to add
  13916. * @param z Rotation to add
  13917. * @returns the TransformNode.
  13918. */
  13919. addRotation(x: number, y: number, z: number): TransformNode;
  13920. /**
  13921. * @hidden
  13922. */
  13923. protected _getEffectiveParent(): Nullable<Node>;
  13924. /**
  13925. * Computes the world matrix of the node
  13926. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13927. * @returns the world matrix
  13928. */
  13929. computeWorldMatrix(force?: boolean): Matrix;
  13930. protected _afterComputeWorldMatrix(): void;
  13931. /**
  13932. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13933. * @param func callback function to add
  13934. *
  13935. * @returns the TransformNode.
  13936. */
  13937. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13938. /**
  13939. * Removes a registered callback function.
  13940. * @param func callback function to remove
  13941. * @returns the TransformNode.
  13942. */
  13943. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13944. /**
  13945. * Gets the position of the current mesh in camera space
  13946. * @param camera defines the camera to use
  13947. * @returns a position
  13948. */
  13949. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13950. /**
  13951. * Returns the distance from the mesh to the active camera
  13952. * @param camera defines the camera to use
  13953. * @returns the distance
  13954. */
  13955. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13956. /**
  13957. * Clone the current transform node
  13958. * @param name Name of the new clone
  13959. * @param newParent New parent for the clone
  13960. * @param doNotCloneChildren Do not clone children hierarchy
  13961. * @returns the new transform node
  13962. */
  13963. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13964. /**
  13965. * Serializes the objects information.
  13966. * @param currentSerializationObject defines the object to serialize in
  13967. * @returns the serialized object
  13968. */
  13969. serialize(currentSerializationObject?: any): any;
  13970. /**
  13971. * Returns a new TransformNode object parsed from the source provided.
  13972. * @param parsedTransformNode is the source.
  13973. * @param scene the scne the object belongs to
  13974. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13975. * @returns a new TransformNode object parsed from the source provided.
  13976. */
  13977. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13978. /**
  13979. * Get all child-transformNodes of this node
  13980. * @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
  13981. * @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
  13982. * @returns an array of TransformNode
  13983. */
  13984. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13985. /**
  13986. * Releases resources associated with this transform node.
  13987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13989. */
  13990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13991. /**
  13992. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13993. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13994. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13995. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13996. * @returns the current mesh
  13997. */
  13998. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13999. private _syncAbsoluteScalingAndRotation;
  14000. }
  14001. }
  14002. declare module BABYLON {
  14003. /**
  14004. * Defines the types of pose enabled controllers that are supported
  14005. */
  14006. export enum PoseEnabledControllerType {
  14007. /**
  14008. * HTC Vive
  14009. */
  14010. VIVE = 0,
  14011. /**
  14012. * Oculus Rift
  14013. */
  14014. OCULUS = 1,
  14015. /**
  14016. * Windows mixed reality
  14017. */
  14018. WINDOWS = 2,
  14019. /**
  14020. * Samsung gear VR
  14021. */
  14022. GEAR_VR = 3,
  14023. /**
  14024. * Google Daydream
  14025. */
  14026. DAYDREAM = 4,
  14027. /**
  14028. * Generic
  14029. */
  14030. GENERIC = 5
  14031. }
  14032. /**
  14033. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14034. */
  14035. export interface MutableGamepadButton {
  14036. /**
  14037. * Value of the button/trigger
  14038. */
  14039. value: number;
  14040. /**
  14041. * If the button/trigger is currently touched
  14042. */
  14043. touched: boolean;
  14044. /**
  14045. * If the button/trigger is currently pressed
  14046. */
  14047. pressed: boolean;
  14048. }
  14049. /**
  14050. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14051. * @hidden
  14052. */
  14053. export interface ExtendedGamepadButton extends GamepadButton {
  14054. /**
  14055. * If the button/trigger is currently pressed
  14056. */
  14057. readonly pressed: boolean;
  14058. /**
  14059. * If the button/trigger is currently touched
  14060. */
  14061. readonly touched: boolean;
  14062. /**
  14063. * Value of the button/trigger
  14064. */
  14065. readonly value: number;
  14066. }
  14067. /** @hidden */
  14068. export interface _GamePadFactory {
  14069. /**
  14070. * Returns wether or not the current gamepad can be created for this type of controller.
  14071. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14072. * @returns true if it can be created, otherwise false
  14073. */
  14074. canCreate(gamepadInfo: any): boolean;
  14075. /**
  14076. * Creates a new instance of the Gamepad.
  14077. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14078. * @returns the new gamepad instance
  14079. */
  14080. create(gamepadInfo: any): Gamepad;
  14081. }
  14082. /**
  14083. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14084. */
  14085. export class PoseEnabledControllerHelper {
  14086. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14087. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14088. /**
  14089. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14090. * @param vrGamepad the gamepad to initialized
  14091. * @returns a vr controller of the type the gamepad identified as
  14092. */
  14093. static InitiateController(vrGamepad: any): Gamepad;
  14094. }
  14095. /**
  14096. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14097. */
  14098. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14099. /**
  14100. * If the controller is used in a webXR session
  14101. */
  14102. isXR: boolean;
  14103. private _deviceRoomPosition;
  14104. private _deviceRoomRotationQuaternion;
  14105. /**
  14106. * The device position in babylon space
  14107. */
  14108. devicePosition: Vector3;
  14109. /**
  14110. * The device rotation in babylon space
  14111. */
  14112. deviceRotationQuaternion: Quaternion;
  14113. /**
  14114. * The scale factor of the device in babylon space
  14115. */
  14116. deviceScaleFactor: number;
  14117. /**
  14118. * (Likely devicePosition should be used instead) The device position in its room space
  14119. */
  14120. position: Vector3;
  14121. /**
  14122. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14123. */
  14124. rotationQuaternion: Quaternion;
  14125. /**
  14126. * The type of controller (Eg. Windows mixed reality)
  14127. */
  14128. controllerType: PoseEnabledControllerType;
  14129. protected _calculatedPosition: Vector3;
  14130. private _calculatedRotation;
  14131. /**
  14132. * The raw pose from the device
  14133. */
  14134. rawPose: DevicePose;
  14135. private _trackPosition;
  14136. private _maxRotationDistFromHeadset;
  14137. private _draggedRoomRotation;
  14138. /**
  14139. * @hidden
  14140. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14141. /**
  14142. * Internal, the mesh attached to the controller
  14143. * @hidden
  14144. */ private _mesh: Nullable<AbstractMesh>;
  14145. private _poseControlledCamera;
  14146. private _leftHandSystemQuaternion;
  14147. /**
  14148. * Internal, matrix used to convert room space to babylon space
  14149. * @hidden
  14150. */ private _deviceToWorld: Matrix;
  14151. /**
  14152. * Node to be used when casting a ray from the controller
  14153. * @hidden
  14154. */ private _pointingPoseNode: Nullable<TransformNode>;
  14155. /**
  14156. * Name of the child mesh that can be used to cast a ray from the controller
  14157. */
  14158. static readonly POINTING_POSE: string;
  14159. /**
  14160. * Creates a new PoseEnabledController from a gamepad
  14161. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14162. */
  14163. constructor(browserGamepad: any);
  14164. private _workingMatrix;
  14165. /**
  14166. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14167. */
  14168. update(): void;
  14169. /**
  14170. * Updates only the pose device and mesh without doing any button event checking
  14171. */
  14172. protected _updatePoseAndMesh(): void;
  14173. /**
  14174. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14175. * @param poseData raw pose fromthe device
  14176. */
  14177. updateFromDevice(poseData: DevicePose): void;
  14178. /**
  14179. * @hidden
  14180. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14181. /**
  14182. * Attaches a mesh to the controller
  14183. * @param mesh the mesh to be attached
  14184. */
  14185. attachToMesh(mesh: AbstractMesh): void;
  14186. /**
  14187. * Attaches the controllers mesh to a camera
  14188. * @param camera the camera the mesh should be attached to
  14189. */
  14190. attachToPoseControlledCamera(camera: TargetCamera): void;
  14191. /**
  14192. * Disposes of the controller
  14193. */
  14194. dispose(): void;
  14195. /**
  14196. * The mesh that is attached to the controller
  14197. */
  14198. readonly mesh: Nullable<AbstractMesh>;
  14199. /**
  14200. * Gets the ray of the controller in the direction the controller is pointing
  14201. * @param length the length the resulting ray should be
  14202. * @returns a ray in the direction the controller is pointing
  14203. */
  14204. getForwardRay(length?: number): Ray;
  14205. }
  14206. }
  14207. declare module BABYLON {
  14208. /**
  14209. * Defines the WebVRController object that represents controllers tracked in 3D space
  14210. */
  14211. export abstract class WebVRController extends PoseEnabledController {
  14212. /**
  14213. * Internal, the default controller model for the controller
  14214. */
  14215. protected _defaultModel: AbstractMesh;
  14216. /**
  14217. * Fired when the trigger state has changed
  14218. */
  14219. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14220. /**
  14221. * Fired when the main button state has changed
  14222. */
  14223. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14224. /**
  14225. * Fired when the secondary button state has changed
  14226. */
  14227. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14228. /**
  14229. * Fired when the pad state has changed
  14230. */
  14231. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14232. /**
  14233. * Fired when controllers stick values have changed
  14234. */
  14235. onPadValuesChangedObservable: Observable<StickValues>;
  14236. /**
  14237. * Array of button availible on the controller
  14238. */
  14239. protected _buttons: Array<MutableGamepadButton>;
  14240. private _onButtonStateChange;
  14241. /**
  14242. * Fired when a controller button's state has changed
  14243. * @param callback the callback containing the button that was modified
  14244. */
  14245. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14246. /**
  14247. * X and Y axis corresponding to the controllers joystick
  14248. */
  14249. pad: StickValues;
  14250. /**
  14251. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14252. */
  14253. hand: string;
  14254. /**
  14255. * The default controller model for the controller
  14256. */
  14257. readonly defaultModel: AbstractMesh;
  14258. /**
  14259. * Creates a new WebVRController from a gamepad
  14260. * @param vrGamepad the gamepad that the WebVRController should be created from
  14261. */
  14262. constructor(vrGamepad: any);
  14263. /**
  14264. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14265. */
  14266. update(): void;
  14267. /**
  14268. * Function to be called when a button is modified
  14269. */
  14270. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14271. /**
  14272. * Loads a mesh and attaches it to the controller
  14273. * @param scene the scene the mesh should be added to
  14274. * @param meshLoaded callback for when the mesh has been loaded
  14275. */
  14276. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14277. private _setButtonValue;
  14278. private _changes;
  14279. private _checkChanges;
  14280. /**
  14281. * Disposes of th webVRCOntroller
  14282. */
  14283. dispose(): void;
  14284. }
  14285. }
  14286. declare module BABYLON {
  14287. /**
  14288. * The HemisphericLight simulates the ambient environment light,
  14289. * so the passed direction is the light reflection direction, not the incoming direction.
  14290. */
  14291. export class HemisphericLight extends Light {
  14292. /**
  14293. * The groundColor is the light in the opposite direction to the one specified during creation.
  14294. * 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.
  14295. */
  14296. groundColor: Color3;
  14297. /**
  14298. * The light reflection direction, not the incoming direction.
  14299. */
  14300. direction: Vector3;
  14301. /**
  14302. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14303. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14304. * The HemisphericLight can't cast shadows.
  14305. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14306. * @param name The friendly name of the light
  14307. * @param direction The direction of the light reflection
  14308. * @param scene The scene the light belongs to
  14309. */
  14310. constructor(name: string, direction: Vector3, scene: Scene);
  14311. protected _buildUniformLayout(): void;
  14312. /**
  14313. * Returns the string "HemisphericLight".
  14314. * @return The class name
  14315. */
  14316. getClassName(): string;
  14317. /**
  14318. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14319. * Returns the updated direction.
  14320. * @param target The target the direction should point to
  14321. * @return The computed direction
  14322. */
  14323. setDirectionToTarget(target: Vector3): Vector3;
  14324. /**
  14325. * Returns the shadow generator associated to the light.
  14326. * @returns Always null for hemispheric lights because it does not support shadows.
  14327. */
  14328. getShadowGenerator(): Nullable<IShadowGenerator>;
  14329. /**
  14330. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14331. * @param effect The effect to update
  14332. * @param lightIndex The index of the light in the effect to update
  14333. * @returns The hemispheric light
  14334. */
  14335. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14336. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14337. /**
  14338. * Computes the world matrix of the node
  14339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14340. * @param useWasUpdatedFlag defines a reserved property
  14341. * @returns the world matrix
  14342. */
  14343. computeWorldMatrix(): Matrix;
  14344. /**
  14345. * Returns the integer 3.
  14346. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14347. */
  14348. getTypeID(): number;
  14349. /**
  14350. * Prepares the list of defines specific to the light type.
  14351. * @param defines the list of defines
  14352. * @param lightIndex defines the index of the light for the effect
  14353. */
  14354. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14355. }
  14356. }
  14357. declare module BABYLON {
  14358. /** @hidden */
  14359. export var vrMultiviewToSingleviewPixelShader: {
  14360. name: string;
  14361. shader: string;
  14362. };
  14363. }
  14364. declare module BABYLON {
  14365. /**
  14366. * Renders to multiple views with a single draw call
  14367. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14368. */
  14369. export class MultiviewRenderTarget extends RenderTargetTexture {
  14370. /**
  14371. * Creates a multiview render target
  14372. * @param scene scene used with the render target
  14373. * @param size the size of the render target (used for each view)
  14374. */
  14375. constructor(scene: Scene, size?: number | {
  14376. width: number;
  14377. height: number;
  14378. } | {
  14379. ratio: number;
  14380. });
  14381. /**
  14382. * @hidden
  14383. * @param faceIndex the face index, if its a cube texture
  14384. */ private _bindFrameBuffer(faceIndex?: number): void;
  14385. /**
  14386. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14387. * @returns the view count
  14388. */
  14389. getViewCount(): number;
  14390. }
  14391. }
  14392. declare module BABYLON {
  14393. /**
  14394. * Represents a camera frustum
  14395. */
  14396. export class Frustum {
  14397. /**
  14398. * Gets the planes representing the frustum
  14399. * @param transform matrix to be applied to the returned planes
  14400. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14401. */
  14402. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14403. /**
  14404. * Gets the near frustum plane transformed by the transform matrix
  14405. * @param transform transformation matrix to be applied to the resulting frustum plane
  14406. * @param frustumPlane the resuling frustum plane
  14407. */
  14408. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14409. /**
  14410. * Gets the far frustum plane transformed by the transform matrix
  14411. * @param transform transformation matrix to be applied to the resulting frustum plane
  14412. * @param frustumPlane the resuling frustum plane
  14413. */
  14414. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14415. /**
  14416. * Gets the left frustum plane transformed by the transform matrix
  14417. * @param transform transformation matrix to be applied to the resulting frustum plane
  14418. * @param frustumPlane the resuling frustum plane
  14419. */
  14420. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14421. /**
  14422. * Gets the right frustum plane transformed by the transform matrix
  14423. * @param transform transformation matrix to be applied to the resulting frustum plane
  14424. * @param frustumPlane the resuling frustum plane
  14425. */
  14426. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14427. /**
  14428. * Gets the top frustum plane transformed by the transform matrix
  14429. * @param transform transformation matrix to be applied to the resulting frustum plane
  14430. * @param frustumPlane the resuling frustum plane
  14431. */
  14432. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14433. /**
  14434. * Gets the bottom frustum plane transformed by the transform matrix
  14435. * @param transform transformation matrix to be applied to the resulting frustum plane
  14436. * @param frustumPlane the resuling frustum plane
  14437. */
  14438. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14439. /**
  14440. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14441. * @param transform transformation matrix to be applied to the resulting frustum planes
  14442. * @param frustumPlanes the resuling frustum planes
  14443. */
  14444. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14445. }
  14446. }
  14447. declare module BABYLON {
  14448. interface Engine {
  14449. /**
  14450. * Creates a new multiview render target
  14451. * @param width defines the width of the texture
  14452. * @param height defines the height of the texture
  14453. * @returns the created multiview texture
  14454. */
  14455. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14456. /**
  14457. * Binds a multiview framebuffer to be drawn to
  14458. * @param multiviewTexture texture to bind
  14459. */
  14460. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14461. }
  14462. interface Camera {
  14463. /**
  14464. * @hidden
  14465. * 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)
  14466. */ private _useMultiviewToSingleView: boolean;
  14467. /**
  14468. * @hidden
  14469. * 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)
  14470. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14471. /**
  14472. * @hidden
  14473. * ensures the multiview texture of the camera exists and has the specified width/height
  14474. * @param width height to set on the multiview texture
  14475. * @param height width to set on the multiview texture
  14476. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14477. }
  14478. interface Scene {
  14479. /** @hidden */ private _transformMatrixR: Matrix;
  14480. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14481. /** @hidden */ private _createMultiviewUbo(): void;
  14482. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14483. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14484. }
  14485. }
  14486. declare module BABYLON {
  14487. /**
  14488. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14489. * This will not be used for webXR as it supports displaying texture arrays directly
  14490. */
  14491. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14492. /**
  14493. * Initializes a VRMultiviewToSingleview
  14494. * @param name name of the post process
  14495. * @param camera camera to be applied to
  14496. * @param scaleFactor scaling factor to the size of the output texture
  14497. */
  14498. constructor(name: string, camera: Camera, scaleFactor: number);
  14499. }
  14500. }
  14501. declare module BABYLON {
  14502. interface Engine {
  14503. /** @hidden */ private _vrDisplay: any;
  14504. /** @hidden */ private _vrSupported: boolean;
  14505. /** @hidden */ private _oldSize: Size;
  14506. /** @hidden */ private _oldHardwareScaleFactor: number;
  14507. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14508. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14509. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14510. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14511. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14512. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14513. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14514. /**
  14515. * Observable signaled when VR display mode changes
  14516. */
  14517. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14518. /**
  14519. * Observable signaled when VR request present is complete
  14520. */
  14521. onVRRequestPresentComplete: Observable<boolean>;
  14522. /**
  14523. * Observable signaled when VR request present starts
  14524. */
  14525. onVRRequestPresentStart: Observable<Engine>;
  14526. /**
  14527. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14528. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14529. */
  14530. isInVRExclusivePointerMode: boolean;
  14531. /**
  14532. * Gets a boolean indicating if a webVR device was detected
  14533. * @returns true if a webVR device was detected
  14534. */
  14535. isVRDevicePresent(): boolean;
  14536. /**
  14537. * Gets the current webVR device
  14538. * @returns the current webVR device (or null)
  14539. */
  14540. getVRDevice(): any;
  14541. /**
  14542. * Initializes a webVR display and starts listening to display change events
  14543. * The onVRDisplayChangedObservable will be notified upon these changes
  14544. * @returns A promise containing a VRDisplay and if vr is supported
  14545. */
  14546. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14547. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14548. /**
  14549. * Call this function to switch to webVR mode
  14550. * Will do nothing if webVR is not supported or if there is no webVR device
  14551. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14552. */
  14553. enableVR(): void;
  14554. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14555. }
  14556. }
  14557. declare module BABYLON {
  14558. /**
  14559. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14560. * IMPORTANT!! The data is right-hand data.
  14561. * @export
  14562. * @interface DevicePose
  14563. */
  14564. export interface DevicePose {
  14565. /**
  14566. * The position of the device, values in array are [x,y,z].
  14567. */
  14568. readonly position: Nullable<Float32Array>;
  14569. /**
  14570. * The linearVelocity of the device, values in array are [x,y,z].
  14571. */
  14572. readonly linearVelocity: Nullable<Float32Array>;
  14573. /**
  14574. * The linearAcceleration of the device, values in array are [x,y,z].
  14575. */
  14576. readonly linearAcceleration: Nullable<Float32Array>;
  14577. /**
  14578. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14579. */
  14580. readonly orientation: Nullable<Float32Array>;
  14581. /**
  14582. * The angularVelocity of the device, values in array are [x,y,z].
  14583. */
  14584. readonly angularVelocity: Nullable<Float32Array>;
  14585. /**
  14586. * The angularAcceleration of the device, values in array are [x,y,z].
  14587. */
  14588. readonly angularAcceleration: Nullable<Float32Array>;
  14589. }
  14590. /**
  14591. * Interface representing a pose controlled object in Babylon.
  14592. * A pose controlled object has both regular pose values as well as pose values
  14593. * from an external device such as a VR head mounted display
  14594. */
  14595. export interface PoseControlled {
  14596. /**
  14597. * The position of the object in babylon space.
  14598. */
  14599. position: Vector3;
  14600. /**
  14601. * The rotation quaternion of the object in babylon space.
  14602. */
  14603. rotationQuaternion: Quaternion;
  14604. /**
  14605. * The position of the device in babylon space.
  14606. */
  14607. devicePosition?: Vector3;
  14608. /**
  14609. * The rotation quaternion of the device in babylon space.
  14610. */
  14611. deviceRotationQuaternion: Quaternion;
  14612. /**
  14613. * The raw pose coming from the device.
  14614. */
  14615. rawPose: Nullable<DevicePose>;
  14616. /**
  14617. * The scale of the device to be used when translating from device space to babylon space.
  14618. */
  14619. deviceScaleFactor: number;
  14620. /**
  14621. * Updates the poseControlled values based on the input device pose.
  14622. * @param poseData the pose data to update the object with
  14623. */
  14624. updateFromDevice(poseData: DevicePose): void;
  14625. }
  14626. /**
  14627. * Set of options to customize the webVRCamera
  14628. */
  14629. export interface WebVROptions {
  14630. /**
  14631. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14632. */
  14633. trackPosition?: boolean;
  14634. /**
  14635. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14636. */
  14637. positionScale?: number;
  14638. /**
  14639. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14640. */
  14641. displayName?: string;
  14642. /**
  14643. * Should the native controller meshes be initialized. (default: true)
  14644. */
  14645. controllerMeshes?: boolean;
  14646. /**
  14647. * Creating a default HemiLight only on controllers. (default: true)
  14648. */
  14649. defaultLightingOnControllers?: boolean;
  14650. /**
  14651. * If you don't want to use the default VR button of the helper. (default: false)
  14652. */
  14653. useCustomVRButton?: boolean;
  14654. /**
  14655. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14656. */
  14657. customVRButton?: HTMLButtonElement;
  14658. /**
  14659. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14660. */
  14661. rayLength?: number;
  14662. /**
  14663. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14664. */
  14665. defaultHeight?: number;
  14666. /**
  14667. * If multiview should be used if availible (default: false)
  14668. */
  14669. useMultiview?: boolean;
  14670. }
  14671. /**
  14672. * This represents a WebVR camera.
  14673. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14674. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14675. */
  14676. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14677. private webVROptions;
  14678. /**
  14679. * @hidden
  14680. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14681. */ private _vrDevice: any;
  14682. /**
  14683. * The rawPose of the vrDevice.
  14684. */
  14685. rawPose: Nullable<DevicePose>;
  14686. private _onVREnabled;
  14687. private _specsVersion;
  14688. private _attached;
  14689. private _frameData;
  14690. protected _descendants: Array<Node>;
  14691. private _deviceRoomPosition;
  14692. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14693. private _standingMatrix;
  14694. /**
  14695. * Represents device position in babylon space.
  14696. */
  14697. devicePosition: Vector3;
  14698. /**
  14699. * Represents device rotation in babylon space.
  14700. */
  14701. deviceRotationQuaternion: Quaternion;
  14702. /**
  14703. * The scale of the device to be used when translating from device space to babylon space.
  14704. */
  14705. deviceScaleFactor: number;
  14706. private _deviceToWorld;
  14707. private _worldToDevice;
  14708. /**
  14709. * References to the webVR controllers for the vrDevice.
  14710. */
  14711. controllers: Array<WebVRController>;
  14712. /**
  14713. * Emits an event when a controller is attached.
  14714. */
  14715. onControllersAttachedObservable: Observable<WebVRController[]>;
  14716. /**
  14717. * Emits an event when a controller's mesh has been loaded;
  14718. */
  14719. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14720. /**
  14721. * Emits an event when the HMD's pose has been updated.
  14722. */
  14723. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14724. private _poseSet;
  14725. /**
  14726. * If the rig cameras be used as parent instead of this camera.
  14727. */
  14728. rigParenting: boolean;
  14729. private _lightOnControllers;
  14730. private _defaultHeight?;
  14731. /**
  14732. * Instantiates a WebVRFreeCamera.
  14733. * @param name The name of the WebVRFreeCamera
  14734. * @param position The starting anchor position for the camera
  14735. * @param scene The scene the camera belongs to
  14736. * @param webVROptions a set of customizable options for the webVRCamera
  14737. */
  14738. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14739. /**
  14740. * Gets the device distance from the ground in meters.
  14741. * @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.
  14742. */
  14743. deviceDistanceToRoomGround(): number;
  14744. /**
  14745. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14746. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14747. */
  14748. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14749. /**
  14750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14751. * @returns A promise with a boolean set to if the standing matrix is supported.
  14752. */
  14753. useStandingMatrixAsync(): Promise<boolean>;
  14754. /**
  14755. * Disposes the camera
  14756. */
  14757. dispose(): void;
  14758. /**
  14759. * Gets a vrController by name.
  14760. * @param name The name of the controller to retreive
  14761. * @returns the controller matching the name specified or null if not found
  14762. */
  14763. getControllerByName(name: string): Nullable<WebVRController>;
  14764. private _leftController;
  14765. /**
  14766. * The controller corresponding to the users left hand.
  14767. */
  14768. readonly leftController: Nullable<WebVRController>;
  14769. private _rightController;
  14770. /**
  14771. * The controller corresponding to the users right hand.
  14772. */
  14773. readonly rightController: Nullable<WebVRController>;
  14774. /**
  14775. * Casts a ray forward from the vrCamera's gaze.
  14776. * @param length Length of the ray (default: 100)
  14777. * @returns the ray corresponding to the gaze
  14778. */
  14779. getForwardRay(length?: number): Ray;
  14780. /**
  14781. * @hidden
  14782. * Updates the camera based on device's frame data
  14783. */ private _checkInputs(): void;
  14784. /**
  14785. * Updates the poseControlled values based on the input device pose.
  14786. * @param poseData Pose coming from the device
  14787. */
  14788. updateFromDevice(poseData: DevicePose): void;
  14789. private _htmlElementAttached;
  14790. private _detachIfAttached;
  14791. /**
  14792. * WebVR's attach control will start broadcasting frames to the device.
  14793. * Note that in certain browsers (chrome for example) this function must be called
  14794. * within a user-interaction callback. Example:
  14795. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14796. *
  14797. * @param element html element to attach the vrDevice to
  14798. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14799. */
  14800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14801. /**
  14802. * Detaches the camera from the html element and disables VR
  14803. *
  14804. * @param element html element to detach from
  14805. */
  14806. detachControl(element: HTMLElement): void;
  14807. /**
  14808. * @returns the name of this class
  14809. */
  14810. getClassName(): string;
  14811. /**
  14812. * Calls resetPose on the vrDisplay
  14813. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14814. */
  14815. resetToCurrentRotation(): void;
  14816. /**
  14817. * @hidden
  14818. * Updates the rig cameras (left and right eye)
  14819. */ private _updateRigCameras(): void;
  14820. private _workingVector;
  14821. private _oneVector;
  14822. private _workingMatrix;
  14823. private updateCacheCalled;
  14824. private _correctPositionIfNotTrackPosition;
  14825. /**
  14826. * @hidden
  14827. * Updates the cached values of the camera
  14828. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14829. */ private _updateCache(ignoreParentClass?: boolean): void;
  14830. /**
  14831. * @hidden
  14832. * Get current device position in babylon world
  14833. */ private _computeDevicePosition(): void;
  14834. /**
  14835. * Updates the current device position and rotation in the babylon world
  14836. */
  14837. update(): void;
  14838. /**
  14839. * @hidden
  14840. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14841. * @returns an identity matrix
  14842. */ private _getViewMatrix(): Matrix;
  14843. private _tmpMatrix;
  14844. /**
  14845. * This function is called by the two RIG cameras.
  14846. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14847. * @hidden
  14848. */ private _getWebVRViewMatrix(): Matrix;
  14849. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14850. private _onGamepadConnectedObserver;
  14851. private _onGamepadDisconnectedObserver;
  14852. private _updateCacheWhenTrackingDisabledObserver;
  14853. /**
  14854. * Initializes the controllers and their meshes
  14855. */
  14856. initControllers(): void;
  14857. }
  14858. }
  14859. declare module BABYLON {
  14860. /**
  14861. * Size options for a post process
  14862. */
  14863. export type PostProcessOptions = {
  14864. width: number;
  14865. height: number;
  14866. };
  14867. /**
  14868. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14869. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14870. */
  14871. export class PostProcess {
  14872. /** Name of the PostProcess. */
  14873. name: string;
  14874. /**
  14875. * Gets or sets the unique id of the post process
  14876. */
  14877. uniqueId: number;
  14878. /**
  14879. * Width of the texture to apply the post process on
  14880. */
  14881. width: number;
  14882. /**
  14883. * Height of the texture to apply the post process on
  14884. */
  14885. height: number;
  14886. /**
  14887. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14888. * @hidden
  14889. */ private _outputTexture: Nullable<InternalTexture>;
  14890. /**
  14891. * Sampling mode used by the shader
  14892. * See https://doc.babylonjs.com/classes/3.1/texture
  14893. */
  14894. renderTargetSamplingMode: number;
  14895. /**
  14896. * Clear color to use when screen clearing
  14897. */
  14898. clearColor: Color4;
  14899. /**
  14900. * If the buffer needs to be cleared before applying the post process. (default: true)
  14901. * Should be set to false if shader will overwrite all previous pixels.
  14902. */
  14903. autoClear: boolean;
  14904. /**
  14905. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14906. */
  14907. alphaMode: number;
  14908. /**
  14909. * Sets the setAlphaBlendConstants of the babylon engine
  14910. */
  14911. alphaConstants: Color4;
  14912. /**
  14913. * Animations to be used for the post processing
  14914. */
  14915. animations: Animation[];
  14916. /**
  14917. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14918. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14919. */
  14920. enablePixelPerfectMode: boolean;
  14921. /**
  14922. * Force the postprocess to be applied without taking in account viewport
  14923. */
  14924. forceFullscreenViewport: boolean;
  14925. /**
  14926. * List of inspectable custom properties (used by the Inspector)
  14927. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14928. */
  14929. inspectableCustomProperties: IInspectable[];
  14930. /**
  14931. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14932. *
  14933. * | Value | Type | Description |
  14934. * | ----- | ----------------------------------- | ----------- |
  14935. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14936. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14937. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14938. *
  14939. */
  14940. scaleMode: number;
  14941. /**
  14942. * Force textures to be a power of two (default: false)
  14943. */
  14944. alwaysForcePOT: boolean;
  14945. private _samples;
  14946. /**
  14947. * Number of sample textures (default: 1)
  14948. */
  14949. samples: number;
  14950. /**
  14951. * Modify the scale of the post process to be the same as the viewport (default: false)
  14952. */
  14953. adaptScaleToCurrentViewport: boolean;
  14954. private _camera;
  14955. private _scene;
  14956. private _engine;
  14957. private _options;
  14958. private _reusable;
  14959. private _textureType;
  14960. /**
  14961. * Smart array of input and output textures for the post process.
  14962. * @hidden
  14963. */ private _textures: SmartArray<InternalTexture>;
  14964. /**
  14965. * The index in _textures that corresponds to the output texture.
  14966. * @hidden
  14967. */ private _currentRenderTextureInd: number;
  14968. private _effect;
  14969. private _samplers;
  14970. private _fragmentUrl;
  14971. private _vertexUrl;
  14972. private _parameters;
  14973. private _scaleRatio;
  14974. protected _indexParameters: any;
  14975. private _shareOutputWithPostProcess;
  14976. private _texelSize;
  14977. private _forcedOutputTexture;
  14978. /**
  14979. * Returns the fragment url or shader name used in the post process.
  14980. * @returns the fragment url or name in the shader store.
  14981. */
  14982. getEffectName(): string;
  14983. /**
  14984. * An event triggered when the postprocess is activated.
  14985. */
  14986. onActivateObservable: Observable<Camera>;
  14987. private _onActivateObserver;
  14988. /**
  14989. * A function that is added to the onActivateObservable
  14990. */
  14991. onActivate: Nullable<(camera: Camera) => void>;
  14992. /**
  14993. * An event triggered when the postprocess changes its size.
  14994. */
  14995. onSizeChangedObservable: Observable<PostProcess>;
  14996. private _onSizeChangedObserver;
  14997. /**
  14998. * A function that is added to the onSizeChangedObservable
  14999. */
  15000. onSizeChanged: (postProcess: PostProcess) => void;
  15001. /**
  15002. * An event triggered when the postprocess applies its effect.
  15003. */
  15004. onApplyObservable: Observable<Effect>;
  15005. private _onApplyObserver;
  15006. /**
  15007. * A function that is added to the onApplyObservable
  15008. */
  15009. onApply: (effect: Effect) => void;
  15010. /**
  15011. * An event triggered before rendering the postprocess
  15012. */
  15013. onBeforeRenderObservable: Observable<Effect>;
  15014. private _onBeforeRenderObserver;
  15015. /**
  15016. * A function that is added to the onBeforeRenderObservable
  15017. */
  15018. onBeforeRender: (effect: Effect) => void;
  15019. /**
  15020. * An event triggered after rendering the postprocess
  15021. */
  15022. onAfterRenderObservable: Observable<Effect>;
  15023. private _onAfterRenderObserver;
  15024. /**
  15025. * A function that is added to the onAfterRenderObservable
  15026. */
  15027. onAfterRender: (efect: Effect) => void;
  15028. /**
  15029. * 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
  15030. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15031. */
  15032. inputTexture: InternalTexture;
  15033. /**
  15034. * Gets the camera which post process is applied to.
  15035. * @returns The camera the post process is applied to.
  15036. */
  15037. getCamera(): Camera;
  15038. /**
  15039. * Gets the texel size of the postprocess.
  15040. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15041. */
  15042. readonly texelSize: Vector2;
  15043. /**
  15044. * Creates a new instance PostProcess
  15045. * @param name The name of the PostProcess.
  15046. * @param fragmentUrl The url of the fragment shader to be used.
  15047. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15048. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15049. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15050. * @param camera The camera to apply the render pass to.
  15051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15052. * @param engine The engine which the post process will be applied. (default: current engine)
  15053. * @param reusable If the post process can be reused on the same frame. (default: false)
  15054. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15055. * @param textureType Type of textures used when performing the post process. (default: 0)
  15056. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15057. * @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
  15058. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15059. */
  15060. constructor(
  15061. /** Name of the PostProcess. */
  15062. 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);
  15063. /**
  15064. * Gets a string idenfifying the name of the class
  15065. * @returns "PostProcess" string
  15066. */
  15067. getClassName(): string;
  15068. /**
  15069. * Gets the engine which this post process belongs to.
  15070. * @returns The engine the post process was enabled with.
  15071. */
  15072. getEngine(): Engine;
  15073. /**
  15074. * The effect that is created when initializing the post process.
  15075. * @returns The created effect corresponding the the postprocess.
  15076. */
  15077. getEffect(): Effect;
  15078. /**
  15079. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15080. * @param postProcess The post process to share the output with.
  15081. * @returns This post process.
  15082. */
  15083. shareOutputWith(postProcess: PostProcess): PostProcess;
  15084. /**
  15085. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15086. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15087. */
  15088. useOwnOutput(): void;
  15089. /**
  15090. * Updates the effect with the current post process compile time values and recompiles the shader.
  15091. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15092. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15093. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15094. * @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
  15095. * @param onCompiled Called when the shader has been compiled.
  15096. * @param onError Called if there is an error when compiling a shader.
  15097. */
  15098. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15099. /**
  15100. * The post process is reusable if it can be used multiple times within one frame.
  15101. * @returns If the post process is reusable
  15102. */
  15103. isReusable(): boolean;
  15104. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15105. markTextureDirty(): void;
  15106. /**
  15107. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15108. * 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.
  15109. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15110. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15111. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15112. * @returns The target texture that was bound to be written to.
  15113. */
  15114. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15115. /**
  15116. * If the post process is supported.
  15117. */
  15118. readonly isSupported: boolean;
  15119. /**
  15120. * The aspect ratio of the output texture.
  15121. */
  15122. readonly aspectRatio: number;
  15123. /**
  15124. * Get a value indicating if the post-process is ready to be used
  15125. * @returns true if the post-process is ready (shader is compiled)
  15126. */
  15127. isReady(): boolean;
  15128. /**
  15129. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15130. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15131. */
  15132. apply(): Nullable<Effect>;
  15133. private _disposeTextures;
  15134. /**
  15135. * Disposes the post process.
  15136. * @param camera The camera to dispose the post process on.
  15137. */
  15138. dispose(camera?: Camera): void;
  15139. }
  15140. }
  15141. declare module BABYLON {
  15142. /** @hidden */
  15143. export var kernelBlurVaryingDeclaration: {
  15144. name: string;
  15145. shader: string;
  15146. };
  15147. }
  15148. declare module BABYLON {
  15149. /** @hidden */
  15150. export var kernelBlurFragment: {
  15151. name: string;
  15152. shader: string;
  15153. };
  15154. }
  15155. declare module BABYLON {
  15156. /** @hidden */
  15157. export var kernelBlurFragment2: {
  15158. name: string;
  15159. shader: string;
  15160. };
  15161. }
  15162. declare module BABYLON {
  15163. /** @hidden */
  15164. export var kernelBlurPixelShader: {
  15165. name: string;
  15166. shader: string;
  15167. };
  15168. }
  15169. declare module BABYLON {
  15170. /** @hidden */
  15171. export var kernelBlurVertex: {
  15172. name: string;
  15173. shader: string;
  15174. };
  15175. }
  15176. declare module BABYLON {
  15177. /** @hidden */
  15178. export var kernelBlurVertexShader: {
  15179. name: string;
  15180. shader: string;
  15181. };
  15182. }
  15183. declare module BABYLON {
  15184. /**
  15185. * The Blur Post Process which blurs an image based on a kernel and direction.
  15186. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15187. */
  15188. export class BlurPostProcess extends PostProcess {
  15189. /** The direction in which to blur the image. */
  15190. direction: Vector2;
  15191. private blockCompilation;
  15192. protected _kernel: number;
  15193. protected _idealKernel: number;
  15194. protected _packedFloat: boolean;
  15195. private _staticDefines;
  15196. /**
  15197. * Sets the length in pixels of the blur sample region
  15198. */
  15199. /**
  15200. * Gets the length in pixels of the blur sample region
  15201. */
  15202. kernel: number;
  15203. /**
  15204. * Sets wether or not the blur needs to unpack/repack floats
  15205. */
  15206. /**
  15207. * Gets wether or not the blur is unpacking/repacking floats
  15208. */
  15209. packedFloat: boolean;
  15210. /**
  15211. * Creates a new instance BlurPostProcess
  15212. * @param name The name of the effect.
  15213. * @param direction The direction in which to blur the image.
  15214. * @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.
  15215. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15216. * @param camera The camera to apply the render pass to.
  15217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15218. * @param engine The engine which the post process will be applied. (default: current engine)
  15219. * @param reusable If the post process can be reused on the same frame. (default: false)
  15220. * @param textureType Type of textures used when performing the post process. (default: 0)
  15221. * @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)
  15222. */
  15223. constructor(name: string,
  15224. /** The direction in which to blur the image. */
  15225. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15226. /**
  15227. * Updates the effect with the current post process compile time values and recompiles the shader.
  15228. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15229. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15230. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15231. * @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
  15232. * @param onCompiled Called when the shader has been compiled.
  15233. * @param onError Called if there is an error when compiling a shader.
  15234. */
  15235. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15236. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15237. /**
  15238. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15239. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15240. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15241. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15242. * The gaps between physical kernels are compensated for in the weighting of the samples
  15243. * @param idealKernel Ideal blur kernel.
  15244. * @return Nearest best kernel.
  15245. */
  15246. protected _nearestBestKernel(idealKernel: number): number;
  15247. /**
  15248. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15249. * @param x The point on the Gaussian distribution to sample.
  15250. * @return the value of the Gaussian function at x.
  15251. */
  15252. protected _gaussianWeight(x: number): number;
  15253. /**
  15254. * Generates a string that can be used as a floating point number in GLSL.
  15255. * @param x Value to print.
  15256. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15257. * @return GLSL float string.
  15258. */
  15259. protected _glslFloat(x: number, decimalFigures?: number): string;
  15260. }
  15261. }
  15262. declare module BABYLON {
  15263. /**
  15264. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15265. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15266. * You can then easily use it as a reflectionTexture on a flat surface.
  15267. * In case the surface is not a plane, please consider relying on reflection probes.
  15268. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15269. */
  15270. export class MirrorTexture extends RenderTargetTexture {
  15271. private scene;
  15272. /**
  15273. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15274. * 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.
  15275. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15276. */
  15277. mirrorPlane: Plane;
  15278. /**
  15279. * Define the blur ratio used to blur the reflection if needed.
  15280. */
  15281. blurRatio: number;
  15282. /**
  15283. * Define the adaptive blur kernel used to blur the reflection if needed.
  15284. * This will autocompute the closest best match for the `blurKernel`
  15285. */
  15286. adaptiveBlurKernel: number;
  15287. /**
  15288. * Define the blur kernel used to blur the reflection if needed.
  15289. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15290. */
  15291. blurKernel: number;
  15292. /**
  15293. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15294. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15295. */
  15296. blurKernelX: number;
  15297. /**
  15298. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15299. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15300. */
  15301. blurKernelY: number;
  15302. private _autoComputeBlurKernel;
  15303. protected _onRatioRescale(): void;
  15304. private _updateGammaSpace;
  15305. private _imageProcessingConfigChangeObserver;
  15306. private _transformMatrix;
  15307. private _mirrorMatrix;
  15308. private _savedViewMatrix;
  15309. private _blurX;
  15310. private _blurY;
  15311. private _adaptiveBlurKernel;
  15312. private _blurKernelX;
  15313. private _blurKernelY;
  15314. private _blurRatio;
  15315. /**
  15316. * Instantiates a Mirror Texture.
  15317. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15318. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15319. * You can then easily use it as a reflectionTexture on a flat surface.
  15320. * In case the surface is not a plane, please consider relying on reflection probes.
  15321. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15322. * @param name
  15323. * @param size
  15324. * @param scene
  15325. * @param generateMipMaps
  15326. * @param type
  15327. * @param samplingMode
  15328. * @param generateDepthBuffer
  15329. */
  15330. constructor(name: string, size: number | {
  15331. width: number;
  15332. height: number;
  15333. } | {
  15334. ratio: number;
  15335. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15336. private _preparePostProcesses;
  15337. /**
  15338. * Clone the mirror texture.
  15339. * @returns the cloned texture
  15340. */
  15341. clone(): MirrorTexture;
  15342. /**
  15343. * Serialize the texture to a JSON representation you could use in Parse later on
  15344. * @returns the serialized JSON representation
  15345. */
  15346. serialize(): any;
  15347. /**
  15348. * Dispose the texture and release its associated resources.
  15349. */
  15350. dispose(): void;
  15351. }
  15352. }
  15353. declare module BABYLON {
  15354. /**
  15355. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15356. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15357. */
  15358. export class Texture extends BaseTexture {
  15359. /**
  15360. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15361. */
  15362. static SerializeBuffers: boolean;
  15363. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15364. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15365. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15366. /** nearest is mag = nearest and min = nearest and mip = linear */
  15367. static readonly NEAREST_SAMPLINGMODE: number;
  15368. /** nearest is mag = nearest and min = nearest and mip = linear */
  15369. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15370. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15371. static readonly BILINEAR_SAMPLINGMODE: number;
  15372. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15373. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15374. /** Trilinear is mag = linear and min = linear and mip = linear */
  15375. static readonly TRILINEAR_SAMPLINGMODE: number;
  15376. /** Trilinear is mag = linear and min = linear and mip = linear */
  15377. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15378. /** mag = nearest and min = nearest and mip = nearest */
  15379. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15380. /** mag = nearest and min = linear and mip = nearest */
  15381. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15382. /** mag = nearest and min = linear and mip = linear */
  15383. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15384. /** mag = nearest and min = linear and mip = none */
  15385. static readonly NEAREST_LINEAR: number;
  15386. /** mag = nearest and min = nearest and mip = none */
  15387. static readonly NEAREST_NEAREST: number;
  15388. /** mag = linear and min = nearest and mip = nearest */
  15389. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15390. /** mag = linear and min = nearest and mip = linear */
  15391. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15392. /** mag = linear and min = linear and mip = none */
  15393. static readonly LINEAR_LINEAR: number;
  15394. /** mag = linear and min = nearest and mip = none */
  15395. static readonly LINEAR_NEAREST: number;
  15396. /** Explicit coordinates mode */
  15397. static readonly EXPLICIT_MODE: number;
  15398. /** Spherical coordinates mode */
  15399. static readonly SPHERICAL_MODE: number;
  15400. /** Planar coordinates mode */
  15401. static readonly PLANAR_MODE: number;
  15402. /** Cubic coordinates mode */
  15403. static readonly CUBIC_MODE: number;
  15404. /** Projection coordinates mode */
  15405. static readonly PROJECTION_MODE: number;
  15406. /** Inverse Cubic coordinates mode */
  15407. static readonly SKYBOX_MODE: number;
  15408. /** Inverse Cubic coordinates mode */
  15409. static readonly INVCUBIC_MODE: number;
  15410. /** Equirectangular coordinates mode */
  15411. static readonly EQUIRECTANGULAR_MODE: number;
  15412. /** Equirectangular Fixed coordinates mode */
  15413. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15414. /** Equirectangular Fixed Mirrored coordinates mode */
  15415. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15416. /** Texture is not repeating outside of 0..1 UVs */
  15417. static readonly CLAMP_ADDRESSMODE: number;
  15418. /** Texture is repeating outside of 0..1 UVs */
  15419. static readonly WRAP_ADDRESSMODE: number;
  15420. /** Texture is repeating and mirrored */
  15421. static readonly MIRROR_ADDRESSMODE: number;
  15422. /**
  15423. * 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
  15424. */
  15425. static UseSerializedUrlIfAny: boolean;
  15426. /**
  15427. * Define the url of the texture.
  15428. */
  15429. url: Nullable<string>;
  15430. /**
  15431. * Define an offset on the texture to offset the u coordinates of the UVs
  15432. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15433. */
  15434. uOffset: number;
  15435. /**
  15436. * Define an offset on the texture to offset the v coordinates of the UVs
  15437. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15438. */
  15439. vOffset: number;
  15440. /**
  15441. * Define an offset on the texture to scale the u coordinates of the UVs
  15442. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15443. */
  15444. uScale: number;
  15445. /**
  15446. * Define an offset on the texture to scale the v coordinates of the UVs
  15447. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15448. */
  15449. vScale: number;
  15450. /**
  15451. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15452. * @see http://doc.babylonjs.com/how_to/more_materials
  15453. */
  15454. uAng: number;
  15455. /**
  15456. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15457. * @see http://doc.babylonjs.com/how_to/more_materials
  15458. */
  15459. vAng: number;
  15460. /**
  15461. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15462. * @see http://doc.babylonjs.com/how_to/more_materials
  15463. */
  15464. wAng: number;
  15465. /**
  15466. * Defines the center of rotation (U)
  15467. */
  15468. uRotationCenter: number;
  15469. /**
  15470. * Defines the center of rotation (V)
  15471. */
  15472. vRotationCenter: number;
  15473. /**
  15474. * Defines the center of rotation (W)
  15475. */
  15476. wRotationCenter: number;
  15477. /**
  15478. * Are mip maps generated for this texture or not.
  15479. */
  15480. readonly noMipmap: boolean;
  15481. /**
  15482. * List of inspectable custom properties (used by the Inspector)
  15483. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15484. */
  15485. inspectableCustomProperties: Nullable<IInspectable[]>;
  15486. private _noMipmap;
  15487. /** @hidden */ private _invertY: boolean;
  15488. private _rowGenerationMatrix;
  15489. private _cachedTextureMatrix;
  15490. private _projectionModeMatrix;
  15491. private _t0;
  15492. private _t1;
  15493. private _t2;
  15494. private _cachedUOffset;
  15495. private _cachedVOffset;
  15496. private _cachedUScale;
  15497. private _cachedVScale;
  15498. private _cachedUAng;
  15499. private _cachedVAng;
  15500. private _cachedWAng;
  15501. private _cachedProjectionMatrixId;
  15502. private _cachedCoordinatesMode;
  15503. /** @hidden */
  15504. protected _initialSamplingMode: number;
  15505. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15506. private _deleteBuffer;
  15507. protected _format: Nullable<number>;
  15508. private _delayedOnLoad;
  15509. private _delayedOnError;
  15510. /**
  15511. * Observable triggered once the texture has been loaded.
  15512. */
  15513. onLoadObservable: Observable<Texture>;
  15514. protected _isBlocking: boolean;
  15515. /**
  15516. * Is the texture preventing material to render while loading.
  15517. * If false, a default texture will be used instead of the loading one during the preparation step.
  15518. */
  15519. isBlocking: boolean;
  15520. /**
  15521. * Get the current sampling mode associated with the texture.
  15522. */
  15523. readonly samplingMode: number;
  15524. /**
  15525. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15526. */
  15527. readonly invertY: boolean;
  15528. /**
  15529. * Instantiates a new texture.
  15530. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15531. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15532. * @param url define the url of the picture to load as a texture
  15533. * @param scene define the scene or engine the texture will belong to
  15534. * @param noMipmap define if the texture will require mip maps or not
  15535. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15536. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15537. * @param onLoad define a callback triggered when the texture has been loaded
  15538. * @param onError define a callback triggered when an error occurred during the loading session
  15539. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15540. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15541. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15542. */
  15543. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15544. /**
  15545. * Update the url (and optional buffer) of this texture if url was null during construction.
  15546. * @param url the url of the texture
  15547. * @param buffer the buffer of the texture (defaults to null)
  15548. * @param onLoad callback called when the texture is loaded (defaults to null)
  15549. */
  15550. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15551. /**
  15552. * Finish the loading sequence of a texture flagged as delayed load.
  15553. * @hidden
  15554. */
  15555. delayLoad(): void;
  15556. private _prepareRowForTextureGeneration;
  15557. /**
  15558. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15559. * @returns the transform matrix of the texture.
  15560. */
  15561. getTextureMatrix(): Matrix;
  15562. /**
  15563. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15564. * @returns The reflection texture transform
  15565. */
  15566. getReflectionTextureMatrix(): Matrix;
  15567. /**
  15568. * Clones the texture.
  15569. * @returns the cloned texture
  15570. */
  15571. clone(): Texture;
  15572. /**
  15573. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15574. * @returns The JSON representation of the texture
  15575. */
  15576. serialize(): any;
  15577. /**
  15578. * Get the current class name of the texture useful for serialization or dynamic coding.
  15579. * @returns "Texture"
  15580. */
  15581. getClassName(): string;
  15582. /**
  15583. * Dispose the texture and release its associated resources.
  15584. */
  15585. dispose(): void;
  15586. /**
  15587. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15588. * @param parsedTexture Define the JSON representation of the texture
  15589. * @param scene Define the scene the parsed texture should be instantiated in
  15590. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15591. * @returns The parsed texture if successful
  15592. */
  15593. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15594. /**
  15595. * Creates a texture from its base 64 representation.
  15596. * @param data Define the base64 payload without the data: prefix
  15597. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15598. * @param scene Define the scene the texture should belong to
  15599. * @param noMipmap Forces the texture to not create mip map information if true
  15600. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15601. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15602. * @param onLoad define a callback triggered when the texture has been loaded
  15603. * @param onError define a callback triggered when an error occurred during the loading session
  15604. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15605. * @returns the created texture
  15606. */
  15607. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15608. /**
  15609. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15610. * @param data Define the base64 payload without the data: prefix
  15611. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15612. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15613. * @param scene Define the scene the texture should belong to
  15614. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15615. * @param noMipmap Forces the texture to not create mip map information if true
  15616. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15617. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15618. * @param onLoad define a callback triggered when the texture has been loaded
  15619. * @param onError define a callback triggered when an error occurred during the loading session
  15620. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15621. * @returns the created texture
  15622. */
  15623. 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;
  15624. }
  15625. }
  15626. declare module BABYLON {
  15627. /**
  15628. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15629. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15630. */
  15631. export class PostProcessManager {
  15632. private _scene;
  15633. private _indexBuffer;
  15634. private _vertexBuffers;
  15635. /**
  15636. * Creates a new instance PostProcess
  15637. * @param scene The scene that the post process is associated with.
  15638. */
  15639. constructor(scene: Scene);
  15640. private _prepareBuffers;
  15641. private _buildIndexBuffer;
  15642. /**
  15643. * Rebuilds the vertex buffers of the manager.
  15644. * @hidden
  15645. */ private _rebuild(): void;
  15646. /**
  15647. * Prepares a frame to be run through a post process.
  15648. * @param sourceTexture The input texture to the post procesess. (default: null)
  15649. * @param postProcesses An array of post processes to be run. (default: null)
  15650. * @returns True if the post processes were able to be run.
  15651. * @hidden
  15652. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15653. /**
  15654. * Manually render a set of post processes to a texture.
  15655. * @param postProcesses An array of post processes to be run.
  15656. * @param targetTexture The target texture to render to.
  15657. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15658. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15659. * @param lodLevel defines which lod of the texture to render to
  15660. */
  15661. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15662. /**
  15663. * Finalize the result of the output of the postprocesses.
  15664. * @param doNotPresent If true the result will not be displayed to the screen.
  15665. * @param targetTexture The target texture to render to.
  15666. * @param faceIndex The index of the face to bind the target texture to.
  15667. * @param postProcesses The array of post processes to render.
  15668. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15669. * @hidden
  15670. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15671. /**
  15672. * Disposes of the post process manager.
  15673. */
  15674. dispose(): void;
  15675. }
  15676. }
  15677. declare module BABYLON {
  15678. /** Interface used by value gradients (color, factor, ...) */
  15679. export interface IValueGradient {
  15680. /**
  15681. * Gets or sets the gradient value (between 0 and 1)
  15682. */
  15683. gradient: number;
  15684. }
  15685. /** Class used to store color4 gradient */
  15686. export class ColorGradient implements IValueGradient {
  15687. /**
  15688. * Gets or sets the gradient value (between 0 and 1)
  15689. */
  15690. gradient: number;
  15691. /**
  15692. * Gets or sets first associated color
  15693. */
  15694. color1: Color4;
  15695. /**
  15696. * Gets or sets second associated color
  15697. */
  15698. color2?: Color4;
  15699. /**
  15700. * Will get a color picked randomly between color1 and color2.
  15701. * If color2 is undefined then color1 will be used
  15702. * @param result defines the target Color4 to store the result in
  15703. */
  15704. getColorToRef(result: Color4): void;
  15705. }
  15706. /** Class used to store color 3 gradient */
  15707. export class Color3Gradient implements IValueGradient {
  15708. /**
  15709. * Gets or sets the gradient value (between 0 and 1)
  15710. */
  15711. gradient: number;
  15712. /**
  15713. * Gets or sets the associated color
  15714. */
  15715. color: Color3;
  15716. }
  15717. /** Class used to store factor gradient */
  15718. export class FactorGradient implements IValueGradient {
  15719. /**
  15720. * Gets or sets the gradient value (between 0 and 1)
  15721. */
  15722. gradient: number;
  15723. /**
  15724. * Gets or sets first associated factor
  15725. */
  15726. factor1: number;
  15727. /**
  15728. * Gets or sets second associated factor
  15729. */
  15730. factor2?: number;
  15731. /**
  15732. * Will get a number picked randomly between factor1 and factor2.
  15733. * If factor2 is undefined then factor1 will be used
  15734. * @returns the picked number
  15735. */
  15736. getFactor(): number;
  15737. }
  15738. /**
  15739. * Helper used to simplify some generic gradient tasks
  15740. */
  15741. export class GradientHelper {
  15742. /**
  15743. * Gets the current gradient from an array of IValueGradient
  15744. * @param ratio defines the current ratio to get
  15745. * @param gradients defines the array of IValueGradient
  15746. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15747. */
  15748. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. interface AbstractScene {
  15753. /**
  15754. * The list of procedural textures added to the scene
  15755. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15756. */
  15757. proceduralTextures: Array<ProceduralTexture>;
  15758. }
  15759. /**
  15760. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15761. * in a given scene.
  15762. */
  15763. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15764. /**
  15765. * The component name helpfull to identify the component in the list of scene components.
  15766. */
  15767. readonly name: string;
  15768. /**
  15769. * The scene the component belongs to.
  15770. */
  15771. scene: Scene;
  15772. /**
  15773. * Creates a new instance of the component for the given scene
  15774. * @param scene Defines the scene to register the component in
  15775. */
  15776. constructor(scene: Scene);
  15777. /**
  15778. * Registers the component in a given scene
  15779. */
  15780. register(): void;
  15781. /**
  15782. * Rebuilds the elements related to this component in case of
  15783. * context lost for instance.
  15784. */
  15785. rebuild(): void;
  15786. /**
  15787. * Disposes the component and the associated ressources.
  15788. */
  15789. dispose(): void;
  15790. private _beforeClear;
  15791. }
  15792. }
  15793. declare module BABYLON {
  15794. interface Engine {
  15795. /**
  15796. * Creates a new render target cube texture
  15797. * @param size defines the size of the texture
  15798. * @param options defines the options used to create the texture
  15799. * @returns a new render target cube texture stored in an InternalTexture
  15800. */
  15801. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15802. }
  15803. }
  15804. declare module BABYLON {
  15805. /** @hidden */
  15806. export var proceduralVertexShader: {
  15807. name: string;
  15808. shader: string;
  15809. };
  15810. }
  15811. declare module BABYLON {
  15812. /**
  15813. * 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.
  15814. * This is the base class of any Procedural texture and contains most of the shareable code.
  15815. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15816. */
  15817. export class ProceduralTexture extends Texture {
  15818. isCube: boolean;
  15819. /**
  15820. * Define if the texture is enabled or not (disabled texture will not render)
  15821. */
  15822. isEnabled: boolean;
  15823. /**
  15824. * Define if the texture must be cleared before rendering (default is true)
  15825. */
  15826. autoClear: boolean;
  15827. /**
  15828. * Callback called when the texture is generated
  15829. */
  15830. onGenerated: () => void;
  15831. /**
  15832. * Event raised when the texture is generated
  15833. */
  15834. onGeneratedObservable: Observable<ProceduralTexture>;
  15835. /** @hidden */ private _generateMipMaps: boolean;
  15836. /** @hidden **/ private _effect: Effect;
  15837. /** @hidden */ private _textures: {
  15838. [key: string]: Texture;
  15839. };
  15840. private _size;
  15841. private _currentRefreshId;
  15842. private _refreshRate;
  15843. private _vertexBuffers;
  15844. private _indexBuffer;
  15845. private _uniforms;
  15846. private _samplers;
  15847. private _fragment;
  15848. private _floats;
  15849. private _ints;
  15850. private _floatsArrays;
  15851. private _colors3;
  15852. private _colors4;
  15853. private _vectors2;
  15854. private _vectors3;
  15855. private _matrices;
  15856. private _fallbackTexture;
  15857. private _fallbackTextureUsed;
  15858. private _engine;
  15859. private _cachedDefines;
  15860. private _contentUpdateId;
  15861. private _contentData;
  15862. /**
  15863. * Instantiates a new procedural texture.
  15864. * 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.
  15865. * This is the base class of any Procedural texture and contains most of the shareable code.
  15866. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15867. * @param name Define the name of the texture
  15868. * @param size Define the size of the texture to create
  15869. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15870. * @param scene Define the scene the texture belongs to
  15871. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15872. * @param generateMipMaps Define if the texture should creates mip maps or not
  15873. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15874. */
  15875. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15876. /**
  15877. * The effect that is created when initializing the post process.
  15878. * @returns The created effect corresponding the the postprocess.
  15879. */
  15880. getEffect(): Effect;
  15881. /**
  15882. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15883. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15884. */
  15885. getContent(): Nullable<ArrayBufferView>;
  15886. private _createIndexBuffer;
  15887. /** @hidden */ private _rebuild(): void;
  15888. /**
  15889. * Resets the texture in order to recreate its associated resources.
  15890. * This can be called in case of context loss
  15891. */
  15892. reset(): void;
  15893. protected _getDefines(): string;
  15894. /**
  15895. * Is the texture ready to be used ? (rendered at least once)
  15896. * @returns true if ready, otherwise, false.
  15897. */
  15898. isReady(): boolean;
  15899. /**
  15900. * Resets the refresh counter of the texture and start bak from scratch.
  15901. * Could be useful to regenerate the texture if it is setup to render only once.
  15902. */
  15903. resetRefreshCounter(): void;
  15904. /**
  15905. * Set the fragment shader to use in order to render the texture.
  15906. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15907. */
  15908. setFragment(fragment: any): void;
  15909. /**
  15910. * Define the refresh rate of the texture or the rendering frequency.
  15911. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15912. */
  15913. refreshRate: number;
  15914. /** @hidden */ private _shouldRender(): boolean;
  15915. /**
  15916. * Get the size the texture is rendering at.
  15917. * @returns the size (texture is always squared)
  15918. */
  15919. getRenderSize(): number;
  15920. /**
  15921. * Resize the texture to new value.
  15922. * @param size Define the new size the texture should have
  15923. * @param generateMipMaps Define whether the new texture should create mip maps
  15924. */
  15925. resize(size: number, generateMipMaps: boolean): void;
  15926. private _checkUniform;
  15927. /**
  15928. * Set a texture in the shader program used to render.
  15929. * @param name Define the name of the uniform samplers as defined in the shader
  15930. * @param texture Define the texture to bind to this sampler
  15931. * @return the texture itself allowing "fluent" like uniform updates
  15932. */
  15933. setTexture(name: string, texture: Texture): ProceduralTexture;
  15934. /**
  15935. * Set a float in the shader.
  15936. * @param name Define the name of the uniform as defined in the shader
  15937. * @param value Define the value to give to the uniform
  15938. * @return the texture itself allowing "fluent" like uniform updates
  15939. */
  15940. setFloat(name: string, value: number): ProceduralTexture;
  15941. /**
  15942. * Set a int in the shader.
  15943. * @param name Define the name of the uniform as defined in the shader
  15944. * @param value Define the value to give to the uniform
  15945. * @return the texture itself allowing "fluent" like uniform updates
  15946. */
  15947. setInt(name: string, value: number): ProceduralTexture;
  15948. /**
  15949. * Set an array of floats in the shader.
  15950. * @param name Define the name of the uniform as defined in the shader
  15951. * @param value Define the value to give to the uniform
  15952. * @return the texture itself allowing "fluent" like uniform updates
  15953. */
  15954. setFloats(name: string, value: number[]): ProceduralTexture;
  15955. /**
  15956. * Set a vec3 in the shader from a Color3.
  15957. * @param name Define the name of the uniform as defined in the shader
  15958. * @param value Define the value to give to the uniform
  15959. * @return the texture itself allowing "fluent" like uniform updates
  15960. */
  15961. setColor3(name: string, value: Color3): ProceduralTexture;
  15962. /**
  15963. * Set a vec4 in the shader from a Color4.
  15964. * @param name Define the name of the uniform as defined in the shader
  15965. * @param value Define the value to give to the uniform
  15966. * @return the texture itself allowing "fluent" like uniform updates
  15967. */
  15968. setColor4(name: string, value: Color4): ProceduralTexture;
  15969. /**
  15970. * Set a vec2 in the shader from a Vector2.
  15971. * @param name Define the name of the uniform as defined in the shader
  15972. * @param value Define the value to give to the uniform
  15973. * @return the texture itself allowing "fluent" like uniform updates
  15974. */
  15975. setVector2(name: string, value: Vector2): ProceduralTexture;
  15976. /**
  15977. * Set a vec3 in the shader from a Vector3.
  15978. * @param name Define the name of the uniform as defined in the shader
  15979. * @param value Define the value to give to the uniform
  15980. * @return the texture itself allowing "fluent" like uniform updates
  15981. */
  15982. setVector3(name: string, value: Vector3): ProceduralTexture;
  15983. /**
  15984. * Set a mat4 in the shader from a MAtrix.
  15985. * @param name Define the name of the uniform as defined in the shader
  15986. * @param value Define the value to give to the uniform
  15987. * @return the texture itself allowing "fluent" like uniform updates
  15988. */
  15989. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15990. /**
  15991. * Render the texture to its associated render target.
  15992. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15993. */
  15994. render(useCameraPostProcess?: boolean): void;
  15995. /**
  15996. * Clone the texture.
  15997. * @returns the cloned texture
  15998. */
  15999. clone(): ProceduralTexture;
  16000. /**
  16001. * Dispose the texture and release its asoociated resources.
  16002. */
  16003. dispose(): void;
  16004. }
  16005. }
  16006. declare module BABYLON {
  16007. /**
  16008. * This represents the base class for particle system in Babylon.
  16009. * 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.
  16010. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16011. * @example https://doc.babylonjs.com/babylon101/particles
  16012. */
  16013. export class BaseParticleSystem {
  16014. /**
  16015. * Source color is added to the destination color without alpha affecting the result
  16016. */
  16017. static BLENDMODE_ONEONE: number;
  16018. /**
  16019. * Blend current color and particle color using particle’s alpha
  16020. */
  16021. static BLENDMODE_STANDARD: number;
  16022. /**
  16023. * Add current color and particle color multiplied by particle’s alpha
  16024. */
  16025. static BLENDMODE_ADD: number;
  16026. /**
  16027. * Multiply current color with particle color
  16028. */
  16029. static BLENDMODE_MULTIPLY: number;
  16030. /**
  16031. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16032. */
  16033. static BLENDMODE_MULTIPLYADD: number;
  16034. /**
  16035. * List of animations used by the particle system.
  16036. */
  16037. animations: Animation[];
  16038. /**
  16039. * The id of the Particle system.
  16040. */
  16041. id: string;
  16042. /**
  16043. * The friendly name of the Particle system.
  16044. */
  16045. name: string;
  16046. /**
  16047. * The rendering group used by the Particle system to chose when to render.
  16048. */
  16049. renderingGroupId: number;
  16050. /**
  16051. * The emitter represents the Mesh or position we are attaching the particle system to.
  16052. */
  16053. emitter: Nullable<AbstractMesh | Vector3>;
  16054. /**
  16055. * The maximum number of particles to emit per frame
  16056. */
  16057. emitRate: number;
  16058. /**
  16059. * If you want to launch only a few particles at once, that can be done, as well.
  16060. */
  16061. manualEmitCount: number;
  16062. /**
  16063. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16064. */
  16065. updateSpeed: number;
  16066. /**
  16067. * The amount of time the particle system is running (depends of the overall update speed).
  16068. */
  16069. targetStopDuration: number;
  16070. /**
  16071. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16072. */
  16073. disposeOnStop: boolean;
  16074. /**
  16075. * Minimum power of emitting particles.
  16076. */
  16077. minEmitPower: number;
  16078. /**
  16079. * Maximum power of emitting particles.
  16080. */
  16081. maxEmitPower: number;
  16082. /**
  16083. * Minimum life time of emitting particles.
  16084. */
  16085. minLifeTime: number;
  16086. /**
  16087. * Maximum life time of emitting particles.
  16088. */
  16089. maxLifeTime: number;
  16090. /**
  16091. * Minimum Size of emitting particles.
  16092. */
  16093. minSize: number;
  16094. /**
  16095. * Maximum Size of emitting particles.
  16096. */
  16097. maxSize: number;
  16098. /**
  16099. * Minimum scale of emitting particles on X axis.
  16100. */
  16101. minScaleX: number;
  16102. /**
  16103. * Maximum scale of emitting particles on X axis.
  16104. */
  16105. maxScaleX: number;
  16106. /**
  16107. * Minimum scale of emitting particles on Y axis.
  16108. */
  16109. minScaleY: number;
  16110. /**
  16111. * Maximum scale of emitting particles on Y axis.
  16112. */
  16113. maxScaleY: number;
  16114. /**
  16115. * Gets or sets the minimal initial rotation in radians.
  16116. */
  16117. minInitialRotation: number;
  16118. /**
  16119. * Gets or sets the maximal initial rotation in radians.
  16120. */
  16121. maxInitialRotation: number;
  16122. /**
  16123. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16124. */
  16125. minAngularSpeed: number;
  16126. /**
  16127. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16128. */
  16129. maxAngularSpeed: number;
  16130. /**
  16131. * The texture used to render each particle. (this can be a spritesheet)
  16132. */
  16133. particleTexture: Nullable<Texture>;
  16134. /**
  16135. * The layer mask we are rendering the particles through.
  16136. */
  16137. layerMask: number;
  16138. /**
  16139. * This can help using your own shader to render the particle system.
  16140. * The according effect will be created
  16141. */
  16142. customShader: any;
  16143. /**
  16144. * By default particle system starts as soon as they are created. This prevents the
  16145. * automatic start to happen and let you decide when to start emitting particles.
  16146. */
  16147. preventAutoStart: boolean;
  16148. private _noiseTexture;
  16149. /**
  16150. * Gets or sets a texture used to add random noise to particle positions
  16151. */
  16152. noiseTexture: Nullable<ProceduralTexture>;
  16153. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16154. noiseStrength: Vector3;
  16155. /**
  16156. * Callback triggered when the particle animation is ending.
  16157. */
  16158. onAnimationEnd: Nullable<() => void>;
  16159. /**
  16160. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16161. */
  16162. blendMode: number;
  16163. /**
  16164. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16165. * to override the particles.
  16166. */
  16167. forceDepthWrite: boolean;
  16168. /** 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 */
  16169. preWarmCycles: number;
  16170. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16171. preWarmStepOffset: number;
  16172. /**
  16173. * 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)
  16174. */
  16175. spriteCellChangeSpeed: number;
  16176. /**
  16177. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16178. */
  16179. startSpriteCellID: number;
  16180. /**
  16181. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16182. */
  16183. endSpriteCellID: number;
  16184. /**
  16185. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16186. */
  16187. spriteCellWidth: number;
  16188. /**
  16189. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16190. */
  16191. spriteCellHeight: number;
  16192. /**
  16193. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16194. */
  16195. spriteRandomStartCell: boolean;
  16196. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16197. translationPivot: Vector2;
  16198. /** @hidden */
  16199. protected _isAnimationSheetEnabled: boolean;
  16200. /**
  16201. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16202. */
  16203. beginAnimationOnStart: boolean;
  16204. /**
  16205. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16206. */
  16207. beginAnimationFrom: number;
  16208. /**
  16209. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16210. */
  16211. beginAnimationTo: number;
  16212. /**
  16213. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16214. */
  16215. beginAnimationLoop: boolean;
  16216. /**
  16217. * Gets or sets a world offset applied to all particles
  16218. */
  16219. worldOffset: Vector3;
  16220. /**
  16221. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16222. */
  16223. isAnimationSheetEnabled: boolean;
  16224. /**
  16225. * Get hosting scene
  16226. * @returns the scene
  16227. */
  16228. getScene(): Scene;
  16229. /**
  16230. * You can use gravity if you want to give an orientation to your particles.
  16231. */
  16232. gravity: Vector3;
  16233. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16234. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16235. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16236. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16237. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16238. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16239. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16240. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16241. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16242. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16243. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16244. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16245. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16246. /**
  16247. * Defines the delay in milliseconds before starting the system (0 by default)
  16248. */
  16249. startDelay: number;
  16250. /**
  16251. * Gets the current list of drag gradients.
  16252. * You must use addDragGradient and removeDragGradient to udpate this list
  16253. * @returns the list of drag gradients
  16254. */
  16255. getDragGradients(): Nullable<Array<FactorGradient>>;
  16256. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16257. limitVelocityDamping: number;
  16258. /**
  16259. * Gets the current list of limit velocity gradients.
  16260. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16261. * @returns the list of limit velocity gradients
  16262. */
  16263. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16264. /**
  16265. * Gets the current list of color gradients.
  16266. * You must use addColorGradient and removeColorGradient to udpate this list
  16267. * @returns the list of color gradients
  16268. */
  16269. getColorGradients(): Nullable<Array<ColorGradient>>;
  16270. /**
  16271. * Gets the current list of size gradients.
  16272. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16273. * @returns the list of size gradients
  16274. */
  16275. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16276. /**
  16277. * Gets the current list of color remap gradients.
  16278. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16279. * @returns the list of color remap gradients
  16280. */
  16281. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16282. /**
  16283. * Gets the current list of alpha remap gradients.
  16284. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16285. * @returns the list of alpha remap gradients
  16286. */
  16287. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16288. /**
  16289. * Gets the current list of life time gradients.
  16290. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16291. * @returns the list of life time gradients
  16292. */
  16293. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16294. /**
  16295. * Gets the current list of angular speed gradients.
  16296. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16297. * @returns the list of angular speed gradients
  16298. */
  16299. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16300. /**
  16301. * Gets the current list of velocity gradients.
  16302. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16303. * @returns the list of velocity gradients
  16304. */
  16305. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16306. /**
  16307. * Gets the current list of start size gradients.
  16308. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16309. * @returns the list of start size gradients
  16310. */
  16311. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16312. /**
  16313. * Gets the current list of emit rate gradients.
  16314. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16315. * @returns the list of emit rate gradients
  16316. */
  16317. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16318. /**
  16319. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16320. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16321. */
  16322. direction1: Vector3;
  16323. /**
  16324. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16325. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16326. */
  16327. direction2: Vector3;
  16328. /**
  16329. * 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.
  16330. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16331. */
  16332. minEmitBox: Vector3;
  16333. /**
  16334. * 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.
  16335. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16336. */
  16337. maxEmitBox: Vector3;
  16338. /**
  16339. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16340. */
  16341. color1: Color4;
  16342. /**
  16343. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16344. */
  16345. color2: Color4;
  16346. /**
  16347. * Color the particle will have at the end of its lifetime
  16348. */
  16349. colorDead: Color4;
  16350. /**
  16351. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16352. */
  16353. textureMask: Color4;
  16354. /**
  16355. * The particle emitter type defines the emitter used by the particle system.
  16356. * It can be for example box, sphere, or cone...
  16357. */
  16358. particleEmitterType: IParticleEmitterType;
  16359. /** @hidden */ private _isSubEmitter: boolean;
  16360. /**
  16361. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16362. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16363. */
  16364. billboardMode: number;
  16365. protected _isBillboardBased: boolean;
  16366. /**
  16367. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16368. */
  16369. isBillboardBased: boolean;
  16370. /**
  16371. * The scene the particle system belongs to.
  16372. */
  16373. protected _scene: Scene;
  16374. /**
  16375. * Local cache of defines for image processing.
  16376. */
  16377. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16378. /**
  16379. * Default configuration related to image processing available in the standard Material.
  16380. */
  16381. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16382. /**
  16383. * Gets the image processing configuration used either in this material.
  16384. */
  16385. /**
  16386. * Sets the Default image processing configuration used either in the this material.
  16387. *
  16388. * If sets to null, the scene one is in use.
  16389. */
  16390. imageProcessingConfiguration: ImageProcessingConfiguration;
  16391. /**
  16392. * Attaches a new image processing configuration to the Standard Material.
  16393. * @param configuration
  16394. */
  16395. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16396. /** @hidden */
  16397. protected _reset(): void;
  16398. /** @hidden */
  16399. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16400. /**
  16401. * Instantiates a particle system.
  16402. * 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.
  16403. * @param name The name of the particle system
  16404. */
  16405. constructor(name: string);
  16406. /**
  16407. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16410. * @returns the emitter
  16411. */
  16412. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16413. /**
  16414. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16415. * @param radius The radius of the hemisphere to emit from
  16416. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16417. * @returns the emitter
  16418. */
  16419. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16420. /**
  16421. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16422. * @param radius The radius of the sphere to emit from
  16423. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16424. * @returns the emitter
  16425. */
  16426. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16427. /**
  16428. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16429. * @param radius The radius of the sphere to emit from
  16430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16432. * @returns the emitter
  16433. */
  16434. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16435. /**
  16436. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16437. * @param radius The radius of the emission cylinder
  16438. * @param height The height of the emission cylinder
  16439. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16440. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16441. * @returns the emitter
  16442. */
  16443. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16444. /**
  16445. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16446. * @param radius The radius of the cylinder to emit from
  16447. * @param height The height of the emission cylinder
  16448. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16451. * @returns the emitter
  16452. */
  16453. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16454. /**
  16455. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16456. * @param radius The radius of the cone to emit from
  16457. * @param angle The base angle of the cone
  16458. * @returns the emitter
  16459. */
  16460. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16461. /**
  16462. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16465. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16466. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16467. * @returns the emitter
  16468. */
  16469. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16470. }
  16471. }
  16472. declare module BABYLON {
  16473. /**
  16474. * Type of sub emitter
  16475. */
  16476. export enum SubEmitterType {
  16477. /**
  16478. * Attached to the particle over it's lifetime
  16479. */
  16480. ATTACHED = 0,
  16481. /**
  16482. * Created when the particle dies
  16483. */
  16484. END = 1
  16485. }
  16486. /**
  16487. * Sub emitter class used to emit particles from an existing particle
  16488. */
  16489. export class SubEmitter {
  16490. /**
  16491. * the particle system to be used by the sub emitter
  16492. */
  16493. particleSystem: ParticleSystem;
  16494. /**
  16495. * Type of the submitter (Default: END)
  16496. */
  16497. type: SubEmitterType;
  16498. /**
  16499. * 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)
  16500. * Note: This only is supported when using an emitter of type Mesh
  16501. */
  16502. inheritDirection: boolean;
  16503. /**
  16504. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16505. */
  16506. inheritedVelocityAmount: number;
  16507. /**
  16508. * Creates a sub emitter
  16509. * @param particleSystem the particle system to be used by the sub emitter
  16510. */
  16511. constructor(
  16512. /**
  16513. * the particle system to be used by the sub emitter
  16514. */
  16515. particleSystem: ParticleSystem);
  16516. /**
  16517. * Clones the sub emitter
  16518. * @returns the cloned sub emitter
  16519. */
  16520. clone(): SubEmitter;
  16521. /**
  16522. * Serialize current object to a JSON object
  16523. * @returns the serialized object
  16524. */
  16525. serialize(): any;
  16526. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16527. /**
  16528. * Creates a new SubEmitter from a serialized JSON version
  16529. * @param serializationObject defines the JSON object to read from
  16530. * @param scene defines the hosting scene
  16531. * @param rootUrl defines the rootUrl for data loading
  16532. * @returns a new SubEmitter
  16533. */
  16534. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16535. /** Release associated resources */
  16536. dispose(): void;
  16537. }
  16538. }
  16539. declare module BABYLON {
  16540. /** @hidden */
  16541. export var clipPlaneFragmentDeclaration: {
  16542. name: string;
  16543. shader: string;
  16544. };
  16545. }
  16546. declare module BABYLON {
  16547. /** @hidden */
  16548. export var imageProcessingDeclaration: {
  16549. name: string;
  16550. shader: string;
  16551. };
  16552. }
  16553. declare module BABYLON {
  16554. /** @hidden */
  16555. export var imageProcessingFunctions: {
  16556. name: string;
  16557. shader: string;
  16558. };
  16559. }
  16560. declare module BABYLON {
  16561. /** @hidden */
  16562. export var clipPlaneFragment: {
  16563. name: string;
  16564. shader: string;
  16565. };
  16566. }
  16567. declare module BABYLON {
  16568. /** @hidden */
  16569. export var particlesPixelShader: {
  16570. name: string;
  16571. shader: string;
  16572. };
  16573. }
  16574. declare module BABYLON {
  16575. /** @hidden */
  16576. export var clipPlaneVertexDeclaration: {
  16577. name: string;
  16578. shader: string;
  16579. };
  16580. }
  16581. declare module BABYLON {
  16582. /** @hidden */
  16583. export var clipPlaneVertex: {
  16584. name: string;
  16585. shader: string;
  16586. };
  16587. }
  16588. declare module BABYLON {
  16589. /** @hidden */
  16590. export var particlesVertexShader: {
  16591. name: string;
  16592. shader: string;
  16593. };
  16594. }
  16595. declare module BABYLON {
  16596. /**
  16597. * This represents a particle system in Babylon.
  16598. * 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.
  16599. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16600. * @example https://doc.babylonjs.com/babylon101/particles
  16601. */
  16602. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16603. /**
  16604. * Billboard mode will only apply to Y axis
  16605. */
  16606. static readonly BILLBOARDMODE_Y: number;
  16607. /**
  16608. * Billboard mode will apply to all axes
  16609. */
  16610. static readonly BILLBOARDMODE_ALL: number;
  16611. /**
  16612. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16613. */
  16614. static readonly BILLBOARDMODE_STRETCHED: number;
  16615. /**
  16616. * This function can be defined to provide custom update for active particles.
  16617. * This function will be called instead of regular update (age, position, color, etc.).
  16618. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16619. */
  16620. updateFunction: (particles: Particle[]) => void;
  16621. private _emitterWorldMatrix;
  16622. /**
  16623. * This function can be defined to specify initial direction for every new particle.
  16624. * It by default use the emitterType defined function
  16625. */
  16626. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16627. /**
  16628. * This function can be defined to specify initial position for every new particle.
  16629. * It by default use the emitterType defined function
  16630. */
  16631. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16632. /**
  16633. * @hidden
  16634. */ private _inheritedVelocityOffset: Vector3;
  16635. /**
  16636. * An event triggered when the system is disposed
  16637. */
  16638. onDisposeObservable: Observable<ParticleSystem>;
  16639. private _onDisposeObserver;
  16640. /**
  16641. * Sets a callback that will be triggered when the system is disposed
  16642. */
  16643. onDispose: () => void;
  16644. private _particles;
  16645. private _epsilon;
  16646. private _capacity;
  16647. private _stockParticles;
  16648. private _newPartsExcess;
  16649. private _vertexData;
  16650. private _vertexBuffer;
  16651. private _vertexBuffers;
  16652. private _spriteBuffer;
  16653. private _indexBuffer;
  16654. private _effect;
  16655. private _customEffect;
  16656. private _cachedDefines;
  16657. private _scaledColorStep;
  16658. private _colorDiff;
  16659. private _scaledDirection;
  16660. private _scaledGravity;
  16661. private _currentRenderId;
  16662. private _alive;
  16663. private _useInstancing;
  16664. private _started;
  16665. private _stopped;
  16666. private _actualFrame;
  16667. private _scaledUpdateSpeed;
  16668. private _vertexBufferSize;
  16669. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16670. /** @hidden */ private _currentEmitRate1: number;
  16671. /** @hidden */ private _currentEmitRate2: number;
  16672. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16673. /** @hidden */ private _currentStartSize1: number;
  16674. /** @hidden */ private _currentStartSize2: number;
  16675. private readonly _rawTextureWidth;
  16676. private _rampGradientsTexture;
  16677. private _useRampGradients;
  16678. /** Gets or sets a boolean indicating that ramp gradients must be used
  16679. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16680. */
  16681. useRampGradients: boolean;
  16682. /**
  16683. * 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.
  16684. * 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: [])
  16685. */
  16686. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16687. private _subEmitters;
  16688. /**
  16689. * @hidden
  16690. * If the particle systems emitter should be disposed when the particle system is disposed
  16691. */ private _disposeEmitterOnDispose: boolean;
  16692. /**
  16693. * The current active Sub-systems, this property is used by the root particle system only.
  16694. */
  16695. activeSubSystems: Array<ParticleSystem>;
  16696. private _rootParticleSystem;
  16697. /**
  16698. * Gets the current list of active particles
  16699. */
  16700. readonly particles: Particle[];
  16701. /**
  16702. * Returns the string "ParticleSystem"
  16703. * @returns a string containing the class name
  16704. */
  16705. getClassName(): string;
  16706. /**
  16707. * Instantiates a particle system.
  16708. * 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.
  16709. * @param name The name of the particle system
  16710. * @param capacity The max number of particles alive at the same time
  16711. * @param scene The scene the particle system belongs to
  16712. * @param customEffect a custom effect used to change the way particles are rendered by default
  16713. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16714. * @param epsilon Offset used to render the particles
  16715. */
  16716. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16717. private _addFactorGradient;
  16718. private _removeFactorGradient;
  16719. /**
  16720. * Adds a new life time gradient
  16721. * @param gradient defines the gradient to use (between 0 and 1)
  16722. * @param factor defines the life time factor to affect to the specified gradient
  16723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16724. * @returns the current particle system
  16725. */
  16726. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16727. /**
  16728. * Remove a specific life time gradient
  16729. * @param gradient defines the gradient to remove
  16730. * @returns the current particle system
  16731. */
  16732. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16733. /**
  16734. * Adds a new size gradient
  16735. * @param gradient defines the gradient to use (between 0 and 1)
  16736. * @param factor defines the size factor to affect to the specified gradient
  16737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16738. * @returns the current particle system
  16739. */
  16740. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16741. /**
  16742. * Remove a specific size gradient
  16743. * @param gradient defines the gradient to remove
  16744. * @returns the current particle system
  16745. */
  16746. removeSizeGradient(gradient: number): IParticleSystem;
  16747. /**
  16748. * Adds a new color remap gradient
  16749. * @param gradient defines the gradient to use (between 0 and 1)
  16750. * @param min defines the color remap minimal range
  16751. * @param max defines the color remap maximal range
  16752. * @returns the current particle system
  16753. */
  16754. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16755. /**
  16756. * Remove a specific color remap gradient
  16757. * @param gradient defines the gradient to remove
  16758. * @returns the current particle system
  16759. */
  16760. removeColorRemapGradient(gradient: number): IParticleSystem;
  16761. /**
  16762. * Adds a new alpha remap gradient
  16763. * @param gradient defines the gradient to use (between 0 and 1)
  16764. * @param min defines the alpha remap minimal range
  16765. * @param max defines the alpha remap maximal range
  16766. * @returns the current particle system
  16767. */
  16768. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16769. /**
  16770. * Remove a specific alpha remap gradient
  16771. * @param gradient defines the gradient to remove
  16772. * @returns the current particle system
  16773. */
  16774. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16775. /**
  16776. * Adds a new angular speed gradient
  16777. * @param gradient defines the gradient to use (between 0 and 1)
  16778. * @param factor defines the angular speed to affect to the specified gradient
  16779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16780. * @returns the current particle system
  16781. */
  16782. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16783. /**
  16784. * Remove a specific angular speed gradient
  16785. * @param gradient defines the gradient to remove
  16786. * @returns the current particle system
  16787. */
  16788. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16789. /**
  16790. * Adds a new velocity gradient
  16791. * @param gradient defines the gradient to use (between 0 and 1)
  16792. * @param factor defines the velocity to affect to the specified gradient
  16793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16794. * @returns the current particle system
  16795. */
  16796. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16797. /**
  16798. * Remove a specific velocity gradient
  16799. * @param gradient defines the gradient to remove
  16800. * @returns the current particle system
  16801. */
  16802. removeVelocityGradient(gradient: number): IParticleSystem;
  16803. /**
  16804. * Adds a new limit velocity gradient
  16805. * @param gradient defines the gradient to use (between 0 and 1)
  16806. * @param factor defines the limit velocity value to affect to the specified gradient
  16807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16808. * @returns the current particle system
  16809. */
  16810. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16811. /**
  16812. * Remove a specific limit velocity gradient
  16813. * @param gradient defines the gradient to remove
  16814. * @returns the current particle system
  16815. */
  16816. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16817. /**
  16818. * Adds a new drag gradient
  16819. * @param gradient defines the gradient to use (between 0 and 1)
  16820. * @param factor defines the drag value to affect to the specified gradient
  16821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16822. * @returns the current particle system
  16823. */
  16824. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16825. /**
  16826. * Remove a specific drag gradient
  16827. * @param gradient defines the gradient to remove
  16828. * @returns the current particle system
  16829. */
  16830. removeDragGradient(gradient: number): IParticleSystem;
  16831. /**
  16832. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16833. * @param gradient defines the gradient to use (between 0 and 1)
  16834. * @param factor defines the emit rate value to affect to the specified gradient
  16835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16836. * @returns the current particle system
  16837. */
  16838. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16839. /**
  16840. * Remove a specific emit rate gradient
  16841. * @param gradient defines the gradient to remove
  16842. * @returns the current particle system
  16843. */
  16844. removeEmitRateGradient(gradient: number): IParticleSystem;
  16845. /**
  16846. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16847. * @param gradient defines the gradient to use (between 0 and 1)
  16848. * @param factor defines the start size value to affect to the specified gradient
  16849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16850. * @returns the current particle system
  16851. */
  16852. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16853. /**
  16854. * Remove a specific start size gradient
  16855. * @param gradient defines the gradient to remove
  16856. * @returns the current particle system
  16857. */
  16858. removeStartSizeGradient(gradient: number): IParticleSystem;
  16859. private _createRampGradientTexture;
  16860. /**
  16861. * Gets the current list of ramp gradients.
  16862. * You must use addRampGradient and removeRampGradient to udpate this list
  16863. * @returns the list of ramp gradients
  16864. */
  16865. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16866. /**
  16867. * Adds a new ramp gradient used to remap particle colors
  16868. * @param gradient defines the gradient to use (between 0 and 1)
  16869. * @param color defines the color to affect to the specified gradient
  16870. * @returns the current particle system
  16871. */
  16872. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16873. /**
  16874. * Remove a specific ramp gradient
  16875. * @param gradient defines the gradient to remove
  16876. * @returns the current particle system
  16877. */
  16878. removeRampGradient(gradient: number): ParticleSystem;
  16879. /**
  16880. * Adds a new color gradient
  16881. * @param gradient defines the gradient to use (between 0 and 1)
  16882. * @param color1 defines the color to affect to the specified gradient
  16883. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16884. * @returns this particle system
  16885. */
  16886. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16887. /**
  16888. * Remove a specific color gradient
  16889. * @param gradient defines the gradient to remove
  16890. * @returns this particle system
  16891. */
  16892. removeColorGradient(gradient: number): IParticleSystem;
  16893. private _fetchR;
  16894. protected _reset(): void;
  16895. private _resetEffect;
  16896. private _createVertexBuffers;
  16897. private _createIndexBuffer;
  16898. /**
  16899. * Gets the maximum number of particles active at the same time.
  16900. * @returns The max number of active particles.
  16901. */
  16902. getCapacity(): number;
  16903. /**
  16904. * Gets whether there are still active particles in the system.
  16905. * @returns True if it is alive, otherwise false.
  16906. */
  16907. isAlive(): boolean;
  16908. /**
  16909. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16910. * @returns True if it has been started, otherwise false.
  16911. */
  16912. isStarted(): boolean;
  16913. private _prepareSubEmitterInternalArray;
  16914. /**
  16915. * Starts the particle system and begins to emit
  16916. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16917. */
  16918. start(delay?: number): void;
  16919. /**
  16920. * Stops the particle system.
  16921. * @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.
  16922. */
  16923. stop(stopSubEmitters?: boolean): void;
  16924. /**
  16925. * Remove all active particles
  16926. */
  16927. reset(): void;
  16928. /**
  16929. * @hidden (for internal use only)
  16930. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16931. /**
  16932. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16933. * Its lifetime will start back at 0.
  16934. */
  16935. recycleParticle: (particle: Particle) => void;
  16936. private _stopSubEmitters;
  16937. private _createParticle;
  16938. private _removeFromRoot;
  16939. private _emitFromParticle;
  16940. private _update;
  16941. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16942. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16943. /** @hidden */
  16944. private _getEffect;
  16945. /**
  16946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16947. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16948. */
  16949. animate(preWarmOnly?: boolean): void;
  16950. private _appendParticleVertices;
  16951. /**
  16952. * Rebuilds the particle system.
  16953. */
  16954. rebuild(): void;
  16955. /**
  16956. * Is this system ready to be used/rendered
  16957. * @return true if the system is ready
  16958. */
  16959. isReady(): boolean;
  16960. private _render;
  16961. /**
  16962. * Renders the particle system in its current state.
  16963. * @returns the current number of particles
  16964. */
  16965. render(): number;
  16966. /**
  16967. * Disposes the particle system and free the associated resources
  16968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16969. */
  16970. dispose(disposeTexture?: boolean): void;
  16971. /**
  16972. * Clones the particle system.
  16973. * @param name The name of the cloned object
  16974. * @param newEmitter The new emitter to use
  16975. * @returns the cloned particle system
  16976. */
  16977. clone(name: string, newEmitter: any): ParticleSystem;
  16978. /**
  16979. * Serializes the particle system to a JSON object.
  16980. * @returns the JSON object
  16981. */
  16982. serialize(): any;
  16983. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  16984. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  16985. /**
  16986. * Parses a JSON object to create a particle system.
  16987. * @param parsedParticleSystem The JSON object to parse
  16988. * @param scene The scene to create the particle system in
  16989. * @param rootUrl The root url to use to load external dependencies like texture
  16990. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16991. * @returns the Parsed particle system
  16992. */
  16993. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16994. }
  16995. }
  16996. declare module BABYLON {
  16997. /**
  16998. * A particle represents one of the element emitted by a particle system.
  16999. * This is mainly define by its coordinates, direction, velocity and age.
  17000. */
  17001. export class Particle {
  17002. /**
  17003. * The particle system the particle belongs to.
  17004. */
  17005. particleSystem: ParticleSystem;
  17006. private static _Count;
  17007. /**
  17008. * Unique ID of the particle
  17009. */
  17010. id: number;
  17011. /**
  17012. * The world position of the particle in the scene.
  17013. */
  17014. position: Vector3;
  17015. /**
  17016. * The world direction of the particle in the scene.
  17017. */
  17018. direction: Vector3;
  17019. /**
  17020. * The color of the particle.
  17021. */
  17022. color: Color4;
  17023. /**
  17024. * The color change of the particle per step.
  17025. */
  17026. colorStep: Color4;
  17027. /**
  17028. * Defines how long will the life of the particle be.
  17029. */
  17030. lifeTime: number;
  17031. /**
  17032. * The current age of the particle.
  17033. */
  17034. age: number;
  17035. /**
  17036. * The current size of the particle.
  17037. */
  17038. size: number;
  17039. /**
  17040. * The current scale of the particle.
  17041. */
  17042. scale: Vector2;
  17043. /**
  17044. * The current angle of the particle.
  17045. */
  17046. angle: number;
  17047. /**
  17048. * Defines how fast is the angle changing.
  17049. */
  17050. angularSpeed: number;
  17051. /**
  17052. * Defines the cell index used by the particle to be rendered from a sprite.
  17053. */
  17054. cellIndex: number;
  17055. /**
  17056. * The information required to support color remapping
  17057. */
  17058. remapData: Vector4;
  17059. /** @hidden */ private _randomCellOffset?: number;
  17060. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17061. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17062. /** @hidden */ private _initialStartSpriteCellID: number;
  17063. /** @hidden */ private _initialEndSpriteCellID: number;
  17064. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17065. /** @hidden */ private _currentColor1: Color4;
  17066. /** @hidden */ private _currentColor2: Color4;
  17067. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17068. /** @hidden */ private _currentSize1: number;
  17069. /** @hidden */ private _currentSize2: number;
  17070. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17071. /** @hidden */ private _currentAngularSpeed1: number;
  17072. /** @hidden */ private _currentAngularSpeed2: number;
  17073. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17074. /** @hidden */ private _currentVelocity1: number;
  17075. /** @hidden */ private _currentVelocity2: number;
  17076. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17077. /** @hidden */ private _currentLimitVelocity1: number;
  17078. /** @hidden */ private _currentLimitVelocity2: number;
  17079. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17080. /** @hidden */ private _currentDrag1: number;
  17081. /** @hidden */ private _currentDrag2: number;
  17082. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17083. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17084. /**
  17085. * Creates a new instance Particle
  17086. * @param particleSystem the particle system the particle belongs to
  17087. */
  17088. constructor(
  17089. /**
  17090. * The particle system the particle belongs to.
  17091. */
  17092. particleSystem: ParticleSystem);
  17093. private updateCellInfoFromSystem;
  17094. /**
  17095. * Defines how the sprite cell index is updated for the particle
  17096. */
  17097. updateCellIndex(): void;
  17098. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17099. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17100. /** @hidden */ private _reset(): void;
  17101. /**
  17102. * Copy the properties of particle to another one.
  17103. * @param other the particle to copy the information to.
  17104. */
  17105. copyTo(other: Particle): void;
  17106. }
  17107. }
  17108. declare module BABYLON {
  17109. /**
  17110. * Particle emitter represents a volume emitting particles.
  17111. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17112. */
  17113. export interface IParticleEmitterType {
  17114. /**
  17115. * Called by the particle System when the direction is computed for the created particle.
  17116. * @param worldMatrix is the world matrix of the particle system
  17117. * @param directionToUpdate is the direction vector to update with the result
  17118. * @param particle is the particle we are computed the direction for
  17119. */
  17120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17121. /**
  17122. * Called by the particle System when the position is computed for the created particle.
  17123. * @param worldMatrix is the world matrix of the particle system
  17124. * @param positionToUpdate is the position vector to update with the result
  17125. * @param particle is the particle we are computed the position for
  17126. */
  17127. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17128. /**
  17129. * Clones the current emitter and returns a copy of it
  17130. * @returns the new emitter
  17131. */
  17132. clone(): IParticleEmitterType;
  17133. /**
  17134. * Called by the GPUParticleSystem to setup the update shader
  17135. * @param effect defines the update shader
  17136. */
  17137. applyToShader(effect: Effect): void;
  17138. /**
  17139. * Returns a string to use to update the GPU particles update shader
  17140. * @returns the effect defines string
  17141. */
  17142. getEffectDefines(): string;
  17143. /**
  17144. * Returns a string representing the class name
  17145. * @returns a string containing the class name
  17146. */
  17147. getClassName(): string;
  17148. /**
  17149. * Serializes the particle system to a JSON object.
  17150. * @returns the JSON object
  17151. */
  17152. serialize(): any;
  17153. /**
  17154. * Parse properties from a JSON object
  17155. * @param serializationObject defines the JSON object
  17156. */
  17157. parse(serializationObject: any): void;
  17158. }
  17159. }
  17160. declare module BABYLON {
  17161. /**
  17162. * Particle emitter emitting particles from the inside of a box.
  17163. * It emits the particles randomly between 2 given directions.
  17164. */
  17165. export class BoxParticleEmitter implements IParticleEmitterType {
  17166. /**
  17167. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17168. */
  17169. direction1: Vector3;
  17170. /**
  17171. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17172. */
  17173. direction2: Vector3;
  17174. /**
  17175. * 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.
  17176. */
  17177. minEmitBox: Vector3;
  17178. /**
  17179. * 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.
  17180. */
  17181. maxEmitBox: Vector3;
  17182. /**
  17183. * Creates a new instance BoxParticleEmitter
  17184. */
  17185. constructor();
  17186. /**
  17187. * Called by the particle System when the direction is computed for the created particle.
  17188. * @param worldMatrix is the world matrix of the particle system
  17189. * @param directionToUpdate is the direction vector to update with the result
  17190. * @param particle is the particle we are computed the direction for
  17191. */
  17192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17193. /**
  17194. * Called by the particle System when the position is computed for the created particle.
  17195. * @param worldMatrix is the world matrix of the particle system
  17196. * @param positionToUpdate is the position vector to update with the result
  17197. * @param particle is the particle we are computed the position for
  17198. */
  17199. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17200. /**
  17201. * Clones the current emitter and returns a copy of it
  17202. * @returns the new emitter
  17203. */
  17204. clone(): BoxParticleEmitter;
  17205. /**
  17206. * Called by the GPUParticleSystem to setup the update shader
  17207. * @param effect defines the update shader
  17208. */
  17209. applyToShader(effect: Effect): void;
  17210. /**
  17211. * Returns a string to use to update the GPU particles update shader
  17212. * @returns a string containng the defines string
  17213. */
  17214. getEffectDefines(): string;
  17215. /**
  17216. * Returns the string "BoxParticleEmitter"
  17217. * @returns a string containing the class name
  17218. */
  17219. getClassName(): string;
  17220. /**
  17221. * Serializes the particle system to a JSON object.
  17222. * @returns the JSON object
  17223. */
  17224. serialize(): any;
  17225. /**
  17226. * Parse properties from a JSON object
  17227. * @param serializationObject defines the JSON object
  17228. */
  17229. parse(serializationObject: any): void;
  17230. }
  17231. }
  17232. declare module BABYLON {
  17233. /**
  17234. * Particle emitter emitting particles from the inside of a cone.
  17235. * It emits the particles alongside the cone volume from the base to the particle.
  17236. * The emission direction might be randomized.
  17237. */
  17238. export class ConeParticleEmitter implements IParticleEmitterType {
  17239. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17240. directionRandomizer: number;
  17241. private _radius;
  17242. private _angle;
  17243. private _height;
  17244. /**
  17245. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17246. */
  17247. radiusRange: number;
  17248. /**
  17249. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17250. */
  17251. heightRange: number;
  17252. /**
  17253. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17254. */
  17255. emitFromSpawnPointOnly: boolean;
  17256. /**
  17257. * Gets or sets the radius of the emission cone
  17258. */
  17259. radius: number;
  17260. /**
  17261. * Gets or sets the angle of the emission cone
  17262. */
  17263. angle: number;
  17264. private _buildHeight;
  17265. /**
  17266. * Creates a new instance ConeParticleEmitter
  17267. * @param radius the radius of the emission cone (1 by default)
  17268. * @param angle the cone base angle (PI by default)
  17269. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17270. */
  17271. constructor(radius?: number, angle?: number,
  17272. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17273. directionRandomizer?: number);
  17274. /**
  17275. * Called by the particle System when the direction is computed for the created particle.
  17276. * @param worldMatrix is the world matrix of the particle system
  17277. * @param directionToUpdate is the direction vector to update with the result
  17278. * @param particle is the particle we are computed the direction for
  17279. */
  17280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17281. /**
  17282. * Called by the particle System when the position is computed for the created particle.
  17283. * @param worldMatrix is the world matrix of the particle system
  17284. * @param positionToUpdate is the position vector to update with the result
  17285. * @param particle is the particle we are computed the position for
  17286. */
  17287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17288. /**
  17289. * Clones the current emitter and returns a copy of it
  17290. * @returns the new emitter
  17291. */
  17292. clone(): ConeParticleEmitter;
  17293. /**
  17294. * Called by the GPUParticleSystem to setup the update shader
  17295. * @param effect defines the update shader
  17296. */
  17297. applyToShader(effect: Effect): void;
  17298. /**
  17299. * Returns a string to use to update the GPU particles update shader
  17300. * @returns a string containng the defines string
  17301. */
  17302. getEffectDefines(): string;
  17303. /**
  17304. * Returns the string "ConeParticleEmitter"
  17305. * @returns a string containing the class name
  17306. */
  17307. getClassName(): string;
  17308. /**
  17309. * Serializes the particle system to a JSON object.
  17310. * @returns the JSON object
  17311. */
  17312. serialize(): any;
  17313. /**
  17314. * Parse properties from a JSON object
  17315. * @param serializationObject defines the JSON object
  17316. */
  17317. parse(serializationObject: any): void;
  17318. }
  17319. }
  17320. declare module BABYLON {
  17321. /**
  17322. * Particle emitter emitting particles from the inside of a cylinder.
  17323. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17324. */
  17325. export class CylinderParticleEmitter implements IParticleEmitterType {
  17326. /**
  17327. * The radius of the emission cylinder.
  17328. */
  17329. radius: number;
  17330. /**
  17331. * The height of the emission cylinder.
  17332. */
  17333. height: number;
  17334. /**
  17335. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17336. */
  17337. radiusRange: number;
  17338. /**
  17339. * How much to randomize the particle direction [0-1].
  17340. */
  17341. directionRandomizer: number;
  17342. /**
  17343. * Creates a new instance CylinderParticleEmitter
  17344. * @param radius the radius of the emission cylinder (1 by default)
  17345. * @param height the height of the emission cylinder (1 by default)
  17346. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17347. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17348. */
  17349. constructor(
  17350. /**
  17351. * The radius of the emission cylinder.
  17352. */
  17353. radius?: number,
  17354. /**
  17355. * The height of the emission cylinder.
  17356. */
  17357. height?: number,
  17358. /**
  17359. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17360. */
  17361. radiusRange?: number,
  17362. /**
  17363. * How much to randomize the particle direction [0-1].
  17364. */
  17365. directionRandomizer?: number);
  17366. /**
  17367. * Called by the particle System when the direction is computed for the created particle.
  17368. * @param worldMatrix is the world matrix of the particle system
  17369. * @param directionToUpdate is the direction vector to update with the result
  17370. * @param particle is the particle we are computed the direction for
  17371. */
  17372. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17373. /**
  17374. * Called by the particle System when the position is computed for the created particle.
  17375. * @param worldMatrix is the world matrix of the particle system
  17376. * @param positionToUpdate is the position vector to update with the result
  17377. * @param particle is the particle we are computed the position for
  17378. */
  17379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17380. /**
  17381. * Clones the current emitter and returns a copy of it
  17382. * @returns the new emitter
  17383. */
  17384. clone(): CylinderParticleEmitter;
  17385. /**
  17386. * Called by the GPUParticleSystem to setup the update shader
  17387. * @param effect defines the update shader
  17388. */
  17389. applyToShader(effect: Effect): void;
  17390. /**
  17391. * Returns a string to use to update the GPU particles update shader
  17392. * @returns a string containng the defines string
  17393. */
  17394. getEffectDefines(): string;
  17395. /**
  17396. * Returns the string "CylinderParticleEmitter"
  17397. * @returns a string containing the class name
  17398. */
  17399. getClassName(): string;
  17400. /**
  17401. * Serializes the particle system to a JSON object.
  17402. * @returns the JSON object
  17403. */
  17404. serialize(): any;
  17405. /**
  17406. * Parse properties from a JSON object
  17407. * @param serializationObject defines the JSON object
  17408. */
  17409. parse(serializationObject: any): void;
  17410. }
  17411. /**
  17412. * Particle emitter emitting particles from the inside of a cylinder.
  17413. * It emits the particles randomly between two vectors.
  17414. */
  17415. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17416. /**
  17417. * The min limit of the emission direction.
  17418. */
  17419. direction1: Vector3;
  17420. /**
  17421. * The max limit of the emission direction.
  17422. */
  17423. direction2: Vector3;
  17424. /**
  17425. * Creates a new instance CylinderDirectedParticleEmitter
  17426. * @param radius the radius of the emission cylinder (1 by default)
  17427. * @param height the height of the emission cylinder (1 by default)
  17428. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17429. * @param direction1 the min limit of the emission direction (up vector by default)
  17430. * @param direction2 the max limit of the emission direction (up vector by default)
  17431. */
  17432. constructor(radius?: number, height?: number, radiusRange?: number,
  17433. /**
  17434. * The min limit of the emission direction.
  17435. */
  17436. direction1?: Vector3,
  17437. /**
  17438. * The max limit of the emission direction.
  17439. */
  17440. direction2?: Vector3);
  17441. /**
  17442. * Called by the particle System when the direction is computed for the created particle.
  17443. * @param worldMatrix is the world matrix of the particle system
  17444. * @param directionToUpdate is the direction vector to update with the result
  17445. * @param particle is the particle we are computed the direction for
  17446. */
  17447. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17448. /**
  17449. * Clones the current emitter and returns a copy of it
  17450. * @returns the new emitter
  17451. */
  17452. clone(): CylinderDirectedParticleEmitter;
  17453. /**
  17454. * Called by the GPUParticleSystem to setup the update shader
  17455. * @param effect defines the update shader
  17456. */
  17457. applyToShader(effect: Effect): void;
  17458. /**
  17459. * Returns a string to use to update the GPU particles update shader
  17460. * @returns a string containng the defines string
  17461. */
  17462. getEffectDefines(): string;
  17463. /**
  17464. * Returns the string "CylinderDirectedParticleEmitter"
  17465. * @returns a string containing the class name
  17466. */
  17467. getClassName(): string;
  17468. /**
  17469. * Serializes the particle system to a JSON object.
  17470. * @returns the JSON object
  17471. */
  17472. serialize(): any;
  17473. /**
  17474. * Parse properties from a JSON object
  17475. * @param serializationObject defines the JSON object
  17476. */
  17477. parse(serializationObject: any): void;
  17478. }
  17479. }
  17480. declare module BABYLON {
  17481. /**
  17482. * Particle emitter emitting particles from the inside of a hemisphere.
  17483. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17484. */
  17485. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17486. /**
  17487. * The radius of the emission hemisphere.
  17488. */
  17489. radius: number;
  17490. /**
  17491. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17492. */
  17493. radiusRange: number;
  17494. /**
  17495. * How much to randomize the particle direction [0-1].
  17496. */
  17497. directionRandomizer: number;
  17498. /**
  17499. * Creates a new instance HemisphericParticleEmitter
  17500. * @param radius the radius of the emission hemisphere (1 by default)
  17501. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17502. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17503. */
  17504. constructor(
  17505. /**
  17506. * The radius of the emission hemisphere.
  17507. */
  17508. radius?: number,
  17509. /**
  17510. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17511. */
  17512. radiusRange?: number,
  17513. /**
  17514. * How much to randomize the particle direction [0-1].
  17515. */
  17516. directionRandomizer?: number);
  17517. /**
  17518. * Called by the particle System when the direction is computed for the created particle.
  17519. * @param worldMatrix is the world matrix of the particle system
  17520. * @param directionToUpdate is the direction vector to update with the result
  17521. * @param particle is the particle we are computed the direction for
  17522. */
  17523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17524. /**
  17525. * Called by the particle System when the position is computed for the created particle.
  17526. * @param worldMatrix is the world matrix of the particle system
  17527. * @param positionToUpdate is the position vector to update with the result
  17528. * @param particle is the particle we are computed the position for
  17529. */
  17530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17531. /**
  17532. * Clones the current emitter and returns a copy of it
  17533. * @returns the new emitter
  17534. */
  17535. clone(): HemisphericParticleEmitter;
  17536. /**
  17537. * Called by the GPUParticleSystem to setup the update shader
  17538. * @param effect defines the update shader
  17539. */
  17540. applyToShader(effect: Effect): void;
  17541. /**
  17542. * Returns a string to use to update the GPU particles update shader
  17543. * @returns a string containng the defines string
  17544. */
  17545. getEffectDefines(): string;
  17546. /**
  17547. * Returns the string "HemisphericParticleEmitter"
  17548. * @returns a string containing the class name
  17549. */
  17550. getClassName(): string;
  17551. /**
  17552. * Serializes the particle system to a JSON object.
  17553. * @returns the JSON object
  17554. */
  17555. serialize(): any;
  17556. /**
  17557. * Parse properties from a JSON object
  17558. * @param serializationObject defines the JSON object
  17559. */
  17560. parse(serializationObject: any): void;
  17561. }
  17562. }
  17563. declare module BABYLON {
  17564. /**
  17565. * Particle emitter emitting particles from a point.
  17566. * It emits the particles randomly between 2 given directions.
  17567. */
  17568. export class PointParticleEmitter implements IParticleEmitterType {
  17569. /**
  17570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17571. */
  17572. direction1: Vector3;
  17573. /**
  17574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17575. */
  17576. direction2: Vector3;
  17577. /**
  17578. * Creates a new instance PointParticleEmitter
  17579. */
  17580. constructor();
  17581. /**
  17582. * Called by the particle System when the direction is computed for the created particle.
  17583. * @param worldMatrix is the world matrix of the particle system
  17584. * @param directionToUpdate is the direction vector to update with the result
  17585. * @param particle is the particle we are computed the direction for
  17586. */
  17587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17588. /**
  17589. * Called by the particle System when the position is computed for the created particle.
  17590. * @param worldMatrix is the world matrix of the particle system
  17591. * @param positionToUpdate is the position vector to update with the result
  17592. * @param particle is the particle we are computed the position for
  17593. */
  17594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17595. /**
  17596. * Clones the current emitter and returns a copy of it
  17597. * @returns the new emitter
  17598. */
  17599. clone(): PointParticleEmitter;
  17600. /**
  17601. * Called by the GPUParticleSystem to setup the update shader
  17602. * @param effect defines the update shader
  17603. */
  17604. applyToShader(effect: Effect): void;
  17605. /**
  17606. * Returns a string to use to update the GPU particles update shader
  17607. * @returns a string containng the defines string
  17608. */
  17609. getEffectDefines(): string;
  17610. /**
  17611. * Returns the string "PointParticleEmitter"
  17612. * @returns a string containing the class name
  17613. */
  17614. getClassName(): string;
  17615. /**
  17616. * Serializes the particle system to a JSON object.
  17617. * @returns the JSON object
  17618. */
  17619. serialize(): any;
  17620. /**
  17621. * Parse properties from a JSON object
  17622. * @param serializationObject defines the JSON object
  17623. */
  17624. parse(serializationObject: any): void;
  17625. }
  17626. }
  17627. declare module BABYLON {
  17628. /**
  17629. * Particle emitter emitting particles from the inside of a sphere.
  17630. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17631. */
  17632. export class SphereParticleEmitter implements IParticleEmitterType {
  17633. /**
  17634. * The radius of the emission sphere.
  17635. */
  17636. radius: number;
  17637. /**
  17638. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17639. */
  17640. radiusRange: number;
  17641. /**
  17642. * How much to randomize the particle direction [0-1].
  17643. */
  17644. directionRandomizer: number;
  17645. /**
  17646. * Creates a new instance SphereParticleEmitter
  17647. * @param radius the radius of the emission sphere (1 by default)
  17648. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17649. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17650. */
  17651. constructor(
  17652. /**
  17653. * The radius of the emission sphere.
  17654. */
  17655. radius?: number,
  17656. /**
  17657. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17658. */
  17659. radiusRange?: number,
  17660. /**
  17661. * How much to randomize the particle direction [0-1].
  17662. */
  17663. directionRandomizer?: number);
  17664. /**
  17665. * Called by the particle System when the direction is computed for the created particle.
  17666. * @param worldMatrix is the world matrix of the particle system
  17667. * @param directionToUpdate is the direction vector to update with the result
  17668. * @param particle is the particle we are computed the direction for
  17669. */
  17670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17671. /**
  17672. * Called by the particle System when the position is computed for the created particle.
  17673. * @param worldMatrix is the world matrix of the particle system
  17674. * @param positionToUpdate is the position vector to update with the result
  17675. * @param particle is the particle we are computed the position for
  17676. */
  17677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17678. /**
  17679. * Clones the current emitter and returns a copy of it
  17680. * @returns the new emitter
  17681. */
  17682. clone(): SphereParticleEmitter;
  17683. /**
  17684. * Called by the GPUParticleSystem to setup the update shader
  17685. * @param effect defines the update shader
  17686. */
  17687. applyToShader(effect: Effect): void;
  17688. /**
  17689. * Returns a string to use to update the GPU particles update shader
  17690. * @returns a string containng the defines string
  17691. */
  17692. getEffectDefines(): string;
  17693. /**
  17694. * Returns the string "SphereParticleEmitter"
  17695. * @returns a string containing the class name
  17696. */
  17697. getClassName(): string;
  17698. /**
  17699. * Serializes the particle system to a JSON object.
  17700. * @returns the JSON object
  17701. */
  17702. serialize(): any;
  17703. /**
  17704. * Parse properties from a JSON object
  17705. * @param serializationObject defines the JSON object
  17706. */
  17707. parse(serializationObject: any): void;
  17708. }
  17709. /**
  17710. * Particle emitter emitting particles from the inside of a sphere.
  17711. * It emits the particles randomly between two vectors.
  17712. */
  17713. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17714. /**
  17715. * The min limit of the emission direction.
  17716. */
  17717. direction1: Vector3;
  17718. /**
  17719. * The max limit of the emission direction.
  17720. */
  17721. direction2: Vector3;
  17722. /**
  17723. * Creates a new instance SphereDirectedParticleEmitter
  17724. * @param radius the radius of the emission sphere (1 by default)
  17725. * @param direction1 the min limit of the emission direction (up vector by default)
  17726. * @param direction2 the max limit of the emission direction (up vector by default)
  17727. */
  17728. constructor(radius?: number,
  17729. /**
  17730. * The min limit of the emission direction.
  17731. */
  17732. direction1?: Vector3,
  17733. /**
  17734. * The max limit of the emission direction.
  17735. */
  17736. direction2?: Vector3);
  17737. /**
  17738. * Called by the particle System when the direction is computed for the created particle.
  17739. * @param worldMatrix is the world matrix of the particle system
  17740. * @param directionToUpdate is the direction vector to update with the result
  17741. * @param particle is the particle we are computed the direction for
  17742. */
  17743. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17744. /**
  17745. * Clones the current emitter and returns a copy of it
  17746. * @returns the new emitter
  17747. */
  17748. clone(): SphereDirectedParticleEmitter;
  17749. /**
  17750. * Called by the GPUParticleSystem to setup the update shader
  17751. * @param effect defines the update shader
  17752. */
  17753. applyToShader(effect: Effect): void;
  17754. /**
  17755. * Returns a string to use to update the GPU particles update shader
  17756. * @returns a string containng the defines string
  17757. */
  17758. getEffectDefines(): string;
  17759. /**
  17760. * Returns the string "SphereDirectedParticleEmitter"
  17761. * @returns a string containing the class name
  17762. */
  17763. getClassName(): string;
  17764. /**
  17765. * Serializes the particle system to a JSON object.
  17766. * @returns the JSON object
  17767. */
  17768. serialize(): any;
  17769. /**
  17770. * Parse properties from a JSON object
  17771. * @param serializationObject defines the JSON object
  17772. */
  17773. parse(serializationObject: any): void;
  17774. }
  17775. }
  17776. declare module BABYLON {
  17777. /**
  17778. * Interface representing a particle system in Babylon.js.
  17779. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17780. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17781. */
  17782. export interface IParticleSystem {
  17783. /**
  17784. * List of animations used by the particle system.
  17785. */
  17786. animations: Animation[];
  17787. /**
  17788. * The id of the Particle system.
  17789. */
  17790. id: string;
  17791. /**
  17792. * The name of the Particle system.
  17793. */
  17794. name: string;
  17795. /**
  17796. * The emitter represents the Mesh or position we are attaching the particle system to.
  17797. */
  17798. emitter: Nullable<AbstractMesh | Vector3>;
  17799. /**
  17800. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17801. */
  17802. isBillboardBased: boolean;
  17803. /**
  17804. * The rendering group used by the Particle system to chose when to render.
  17805. */
  17806. renderingGroupId: number;
  17807. /**
  17808. * The layer mask we are rendering the particles through.
  17809. */
  17810. layerMask: number;
  17811. /**
  17812. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17813. */
  17814. updateSpeed: number;
  17815. /**
  17816. * The amount of time the particle system is running (depends of the overall update speed).
  17817. */
  17818. targetStopDuration: number;
  17819. /**
  17820. * The texture used to render each particle. (this can be a spritesheet)
  17821. */
  17822. particleTexture: Nullable<Texture>;
  17823. /**
  17824. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17825. */
  17826. blendMode: number;
  17827. /**
  17828. * Minimum life time of emitting particles.
  17829. */
  17830. minLifeTime: number;
  17831. /**
  17832. * Maximum life time of emitting particles.
  17833. */
  17834. maxLifeTime: number;
  17835. /**
  17836. * Minimum Size of emitting particles.
  17837. */
  17838. minSize: number;
  17839. /**
  17840. * Maximum Size of emitting particles.
  17841. */
  17842. maxSize: number;
  17843. /**
  17844. * Minimum scale of emitting particles on X axis.
  17845. */
  17846. minScaleX: number;
  17847. /**
  17848. * Maximum scale of emitting particles on X axis.
  17849. */
  17850. maxScaleX: number;
  17851. /**
  17852. * Minimum scale of emitting particles on Y axis.
  17853. */
  17854. minScaleY: number;
  17855. /**
  17856. * Maximum scale of emitting particles on Y axis.
  17857. */
  17858. maxScaleY: number;
  17859. /**
  17860. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17861. */
  17862. color1: Color4;
  17863. /**
  17864. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17865. */
  17866. color2: Color4;
  17867. /**
  17868. * Color the particle will have at the end of its lifetime.
  17869. */
  17870. colorDead: Color4;
  17871. /**
  17872. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17873. */
  17874. emitRate: number;
  17875. /**
  17876. * You can use gravity if you want to give an orientation to your particles.
  17877. */
  17878. gravity: Vector3;
  17879. /**
  17880. * Minimum power of emitting particles.
  17881. */
  17882. minEmitPower: number;
  17883. /**
  17884. * Maximum power of emitting particles.
  17885. */
  17886. maxEmitPower: number;
  17887. /**
  17888. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17889. */
  17890. minAngularSpeed: number;
  17891. /**
  17892. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17893. */
  17894. maxAngularSpeed: number;
  17895. /**
  17896. * Gets or sets the minimal initial rotation in radians.
  17897. */
  17898. minInitialRotation: number;
  17899. /**
  17900. * Gets or sets the maximal initial rotation in radians.
  17901. */
  17902. maxInitialRotation: number;
  17903. /**
  17904. * The particle emitter type defines the emitter used by the particle system.
  17905. * It can be for example box, sphere, or cone...
  17906. */
  17907. particleEmitterType: Nullable<IParticleEmitterType>;
  17908. /**
  17909. * Defines the delay in milliseconds before starting the system (0 by default)
  17910. */
  17911. startDelay: number;
  17912. /**
  17913. * 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
  17914. */
  17915. preWarmCycles: number;
  17916. /**
  17917. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17918. */
  17919. preWarmStepOffset: number;
  17920. /**
  17921. * 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)
  17922. */
  17923. spriteCellChangeSpeed: number;
  17924. /**
  17925. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17926. */
  17927. startSpriteCellID: number;
  17928. /**
  17929. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17930. */
  17931. endSpriteCellID: number;
  17932. /**
  17933. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17934. */
  17935. spriteCellWidth: number;
  17936. /**
  17937. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17938. */
  17939. spriteCellHeight: number;
  17940. /**
  17941. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17942. */
  17943. spriteRandomStartCell: boolean;
  17944. /**
  17945. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17946. */
  17947. isAnimationSheetEnabled: boolean;
  17948. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17949. translationPivot: Vector2;
  17950. /**
  17951. * Gets or sets a texture used to add random noise to particle positions
  17952. */
  17953. noiseTexture: Nullable<BaseTexture>;
  17954. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17955. noiseStrength: Vector3;
  17956. /**
  17957. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17958. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17959. */
  17960. billboardMode: number;
  17961. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17962. limitVelocityDamping: number;
  17963. /**
  17964. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17965. */
  17966. beginAnimationOnStart: boolean;
  17967. /**
  17968. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17969. */
  17970. beginAnimationFrom: number;
  17971. /**
  17972. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17973. */
  17974. beginAnimationTo: number;
  17975. /**
  17976. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17977. */
  17978. beginAnimationLoop: boolean;
  17979. /**
  17980. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17981. */
  17982. disposeOnStop: boolean;
  17983. /**
  17984. * Gets the maximum number of particles active at the same time.
  17985. * @returns The max number of active particles.
  17986. */
  17987. getCapacity(): number;
  17988. /**
  17989. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17990. * @returns True if it has been started, otherwise false.
  17991. */
  17992. isStarted(): boolean;
  17993. /**
  17994. * Animates the particle system for this frame.
  17995. */
  17996. animate(): void;
  17997. /**
  17998. * Renders the particle system in its current state.
  17999. * @returns the current number of particles
  18000. */
  18001. render(): number;
  18002. /**
  18003. * Dispose the particle system and frees its associated resources.
  18004. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18005. */
  18006. dispose(disposeTexture?: boolean): void;
  18007. /**
  18008. * Clones the particle system.
  18009. * @param name The name of the cloned object
  18010. * @param newEmitter The new emitter to use
  18011. * @returns the cloned particle system
  18012. */
  18013. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18014. /**
  18015. * Serializes the particle system to a JSON object.
  18016. * @returns the JSON object
  18017. */
  18018. serialize(): any;
  18019. /**
  18020. * Rebuild the particle system
  18021. */
  18022. rebuild(): void;
  18023. /**
  18024. * Starts the particle system and begins to emit
  18025. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18026. */
  18027. start(delay?: number): void;
  18028. /**
  18029. * Stops the particle system.
  18030. */
  18031. stop(): void;
  18032. /**
  18033. * Remove all active particles
  18034. */
  18035. reset(): void;
  18036. /**
  18037. * Is this system ready to be used/rendered
  18038. * @return true if the system is ready
  18039. */
  18040. isReady(): boolean;
  18041. /**
  18042. * Adds a new color gradient
  18043. * @param gradient defines the gradient to use (between 0 and 1)
  18044. * @param color1 defines the color to affect to the specified gradient
  18045. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18046. * @returns the current particle system
  18047. */
  18048. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18049. /**
  18050. * Remove a specific color gradient
  18051. * @param gradient defines the gradient to remove
  18052. * @returns the current particle system
  18053. */
  18054. removeColorGradient(gradient: number): IParticleSystem;
  18055. /**
  18056. * Adds a new size gradient
  18057. * @param gradient defines the gradient to use (between 0 and 1)
  18058. * @param factor defines the size factor to affect to the specified gradient
  18059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18060. * @returns the current particle system
  18061. */
  18062. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18063. /**
  18064. * Remove a specific size gradient
  18065. * @param gradient defines the gradient to remove
  18066. * @returns the current particle system
  18067. */
  18068. removeSizeGradient(gradient: number): IParticleSystem;
  18069. /**
  18070. * Gets the current list of color gradients.
  18071. * You must use addColorGradient and removeColorGradient to udpate this list
  18072. * @returns the list of color gradients
  18073. */
  18074. getColorGradients(): Nullable<Array<ColorGradient>>;
  18075. /**
  18076. * Gets the current list of size gradients.
  18077. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18078. * @returns the list of size gradients
  18079. */
  18080. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18081. /**
  18082. * Gets the current list of angular speed gradients.
  18083. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18084. * @returns the list of angular speed gradients
  18085. */
  18086. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18087. /**
  18088. * Adds a new angular speed gradient
  18089. * @param gradient defines the gradient to use (between 0 and 1)
  18090. * @param factor defines the angular speed to affect to the specified gradient
  18091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18092. * @returns the current particle system
  18093. */
  18094. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18095. /**
  18096. * Remove a specific angular speed gradient
  18097. * @param gradient defines the gradient to remove
  18098. * @returns the current particle system
  18099. */
  18100. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18101. /**
  18102. * Gets the current list of velocity gradients.
  18103. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18104. * @returns the list of velocity gradients
  18105. */
  18106. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18107. /**
  18108. * Adds a new velocity gradient
  18109. * @param gradient defines the gradient to use (between 0 and 1)
  18110. * @param factor defines the velocity to affect to the specified gradient
  18111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18112. * @returns the current particle system
  18113. */
  18114. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18115. /**
  18116. * Remove a specific velocity gradient
  18117. * @param gradient defines the gradient to remove
  18118. * @returns the current particle system
  18119. */
  18120. removeVelocityGradient(gradient: number): IParticleSystem;
  18121. /**
  18122. * Gets the current list of limit velocity gradients.
  18123. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18124. * @returns the list of limit velocity gradients
  18125. */
  18126. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18127. /**
  18128. * Adds a new limit velocity gradient
  18129. * @param gradient defines the gradient to use (between 0 and 1)
  18130. * @param factor defines the limit velocity to affect to the specified gradient
  18131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18132. * @returns the current particle system
  18133. */
  18134. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18135. /**
  18136. * Remove a specific limit velocity gradient
  18137. * @param gradient defines the gradient to remove
  18138. * @returns the current particle system
  18139. */
  18140. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18141. /**
  18142. * Adds a new drag gradient
  18143. * @param gradient defines the gradient to use (between 0 and 1)
  18144. * @param factor defines the drag to affect to the specified gradient
  18145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18146. * @returns the current particle system
  18147. */
  18148. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18149. /**
  18150. * Remove a specific drag gradient
  18151. * @param gradient defines the gradient to remove
  18152. * @returns the current particle system
  18153. */
  18154. removeDragGradient(gradient: number): IParticleSystem;
  18155. /**
  18156. * Gets the current list of drag gradients.
  18157. * You must use addDragGradient and removeDragGradient to udpate this list
  18158. * @returns the list of drag gradients
  18159. */
  18160. getDragGradients(): Nullable<Array<FactorGradient>>;
  18161. /**
  18162. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18163. * @param gradient defines the gradient to use (between 0 and 1)
  18164. * @param factor defines the emit rate to affect to the specified gradient
  18165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18166. * @returns the current particle system
  18167. */
  18168. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18169. /**
  18170. * Remove a specific emit rate gradient
  18171. * @param gradient defines the gradient to remove
  18172. * @returns the current particle system
  18173. */
  18174. removeEmitRateGradient(gradient: number): IParticleSystem;
  18175. /**
  18176. * Gets the current list of emit rate gradients.
  18177. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18178. * @returns the list of emit rate gradients
  18179. */
  18180. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18181. /**
  18182. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18183. * @param gradient defines the gradient to use (between 0 and 1)
  18184. * @param factor defines the start size to affect to the specified gradient
  18185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18186. * @returns the current particle system
  18187. */
  18188. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18189. /**
  18190. * Remove a specific start size gradient
  18191. * @param gradient defines the gradient to remove
  18192. * @returns the current particle system
  18193. */
  18194. removeStartSizeGradient(gradient: number): IParticleSystem;
  18195. /**
  18196. * Gets the current list of start size gradients.
  18197. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18198. * @returns the list of start size gradients
  18199. */
  18200. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18201. /**
  18202. * Adds a new life time gradient
  18203. * @param gradient defines the gradient to use (between 0 and 1)
  18204. * @param factor defines the life time factor to affect to the specified gradient
  18205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18206. * @returns the current particle system
  18207. */
  18208. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18209. /**
  18210. * Remove a specific life time gradient
  18211. * @param gradient defines the gradient to remove
  18212. * @returns the current particle system
  18213. */
  18214. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18215. /**
  18216. * Gets the current list of life time gradients.
  18217. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18218. * @returns the list of life time gradients
  18219. */
  18220. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18221. /**
  18222. * Gets the current list of color gradients.
  18223. * You must use addColorGradient and removeColorGradient to udpate this list
  18224. * @returns the list of color gradients
  18225. */
  18226. getColorGradients(): Nullable<Array<ColorGradient>>;
  18227. /**
  18228. * Adds a new ramp gradient used to remap particle colors
  18229. * @param gradient defines the gradient to use (between 0 and 1)
  18230. * @param color defines the color to affect to the specified gradient
  18231. * @returns the current particle system
  18232. */
  18233. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18234. /**
  18235. * Gets the current list of ramp gradients.
  18236. * You must use addRampGradient and removeRampGradient to udpate this list
  18237. * @returns the list of ramp gradients
  18238. */
  18239. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18240. /** Gets or sets a boolean indicating that ramp gradients must be used
  18241. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18242. */
  18243. useRampGradients: boolean;
  18244. /**
  18245. * Adds a new color remap gradient
  18246. * @param gradient defines the gradient to use (between 0 and 1)
  18247. * @param min defines the color remap minimal range
  18248. * @param max defines the color remap maximal range
  18249. * @returns the current particle system
  18250. */
  18251. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18252. /**
  18253. * Gets the current list of color remap gradients.
  18254. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18255. * @returns the list of color remap gradients
  18256. */
  18257. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18258. /**
  18259. * Adds a new alpha remap gradient
  18260. * @param gradient defines the gradient to use (between 0 and 1)
  18261. * @param min defines the alpha remap minimal range
  18262. * @param max defines the alpha remap maximal range
  18263. * @returns the current particle system
  18264. */
  18265. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18266. /**
  18267. * Gets the current list of alpha remap gradients.
  18268. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18269. * @returns the list of alpha remap gradients
  18270. */
  18271. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18272. /**
  18273. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18274. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18275. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18276. * @returns the emitter
  18277. */
  18278. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18279. /**
  18280. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18281. * @param radius The radius of the hemisphere to emit from
  18282. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18283. * @returns the emitter
  18284. */
  18285. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18286. /**
  18287. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18288. * @param radius The radius of the sphere to emit from
  18289. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18290. * @returns the emitter
  18291. */
  18292. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18293. /**
  18294. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18295. * @param radius The radius of the sphere to emit from
  18296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18298. * @returns the emitter
  18299. */
  18300. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18301. /**
  18302. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18303. * @param radius The radius of the emission cylinder
  18304. * @param height The height of the emission cylinder
  18305. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18306. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18307. * @returns the emitter
  18308. */
  18309. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18310. /**
  18311. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18312. * @param radius The radius of the cylinder to emit from
  18313. * @param height The height of the emission cylinder
  18314. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18317. * @returns the emitter
  18318. */
  18319. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18320. /**
  18321. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18322. * @param radius The radius of the cone to emit from
  18323. * @param angle The base angle of the cone
  18324. * @returns the emitter
  18325. */
  18326. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18327. /**
  18328. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18329. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18330. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18331. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18332. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18333. * @returns the emitter
  18334. */
  18335. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18336. /**
  18337. * Get hosting scene
  18338. * @returns the scene
  18339. */
  18340. getScene(): Scene;
  18341. }
  18342. }
  18343. declare module BABYLON {
  18344. /**
  18345. * Creates an instance based on a source mesh.
  18346. */
  18347. export class InstancedMesh extends AbstractMesh {
  18348. private _sourceMesh;
  18349. private _currentLOD;
  18350. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18351. constructor(name: string, source: Mesh);
  18352. /**
  18353. * Returns the string "InstancedMesh".
  18354. */
  18355. getClassName(): string;
  18356. /** Gets the list of lights affecting that mesh */
  18357. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18358. /**
  18359. * If the source mesh receives shadows
  18360. */
  18361. readonly receiveShadows: boolean;
  18362. /**
  18363. * The material of the source mesh
  18364. */
  18365. readonly material: Nullable<Material>;
  18366. /**
  18367. * Visibility of the source mesh
  18368. */
  18369. readonly visibility: number;
  18370. /**
  18371. * Skeleton of the source mesh
  18372. */
  18373. readonly skeleton: Nullable<Skeleton>;
  18374. /**
  18375. * Rendering ground id of the source mesh
  18376. */
  18377. renderingGroupId: number;
  18378. /**
  18379. * Returns the total number of vertices (integer).
  18380. */
  18381. getTotalVertices(): number;
  18382. /**
  18383. * Returns a positive integer : the total number of indices in this mesh geometry.
  18384. * @returns the numner of indices or zero if the mesh has no geometry.
  18385. */
  18386. getTotalIndices(): number;
  18387. /**
  18388. * The source mesh of the instance
  18389. */
  18390. readonly sourceMesh: Mesh;
  18391. /**
  18392. * Is this node ready to be used/rendered
  18393. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18394. * @return {boolean} is it ready
  18395. */
  18396. isReady(completeCheck?: boolean): boolean;
  18397. /**
  18398. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18399. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18400. * @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.
  18401. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18402. */
  18403. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18404. /**
  18405. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18406. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18407. * The `data` are either a numeric array either a Float32Array.
  18408. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18409. * 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).
  18410. * Note that a new underlying VertexBuffer object is created each call.
  18411. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18412. *
  18413. * Possible `kind` values :
  18414. * - VertexBuffer.PositionKind
  18415. * - VertexBuffer.UVKind
  18416. * - VertexBuffer.UV2Kind
  18417. * - VertexBuffer.UV3Kind
  18418. * - VertexBuffer.UV4Kind
  18419. * - VertexBuffer.UV5Kind
  18420. * - VertexBuffer.UV6Kind
  18421. * - VertexBuffer.ColorKind
  18422. * - VertexBuffer.MatricesIndicesKind
  18423. * - VertexBuffer.MatricesIndicesExtraKind
  18424. * - VertexBuffer.MatricesWeightsKind
  18425. * - VertexBuffer.MatricesWeightsExtraKind
  18426. *
  18427. * Returns the Mesh.
  18428. */
  18429. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18430. /**
  18431. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18432. * If the mesh has no geometry, it is simply returned as it is.
  18433. * The `data` are either a numeric array either a Float32Array.
  18434. * No new underlying VertexBuffer object is created.
  18435. * 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.
  18436. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18437. *
  18438. * Possible `kind` values :
  18439. * - VertexBuffer.PositionKind
  18440. * - VertexBuffer.UVKind
  18441. * - VertexBuffer.UV2Kind
  18442. * - VertexBuffer.UV3Kind
  18443. * - VertexBuffer.UV4Kind
  18444. * - VertexBuffer.UV5Kind
  18445. * - VertexBuffer.UV6Kind
  18446. * - VertexBuffer.ColorKind
  18447. * - VertexBuffer.MatricesIndicesKind
  18448. * - VertexBuffer.MatricesIndicesExtraKind
  18449. * - VertexBuffer.MatricesWeightsKind
  18450. * - VertexBuffer.MatricesWeightsExtraKind
  18451. *
  18452. * Returns the Mesh.
  18453. */
  18454. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18455. /**
  18456. * Sets the mesh indices.
  18457. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18458. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18459. * This method creates a new index buffer each call.
  18460. * Returns the Mesh.
  18461. */
  18462. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18463. /**
  18464. * Boolean : True if the mesh owns the requested kind of data.
  18465. */
  18466. isVerticesDataPresent(kind: string): boolean;
  18467. /**
  18468. * Returns an array of indices (IndicesArray).
  18469. */
  18470. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18471. /**
  18472. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18473. * This means the mesh underlying bounding box and sphere are recomputed.
  18474. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18475. * @returns the current mesh
  18476. */
  18477. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18478. /** @hidden */ private _preActivate(): InstancedMesh;
  18479. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18480. /** @hidden */ private _postActivate(): void;
  18481. getWorldMatrix(): Matrix;
  18482. readonly isAnInstance: boolean;
  18483. /**
  18484. * Returns the current associated LOD AbstractMesh.
  18485. */
  18486. getLOD(camera: Camera): AbstractMesh;
  18487. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18488. /** @hidden */ private _generatePointsArray(): boolean;
  18489. /**
  18490. * Creates a new InstancedMesh from the current mesh.
  18491. * - name (string) : the cloned mesh name
  18492. * - newParent (optional Node) : the optional Node to parent the clone to.
  18493. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18494. *
  18495. * Returns the clone.
  18496. */
  18497. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18498. /**
  18499. * Disposes the InstancedMesh.
  18500. * Returns nothing.
  18501. */
  18502. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18503. }
  18504. }
  18505. declare module BABYLON {
  18506. /**
  18507. * Defines the options associated with the creation of a shader material.
  18508. */
  18509. export interface IShaderMaterialOptions {
  18510. /**
  18511. * Does the material work in alpha blend mode
  18512. */
  18513. needAlphaBlending: boolean;
  18514. /**
  18515. * Does the material work in alpha test mode
  18516. */
  18517. needAlphaTesting: boolean;
  18518. /**
  18519. * The list of attribute names used in the shader
  18520. */
  18521. attributes: string[];
  18522. /**
  18523. * The list of unifrom names used in the shader
  18524. */
  18525. uniforms: string[];
  18526. /**
  18527. * The list of UBO names used in the shader
  18528. */
  18529. uniformBuffers: string[];
  18530. /**
  18531. * The list of sampler names used in the shader
  18532. */
  18533. samplers: string[];
  18534. /**
  18535. * The list of defines used in the shader
  18536. */
  18537. defines: string[];
  18538. }
  18539. /**
  18540. * 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.
  18541. *
  18542. * This returned material effects how the mesh will look based on the code in the shaders.
  18543. *
  18544. * @see http://doc.babylonjs.com/how_to/shader_material
  18545. */
  18546. export class ShaderMaterial extends Material {
  18547. private _shaderPath;
  18548. private _options;
  18549. private _textures;
  18550. private _textureArrays;
  18551. private _floats;
  18552. private _ints;
  18553. private _floatsArrays;
  18554. private _colors3;
  18555. private _colors3Arrays;
  18556. private _colors4;
  18557. private _colors4Arrays;
  18558. private _vectors2;
  18559. private _vectors3;
  18560. private _vectors4;
  18561. private _matrices;
  18562. private _matrices3x3;
  18563. private _matrices2x2;
  18564. private _vectors2Arrays;
  18565. private _vectors3Arrays;
  18566. private _vectors4Arrays;
  18567. private _cachedWorldViewMatrix;
  18568. private _cachedWorldViewProjectionMatrix;
  18569. private _renderId;
  18570. /**
  18571. * Instantiate a new shader material.
  18572. * 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.
  18573. * This returned material effects how the mesh will look based on the code in the shaders.
  18574. * @see http://doc.babylonjs.com/how_to/shader_material
  18575. * @param name Define the name of the material in the scene
  18576. * @param scene Define the scene the material belongs to
  18577. * @param shaderPath Defines the route to the shader code in one of three ways:
  18578. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18579. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18580. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18581. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18582. * @param options Define the options used to create the shader
  18583. */
  18584. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18585. /**
  18586. * Gets the options used to compile the shader.
  18587. * They can be modified to trigger a new compilation
  18588. */
  18589. readonly options: IShaderMaterialOptions;
  18590. /**
  18591. * Gets the current class name of the material e.g. "ShaderMaterial"
  18592. * Mainly use in serialization.
  18593. * @returns the class name
  18594. */
  18595. getClassName(): string;
  18596. /**
  18597. * Specifies if the material will require alpha blending
  18598. * @returns a boolean specifying if alpha blending is needed
  18599. */
  18600. needAlphaBlending(): boolean;
  18601. /**
  18602. * Specifies if this material should be rendered in alpha test mode
  18603. * @returns a boolean specifying if an alpha test is needed.
  18604. */
  18605. needAlphaTesting(): boolean;
  18606. private _checkUniform;
  18607. /**
  18608. * Set a texture in the shader.
  18609. * @param name Define the name of the uniform samplers as defined in the shader
  18610. * @param texture Define the texture to bind to this sampler
  18611. * @return the material itself allowing "fluent" like uniform updates
  18612. */
  18613. setTexture(name: string, texture: Texture): ShaderMaterial;
  18614. /**
  18615. * Set a texture array in the shader.
  18616. * @param name Define the name of the uniform sampler array as defined in the shader
  18617. * @param textures Define the list of textures to bind to this sampler
  18618. * @return the material itself allowing "fluent" like uniform updates
  18619. */
  18620. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18621. /**
  18622. * Set a float in the shader.
  18623. * @param name Define the name of the uniform as defined in the shader
  18624. * @param value Define the value to give to the uniform
  18625. * @return the material itself allowing "fluent" like uniform updates
  18626. */
  18627. setFloat(name: string, value: number): ShaderMaterial;
  18628. /**
  18629. * Set a int in the shader.
  18630. * @param name Define the name of the uniform as defined in the shader
  18631. * @param value Define the value to give to the uniform
  18632. * @return the material itself allowing "fluent" like uniform updates
  18633. */
  18634. setInt(name: string, value: number): ShaderMaterial;
  18635. /**
  18636. * Set an array of floats in the shader.
  18637. * @param name Define the name of the uniform as defined in the shader
  18638. * @param value Define the value to give to the uniform
  18639. * @return the material itself allowing "fluent" like uniform updates
  18640. */
  18641. setFloats(name: string, value: number[]): ShaderMaterial;
  18642. /**
  18643. * Set a vec3 in the shader from a Color3.
  18644. * @param name Define the name of the uniform as defined in the shader
  18645. * @param value Define the value to give to the uniform
  18646. * @return the material itself allowing "fluent" like uniform updates
  18647. */
  18648. setColor3(name: string, value: Color3): ShaderMaterial;
  18649. /**
  18650. * Set a vec3 array in the shader from a Color3 array.
  18651. * @param name Define the name of the uniform as defined in the shader
  18652. * @param value Define the value to give to the uniform
  18653. * @return the material itself allowing "fluent" like uniform updates
  18654. */
  18655. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18656. /**
  18657. * Set a vec4 in the shader from a Color4.
  18658. * @param name Define the name of the uniform as defined in the shader
  18659. * @param value Define the value to give to the uniform
  18660. * @return the material itself allowing "fluent" like uniform updates
  18661. */
  18662. setColor4(name: string, value: Color4): ShaderMaterial;
  18663. /**
  18664. * Set a vec4 array in the shader from a Color4 array.
  18665. * @param name Define the name of the uniform as defined in the shader
  18666. * @param value Define the value to give to the uniform
  18667. * @return the material itself allowing "fluent" like uniform updates
  18668. */
  18669. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18670. /**
  18671. * Set a vec2 in the shader from a Vector2.
  18672. * @param name Define the name of the uniform as defined in the shader
  18673. * @param value Define the value to give to the uniform
  18674. * @return the material itself allowing "fluent" like uniform updates
  18675. */
  18676. setVector2(name: string, value: Vector2): ShaderMaterial;
  18677. /**
  18678. * Set a vec3 in the shader from a Vector3.
  18679. * @param name Define the name of the uniform as defined in the shader
  18680. * @param value Define the value to give to the uniform
  18681. * @return the material itself allowing "fluent" like uniform updates
  18682. */
  18683. setVector3(name: string, value: Vector3): ShaderMaterial;
  18684. /**
  18685. * Set a vec4 in the shader from a Vector4.
  18686. * @param name Define the name of the uniform as defined in the shader
  18687. * @param value Define the value to give to the uniform
  18688. * @return the material itself allowing "fluent" like uniform updates
  18689. */
  18690. setVector4(name: string, value: Vector4): ShaderMaterial;
  18691. /**
  18692. * Set a mat4 in the shader from a Matrix.
  18693. * @param name Define the name of the uniform as defined in the shader
  18694. * @param value Define the value to give to the uniform
  18695. * @return the material itself allowing "fluent" like uniform updates
  18696. */
  18697. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18698. /**
  18699. * Set a mat3 in the shader from a Float32Array.
  18700. * @param name Define the name of the uniform as defined in the shader
  18701. * @param value Define the value to give to the uniform
  18702. * @return the material itself allowing "fluent" like uniform updates
  18703. */
  18704. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18705. /**
  18706. * Set a mat2 in the shader from a Float32Array.
  18707. * @param name Define the name of the uniform as defined in the shader
  18708. * @param value Define the value to give to the uniform
  18709. * @return the material itself allowing "fluent" like uniform updates
  18710. */
  18711. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18712. /**
  18713. * Set a vec2 array in the shader from a number array.
  18714. * @param name Define the name of the uniform as defined in the shader
  18715. * @param value Define the value to give to the uniform
  18716. * @return the material itself allowing "fluent" like uniform updates
  18717. */
  18718. setArray2(name: string, value: number[]): ShaderMaterial;
  18719. /**
  18720. * Set a vec3 array in the shader from a number array.
  18721. * @param name Define the name of the uniform as defined in the shader
  18722. * @param value Define the value to give to the uniform
  18723. * @return the material itself allowing "fluent" like uniform updates
  18724. */
  18725. setArray3(name: string, value: number[]): ShaderMaterial;
  18726. /**
  18727. * Set a vec4 array in the shader from a number array.
  18728. * @param name Define the name of the uniform as defined in the shader
  18729. * @param value Define the value to give to the uniform
  18730. * @return the material itself allowing "fluent" like uniform updates
  18731. */
  18732. setArray4(name: string, value: number[]): ShaderMaterial;
  18733. private _checkCache;
  18734. /**
  18735. * Specifies that the submesh is ready to be used
  18736. * @param mesh defines the mesh to check
  18737. * @param subMesh defines which submesh to check
  18738. * @param useInstances specifies that instances should be used
  18739. * @returns a boolean indicating that the submesh is ready or not
  18740. */
  18741. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18742. /**
  18743. * Checks if the material is ready to render the requested mesh
  18744. * @param mesh Define the mesh to render
  18745. * @param useInstances Define whether or not the material is used with instances
  18746. * @returns true if ready, otherwise false
  18747. */
  18748. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18749. /**
  18750. * Binds the world matrix to the material
  18751. * @param world defines the world transformation matrix
  18752. */
  18753. bindOnlyWorldMatrix(world: Matrix): void;
  18754. /**
  18755. * Binds the material to the mesh
  18756. * @param world defines the world transformation matrix
  18757. * @param mesh defines the mesh to bind the material to
  18758. */
  18759. bind(world: Matrix, mesh?: Mesh): void;
  18760. /**
  18761. * Gets the active textures from the material
  18762. * @returns an array of textures
  18763. */
  18764. getActiveTextures(): BaseTexture[];
  18765. /**
  18766. * Specifies if the material uses a texture
  18767. * @param texture defines the texture to check against the material
  18768. * @returns a boolean specifying if the material uses the texture
  18769. */
  18770. hasTexture(texture: BaseTexture): boolean;
  18771. /**
  18772. * Makes a duplicate of the material, and gives it a new name
  18773. * @param name defines the new name for the duplicated material
  18774. * @returns the cloned material
  18775. */
  18776. clone(name: string): ShaderMaterial;
  18777. /**
  18778. * Disposes the material
  18779. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18780. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18781. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18782. */
  18783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18784. /**
  18785. * Serializes this material in a JSON representation
  18786. * @returns the serialized material object
  18787. */
  18788. serialize(): any;
  18789. /**
  18790. * Creates a shader material from parsed shader material data
  18791. * @param source defines the JSON represnetation of the material
  18792. * @param scene defines the hosting scene
  18793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18794. * @returns a new material
  18795. */
  18796. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18797. }
  18798. }
  18799. declare module BABYLON {
  18800. /** @hidden */
  18801. export var colorPixelShader: {
  18802. name: string;
  18803. shader: string;
  18804. };
  18805. }
  18806. declare module BABYLON {
  18807. /** @hidden */
  18808. export var colorVertexShader: {
  18809. name: string;
  18810. shader: string;
  18811. };
  18812. }
  18813. declare module BABYLON {
  18814. /**
  18815. * Line mesh
  18816. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18817. */
  18818. export class LinesMesh extends Mesh {
  18819. /**
  18820. * If vertex color should be applied to the mesh
  18821. */
  18822. readonly useVertexColor?: boolean | undefined;
  18823. /**
  18824. * If vertex alpha should be applied to the mesh
  18825. */
  18826. readonly useVertexAlpha?: boolean | undefined;
  18827. /**
  18828. * Color of the line (Default: White)
  18829. */
  18830. color: Color3;
  18831. /**
  18832. * Alpha of the line (Default: 1)
  18833. */
  18834. alpha: number;
  18835. /**
  18836. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18837. * This margin is expressed in world space coordinates, so its value may vary.
  18838. * Default value is 0.1
  18839. */
  18840. intersectionThreshold: number;
  18841. private _colorShader;
  18842. private color4;
  18843. /**
  18844. * Creates a new LinesMesh
  18845. * @param name defines the name
  18846. * @param scene defines the hosting scene
  18847. * @param parent defines the parent mesh if any
  18848. * @param source defines the optional source LinesMesh used to clone data from
  18849. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18850. * When false, achieved by calling a clone(), also passing False.
  18851. * This will make creation of children, recursive.
  18852. * @param useVertexColor defines if this LinesMesh supports vertex color
  18853. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18854. */
  18855. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  18856. /**
  18857. * If vertex color should be applied to the mesh
  18858. */
  18859. useVertexColor?: boolean | undefined,
  18860. /**
  18861. * If vertex alpha should be applied to the mesh
  18862. */
  18863. useVertexAlpha?: boolean | undefined);
  18864. private _addClipPlaneDefine;
  18865. private _removeClipPlaneDefine;
  18866. isReady(): boolean;
  18867. /**
  18868. * Returns the string "LineMesh"
  18869. */
  18870. getClassName(): string;
  18871. /**
  18872. * @hidden
  18873. */
  18874. /**
  18875. * @hidden
  18876. */
  18877. material: Material;
  18878. /**
  18879. * @hidden
  18880. */
  18881. readonly checkCollisions: boolean;
  18882. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  18883. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  18884. /**
  18885. * Disposes of the line mesh
  18886. * @param doNotRecurse If children should be disposed
  18887. */
  18888. dispose(doNotRecurse?: boolean): void;
  18889. /**
  18890. * Returns a new LineMesh object cloned from the current one.
  18891. */
  18892. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18893. /**
  18894. * Creates a new InstancedLinesMesh object from the mesh model.
  18895. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18896. * @param name defines the name of the new instance
  18897. * @returns a new InstancedLinesMesh
  18898. */
  18899. createInstance(name: string): InstancedLinesMesh;
  18900. }
  18901. /**
  18902. * Creates an instance based on a source LinesMesh
  18903. */
  18904. export class InstancedLinesMesh extends InstancedMesh {
  18905. /**
  18906. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18907. * This margin is expressed in world space coordinates, so its value may vary.
  18908. * Initilized with the intersectionThreshold value of the source LinesMesh
  18909. */
  18910. intersectionThreshold: number;
  18911. constructor(name: string, source: LinesMesh);
  18912. /**
  18913. * Returns the string "InstancedLinesMesh".
  18914. */
  18915. getClassName(): string;
  18916. }
  18917. }
  18918. declare module BABYLON {
  18919. /** @hidden */
  18920. export var linePixelShader: {
  18921. name: string;
  18922. shader: string;
  18923. };
  18924. }
  18925. declare module BABYLON {
  18926. /** @hidden */
  18927. export var lineVertexShader: {
  18928. name: string;
  18929. shader: string;
  18930. };
  18931. }
  18932. declare module BABYLON {
  18933. interface AbstractMesh {
  18934. /**
  18935. * Gets the edgesRenderer associated with the mesh
  18936. */
  18937. edgesRenderer: Nullable<EdgesRenderer>;
  18938. }
  18939. interface LinesMesh {
  18940. /**
  18941. * Enables the edge rendering mode on the mesh.
  18942. * This mode makes the mesh edges visible
  18943. * @param epsilon defines the maximal distance between two angles to detect a face
  18944. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18945. * @returns the currentAbstractMesh
  18946. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18947. */
  18948. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18949. }
  18950. interface InstancedLinesMesh {
  18951. /**
  18952. * Enables the edge rendering mode on the mesh.
  18953. * This mode makes the mesh edges visible
  18954. * @param epsilon defines the maximal distance between two angles to detect a face
  18955. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18956. * @returns the current InstancedLinesMesh
  18957. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18958. */
  18959. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  18960. }
  18961. /**
  18962. * Defines the minimum contract an Edges renderer should follow.
  18963. */
  18964. export interface IEdgesRenderer extends IDisposable {
  18965. /**
  18966. * Gets or sets a boolean indicating if the edgesRenderer is active
  18967. */
  18968. isEnabled: boolean;
  18969. /**
  18970. * Renders the edges of the attached mesh,
  18971. */
  18972. render(): void;
  18973. /**
  18974. * Checks wether or not the edges renderer is ready to render.
  18975. * @return true if ready, otherwise false.
  18976. */
  18977. isReady(): boolean;
  18978. }
  18979. /**
  18980. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  18981. */
  18982. export class EdgesRenderer implements IEdgesRenderer {
  18983. /**
  18984. * Define the size of the edges with an orthographic camera
  18985. */
  18986. edgesWidthScalerForOrthographic: number;
  18987. /**
  18988. * Define the size of the edges with a perspective camera
  18989. */
  18990. edgesWidthScalerForPerspective: number;
  18991. protected _source: AbstractMesh;
  18992. protected _linesPositions: number[];
  18993. protected _linesNormals: number[];
  18994. protected _linesIndices: number[];
  18995. protected _epsilon: number;
  18996. protected _indicesCount: number;
  18997. protected _lineShader: ShaderMaterial;
  18998. protected _ib: DataBuffer;
  18999. protected _buffers: {
  19000. [key: string]: Nullable<VertexBuffer>;
  19001. };
  19002. protected _checkVerticesInsteadOfIndices: boolean;
  19003. private _meshRebuildObserver;
  19004. private _meshDisposeObserver;
  19005. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19006. isEnabled: boolean;
  19007. /**
  19008. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19009. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19010. * @param source Mesh used to create edges
  19011. * @param epsilon sum of angles in adjacency to check for edge
  19012. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19013. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19014. */
  19015. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19016. protected _prepareRessources(): void;
  19017. /** @hidden */ private _rebuild(): void;
  19018. /**
  19019. * Releases the required resources for the edges renderer
  19020. */
  19021. dispose(): void;
  19022. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19023. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19024. /**
  19025. * Checks if the pair of p0 and p1 is en edge
  19026. * @param faceIndex
  19027. * @param edge
  19028. * @param faceNormals
  19029. * @param p0
  19030. * @param p1
  19031. * @private
  19032. */
  19033. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19034. /**
  19035. * push line into the position, normal and index buffer
  19036. * @protected
  19037. */
  19038. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19039. /**
  19040. * Generates lines edges from adjacencjes
  19041. * @private
  19042. */ private _generateEdgesLines(): void;
  19043. /**
  19044. * Checks wether or not the edges renderer is ready to render.
  19045. * @return true if ready, otherwise false.
  19046. */
  19047. isReady(): boolean;
  19048. /**
  19049. * Renders the edges of the attached mesh,
  19050. */
  19051. render(): void;
  19052. }
  19053. /**
  19054. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19055. */
  19056. export class LineEdgesRenderer extends EdgesRenderer {
  19057. /**
  19058. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19059. * @param source LineMesh used to generate edges
  19060. * @param epsilon not important (specified angle for edge detection)
  19061. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19062. */
  19063. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19064. /**
  19065. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19066. */ private _generateEdgesLines(): void;
  19067. }
  19068. }
  19069. declare module BABYLON {
  19070. /**
  19071. * This represents the object necessary to create a rendering group.
  19072. * This is exclusively used and created by the rendering manager.
  19073. * To modify the behavior, you use the available helpers in your scene or meshes.
  19074. * @hidden
  19075. */
  19076. export class RenderingGroup {
  19077. index: number;
  19078. private static _zeroVector;
  19079. private _scene;
  19080. private _opaqueSubMeshes;
  19081. private _transparentSubMeshes;
  19082. private _alphaTestSubMeshes;
  19083. private _depthOnlySubMeshes;
  19084. private _particleSystems;
  19085. private _spriteManagers;
  19086. private _opaqueSortCompareFn;
  19087. private _alphaTestSortCompareFn;
  19088. private _transparentSortCompareFn;
  19089. private _renderOpaque;
  19090. private _renderAlphaTest;
  19091. private _renderTransparent;
  19092. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19093. onBeforeTransparentRendering: () => void;
  19094. /**
  19095. * Set the opaque sort comparison function.
  19096. * If null the sub meshes will be render in the order they were created
  19097. */
  19098. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19099. /**
  19100. * Set the alpha test sort comparison function.
  19101. * If null the sub meshes will be render in the order they were created
  19102. */
  19103. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19104. /**
  19105. * Set the transparent sort comparison function.
  19106. * If null the sub meshes will be render in the order they were created
  19107. */
  19108. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19109. /**
  19110. * Creates a new rendering group.
  19111. * @param index The rendering group index
  19112. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19113. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19114. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19115. */
  19116. 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>);
  19117. /**
  19118. * Render all the sub meshes contained in the group.
  19119. * @param customRenderFunction Used to override the default render behaviour of the group.
  19120. * @returns true if rendered some submeshes.
  19121. */
  19122. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19123. /**
  19124. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19125. * @param subMeshes The submeshes to render
  19126. */
  19127. private renderOpaqueSorted;
  19128. /**
  19129. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19130. * @param subMeshes The submeshes to render
  19131. */
  19132. private renderAlphaTestSorted;
  19133. /**
  19134. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19135. * @param subMeshes The submeshes to render
  19136. */
  19137. private renderTransparentSorted;
  19138. /**
  19139. * Renders the submeshes in a specified order.
  19140. * @param subMeshes The submeshes to sort before render
  19141. * @param sortCompareFn The comparison function use to sort
  19142. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19143. * @param transparent Specifies to activate blending if true
  19144. */
  19145. private static renderSorted;
  19146. /**
  19147. * Renders the submeshes in the order they were dispatched (no sort applied).
  19148. * @param subMeshes The submeshes to render
  19149. */
  19150. private static renderUnsorted;
  19151. /**
  19152. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19153. * are rendered back to front if in the same alpha index.
  19154. *
  19155. * @param a The first submesh
  19156. * @param b The second submesh
  19157. * @returns The result of the comparison
  19158. */
  19159. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19160. /**
  19161. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19162. * are rendered back to front.
  19163. *
  19164. * @param a The first submesh
  19165. * @param b The second submesh
  19166. * @returns The result of the comparison
  19167. */
  19168. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19169. /**
  19170. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19171. * are rendered front to back (prevent overdraw).
  19172. *
  19173. * @param a The first submesh
  19174. * @param b The second submesh
  19175. * @returns The result of the comparison
  19176. */
  19177. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19178. /**
  19179. * Resets the different lists of submeshes to prepare a new frame.
  19180. */
  19181. prepare(): void;
  19182. dispose(): void;
  19183. /**
  19184. * Inserts the submesh in its correct queue depending on its material.
  19185. * @param subMesh The submesh to dispatch
  19186. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19187. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19188. */
  19189. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19190. dispatchSprites(spriteManager: ISpriteManager): void;
  19191. dispatchParticles(particleSystem: IParticleSystem): void;
  19192. private _renderParticles;
  19193. private _renderSprites;
  19194. }
  19195. }
  19196. declare module BABYLON {
  19197. /**
  19198. * Interface describing the different options available in the rendering manager
  19199. * regarding Auto Clear between groups.
  19200. */
  19201. export interface IRenderingManagerAutoClearSetup {
  19202. /**
  19203. * Defines whether or not autoclear is enable.
  19204. */
  19205. autoClear: boolean;
  19206. /**
  19207. * Defines whether or not to autoclear the depth buffer.
  19208. */
  19209. depth: boolean;
  19210. /**
  19211. * Defines whether or not to autoclear the stencil buffer.
  19212. */
  19213. stencil: boolean;
  19214. }
  19215. /**
  19216. * This class is used by the onRenderingGroupObservable
  19217. */
  19218. export class RenderingGroupInfo {
  19219. /**
  19220. * The Scene that being rendered
  19221. */
  19222. scene: Scene;
  19223. /**
  19224. * The camera currently used for the rendering pass
  19225. */
  19226. camera: Nullable<Camera>;
  19227. /**
  19228. * The ID of the renderingGroup being processed
  19229. */
  19230. renderingGroupId: number;
  19231. }
  19232. /**
  19233. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19234. * It is enable to manage the different groups as well as the different necessary sort functions.
  19235. * This should not be used directly aside of the few static configurations
  19236. */
  19237. export class RenderingManager {
  19238. /**
  19239. * The max id used for rendering groups (not included)
  19240. */
  19241. static MAX_RENDERINGGROUPS: number;
  19242. /**
  19243. * The min id used for rendering groups (included)
  19244. */
  19245. static MIN_RENDERINGGROUPS: number;
  19246. /**
  19247. * Used to globally prevent autoclearing scenes.
  19248. */
  19249. static AUTOCLEAR: boolean;
  19250. /**
  19251. * @hidden
  19252. */ private _useSceneAutoClearSetup: boolean;
  19253. private _scene;
  19254. private _renderingGroups;
  19255. private _depthStencilBufferAlreadyCleaned;
  19256. private _autoClearDepthStencil;
  19257. private _customOpaqueSortCompareFn;
  19258. private _customAlphaTestSortCompareFn;
  19259. private _customTransparentSortCompareFn;
  19260. private _renderingGroupInfo;
  19261. /**
  19262. * Instantiates a new rendering group for a particular scene
  19263. * @param scene Defines the scene the groups belongs to
  19264. */
  19265. constructor(scene: Scene);
  19266. private _clearDepthStencilBuffer;
  19267. /**
  19268. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19269. * @hidden
  19270. */
  19271. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19272. /**
  19273. * Resets the different information of the group to prepare a new frame
  19274. * @hidden
  19275. */
  19276. reset(): void;
  19277. /**
  19278. * Dispose and release the group and its associated resources.
  19279. * @hidden
  19280. */
  19281. dispose(): void;
  19282. /**
  19283. * Clear the info related to rendering groups preventing retention points during dispose.
  19284. */
  19285. freeRenderingGroups(): void;
  19286. private _prepareRenderingGroup;
  19287. /**
  19288. * Add a sprite manager to the rendering manager in order to render it this frame.
  19289. * @param spriteManager Define the sprite manager to render
  19290. */
  19291. dispatchSprites(spriteManager: ISpriteManager): void;
  19292. /**
  19293. * Add a particle system to the rendering manager in order to render it this frame.
  19294. * @param particleSystem Define the particle system to render
  19295. */
  19296. dispatchParticles(particleSystem: IParticleSystem): void;
  19297. /**
  19298. * Add a submesh to the manager in order to render it this frame
  19299. * @param subMesh The submesh to dispatch
  19300. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19301. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19302. */
  19303. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19304. /**
  19305. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19306. * This allowed control for front to back rendering or reversly depending of the special needs.
  19307. *
  19308. * @param renderingGroupId The rendering group id corresponding to its index
  19309. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19310. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19311. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19312. */
  19313. 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;
  19314. /**
  19315. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19316. *
  19317. * @param renderingGroupId The rendering group id corresponding to its index
  19318. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19319. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19320. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19321. */
  19322. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19323. /**
  19324. * Gets the current auto clear configuration for one rendering group of the rendering
  19325. * manager.
  19326. * @param index the rendering group index to get the information for
  19327. * @returns The auto clear setup for the requested rendering group
  19328. */
  19329. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19330. }
  19331. }
  19332. declare module BABYLON {
  19333. /**
  19334. * This Helps creating a texture that will be created from a camera in your scene.
  19335. * It is basically a dynamic texture that could be used to create special effects for instance.
  19336. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19337. */
  19338. export class RenderTargetTexture extends Texture {
  19339. isCube: boolean;
  19340. /**
  19341. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19342. */
  19343. static readonly REFRESHRATE_RENDER_ONCE: number;
  19344. /**
  19345. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19346. */
  19347. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19348. /**
  19349. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19350. * the central point of your effect and can save a lot of performances.
  19351. */
  19352. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19353. /**
  19354. * Use this predicate to dynamically define the list of mesh you want to render.
  19355. * If set, the renderList property will be overwritten.
  19356. */
  19357. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19358. private _renderList;
  19359. /**
  19360. * Use this list to define the list of mesh you want to render.
  19361. */
  19362. renderList: Nullable<Array<AbstractMesh>>;
  19363. private _hookArray;
  19364. /**
  19365. * Define if particles should be rendered in your texture.
  19366. */
  19367. renderParticles: boolean;
  19368. /**
  19369. * Define if sprites should be rendered in your texture.
  19370. */
  19371. renderSprites: boolean;
  19372. /**
  19373. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19374. */
  19375. coordinatesMode: number;
  19376. /**
  19377. * Define the camera used to render the texture.
  19378. */
  19379. activeCamera: Nullable<Camera>;
  19380. /**
  19381. * Override the render function of the texture with your own one.
  19382. */
  19383. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19384. /**
  19385. * Define if camera post processes should be use while rendering the texture.
  19386. */
  19387. useCameraPostProcesses: boolean;
  19388. /**
  19389. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19390. */
  19391. ignoreCameraViewport: boolean;
  19392. private _postProcessManager;
  19393. private _postProcesses;
  19394. private _resizeObserver;
  19395. /**
  19396. * An event triggered when the texture is unbind.
  19397. */
  19398. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19399. /**
  19400. * An event triggered when the texture is unbind.
  19401. */
  19402. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19403. private _onAfterUnbindObserver;
  19404. /**
  19405. * Set a after unbind callback in the texture.
  19406. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19407. */
  19408. onAfterUnbind: () => void;
  19409. /**
  19410. * An event triggered before rendering the texture
  19411. */
  19412. onBeforeRenderObservable: Observable<number>;
  19413. private _onBeforeRenderObserver;
  19414. /**
  19415. * Set a before render callback in the texture.
  19416. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19417. */
  19418. onBeforeRender: (faceIndex: number) => void;
  19419. /**
  19420. * An event triggered after rendering the texture
  19421. */
  19422. onAfterRenderObservable: Observable<number>;
  19423. private _onAfterRenderObserver;
  19424. /**
  19425. * Set a after render callback in the texture.
  19426. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19427. */
  19428. onAfterRender: (faceIndex: number) => void;
  19429. /**
  19430. * An event triggered after the texture clear
  19431. */
  19432. onClearObservable: Observable<Engine>;
  19433. private _onClearObserver;
  19434. /**
  19435. * Set a clear callback in the texture.
  19436. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19437. */
  19438. onClear: (Engine: Engine) => void;
  19439. /**
  19440. * An event triggered when the texture is resized.
  19441. */
  19442. onResizeObservable: Observable<RenderTargetTexture>;
  19443. /**
  19444. * Define the clear color of the Render Target if it should be different from the scene.
  19445. */
  19446. clearColor: Color4;
  19447. protected _size: number | {
  19448. width: number;
  19449. height: number;
  19450. };
  19451. protected _initialSizeParameter: number | {
  19452. width: number;
  19453. height: number;
  19454. } | {
  19455. ratio: number;
  19456. };
  19457. protected _sizeRatio: Nullable<number>;
  19458. /** @hidden */ private _generateMipMaps: boolean;
  19459. protected _renderingManager: RenderingManager;
  19460. /** @hidden */ private _waitingRenderList: string[];
  19461. protected _doNotChangeAspectRatio: boolean;
  19462. protected _currentRefreshId: number;
  19463. protected _refreshRate: number;
  19464. protected _textureMatrix: Matrix;
  19465. protected _samples: number;
  19466. protected _renderTargetOptions: RenderTargetCreationOptions;
  19467. /**
  19468. * Gets render target creation options that were used.
  19469. */
  19470. readonly renderTargetOptions: RenderTargetCreationOptions;
  19471. protected _engine: Engine;
  19472. protected _onRatioRescale(): void;
  19473. /**
  19474. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19475. * It must define where the camera used to render the texture is set
  19476. */
  19477. boundingBoxPosition: Vector3;
  19478. private _boundingBoxSize;
  19479. /**
  19480. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19481. * When defined, the cubemap will switch to local mode
  19482. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19483. * @example https://www.babylonjs-playground.com/#RNASML
  19484. */
  19485. boundingBoxSize: Vector3;
  19486. /**
  19487. * In case the RTT has been created with a depth texture, get the associated
  19488. * depth texture.
  19489. * Otherwise, return null.
  19490. */
  19491. depthStencilTexture: Nullable<InternalTexture>;
  19492. /**
  19493. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19494. * or used a shadow, depth texture...
  19495. * @param name The friendly name of the texture
  19496. * @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)
  19497. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19498. * @param generateMipMaps True if mip maps need to be generated after render.
  19499. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19500. * @param type The type of the buffer in the RTT (int, half float, float...)
  19501. * @param isCube True if a cube texture needs to be created
  19502. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19503. * @param generateDepthBuffer True to generate a depth buffer
  19504. * @param generateStencilBuffer True to generate a stencil buffer
  19505. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19506. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19507. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19508. */
  19509. constructor(name: string, size: number | {
  19510. width: number;
  19511. height: number;
  19512. } | {
  19513. ratio: number;
  19514. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19515. /**
  19516. * Creates a depth stencil texture.
  19517. * This is only available in WebGL 2 or with the depth texture extension available.
  19518. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19519. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19520. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19521. */
  19522. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19523. private _processSizeParameter;
  19524. /**
  19525. * Define the number of samples to use in case of MSAA.
  19526. * It defaults to one meaning no MSAA has been enabled.
  19527. */
  19528. samples: number;
  19529. /**
  19530. * Resets the refresh counter of the texture and start bak from scratch.
  19531. * Could be useful to regenerate the texture if it is setup to render only once.
  19532. */
  19533. resetRefreshCounter(): void;
  19534. /**
  19535. * Define the refresh rate of the texture or the rendering frequency.
  19536. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19537. */
  19538. refreshRate: number;
  19539. /**
  19540. * Adds a post process to the render target rendering passes.
  19541. * @param postProcess define the post process to add
  19542. */
  19543. addPostProcess(postProcess: PostProcess): void;
  19544. /**
  19545. * Clear all the post processes attached to the render target
  19546. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19547. */
  19548. clearPostProcesses(dispose?: boolean): void;
  19549. /**
  19550. * Remove one of the post process from the list of attached post processes to the texture
  19551. * @param postProcess define the post process to remove from the list
  19552. */
  19553. removePostProcess(postProcess: PostProcess): void;
  19554. /** @hidden */ private _shouldRender(): boolean;
  19555. /**
  19556. * Gets the actual render size of the texture.
  19557. * @returns the width of the render size
  19558. */
  19559. getRenderSize(): number;
  19560. /**
  19561. * Gets the actual render width of the texture.
  19562. * @returns the width of the render size
  19563. */
  19564. getRenderWidth(): number;
  19565. /**
  19566. * Gets the actual render height of the texture.
  19567. * @returns the height of the render size
  19568. */
  19569. getRenderHeight(): number;
  19570. /**
  19571. * Get if the texture can be rescaled or not.
  19572. */
  19573. readonly canRescale: boolean;
  19574. /**
  19575. * Resize the texture using a ratio.
  19576. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19577. */
  19578. scale(ratio: number): void;
  19579. /**
  19580. * Get the texture reflection matrix used to rotate/transform the reflection.
  19581. * @returns the reflection matrix
  19582. */
  19583. getReflectionTextureMatrix(): Matrix;
  19584. /**
  19585. * Resize the texture to a new desired size.
  19586. * Be carrefull as it will recreate all the data in the new texture.
  19587. * @param size Define the new size. It can be:
  19588. * - a number for squared texture,
  19589. * - an object containing { width: number, height: number }
  19590. * - or an object containing a ratio { ratio: number }
  19591. */
  19592. resize(size: number | {
  19593. width: number;
  19594. height: number;
  19595. } | {
  19596. ratio: number;
  19597. }): void;
  19598. /**
  19599. * Renders all the objects from the render list into the texture.
  19600. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19601. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19602. */
  19603. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19604. private _bestReflectionRenderTargetDimension;
  19605. /**
  19606. * @hidden
  19607. * @param faceIndex face index to bind to if this is a cubetexture
  19608. */ private _bindFrameBuffer(faceIndex?: number): void;
  19609. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19610. private renderToTarget;
  19611. /**
  19612. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19613. * This allowed control for front to back rendering or reversly depending of the special needs.
  19614. *
  19615. * @param renderingGroupId The rendering group id corresponding to its index
  19616. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19617. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19618. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19619. */
  19620. 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;
  19621. /**
  19622. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19623. *
  19624. * @param renderingGroupId The rendering group id corresponding to its index
  19625. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19626. */
  19627. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19628. /**
  19629. * Clones the texture.
  19630. * @returns the cloned texture
  19631. */
  19632. clone(): RenderTargetTexture;
  19633. /**
  19634. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19635. * @returns The JSON representation of the texture
  19636. */
  19637. serialize(): any;
  19638. /**
  19639. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19640. */
  19641. disposeFramebufferObjects(): void;
  19642. /**
  19643. * Dispose the texture and release its associated resources.
  19644. */
  19645. dispose(): void;
  19646. /** @hidden */ private _rebuild(): void;
  19647. /**
  19648. * Clear the info related to rendering groups preventing retention point in material dispose.
  19649. */
  19650. freeRenderingGroups(): void;
  19651. /**
  19652. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19653. * @returns the view count
  19654. */
  19655. getViewCount(): number;
  19656. }
  19657. }
  19658. declare module BABYLON {
  19659. /**
  19660. * Base class for the main features of a material in Babylon.js
  19661. */
  19662. export class Material implements IAnimatable {
  19663. /**
  19664. * Returns the triangle fill mode
  19665. */
  19666. static readonly TriangleFillMode: number;
  19667. /**
  19668. * Returns the wireframe mode
  19669. */
  19670. static readonly WireFrameFillMode: number;
  19671. /**
  19672. * Returns the point fill mode
  19673. */
  19674. static readonly PointFillMode: number;
  19675. /**
  19676. * Returns the point list draw mode
  19677. */
  19678. static readonly PointListDrawMode: number;
  19679. /**
  19680. * Returns the line list draw mode
  19681. */
  19682. static readonly LineListDrawMode: number;
  19683. /**
  19684. * Returns the line loop draw mode
  19685. */
  19686. static readonly LineLoopDrawMode: number;
  19687. /**
  19688. * Returns the line strip draw mode
  19689. */
  19690. static readonly LineStripDrawMode: number;
  19691. /**
  19692. * Returns the triangle strip draw mode
  19693. */
  19694. static readonly TriangleStripDrawMode: number;
  19695. /**
  19696. * Returns the triangle fan draw mode
  19697. */
  19698. static readonly TriangleFanDrawMode: number;
  19699. /**
  19700. * Stores the clock-wise side orientation
  19701. */
  19702. static readonly ClockWiseSideOrientation: number;
  19703. /**
  19704. * Stores the counter clock-wise side orientation
  19705. */
  19706. static readonly CounterClockWiseSideOrientation: number;
  19707. /**
  19708. * The dirty texture flag value
  19709. */
  19710. static readonly TextureDirtyFlag: number;
  19711. /**
  19712. * The dirty light flag value
  19713. */
  19714. static readonly LightDirtyFlag: number;
  19715. /**
  19716. * The dirty fresnel flag value
  19717. */
  19718. static readonly FresnelDirtyFlag: number;
  19719. /**
  19720. * The dirty attribute flag value
  19721. */
  19722. static readonly AttributesDirtyFlag: number;
  19723. /**
  19724. * The dirty misc flag value
  19725. */
  19726. static readonly MiscDirtyFlag: number;
  19727. /**
  19728. * The all dirty flag value
  19729. */
  19730. static readonly AllDirtyFlag: number;
  19731. /**
  19732. * The ID of the material
  19733. */
  19734. id: string;
  19735. /**
  19736. * Gets or sets the unique id of the material
  19737. */
  19738. uniqueId: number;
  19739. /**
  19740. * The name of the material
  19741. */
  19742. name: string;
  19743. /**
  19744. * Gets or sets user defined metadata
  19745. */
  19746. metadata: any;
  19747. /**
  19748. * For internal use only. Please do not use.
  19749. */
  19750. reservedDataStore: any;
  19751. /**
  19752. * Specifies if the ready state should be checked on each call
  19753. */
  19754. checkReadyOnEveryCall: boolean;
  19755. /**
  19756. * Specifies if the ready state should be checked once
  19757. */
  19758. checkReadyOnlyOnce: boolean;
  19759. /**
  19760. * The state of the material
  19761. */
  19762. state: string;
  19763. /**
  19764. * The alpha value of the material
  19765. */
  19766. protected _alpha: number;
  19767. /**
  19768. * List of inspectable custom properties (used by the Inspector)
  19769. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19770. */
  19771. inspectableCustomProperties: IInspectable[];
  19772. /**
  19773. * Sets the alpha value of the material
  19774. */
  19775. /**
  19776. * Gets the alpha value of the material
  19777. */
  19778. alpha: number;
  19779. /**
  19780. * Specifies if back face culling is enabled
  19781. */
  19782. protected _backFaceCulling: boolean;
  19783. /**
  19784. * Sets the back-face culling state
  19785. */
  19786. /**
  19787. * Gets the back-face culling state
  19788. */
  19789. backFaceCulling: boolean;
  19790. /**
  19791. * Stores the value for side orientation
  19792. */
  19793. sideOrientation: number;
  19794. /**
  19795. * Callback triggered when the material is compiled
  19796. */
  19797. onCompiled: Nullable<(effect: Effect) => void>;
  19798. /**
  19799. * Callback triggered when an error occurs
  19800. */
  19801. onError: Nullable<(effect: Effect, errors: string) => void>;
  19802. /**
  19803. * Callback triggered to get the render target textures
  19804. */
  19805. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19806. /**
  19807. * Gets a boolean indicating that current material needs to register RTT
  19808. */
  19809. readonly hasRenderTargetTextures: boolean;
  19810. /**
  19811. * Specifies if the material should be serialized
  19812. */
  19813. doNotSerialize: boolean;
  19814. /**
  19815. * @hidden
  19816. */ private _storeEffectOnSubMeshes: boolean;
  19817. /**
  19818. * Stores the animations for the material
  19819. */
  19820. animations: Nullable<Array<Animation>>;
  19821. /**
  19822. * An event triggered when the material is disposed
  19823. */
  19824. onDisposeObservable: Observable<Material>;
  19825. /**
  19826. * An observer which watches for dispose events
  19827. */
  19828. private _onDisposeObserver;
  19829. private _onUnBindObservable;
  19830. /**
  19831. * Called during a dispose event
  19832. */
  19833. onDispose: () => void;
  19834. private _onBindObservable;
  19835. /**
  19836. * An event triggered when the material is bound
  19837. */
  19838. readonly onBindObservable: Observable<AbstractMesh>;
  19839. /**
  19840. * An observer which watches for bind events
  19841. */
  19842. private _onBindObserver;
  19843. /**
  19844. * Called during a bind event
  19845. */
  19846. onBind: (Mesh: AbstractMesh) => void;
  19847. /**
  19848. * An event triggered when the material is unbound
  19849. */
  19850. readonly onUnBindObservable: Observable<Material>;
  19851. /**
  19852. * Stores the value of the alpha mode
  19853. */
  19854. private _alphaMode;
  19855. /**
  19856. * Sets the value of the alpha mode.
  19857. *
  19858. * | Value | Type | Description |
  19859. * | --- | --- | --- |
  19860. * | 0 | ALPHA_DISABLE | |
  19861. * | 1 | ALPHA_ADD | |
  19862. * | 2 | ALPHA_COMBINE | |
  19863. * | 3 | ALPHA_SUBTRACT | |
  19864. * | 4 | ALPHA_MULTIPLY | |
  19865. * | 5 | ALPHA_MAXIMIZED | |
  19866. * | 6 | ALPHA_ONEONE | |
  19867. * | 7 | ALPHA_PREMULTIPLIED | |
  19868. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19869. * | 9 | ALPHA_INTERPOLATE | |
  19870. * | 10 | ALPHA_SCREENMODE | |
  19871. *
  19872. */
  19873. /**
  19874. * Gets the value of the alpha mode
  19875. */
  19876. alphaMode: number;
  19877. /**
  19878. * Stores the state of the need depth pre-pass value
  19879. */
  19880. private _needDepthPrePass;
  19881. /**
  19882. * Sets the need depth pre-pass value
  19883. */
  19884. /**
  19885. * Gets the depth pre-pass value
  19886. */
  19887. needDepthPrePass: boolean;
  19888. /**
  19889. * Specifies if depth writing should be disabled
  19890. */
  19891. disableDepthWrite: boolean;
  19892. /**
  19893. * Specifies if depth writing should be forced
  19894. */
  19895. forceDepthWrite: boolean;
  19896. /**
  19897. * Specifies if there should be a separate pass for culling
  19898. */
  19899. separateCullingPass: boolean;
  19900. /**
  19901. * Stores the state specifing if fog should be enabled
  19902. */
  19903. private _fogEnabled;
  19904. /**
  19905. * Sets the state for enabling fog
  19906. */
  19907. /**
  19908. * Gets the value of the fog enabled state
  19909. */
  19910. fogEnabled: boolean;
  19911. /**
  19912. * Stores the size of points
  19913. */
  19914. pointSize: number;
  19915. /**
  19916. * Stores the z offset value
  19917. */
  19918. zOffset: number;
  19919. /**
  19920. * Gets a value specifying if wireframe mode is enabled
  19921. */
  19922. /**
  19923. * Sets the state of wireframe mode
  19924. */
  19925. wireframe: boolean;
  19926. /**
  19927. * Gets the value specifying if point clouds are enabled
  19928. */
  19929. /**
  19930. * Sets the state of point cloud mode
  19931. */
  19932. pointsCloud: boolean;
  19933. /**
  19934. * Gets the material fill mode
  19935. */
  19936. /**
  19937. * Sets the material fill mode
  19938. */
  19939. fillMode: number;
  19940. /**
  19941. * @hidden
  19942. * Stores the effects for the material
  19943. */ private _effect: Nullable<Effect>;
  19944. /**
  19945. * @hidden
  19946. * Specifies if the material was previously ready
  19947. */ private _wasPreviouslyReady: boolean;
  19948. /**
  19949. * Specifies if uniform buffers should be used
  19950. */
  19951. private _useUBO;
  19952. /**
  19953. * Stores a reference to the scene
  19954. */
  19955. private _scene;
  19956. /**
  19957. * Stores the fill mode state
  19958. */
  19959. private _fillMode;
  19960. /**
  19961. * Specifies if the depth write state should be cached
  19962. */
  19963. private _cachedDepthWriteState;
  19964. /**
  19965. * Stores the uniform buffer
  19966. */
  19967. protected _uniformBuffer: UniformBuffer;
  19968. /** @hidden */ private _indexInSceneMaterialArray: number;
  19969. /** @hidden */
  19970. meshMap: Nullable<{
  19971. [id: string]: AbstractMesh | undefined;
  19972. }>;
  19973. /**
  19974. * Creates a material instance
  19975. * @param name defines the name of the material
  19976. * @param scene defines the scene to reference
  19977. * @param doNotAdd specifies if the material should be added to the scene
  19978. */
  19979. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  19980. /**
  19981. * Returns a string representation of the current material
  19982. * @param fullDetails defines a boolean indicating which levels of logging is desired
  19983. * @returns a string with material information
  19984. */
  19985. toString(fullDetails?: boolean): string;
  19986. /**
  19987. * Gets the class name of the material
  19988. * @returns a string with the class name of the material
  19989. */
  19990. getClassName(): string;
  19991. /**
  19992. * Specifies if updates for the material been locked
  19993. */
  19994. readonly isFrozen: boolean;
  19995. /**
  19996. * Locks updates for the material
  19997. */
  19998. freeze(): void;
  19999. /**
  20000. * Unlocks updates for the material
  20001. */
  20002. unfreeze(): void;
  20003. /**
  20004. * Specifies if the material is ready to be used
  20005. * @param mesh defines the mesh to check
  20006. * @param useInstances specifies if instances should be used
  20007. * @returns a boolean indicating if the material is ready to be used
  20008. */
  20009. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20010. /**
  20011. * Specifies that the submesh is ready to be used
  20012. * @param mesh defines the mesh to check
  20013. * @param subMesh defines which submesh to check
  20014. * @param useInstances specifies that instances should be used
  20015. * @returns a boolean indicating that the submesh is ready or not
  20016. */
  20017. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20018. /**
  20019. * Returns the material effect
  20020. * @returns the effect associated with the material
  20021. */
  20022. getEffect(): Nullable<Effect>;
  20023. /**
  20024. * Returns the current scene
  20025. * @returns a Scene
  20026. */
  20027. getScene(): Scene;
  20028. /**
  20029. * Specifies if the material will require alpha blending
  20030. * @returns a boolean specifying if alpha blending is needed
  20031. */
  20032. needAlphaBlending(): boolean;
  20033. /**
  20034. * Specifies if the mesh will require alpha blending
  20035. * @param mesh defines the mesh to check
  20036. * @returns a boolean specifying if alpha blending is needed for the mesh
  20037. */
  20038. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20039. /**
  20040. * Specifies if this material should be rendered in alpha test mode
  20041. * @returns a boolean specifying if an alpha test is needed.
  20042. */
  20043. needAlphaTesting(): boolean;
  20044. /**
  20045. * Gets the texture used for the alpha test
  20046. * @returns the texture to use for alpha testing
  20047. */
  20048. getAlphaTestTexture(): Nullable<BaseTexture>;
  20049. /**
  20050. * Marks the material to indicate that it needs to be re-calculated
  20051. */
  20052. markDirty(): void;
  20053. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20054. /**
  20055. * Binds the material to the mesh
  20056. * @param world defines the world transformation matrix
  20057. * @param mesh defines the mesh to bind the material to
  20058. */
  20059. bind(world: Matrix, mesh?: Mesh): void;
  20060. /**
  20061. * Binds the submesh to the material
  20062. * @param world defines the world transformation matrix
  20063. * @param mesh defines the mesh containing the submesh
  20064. * @param subMesh defines the submesh to bind the material to
  20065. */
  20066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20067. /**
  20068. * Binds the world matrix to the material
  20069. * @param world defines the world transformation matrix
  20070. */
  20071. bindOnlyWorldMatrix(world: Matrix): void;
  20072. /**
  20073. * Binds the scene's uniform buffer to the effect.
  20074. * @param effect defines the effect to bind to the scene uniform buffer
  20075. * @param sceneUbo defines the uniform buffer storing scene data
  20076. */
  20077. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20078. /**
  20079. * Binds the view matrix to the effect
  20080. * @param effect defines the effect to bind the view matrix to
  20081. */
  20082. bindView(effect: Effect): void;
  20083. /**
  20084. * Binds the view projection matrix to the effect
  20085. * @param effect defines the effect to bind the view projection matrix to
  20086. */
  20087. bindViewProjection(effect: Effect): void;
  20088. /**
  20089. * Specifies if material alpha testing should be turned on for the mesh
  20090. * @param mesh defines the mesh to check
  20091. */
  20092. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20093. /**
  20094. * Processes to execute after binding the material to a mesh
  20095. * @param mesh defines the rendered mesh
  20096. */
  20097. protected _afterBind(mesh?: Mesh): void;
  20098. /**
  20099. * Unbinds the material from the mesh
  20100. */
  20101. unbind(): void;
  20102. /**
  20103. * Gets the active textures from the material
  20104. * @returns an array of textures
  20105. */
  20106. getActiveTextures(): BaseTexture[];
  20107. /**
  20108. * Specifies if the material uses a texture
  20109. * @param texture defines the texture to check against the material
  20110. * @returns a boolean specifying if the material uses the texture
  20111. */
  20112. hasTexture(texture: BaseTexture): boolean;
  20113. /**
  20114. * Makes a duplicate of the material, and gives it a new name
  20115. * @param name defines the new name for the duplicated material
  20116. * @returns the cloned material
  20117. */
  20118. clone(name: string): Nullable<Material>;
  20119. /**
  20120. * Gets the meshes bound to the material
  20121. * @returns an array of meshes bound to the material
  20122. */
  20123. getBindedMeshes(): AbstractMesh[];
  20124. /**
  20125. * Force shader compilation
  20126. * @param mesh defines the mesh associated with this material
  20127. * @param onCompiled defines a function to execute once the material is compiled
  20128. * @param options defines the options to configure the compilation
  20129. */
  20130. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20131. clipPlane: boolean;
  20132. }>): void;
  20133. /**
  20134. * Force shader compilation
  20135. * @param mesh defines the mesh that will use this material
  20136. * @param options defines additional options for compiling the shaders
  20137. * @returns a promise that resolves when the compilation completes
  20138. */
  20139. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20140. clipPlane: boolean;
  20141. }>): Promise<void>;
  20142. private static readonly _AllDirtyCallBack;
  20143. private static readonly _ImageProcessingDirtyCallBack;
  20144. private static readonly _TextureDirtyCallBack;
  20145. private static readonly _FresnelDirtyCallBack;
  20146. private static readonly _MiscDirtyCallBack;
  20147. private static readonly _LightsDirtyCallBack;
  20148. private static readonly _AttributeDirtyCallBack;
  20149. private static _FresnelAndMiscDirtyCallBack;
  20150. private static _TextureAndMiscDirtyCallBack;
  20151. private static readonly _DirtyCallbackArray;
  20152. private static readonly _RunDirtyCallBacks;
  20153. /**
  20154. * Marks a define in the material to indicate that it needs to be re-computed
  20155. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20156. */
  20157. markAsDirty(flag: number): void;
  20158. /**
  20159. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20160. * @param func defines a function which checks material defines against the submeshes
  20161. */
  20162. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20163. /**
  20164. * Indicates that we need to re-calculated for all submeshes
  20165. */
  20166. protected _markAllSubMeshesAsAllDirty(): void;
  20167. /**
  20168. * Indicates that image processing needs to be re-calculated for all submeshes
  20169. */
  20170. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20171. /**
  20172. * Indicates that textures need to be re-calculated for all submeshes
  20173. */
  20174. protected _markAllSubMeshesAsTexturesDirty(): void;
  20175. /**
  20176. * Indicates that fresnel needs to be re-calculated for all submeshes
  20177. */
  20178. protected _markAllSubMeshesAsFresnelDirty(): void;
  20179. /**
  20180. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20181. */
  20182. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20183. /**
  20184. * Indicates that lights need to be re-calculated for all submeshes
  20185. */
  20186. protected _markAllSubMeshesAsLightsDirty(): void;
  20187. /**
  20188. * Indicates that attributes need to be re-calculated for all submeshes
  20189. */
  20190. protected _markAllSubMeshesAsAttributesDirty(): void;
  20191. /**
  20192. * Indicates that misc needs to be re-calculated for all submeshes
  20193. */
  20194. protected _markAllSubMeshesAsMiscDirty(): void;
  20195. /**
  20196. * Indicates that textures and misc need to be re-calculated for all submeshes
  20197. */
  20198. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20199. /**
  20200. * Disposes the material
  20201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20203. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20204. */
  20205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20206. /** @hidden */
  20207. private releaseVertexArrayObject;
  20208. /**
  20209. * Serializes this material
  20210. * @returns the serialized material object
  20211. */
  20212. serialize(): any;
  20213. /**
  20214. * Creates a material from parsed material data
  20215. * @param parsedMaterial defines parsed material data
  20216. * @param scene defines the hosting scene
  20217. * @param rootUrl defines the root URL to use to load textures
  20218. * @returns a new material
  20219. */
  20220. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20221. }
  20222. }
  20223. declare module BABYLON {
  20224. /**
  20225. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20226. * separate meshes. This can be use to improve performances.
  20227. * @see http://doc.babylonjs.com/how_to/multi_materials
  20228. */
  20229. export class MultiMaterial extends Material {
  20230. private _subMaterials;
  20231. /**
  20232. * Gets or Sets the list of Materials used within the multi material.
  20233. * They need to be ordered according to the submeshes order in the associated mesh
  20234. */
  20235. subMaterials: Nullable<Material>[];
  20236. /**
  20237. * Function used to align with Node.getChildren()
  20238. * @returns the list of Materials used within the multi material
  20239. */
  20240. getChildren(): Nullable<Material>[];
  20241. /**
  20242. * Instantiates a new Multi Material
  20243. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20244. * separate meshes. This can be use to improve performances.
  20245. * @see http://doc.babylonjs.com/how_to/multi_materials
  20246. * @param name Define the name in the scene
  20247. * @param scene Define the scene the material belongs to
  20248. */
  20249. constructor(name: string, scene: Scene);
  20250. private _hookArray;
  20251. /**
  20252. * Get one of the submaterial by its index in the submaterials array
  20253. * @param index The index to look the sub material at
  20254. * @returns The Material if the index has been defined
  20255. */
  20256. getSubMaterial(index: number): Nullable<Material>;
  20257. /**
  20258. * Get the list of active textures for the whole sub materials list.
  20259. * @returns All the textures that will be used during the rendering
  20260. */
  20261. getActiveTextures(): BaseTexture[];
  20262. /**
  20263. * Gets the current class name of the material e.g. "MultiMaterial"
  20264. * Mainly use in serialization.
  20265. * @returns the class name
  20266. */
  20267. getClassName(): string;
  20268. /**
  20269. * Checks if the material is ready to render the requested sub mesh
  20270. * @param mesh Define the mesh the submesh belongs to
  20271. * @param subMesh Define the sub mesh to look readyness for
  20272. * @param useInstances Define whether or not the material is used with instances
  20273. * @returns true if ready, otherwise false
  20274. */
  20275. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20276. /**
  20277. * Clones the current material and its related sub materials
  20278. * @param name Define the name of the newly cloned material
  20279. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20280. * @returns the cloned material
  20281. */
  20282. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20283. /**
  20284. * Serializes the materials into a JSON representation.
  20285. * @returns the JSON representation
  20286. */
  20287. serialize(): any;
  20288. /**
  20289. * Dispose the material and release its associated resources
  20290. * @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)
  20291. * @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)
  20292. * @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)
  20293. */
  20294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20295. /**
  20296. * Creates a MultiMaterial from parsed MultiMaterial data.
  20297. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20298. * @param scene defines the hosting scene
  20299. * @returns a new MultiMaterial
  20300. */
  20301. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20302. }
  20303. }
  20304. declare module BABYLON {
  20305. /**
  20306. * Base class for submeshes
  20307. */
  20308. export class BaseSubMesh {
  20309. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20310. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20311. /**
  20312. * Gets associated effect
  20313. */
  20314. readonly effect: Nullable<Effect>;
  20315. /**
  20316. * Sets associated effect (effect used to render this submesh)
  20317. * @param effect defines the effect to associate with
  20318. * @param defines defines the set of defines used to compile this effect
  20319. */
  20320. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20321. }
  20322. /**
  20323. * Defines a subdivision inside a mesh
  20324. */
  20325. export class SubMesh extends BaseSubMesh implements ICullable {
  20326. /** the material index to use */
  20327. materialIndex: number;
  20328. /** vertex index start */
  20329. verticesStart: number;
  20330. /** vertices count */
  20331. verticesCount: number;
  20332. /** index start */
  20333. indexStart: number;
  20334. /** indices count */
  20335. indexCount: number;
  20336. /** @hidden */ private _linesIndexCount: number;
  20337. private _mesh;
  20338. private _renderingMesh;
  20339. private _boundingInfo;
  20340. private _linesIndexBuffer;
  20341. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20342. /** @hidden */ private _trianglePlanes: Plane[];
  20343. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20344. /** @hidden */ private _renderId: number;
  20345. /** @hidden */ private _alphaIndex: number;
  20346. /** @hidden */ private _distanceToCamera: number;
  20347. /** @hidden */ private _id: number;
  20348. private _currentMaterial;
  20349. /**
  20350. * Add a new submesh to a mesh
  20351. * @param materialIndex defines the material index to use
  20352. * @param verticesStart defines vertex index start
  20353. * @param verticesCount defines vertices count
  20354. * @param indexStart defines index start
  20355. * @param indexCount defines indices count
  20356. * @param mesh defines the parent mesh
  20357. * @param renderingMesh defines an optional rendering mesh
  20358. * @param createBoundingBox defines if bounding box should be created for this submesh
  20359. * @returns the new submesh
  20360. */
  20361. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20362. /**
  20363. * Creates a new submesh
  20364. * @param materialIndex defines the material index to use
  20365. * @param verticesStart defines vertex index start
  20366. * @param verticesCount defines vertices count
  20367. * @param indexStart defines index start
  20368. * @param indexCount defines indices count
  20369. * @param mesh defines the parent mesh
  20370. * @param renderingMesh defines an optional rendering mesh
  20371. * @param createBoundingBox defines if bounding box should be created for this submesh
  20372. */
  20373. constructor(
  20374. /** the material index to use */
  20375. materialIndex: number,
  20376. /** vertex index start */
  20377. verticesStart: number,
  20378. /** vertices count */
  20379. verticesCount: number,
  20380. /** index start */
  20381. indexStart: number,
  20382. /** indices count */
  20383. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20384. /**
  20385. * Returns true if this submesh covers the entire parent mesh
  20386. * @ignorenaming
  20387. */
  20388. readonly IsGlobal: boolean;
  20389. /**
  20390. * Returns the submesh BoudingInfo object
  20391. * @returns current bounding info (or mesh's one if the submesh is global)
  20392. */
  20393. getBoundingInfo(): BoundingInfo;
  20394. /**
  20395. * Sets the submesh BoundingInfo
  20396. * @param boundingInfo defines the new bounding info to use
  20397. * @returns the SubMesh
  20398. */
  20399. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20400. /**
  20401. * Returns the mesh of the current submesh
  20402. * @return the parent mesh
  20403. */
  20404. getMesh(): AbstractMesh;
  20405. /**
  20406. * Returns the rendering mesh of the submesh
  20407. * @returns the rendering mesh (could be different from parent mesh)
  20408. */
  20409. getRenderingMesh(): Mesh;
  20410. /**
  20411. * Returns the submesh material
  20412. * @returns null or the current material
  20413. */
  20414. getMaterial(): Nullable<Material>;
  20415. /**
  20416. * Sets a new updated BoundingInfo object to the submesh
  20417. * @param data defines an optional position array to use to determine the bounding info
  20418. * @returns the SubMesh
  20419. */
  20420. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20421. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20422. /**
  20423. * Updates the submesh BoundingInfo
  20424. * @param world defines the world matrix to use to update the bounding info
  20425. * @returns the submesh
  20426. */
  20427. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20428. /**
  20429. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20430. * @param frustumPlanes defines the frustum planes
  20431. * @returns true if the submesh is intersecting with the frustum
  20432. */
  20433. isInFrustum(frustumPlanes: Plane[]): boolean;
  20434. /**
  20435. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20436. * @param frustumPlanes defines the frustum planes
  20437. * @returns true if the submesh is inside the frustum
  20438. */
  20439. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20440. /**
  20441. * Renders the submesh
  20442. * @param enableAlphaMode defines if alpha needs to be used
  20443. * @returns the submesh
  20444. */
  20445. render(enableAlphaMode: boolean): SubMesh;
  20446. /**
  20447. * @hidden
  20448. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20449. /**
  20450. * Checks if the submesh intersects with a ray
  20451. * @param ray defines the ray to test
  20452. * @returns true is the passed ray intersects the submesh bounding box
  20453. */
  20454. canIntersects(ray: Ray): boolean;
  20455. /**
  20456. * Intersects current submesh with a ray
  20457. * @param ray defines the ray to test
  20458. * @param positions defines mesh's positions array
  20459. * @param indices defines mesh's indices array
  20460. * @param fastCheck defines if only bounding info should be used
  20461. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20462. * @returns intersection info or null if no intersection
  20463. */
  20464. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20465. /** @hidden */
  20466. private _intersectLines;
  20467. /** @hidden */
  20468. private _intersectUnIndexedLines;
  20469. /** @hidden */
  20470. private _intersectTriangles;
  20471. /** @hidden */
  20472. private _intersectUnIndexedTriangles;
  20473. /** @hidden */ private _rebuild(): void;
  20474. /**
  20475. * Creates a new submesh from the passed mesh
  20476. * @param newMesh defines the new hosting mesh
  20477. * @param newRenderingMesh defines an optional rendering mesh
  20478. * @returns the new submesh
  20479. */
  20480. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20481. /**
  20482. * Release associated resources
  20483. */
  20484. dispose(): void;
  20485. /**
  20486. * Gets the class name
  20487. * @returns the string "SubMesh".
  20488. */
  20489. getClassName(): string;
  20490. /**
  20491. * Creates a new submesh from indices data
  20492. * @param materialIndex the index of the main mesh material
  20493. * @param startIndex the index where to start the copy in the mesh indices array
  20494. * @param indexCount the number of indices to copy then from the startIndex
  20495. * @param mesh the main mesh to create the submesh from
  20496. * @param renderingMesh the optional rendering mesh
  20497. * @returns a new submesh
  20498. */
  20499. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20500. }
  20501. }
  20502. declare module BABYLON {
  20503. /**
  20504. * Class used to represent data loading progression
  20505. */
  20506. export class SceneLoaderFlags {
  20507. private static _ForceFullSceneLoadingForIncremental;
  20508. private static _ShowLoadingScreen;
  20509. private static _CleanBoneMatrixWeights;
  20510. private static _loggingLevel;
  20511. /**
  20512. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20513. */
  20514. static ForceFullSceneLoadingForIncremental: boolean;
  20515. /**
  20516. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20517. */
  20518. static ShowLoadingScreen: boolean;
  20519. /**
  20520. * Defines the current logging level (while loading the scene)
  20521. * @ignorenaming
  20522. */
  20523. static loggingLevel: number;
  20524. /**
  20525. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20526. */
  20527. static CleanBoneMatrixWeights: boolean;
  20528. }
  20529. }
  20530. declare module BABYLON {
  20531. /**
  20532. * Class used to store geometry data (vertex buffers + index buffer)
  20533. */
  20534. export class Geometry implements IGetSetVerticesData {
  20535. /**
  20536. * Gets or sets the ID of the geometry
  20537. */
  20538. id: string;
  20539. /**
  20540. * Gets or sets the unique ID of the geometry
  20541. */
  20542. uniqueId: number;
  20543. /**
  20544. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20545. */
  20546. delayLoadState: number;
  20547. /**
  20548. * Gets the file containing the data to load when running in delay load state
  20549. */
  20550. delayLoadingFile: Nullable<string>;
  20551. /**
  20552. * Callback called when the geometry is updated
  20553. */
  20554. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20555. private _scene;
  20556. private _engine;
  20557. private _meshes;
  20558. private _totalVertices;
  20559. /** @hidden */ private _indices: IndicesArray;
  20560. /** @hidden */ private _vertexBuffers: {
  20561. [key: string]: VertexBuffer;
  20562. };
  20563. private _isDisposed;
  20564. private _extend;
  20565. private _boundingBias;
  20566. /** @hidden */ private _delayInfo: Array<string>;
  20567. private _indexBuffer;
  20568. private _indexBufferIsUpdatable;
  20569. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20570. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20571. /** @hidden */ private _softwareSkinningFrameId: number;
  20572. private _vertexArrayObjects;
  20573. private _updatable;
  20574. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20575. /**
  20576. * 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
  20577. */
  20578. /**
  20579. * 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
  20580. */
  20581. boundingBias: Vector2;
  20582. /**
  20583. * Static function used to attach a new empty geometry to a mesh
  20584. * @param mesh defines the mesh to attach the geometry to
  20585. * @returns the new Geometry
  20586. */
  20587. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20588. /**
  20589. * Creates a new geometry
  20590. * @param id defines the unique ID
  20591. * @param scene defines the hosting scene
  20592. * @param vertexData defines the VertexData used to get geometry data
  20593. * @param updatable defines if geometry must be updatable (false by default)
  20594. * @param mesh defines the mesh that will be associated with the geometry
  20595. */
  20596. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20597. /**
  20598. * Gets the current extend of the geometry
  20599. */
  20600. readonly extend: {
  20601. minimum: Vector3;
  20602. maximum: Vector3;
  20603. };
  20604. /**
  20605. * Gets the hosting scene
  20606. * @returns the hosting Scene
  20607. */
  20608. getScene(): Scene;
  20609. /**
  20610. * Gets the hosting engine
  20611. * @returns the hosting Engine
  20612. */
  20613. getEngine(): Engine;
  20614. /**
  20615. * Defines if the geometry is ready to use
  20616. * @returns true if the geometry is ready to be used
  20617. */
  20618. isReady(): boolean;
  20619. /**
  20620. * Gets a value indicating that the geometry should not be serialized
  20621. */
  20622. readonly doNotSerialize: boolean;
  20623. /** @hidden */ private _rebuild(): void;
  20624. /**
  20625. * Affects all geometry data in one call
  20626. * @param vertexData defines the geometry data
  20627. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20628. */
  20629. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20630. /**
  20631. * Set specific vertex data
  20632. * @param kind defines the data kind (Position, normal, etc...)
  20633. * @param data defines the vertex data to use
  20634. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20635. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20636. */
  20637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20638. /**
  20639. * Removes a specific vertex data
  20640. * @param kind defines the data kind (Position, normal, etc...)
  20641. */
  20642. removeVerticesData(kind: string): void;
  20643. /**
  20644. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20645. * @param buffer defines the vertex buffer to use
  20646. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20647. */
  20648. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20649. /**
  20650. * Update a specific vertex buffer
  20651. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20652. * It will do nothing if the buffer is not updatable
  20653. * @param kind defines the data kind (Position, normal, etc...)
  20654. * @param data defines the data to use
  20655. * @param offset defines the offset in the target buffer where to store the data
  20656. * @param useBytes set to true if the offset is in bytes
  20657. */
  20658. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20659. /**
  20660. * Update a specific vertex buffer
  20661. * This function will create a new buffer if the current one is not updatable
  20662. * @param kind defines the data kind (Position, normal, etc...)
  20663. * @param data defines the data to use
  20664. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20665. */
  20666. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20667. private _updateBoundingInfo;
  20668. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20669. /**
  20670. * Gets total number of vertices
  20671. * @returns the total number of vertices
  20672. */
  20673. getTotalVertices(): number;
  20674. /**
  20675. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20676. * @param kind defines the data kind (Position, normal, etc...)
  20677. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20678. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20679. * @returns a float array containing vertex data
  20680. */
  20681. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20682. /**
  20683. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20684. * @param kind defines the data kind (Position, normal, etc...)
  20685. * @returns true if the vertex buffer with the specified kind is updatable
  20686. */
  20687. isVertexBufferUpdatable(kind: string): boolean;
  20688. /**
  20689. * Gets a specific vertex buffer
  20690. * @param kind defines the data kind (Position, normal, etc...)
  20691. * @returns a VertexBuffer
  20692. */
  20693. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20694. /**
  20695. * Returns all vertex buffers
  20696. * @return an object holding all vertex buffers indexed by kind
  20697. */
  20698. getVertexBuffers(): Nullable<{
  20699. [key: string]: VertexBuffer;
  20700. }>;
  20701. /**
  20702. * Gets a boolean indicating if specific vertex buffer is present
  20703. * @param kind defines the data kind (Position, normal, etc...)
  20704. * @returns true if data is present
  20705. */
  20706. isVerticesDataPresent(kind: string): boolean;
  20707. /**
  20708. * Gets a list of all attached data kinds (Position, normal, etc...)
  20709. * @returns a list of string containing all kinds
  20710. */
  20711. getVerticesDataKinds(): string[];
  20712. /**
  20713. * Update index buffer
  20714. * @param indices defines the indices to store in the index buffer
  20715. * @param offset defines the offset in the target buffer where to store the data
  20716. * @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)
  20717. */
  20718. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20719. /**
  20720. * Creates a new index buffer
  20721. * @param indices defines the indices to store in the index buffer
  20722. * @param totalVertices defines the total number of vertices (could be null)
  20723. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20724. */
  20725. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20726. /**
  20727. * Return the total number of indices
  20728. * @returns the total number of indices
  20729. */
  20730. getTotalIndices(): number;
  20731. /**
  20732. * Gets the index buffer array
  20733. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20734. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20735. * @returns the index buffer array
  20736. */
  20737. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20738. /**
  20739. * Gets the index buffer
  20740. * @return the index buffer
  20741. */
  20742. getIndexBuffer(): Nullable<DataBuffer>;
  20743. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20744. /**
  20745. * Release the associated resources for a specific mesh
  20746. * @param mesh defines the source mesh
  20747. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20748. */
  20749. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20750. /**
  20751. * Apply current geometry to a given mesh
  20752. * @param mesh defines the mesh to apply geometry to
  20753. */
  20754. applyToMesh(mesh: Mesh): void;
  20755. private _updateExtend;
  20756. private _applyToMesh;
  20757. private notifyUpdate;
  20758. /**
  20759. * Load the geometry if it was flagged as delay loaded
  20760. * @param scene defines the hosting scene
  20761. * @param onLoaded defines a callback called when the geometry is loaded
  20762. */
  20763. load(scene: Scene, onLoaded?: () => void): void;
  20764. private _queueLoad;
  20765. /**
  20766. * Invert the geometry to move from a right handed system to a left handed one.
  20767. */
  20768. toLeftHanded(): void;
  20769. /** @hidden */ private _resetPointsArrayCache(): void;
  20770. /** @hidden */ private _generatePointsArray(): boolean;
  20771. /**
  20772. * Gets a value indicating if the geometry is disposed
  20773. * @returns true if the geometry was disposed
  20774. */
  20775. isDisposed(): boolean;
  20776. private _disposeVertexArrayObjects;
  20777. /**
  20778. * Free all associated resources
  20779. */
  20780. dispose(): void;
  20781. /**
  20782. * Clone the current geometry into a new geometry
  20783. * @param id defines the unique ID of the new geometry
  20784. * @returns a new geometry object
  20785. */
  20786. copy(id: string): Geometry;
  20787. /**
  20788. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20789. * @return a JSON representation of the current geometry data (without the vertices data)
  20790. */
  20791. serialize(): any;
  20792. private toNumberArray;
  20793. /**
  20794. * Serialize all vertices data into a JSON oject
  20795. * @returns a JSON representation of the current geometry data
  20796. */
  20797. serializeVerticeData(): any;
  20798. /**
  20799. * Extracts a clone of a mesh geometry
  20800. * @param mesh defines the source mesh
  20801. * @param id defines the unique ID of the new geometry object
  20802. * @returns the new geometry object
  20803. */
  20804. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20805. /**
  20806. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20807. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20808. * Be aware Math.random() could cause collisions, but:
  20809. * "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"
  20810. * @returns a string containing a new GUID
  20811. */
  20812. static RandomId(): string;
  20813. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20814. private static _CleanMatricesWeights;
  20815. /**
  20816. * Create a new geometry from persisted data (Using .babylon file format)
  20817. * @param parsedVertexData defines the persisted data
  20818. * @param scene defines the hosting scene
  20819. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20820. * @returns the new geometry object
  20821. */
  20822. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20823. }
  20824. }
  20825. declare module BABYLON {
  20826. /**
  20827. * Define an interface for all classes that will get and set the data on vertices
  20828. */
  20829. export interface IGetSetVerticesData {
  20830. /**
  20831. * Gets a boolean indicating if specific vertex data is present
  20832. * @param kind defines the vertex data kind to use
  20833. * @returns true is data kind is present
  20834. */
  20835. isVerticesDataPresent(kind: string): boolean;
  20836. /**
  20837. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20838. * @param kind defines the data kind (Position, normal, etc...)
  20839. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20840. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20841. * @returns a float array containing vertex data
  20842. */
  20843. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20844. /**
  20845. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20846. * @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.
  20847. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20848. * @returns the indices array or an empty array if the mesh has no geometry
  20849. */
  20850. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20851. /**
  20852. * Set specific vertex data
  20853. * @param kind defines the data kind (Position, normal, etc...)
  20854. * @param data defines the vertex data to use
  20855. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20856. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20857. */
  20858. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20859. /**
  20860. * Update a specific associated vertex buffer
  20861. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20862. * - VertexBuffer.PositionKind
  20863. * - VertexBuffer.UVKind
  20864. * - VertexBuffer.UV2Kind
  20865. * - VertexBuffer.UV3Kind
  20866. * - VertexBuffer.UV4Kind
  20867. * - VertexBuffer.UV5Kind
  20868. * - VertexBuffer.UV6Kind
  20869. * - VertexBuffer.ColorKind
  20870. * - VertexBuffer.MatricesIndicesKind
  20871. * - VertexBuffer.MatricesIndicesExtraKind
  20872. * - VertexBuffer.MatricesWeightsKind
  20873. * - VertexBuffer.MatricesWeightsExtraKind
  20874. * @param data defines the data source
  20875. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20876. * @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)
  20877. */
  20878. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20879. /**
  20880. * Creates a new index buffer
  20881. * @param indices defines the indices to store in the index buffer
  20882. * @param totalVertices defines the total number of vertices (could be null)
  20883. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20884. */
  20885. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20886. }
  20887. /**
  20888. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20889. */
  20890. export class VertexData {
  20891. /**
  20892. * Mesh side orientation : usually the external or front surface
  20893. */
  20894. static readonly FRONTSIDE: number;
  20895. /**
  20896. * Mesh side orientation : usually the internal or back surface
  20897. */
  20898. static readonly BACKSIDE: number;
  20899. /**
  20900. * Mesh side orientation : both internal and external or front and back surfaces
  20901. */
  20902. static readonly DOUBLESIDE: number;
  20903. /**
  20904. * Mesh side orientation : by default, `FRONTSIDE`
  20905. */
  20906. static readonly DEFAULTSIDE: number;
  20907. /**
  20908. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20909. */
  20910. positions: Nullable<FloatArray>;
  20911. /**
  20912. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20913. */
  20914. normals: Nullable<FloatArray>;
  20915. /**
  20916. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20917. */
  20918. tangents: Nullable<FloatArray>;
  20919. /**
  20920. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20921. */
  20922. uvs: Nullable<FloatArray>;
  20923. /**
  20924. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20925. */
  20926. uvs2: Nullable<FloatArray>;
  20927. /**
  20928. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20929. */
  20930. uvs3: Nullable<FloatArray>;
  20931. /**
  20932. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20933. */
  20934. uvs4: Nullable<FloatArray>;
  20935. /**
  20936. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20937. */
  20938. uvs5: Nullable<FloatArray>;
  20939. /**
  20940. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20941. */
  20942. uvs6: Nullable<FloatArray>;
  20943. /**
  20944. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20945. */
  20946. colors: Nullable<FloatArray>;
  20947. /**
  20948. * 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).
  20949. */
  20950. matricesIndices: Nullable<FloatArray>;
  20951. /**
  20952. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20953. */
  20954. matricesWeights: Nullable<FloatArray>;
  20955. /**
  20956. * An array extending the number of possible indices
  20957. */
  20958. matricesIndicesExtra: Nullable<FloatArray>;
  20959. /**
  20960. * An array extending the number of possible weights when the number of indices is extended
  20961. */
  20962. matricesWeightsExtra: Nullable<FloatArray>;
  20963. /**
  20964. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20965. */
  20966. indices: Nullable<IndicesArray>;
  20967. /**
  20968. * Uses the passed data array to set the set the values for the specified kind of data
  20969. * @param data a linear array of floating numbers
  20970. * @param kind the type of data that is being set, eg positions, colors etc
  20971. */
  20972. set(data: FloatArray, kind: string): void;
  20973. /**
  20974. * Associates the vertexData to the passed Mesh.
  20975. * Sets it as updatable or not (default `false`)
  20976. * @param mesh the mesh the vertexData is applied to
  20977. * @param updatable when used and having the value true allows new data to update the vertexData
  20978. * @returns the VertexData
  20979. */
  20980. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20981. /**
  20982. * Associates the vertexData to the passed Geometry.
  20983. * Sets it as updatable or not (default `false`)
  20984. * @param geometry the geometry the vertexData is applied to
  20985. * @param updatable when used and having the value true allows new data to update the vertexData
  20986. * @returns VertexData
  20987. */
  20988. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20989. /**
  20990. * Updates the associated mesh
  20991. * @param mesh the mesh to be updated
  20992. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20993. * @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
  20994. * @returns VertexData
  20995. */
  20996. updateMesh(mesh: Mesh): VertexData;
  20997. /**
  20998. * Updates the associated geometry
  20999. * @param geometry the geometry to be updated
  21000. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21001. * @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
  21002. * @returns VertexData.
  21003. */
  21004. updateGeometry(geometry: Geometry): VertexData;
  21005. private _applyTo;
  21006. private _update;
  21007. /**
  21008. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21009. * @param matrix the transforming matrix
  21010. * @returns the VertexData
  21011. */
  21012. transform(matrix: Matrix): VertexData;
  21013. /**
  21014. * Merges the passed VertexData into the current one
  21015. * @param other the VertexData to be merged into the current one
  21016. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21017. * @returns the modified VertexData
  21018. */
  21019. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21020. private _mergeElement;
  21021. private _validate;
  21022. /**
  21023. * Serializes the VertexData
  21024. * @returns a serialized object
  21025. */
  21026. serialize(): any;
  21027. /**
  21028. * Extracts the vertexData from a mesh
  21029. * @param mesh the mesh from which to extract the VertexData
  21030. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21031. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21032. * @returns the object VertexData associated to the passed mesh
  21033. */
  21034. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21035. /**
  21036. * Extracts the vertexData from the geometry
  21037. * @param geometry the geometry from which to extract the VertexData
  21038. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21039. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21040. * @returns the object VertexData associated to the passed mesh
  21041. */
  21042. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21043. private static _ExtractFrom;
  21044. /**
  21045. * Creates the VertexData for a Ribbon
  21046. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21047. * * pathArray array of paths, each of which an array of successive Vector3
  21048. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21049. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21050. * * 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
  21051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21052. * * 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)
  21053. * * 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)
  21054. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21055. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21056. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21057. * @returns the VertexData of the ribbon
  21058. */
  21059. static CreateRibbon(options: {
  21060. pathArray: Vector3[][];
  21061. closeArray?: boolean;
  21062. closePath?: boolean;
  21063. offset?: number;
  21064. sideOrientation?: number;
  21065. frontUVs?: Vector4;
  21066. backUVs?: Vector4;
  21067. invertUV?: boolean;
  21068. uvs?: Vector2[];
  21069. colors?: Color4[];
  21070. }): VertexData;
  21071. /**
  21072. * Creates the VertexData for a box
  21073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21074. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21075. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21076. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21077. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21078. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21079. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21081. * * 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)
  21082. * * 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)
  21083. * @returns the VertexData of the box
  21084. */
  21085. static CreateBox(options: {
  21086. size?: number;
  21087. width?: number;
  21088. height?: number;
  21089. depth?: number;
  21090. faceUV?: Vector4[];
  21091. faceColors?: Color4[];
  21092. sideOrientation?: number;
  21093. frontUVs?: Vector4;
  21094. backUVs?: Vector4;
  21095. }): VertexData;
  21096. /**
  21097. * Creates the VertexData for a tiled box
  21098. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21099. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21100. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21101. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21102. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21103. * @returns the VertexData of the box
  21104. */
  21105. static CreateTiledBox(options: {
  21106. pattern?: number;
  21107. width?: number;
  21108. height?: number;
  21109. depth?: number;
  21110. tileSize?: number;
  21111. tileWidth?: number;
  21112. tileHeight?: number;
  21113. alignHorizontal?: number;
  21114. alignVertical?: number;
  21115. faceUV?: Vector4[];
  21116. faceColors?: Color4[];
  21117. sideOrientation?: number;
  21118. }): VertexData;
  21119. /**
  21120. * Creates the VertexData for a tiled plane
  21121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21122. * * pattern a limited pattern arrangement depending on the number
  21123. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21124. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21125. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21127. * * 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)
  21128. * * 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)
  21129. * @returns the VertexData of the tiled plane
  21130. */
  21131. static CreateTiledPlane(options: {
  21132. pattern?: number;
  21133. tileSize?: number;
  21134. tileWidth?: number;
  21135. tileHeight?: number;
  21136. size?: number;
  21137. width?: number;
  21138. height?: number;
  21139. alignHorizontal?: number;
  21140. alignVertical?: number;
  21141. sideOrientation?: number;
  21142. frontUVs?: Vector4;
  21143. backUVs?: Vector4;
  21144. }): VertexData;
  21145. /**
  21146. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21147. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21148. * * segments sets the number of horizontal strips optional, default 32
  21149. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21150. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21151. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21152. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21153. * * 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
  21154. * * 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
  21155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21156. * * 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)
  21157. * * 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)
  21158. * @returns the VertexData of the ellipsoid
  21159. */
  21160. static CreateSphere(options: {
  21161. segments?: number;
  21162. diameter?: number;
  21163. diameterX?: number;
  21164. diameterY?: number;
  21165. diameterZ?: number;
  21166. arc?: number;
  21167. slice?: number;
  21168. sideOrientation?: number;
  21169. frontUVs?: Vector4;
  21170. backUVs?: Vector4;
  21171. }): VertexData;
  21172. /**
  21173. * Creates the VertexData for a cylinder, cone or prism
  21174. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21175. * * height sets the height (y direction) of the cylinder, optional, default 2
  21176. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21177. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21178. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21179. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21180. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21181. * * 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
  21182. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21183. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21184. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21185. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21187. * * 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)
  21188. * * 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)
  21189. * @returns the VertexData of the cylinder, cone or prism
  21190. */
  21191. static CreateCylinder(options: {
  21192. height?: number;
  21193. diameterTop?: number;
  21194. diameterBottom?: number;
  21195. diameter?: number;
  21196. tessellation?: number;
  21197. subdivisions?: number;
  21198. arc?: number;
  21199. faceColors?: Color4[];
  21200. faceUV?: Vector4[];
  21201. hasRings?: boolean;
  21202. enclose?: boolean;
  21203. sideOrientation?: number;
  21204. frontUVs?: Vector4;
  21205. backUVs?: Vector4;
  21206. }): VertexData;
  21207. /**
  21208. * Creates the VertexData for a torus
  21209. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21210. * * diameter the diameter of the torus, optional default 1
  21211. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21212. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21214. * * 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)
  21215. * * 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)
  21216. * @returns the VertexData of the torus
  21217. */
  21218. static CreateTorus(options: {
  21219. diameter?: number;
  21220. thickness?: number;
  21221. tessellation?: number;
  21222. sideOrientation?: number;
  21223. frontUVs?: Vector4;
  21224. backUVs?: Vector4;
  21225. }): VertexData;
  21226. /**
  21227. * Creates the VertexData of the LineSystem
  21228. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21229. * - lines an array of lines, each line being an array of successive Vector3
  21230. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21231. * @returns the VertexData of the LineSystem
  21232. */
  21233. static CreateLineSystem(options: {
  21234. lines: Vector3[][];
  21235. colors?: Nullable<Color4[][]>;
  21236. }): VertexData;
  21237. /**
  21238. * Create the VertexData for a DashedLines
  21239. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21240. * - points an array successive Vector3
  21241. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21242. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21243. * - dashNb the intended total number of dashes, optional, default 200
  21244. * @returns the VertexData for the DashedLines
  21245. */
  21246. static CreateDashedLines(options: {
  21247. points: Vector3[];
  21248. dashSize?: number;
  21249. gapSize?: number;
  21250. dashNb?: number;
  21251. }): VertexData;
  21252. /**
  21253. * Creates the VertexData for a Ground
  21254. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21255. * - width the width (x direction) of the ground, optional, default 1
  21256. * - height the height (z direction) of the ground, optional, default 1
  21257. * - subdivisions the number of subdivisions per side, optional, default 1
  21258. * @returns the VertexData of the Ground
  21259. */
  21260. static CreateGround(options: {
  21261. width?: number;
  21262. height?: number;
  21263. subdivisions?: number;
  21264. subdivisionsX?: number;
  21265. subdivisionsY?: number;
  21266. }): VertexData;
  21267. /**
  21268. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21269. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21270. * * xmin the ground minimum X coordinate, optional, default -1
  21271. * * zmin the ground minimum Z coordinate, optional, default -1
  21272. * * xmax the ground maximum X coordinate, optional, default 1
  21273. * * zmax the ground maximum Z coordinate, optional, default 1
  21274. * * 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}
  21275. * * 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}
  21276. * @returns the VertexData of the TiledGround
  21277. */
  21278. static CreateTiledGround(options: {
  21279. xmin: number;
  21280. zmin: number;
  21281. xmax: number;
  21282. zmax: number;
  21283. subdivisions?: {
  21284. w: number;
  21285. h: number;
  21286. };
  21287. precision?: {
  21288. w: number;
  21289. h: number;
  21290. };
  21291. }): VertexData;
  21292. /**
  21293. * Creates the VertexData of the Ground designed from a heightmap
  21294. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21295. * * width the width (x direction) of the ground
  21296. * * height the height (z direction) of the ground
  21297. * * subdivisions the number of subdivisions per side
  21298. * * minHeight the minimum altitude on the ground, optional, default 0
  21299. * * maxHeight the maximum altitude on the ground, optional default 1
  21300. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21301. * * buffer the array holding the image color data
  21302. * * bufferWidth the width of image
  21303. * * bufferHeight the height of image
  21304. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21305. * @returns the VertexData of the Ground designed from a heightmap
  21306. */
  21307. static CreateGroundFromHeightMap(options: {
  21308. width: number;
  21309. height: number;
  21310. subdivisions: number;
  21311. minHeight: number;
  21312. maxHeight: number;
  21313. colorFilter: Color3;
  21314. buffer: Uint8Array;
  21315. bufferWidth: number;
  21316. bufferHeight: number;
  21317. alphaFilter: number;
  21318. }): VertexData;
  21319. /**
  21320. * Creates the VertexData for a Plane
  21321. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21322. * * size sets the width and height of the plane to the value of size, optional default 1
  21323. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21324. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21326. * * 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)
  21327. * * 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)
  21328. * @returns the VertexData of the box
  21329. */
  21330. static CreatePlane(options: {
  21331. size?: number;
  21332. width?: number;
  21333. height?: number;
  21334. sideOrientation?: number;
  21335. frontUVs?: Vector4;
  21336. backUVs?: Vector4;
  21337. }): VertexData;
  21338. /**
  21339. * Creates the VertexData of the Disc or regular Polygon
  21340. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21341. * * radius the radius of the disc, optional default 0.5
  21342. * * tessellation the number of polygon sides, optional, default 64
  21343. * * 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
  21344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21345. * * 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)
  21346. * * 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)
  21347. * @returns the VertexData of the box
  21348. */
  21349. static CreateDisc(options: {
  21350. radius?: number;
  21351. tessellation?: number;
  21352. arc?: number;
  21353. sideOrientation?: number;
  21354. frontUVs?: Vector4;
  21355. backUVs?: Vector4;
  21356. }): VertexData;
  21357. /**
  21358. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21359. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21360. * @param polygon a mesh built from polygonTriangulation.build()
  21361. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21362. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21363. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21364. * @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)
  21365. * @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)
  21366. * @returns the VertexData of the Polygon
  21367. */
  21368. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21369. /**
  21370. * Creates the VertexData of the IcoSphere
  21371. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21372. * * radius the radius of the IcoSphere, optional default 1
  21373. * * radiusX allows stretching in the x direction, optional, default radius
  21374. * * radiusY allows stretching in the y direction, optional, default radius
  21375. * * radiusZ allows stretching in the z direction, optional, default radius
  21376. * * flat when true creates a flat shaded mesh, optional, default true
  21377. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21379. * * 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)
  21380. * * 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)
  21381. * @returns the VertexData of the IcoSphere
  21382. */
  21383. static CreateIcoSphere(options: {
  21384. radius?: number;
  21385. radiusX?: number;
  21386. radiusY?: number;
  21387. radiusZ?: number;
  21388. flat?: boolean;
  21389. subdivisions?: number;
  21390. sideOrientation?: number;
  21391. frontUVs?: Vector4;
  21392. backUVs?: Vector4;
  21393. }): VertexData;
  21394. /**
  21395. * Creates the VertexData for a Polyhedron
  21396. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21397. * * type provided types are:
  21398. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21399. * * 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)
  21400. * * size the size of the IcoSphere, optional default 1
  21401. * * sizeX allows stretching in the x direction, optional, default size
  21402. * * sizeY allows stretching in the y direction, optional, default size
  21403. * * sizeZ allows stretching in the z direction, optional, default size
  21404. * * 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
  21405. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21406. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21407. * * flat when true creates a flat shaded mesh, optional, default true
  21408. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21409. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21410. * * 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)
  21411. * * 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)
  21412. * @returns the VertexData of the Polyhedron
  21413. */
  21414. static CreatePolyhedron(options: {
  21415. type?: number;
  21416. size?: number;
  21417. sizeX?: number;
  21418. sizeY?: number;
  21419. sizeZ?: number;
  21420. custom?: any;
  21421. faceUV?: Vector4[];
  21422. faceColors?: Color4[];
  21423. flat?: boolean;
  21424. sideOrientation?: number;
  21425. frontUVs?: Vector4;
  21426. backUVs?: Vector4;
  21427. }): VertexData;
  21428. /**
  21429. * Creates the VertexData for a TorusKnot
  21430. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21431. * * radius the radius of the torus knot, optional, default 2
  21432. * * tube the thickness of the tube, optional, default 0.5
  21433. * * radialSegments the number of sides on each tube segments, optional, default 32
  21434. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21435. * * p the number of windings around the z axis, optional, default 2
  21436. * * q the number of windings around the x axis, optional, default 3
  21437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21438. * * 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)
  21439. * * 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)
  21440. * @returns the VertexData of the Torus Knot
  21441. */
  21442. static CreateTorusKnot(options: {
  21443. radius?: number;
  21444. tube?: number;
  21445. radialSegments?: number;
  21446. tubularSegments?: number;
  21447. p?: number;
  21448. q?: number;
  21449. sideOrientation?: number;
  21450. frontUVs?: Vector4;
  21451. backUVs?: Vector4;
  21452. }): VertexData;
  21453. /**
  21454. * Compute normals for given positions and indices
  21455. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21456. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21457. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21458. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21459. * * facetNormals : optional array of facet normals (vector3)
  21460. * * facetPositions : optional array of facet positions (vector3)
  21461. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21462. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21463. * * bInfo : optional bounding info, required for facetPartitioning computation
  21464. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21465. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21466. * * useRightHandedSystem: optional boolean to for right handed system computation
  21467. * * depthSort : optional boolean to enable the facet depth sort computation
  21468. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21469. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21470. */
  21471. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21472. facetNormals?: any;
  21473. facetPositions?: any;
  21474. facetPartitioning?: any;
  21475. ratio?: number;
  21476. bInfo?: any;
  21477. bbSize?: Vector3;
  21478. subDiv?: any;
  21479. useRightHandedSystem?: boolean;
  21480. depthSort?: boolean;
  21481. distanceTo?: Vector3;
  21482. depthSortedFacets?: any;
  21483. }): void;
  21484. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21485. /**
  21486. * Applies VertexData created from the imported parameters to the geometry
  21487. * @param parsedVertexData the parsed data from an imported file
  21488. * @param geometry the geometry to apply the VertexData to
  21489. */
  21490. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21491. }
  21492. }
  21493. declare module BABYLON {
  21494. /**
  21495. * Defines a target to use with MorphTargetManager
  21496. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21497. */
  21498. export class MorphTarget implements IAnimatable {
  21499. /** defines the name of the target */
  21500. name: string;
  21501. /**
  21502. * Gets or sets the list of animations
  21503. */
  21504. animations: Animation[];
  21505. private _scene;
  21506. private _positions;
  21507. private _normals;
  21508. private _tangents;
  21509. private _uvs;
  21510. private _influence;
  21511. /**
  21512. * Observable raised when the influence changes
  21513. */
  21514. onInfluenceChanged: Observable<boolean>;
  21515. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21516. /**
  21517. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21518. */
  21519. influence: number;
  21520. /**
  21521. * Gets or sets the id of the morph Target
  21522. */
  21523. id: string;
  21524. private _animationPropertiesOverride;
  21525. /**
  21526. * Gets or sets the animation properties override
  21527. */
  21528. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21529. /**
  21530. * Creates a new MorphTarget
  21531. * @param name defines the name of the target
  21532. * @param influence defines the influence to use
  21533. * @param scene defines the scene the morphtarget belongs to
  21534. */
  21535. constructor(
  21536. /** defines the name of the target */
  21537. name: string, influence?: number, scene?: Nullable<Scene>);
  21538. /**
  21539. * Gets a boolean defining if the target contains position data
  21540. */
  21541. readonly hasPositions: boolean;
  21542. /**
  21543. * Gets a boolean defining if the target contains normal data
  21544. */
  21545. readonly hasNormals: boolean;
  21546. /**
  21547. * Gets a boolean defining if the target contains tangent data
  21548. */
  21549. readonly hasTangents: boolean;
  21550. /**
  21551. * Gets a boolean defining if the target contains texture coordinates data
  21552. */
  21553. readonly hasUVs: boolean;
  21554. /**
  21555. * Affects position data to this target
  21556. * @param data defines the position data to use
  21557. */
  21558. setPositions(data: Nullable<FloatArray>): void;
  21559. /**
  21560. * Gets the position data stored in this target
  21561. * @returns a FloatArray containing the position data (or null if not present)
  21562. */
  21563. getPositions(): Nullable<FloatArray>;
  21564. /**
  21565. * Affects normal data to this target
  21566. * @param data defines the normal data to use
  21567. */
  21568. setNormals(data: Nullable<FloatArray>): void;
  21569. /**
  21570. * Gets the normal data stored in this target
  21571. * @returns a FloatArray containing the normal data (or null if not present)
  21572. */
  21573. getNormals(): Nullable<FloatArray>;
  21574. /**
  21575. * Affects tangent data to this target
  21576. * @param data defines the tangent data to use
  21577. */
  21578. setTangents(data: Nullable<FloatArray>): void;
  21579. /**
  21580. * Gets the tangent data stored in this target
  21581. * @returns a FloatArray containing the tangent data (or null if not present)
  21582. */
  21583. getTangents(): Nullable<FloatArray>;
  21584. /**
  21585. * Affects texture coordinates data to this target
  21586. * @param data defines the texture coordinates data to use
  21587. */
  21588. setUVs(data: Nullable<FloatArray>): void;
  21589. /**
  21590. * Gets the texture coordinates data stored in this target
  21591. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21592. */
  21593. getUVs(): Nullable<FloatArray>;
  21594. /**
  21595. * Serializes the current target into a Serialization object
  21596. * @returns the serialized object
  21597. */
  21598. serialize(): any;
  21599. /**
  21600. * Returns the string "MorphTarget"
  21601. * @returns "MorphTarget"
  21602. */
  21603. getClassName(): string;
  21604. /**
  21605. * Creates a new target from serialized data
  21606. * @param serializationObject defines the serialized data to use
  21607. * @returns a new MorphTarget
  21608. */
  21609. static Parse(serializationObject: any): MorphTarget;
  21610. /**
  21611. * Creates a MorphTarget from mesh data
  21612. * @param mesh defines the source mesh
  21613. * @param name defines the name to use for the new target
  21614. * @param influence defines the influence to attach to the target
  21615. * @returns a new MorphTarget
  21616. */
  21617. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21618. }
  21619. }
  21620. declare module BABYLON {
  21621. /**
  21622. * This class is used to deform meshes using morphing between different targets
  21623. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21624. */
  21625. export class MorphTargetManager {
  21626. private _targets;
  21627. private _targetInfluenceChangedObservers;
  21628. private _targetDataLayoutChangedObservers;
  21629. private _activeTargets;
  21630. private _scene;
  21631. private _influences;
  21632. private _supportsNormals;
  21633. private _supportsTangents;
  21634. private _supportsUVs;
  21635. private _vertexCount;
  21636. private _uniqueId;
  21637. private _tempInfluences;
  21638. /**
  21639. * Gets or sets a boolean indicating if normals must be morphed
  21640. */
  21641. enableNormalMorphing: boolean;
  21642. /**
  21643. * Gets or sets a boolean indicating if tangents must be morphed
  21644. */
  21645. enableTangentMorphing: boolean;
  21646. /**
  21647. * Gets or sets a boolean indicating if UV must be morphed
  21648. */
  21649. enableUVMorphing: boolean;
  21650. /**
  21651. * Creates a new MorphTargetManager
  21652. * @param scene defines the current scene
  21653. */
  21654. constructor(scene?: Nullable<Scene>);
  21655. /**
  21656. * Gets the unique ID of this manager
  21657. */
  21658. readonly uniqueId: number;
  21659. /**
  21660. * Gets the number of vertices handled by this manager
  21661. */
  21662. readonly vertexCount: number;
  21663. /**
  21664. * Gets a boolean indicating if this manager supports morphing of normals
  21665. */
  21666. readonly supportsNormals: boolean;
  21667. /**
  21668. * Gets a boolean indicating if this manager supports morphing of tangents
  21669. */
  21670. readonly supportsTangents: boolean;
  21671. /**
  21672. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21673. */
  21674. readonly supportsUVs: boolean;
  21675. /**
  21676. * Gets the number of targets stored in this manager
  21677. */
  21678. readonly numTargets: number;
  21679. /**
  21680. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21681. */
  21682. readonly numInfluencers: number;
  21683. /**
  21684. * Gets the list of influences (one per target)
  21685. */
  21686. readonly influences: Float32Array;
  21687. /**
  21688. * Gets the active target at specified index. An active target is a target with an influence > 0
  21689. * @param index defines the index to check
  21690. * @returns the requested target
  21691. */
  21692. getActiveTarget(index: number): MorphTarget;
  21693. /**
  21694. * Gets the target at specified index
  21695. * @param index defines the index to check
  21696. * @returns the requested target
  21697. */
  21698. getTarget(index: number): MorphTarget;
  21699. /**
  21700. * Add a new target to this manager
  21701. * @param target defines the target to add
  21702. */
  21703. addTarget(target: MorphTarget): void;
  21704. /**
  21705. * Removes a target from the manager
  21706. * @param target defines the target to remove
  21707. */
  21708. removeTarget(target: MorphTarget): void;
  21709. /**
  21710. * Serializes the current manager into a Serialization object
  21711. * @returns the serialized object
  21712. */
  21713. serialize(): any;
  21714. private _syncActiveTargets;
  21715. /**
  21716. * Syncrhonize the targets with all the meshes using this morph target manager
  21717. */
  21718. synchronize(): void;
  21719. /**
  21720. * Creates a new MorphTargetManager from serialized data
  21721. * @param serializationObject defines the serialized data
  21722. * @param scene defines the hosting scene
  21723. * @returns the new MorphTargetManager
  21724. */
  21725. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21726. }
  21727. }
  21728. declare module BABYLON {
  21729. /**
  21730. * Class used to represent a specific level of detail of a mesh
  21731. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21732. */
  21733. export class MeshLODLevel {
  21734. /** Defines the distance where this level should start being displayed */
  21735. distance: number;
  21736. /** Defines the mesh to use to render this level */
  21737. mesh: Nullable<Mesh>;
  21738. /**
  21739. * Creates a new LOD level
  21740. * @param distance defines the distance where this level should star being displayed
  21741. * @param mesh defines the mesh to use to render this level
  21742. */
  21743. constructor(
  21744. /** Defines the distance where this level should start being displayed */
  21745. distance: number,
  21746. /** Defines the mesh to use to render this level */
  21747. mesh: Nullable<Mesh>);
  21748. }
  21749. }
  21750. declare module BABYLON {
  21751. /**
  21752. * Mesh representing the gorund
  21753. */
  21754. export class GroundMesh extends Mesh {
  21755. /** If octree should be generated */
  21756. generateOctree: boolean;
  21757. private _heightQuads;
  21758. /** @hidden */ private _subdivisionsX: number;
  21759. /** @hidden */ private _subdivisionsY: number;
  21760. /** @hidden */ private _width: number;
  21761. /** @hidden */ private _height: number;
  21762. /** @hidden */ private _minX: number;
  21763. /** @hidden */ private _maxX: number;
  21764. /** @hidden */ private _minZ: number;
  21765. /** @hidden */ private _maxZ: number;
  21766. constructor(name: string, scene: Scene);
  21767. /**
  21768. * "GroundMesh"
  21769. * @returns "GroundMesh"
  21770. */
  21771. getClassName(): string;
  21772. /**
  21773. * The minimum of x and y subdivisions
  21774. */
  21775. readonly subdivisions: number;
  21776. /**
  21777. * X subdivisions
  21778. */
  21779. readonly subdivisionsX: number;
  21780. /**
  21781. * Y subdivisions
  21782. */
  21783. readonly subdivisionsY: number;
  21784. /**
  21785. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21786. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21787. * @param chunksCount the number of subdivisions for x and y
  21788. * @param octreeBlocksSize (Default: 32)
  21789. */
  21790. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21791. /**
  21792. * Returns a height (y) value in the Worl system :
  21793. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21794. * @param x x coordinate
  21795. * @param z z coordinate
  21796. * @returns the ground y position if (x, z) are outside the ground surface.
  21797. */
  21798. getHeightAtCoordinates(x: number, z: number): number;
  21799. /**
  21800. * Returns a normalized vector (Vector3) orthogonal to the ground
  21801. * at the ground coordinates (x, z) expressed in the World system.
  21802. * @param x x coordinate
  21803. * @param z z coordinate
  21804. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21805. */
  21806. getNormalAtCoordinates(x: number, z: number): Vector3;
  21807. /**
  21808. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21809. * at the ground coordinates (x, z) expressed in the World system.
  21810. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21811. * @param x x coordinate
  21812. * @param z z coordinate
  21813. * @param ref vector to store the result
  21814. * @returns the GroundMesh.
  21815. */
  21816. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21817. /**
  21818. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21819. * if the ground has been updated.
  21820. * This can be used in the render loop.
  21821. * @returns the GroundMesh.
  21822. */
  21823. updateCoordinateHeights(): GroundMesh;
  21824. private _getFacetAt;
  21825. private _initHeightQuads;
  21826. private _computeHeightQuads;
  21827. /**
  21828. * Serializes this ground mesh
  21829. * @param serializationObject object to write serialization to
  21830. */
  21831. serialize(serializationObject: any): void;
  21832. /**
  21833. * Parses a serialized ground mesh
  21834. * @param parsedMesh the serialized mesh
  21835. * @param scene the scene to create the ground mesh in
  21836. * @returns the created ground mesh
  21837. */
  21838. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21839. }
  21840. }
  21841. declare module BABYLON {
  21842. /**
  21843. * Interface for Physics-Joint data
  21844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21845. */
  21846. export interface PhysicsJointData {
  21847. /**
  21848. * The main pivot of the joint
  21849. */
  21850. mainPivot?: Vector3;
  21851. /**
  21852. * The connected pivot of the joint
  21853. */
  21854. connectedPivot?: Vector3;
  21855. /**
  21856. * The main axis of the joint
  21857. */
  21858. mainAxis?: Vector3;
  21859. /**
  21860. * The connected axis of the joint
  21861. */
  21862. connectedAxis?: Vector3;
  21863. /**
  21864. * The collision of the joint
  21865. */
  21866. collision?: boolean;
  21867. /**
  21868. * Native Oimo/Cannon/Energy data
  21869. */
  21870. nativeParams?: any;
  21871. }
  21872. /**
  21873. * This is a holder class for the physics joint created by the physics plugin
  21874. * It holds a set of functions to control the underlying joint
  21875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21876. */
  21877. export class PhysicsJoint {
  21878. /**
  21879. * The type of the physics joint
  21880. */
  21881. type: number;
  21882. /**
  21883. * The data for the physics joint
  21884. */
  21885. jointData: PhysicsJointData;
  21886. private _physicsJoint;
  21887. protected _physicsPlugin: IPhysicsEnginePlugin;
  21888. /**
  21889. * Initializes the physics joint
  21890. * @param type The type of the physics joint
  21891. * @param jointData The data for the physics joint
  21892. */
  21893. constructor(
  21894. /**
  21895. * The type of the physics joint
  21896. */
  21897. type: number,
  21898. /**
  21899. * The data for the physics joint
  21900. */
  21901. jointData: PhysicsJointData);
  21902. /**
  21903. * Gets the physics joint
  21904. */
  21905. /**
  21906. * Sets the physics joint
  21907. */
  21908. physicsJoint: any;
  21909. /**
  21910. * Sets the physics plugin
  21911. */
  21912. physicsPlugin: IPhysicsEnginePlugin;
  21913. /**
  21914. * Execute a function that is physics-plugin specific.
  21915. * @param {Function} func the function that will be executed.
  21916. * It accepts two parameters: the physics world and the physics joint
  21917. */
  21918. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  21919. /**
  21920. * Distance-Joint type
  21921. */
  21922. static DistanceJoint: number;
  21923. /**
  21924. * Hinge-Joint type
  21925. */
  21926. static HingeJoint: number;
  21927. /**
  21928. * Ball-and-Socket joint type
  21929. */
  21930. static BallAndSocketJoint: number;
  21931. /**
  21932. * Wheel-Joint type
  21933. */
  21934. static WheelJoint: number;
  21935. /**
  21936. * Slider-Joint type
  21937. */
  21938. static SliderJoint: number;
  21939. /**
  21940. * Prismatic-Joint type
  21941. */
  21942. static PrismaticJoint: number;
  21943. /**
  21944. * Universal-Joint type
  21945. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  21946. */
  21947. static UniversalJoint: number;
  21948. /**
  21949. * Hinge-Joint 2 type
  21950. */
  21951. static Hinge2Joint: number;
  21952. /**
  21953. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  21954. */
  21955. static PointToPointJoint: number;
  21956. /**
  21957. * Spring-Joint type
  21958. */
  21959. static SpringJoint: number;
  21960. /**
  21961. * Lock-Joint type
  21962. */
  21963. static LockJoint: number;
  21964. }
  21965. /**
  21966. * A class representing a physics distance joint
  21967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21968. */
  21969. export class DistanceJoint extends PhysicsJoint {
  21970. /**
  21971. *
  21972. * @param jointData The data for the Distance-Joint
  21973. */
  21974. constructor(jointData: DistanceJointData);
  21975. /**
  21976. * Update the predefined distance.
  21977. * @param maxDistance The maximum preferred distance
  21978. * @param minDistance The minimum preferred distance
  21979. */
  21980. updateDistance(maxDistance: number, minDistance?: number): void;
  21981. }
  21982. /**
  21983. * Represents a Motor-Enabled Joint
  21984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21985. */
  21986. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  21987. /**
  21988. * Initializes the Motor-Enabled Joint
  21989. * @param type The type of the joint
  21990. * @param jointData The physica joint data for the joint
  21991. */
  21992. constructor(type: number, jointData: PhysicsJointData);
  21993. /**
  21994. * Set the motor values.
  21995. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21996. * @param force the force to apply
  21997. * @param maxForce max force for this motor.
  21998. */
  21999. setMotor(force?: number, maxForce?: number): void;
  22000. /**
  22001. * Set the motor's limits.
  22002. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22003. * @param upperLimit The upper limit of the motor
  22004. * @param lowerLimit The lower limit of the motor
  22005. */
  22006. setLimit(upperLimit: number, lowerLimit?: number): void;
  22007. }
  22008. /**
  22009. * This class represents a single physics Hinge-Joint
  22010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22011. */
  22012. export class HingeJoint extends MotorEnabledJoint {
  22013. /**
  22014. * Initializes the Hinge-Joint
  22015. * @param jointData The joint data for the Hinge-Joint
  22016. */
  22017. constructor(jointData: PhysicsJointData);
  22018. /**
  22019. * Set the motor values.
  22020. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22021. * @param {number} force the force to apply
  22022. * @param {number} maxForce max force for this motor.
  22023. */
  22024. setMotor(force?: number, maxForce?: number): void;
  22025. /**
  22026. * Set the motor's limits.
  22027. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22028. * @param upperLimit The upper limit of the motor
  22029. * @param lowerLimit The lower limit of the motor
  22030. */
  22031. setLimit(upperLimit: number, lowerLimit?: number): void;
  22032. }
  22033. /**
  22034. * This class represents a dual hinge physics joint (same as wheel joint)
  22035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22036. */
  22037. export class Hinge2Joint extends MotorEnabledJoint {
  22038. /**
  22039. * Initializes the Hinge2-Joint
  22040. * @param jointData The joint data for the Hinge2-Joint
  22041. */
  22042. constructor(jointData: PhysicsJointData);
  22043. /**
  22044. * Set the motor values.
  22045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22046. * @param {number} targetSpeed the speed the motor is to reach
  22047. * @param {number} maxForce max force for this motor.
  22048. * @param {motorIndex} the motor's index, 0 or 1.
  22049. */
  22050. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22051. /**
  22052. * Set the motor limits.
  22053. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22054. * @param {number} upperLimit the upper limit
  22055. * @param {number} lowerLimit lower limit
  22056. * @param {motorIndex} the motor's index, 0 or 1.
  22057. */
  22058. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22059. }
  22060. /**
  22061. * Interface for a motor enabled joint
  22062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22063. */
  22064. export interface IMotorEnabledJoint {
  22065. /**
  22066. * Physics joint
  22067. */
  22068. physicsJoint: any;
  22069. /**
  22070. * Sets the motor of the motor-enabled joint
  22071. * @param force The force of the motor
  22072. * @param maxForce The maximum force of the motor
  22073. * @param motorIndex The index of the motor
  22074. */
  22075. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22076. /**
  22077. * Sets the limit of the motor
  22078. * @param upperLimit The upper limit of the motor
  22079. * @param lowerLimit The lower limit of the motor
  22080. * @param motorIndex The index of the motor
  22081. */
  22082. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22083. }
  22084. /**
  22085. * Joint data for a Distance-Joint
  22086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22087. */
  22088. export interface DistanceJointData extends PhysicsJointData {
  22089. /**
  22090. * Max distance the 2 joint objects can be apart
  22091. */
  22092. maxDistance: number;
  22093. }
  22094. /**
  22095. * Joint data from a spring joint
  22096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22097. */
  22098. export interface SpringJointData extends PhysicsJointData {
  22099. /**
  22100. * Length of the spring
  22101. */
  22102. length: number;
  22103. /**
  22104. * Stiffness of the spring
  22105. */
  22106. stiffness: number;
  22107. /**
  22108. * Damping of the spring
  22109. */
  22110. damping: number;
  22111. /** this callback will be called when applying the force to the impostors. */
  22112. forceApplicationCallback: () => void;
  22113. }
  22114. }
  22115. declare module BABYLON {
  22116. /**
  22117. * Holds the data for the raycast result
  22118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22119. */
  22120. export class PhysicsRaycastResult {
  22121. private _hasHit;
  22122. private _hitDistance;
  22123. private _hitNormalWorld;
  22124. private _hitPointWorld;
  22125. private _rayFromWorld;
  22126. private _rayToWorld;
  22127. /**
  22128. * Gets if there was a hit
  22129. */
  22130. readonly hasHit: boolean;
  22131. /**
  22132. * Gets the distance from the hit
  22133. */
  22134. readonly hitDistance: number;
  22135. /**
  22136. * Gets the hit normal/direction in the world
  22137. */
  22138. readonly hitNormalWorld: Vector3;
  22139. /**
  22140. * Gets the hit point in the world
  22141. */
  22142. readonly hitPointWorld: Vector3;
  22143. /**
  22144. * Gets the ray "start point" of the ray in the world
  22145. */
  22146. readonly rayFromWorld: Vector3;
  22147. /**
  22148. * Gets the ray "end point" of the ray in the world
  22149. */
  22150. readonly rayToWorld: Vector3;
  22151. /**
  22152. * Sets the hit data (normal & point in world space)
  22153. * @param hitNormalWorld defines the normal in world space
  22154. * @param hitPointWorld defines the point in world space
  22155. */
  22156. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22157. /**
  22158. * Sets the distance from the start point to the hit point
  22159. * @param distance
  22160. */
  22161. setHitDistance(distance: number): void;
  22162. /**
  22163. * Calculates the distance manually
  22164. */
  22165. calculateHitDistance(): void;
  22166. /**
  22167. * Resets all the values to default
  22168. * @param from The from point on world space
  22169. * @param to The to point on world space
  22170. */
  22171. reset(from?: Vector3, to?: Vector3): void;
  22172. }
  22173. /**
  22174. * Interface for the size containing width and height
  22175. */
  22176. interface IXYZ {
  22177. /**
  22178. * X
  22179. */
  22180. x: number;
  22181. /**
  22182. * Y
  22183. */
  22184. y: number;
  22185. /**
  22186. * Z
  22187. */
  22188. z: number;
  22189. }
  22190. }
  22191. declare module BABYLON {
  22192. /**
  22193. * Interface used to describe a physics joint
  22194. */
  22195. export interface PhysicsImpostorJoint {
  22196. /** Defines the main impostor to which the joint is linked */
  22197. mainImpostor: PhysicsImpostor;
  22198. /** Defines the impostor that is connected to the main impostor using this joint */
  22199. connectedImpostor: PhysicsImpostor;
  22200. /** Defines the joint itself */
  22201. joint: PhysicsJoint;
  22202. }
  22203. /** @hidden */
  22204. export interface IPhysicsEnginePlugin {
  22205. world: any;
  22206. name: string;
  22207. setGravity(gravity: Vector3): void;
  22208. setTimeStep(timeStep: number): void;
  22209. getTimeStep(): number;
  22210. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22211. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22212. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22213. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22214. removePhysicsBody(impostor: PhysicsImpostor): void;
  22215. generateJoint(joint: PhysicsImpostorJoint): void;
  22216. removeJoint(joint: PhysicsImpostorJoint): void;
  22217. isSupported(): boolean;
  22218. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22219. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22220. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22221. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22222. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22223. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22224. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22225. getBodyMass(impostor: PhysicsImpostor): number;
  22226. getBodyFriction(impostor: PhysicsImpostor): number;
  22227. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22228. getBodyRestitution(impostor: PhysicsImpostor): number;
  22229. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22230. getBodyPressure?(impostor: PhysicsImpostor): number;
  22231. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22232. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22233. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22234. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22235. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22236. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22237. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22238. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22239. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22240. sleepBody(impostor: PhysicsImpostor): void;
  22241. wakeUpBody(impostor: PhysicsImpostor): void;
  22242. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22243. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22244. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22245. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22246. getRadius(impostor: PhysicsImpostor): number;
  22247. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22248. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22249. dispose(): void;
  22250. }
  22251. /**
  22252. * Interface used to define a physics engine
  22253. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22254. */
  22255. export interface IPhysicsEngine {
  22256. /**
  22257. * Gets the gravity vector used by the simulation
  22258. */
  22259. gravity: Vector3;
  22260. /**
  22261. * Sets the gravity vector used by the simulation
  22262. * @param gravity defines the gravity vector to use
  22263. */
  22264. setGravity(gravity: Vector3): void;
  22265. /**
  22266. * Set the time step of the physics engine.
  22267. * Default is 1/60.
  22268. * To slow it down, enter 1/600 for example.
  22269. * To speed it up, 1/30
  22270. * @param newTimeStep the new timestep to apply to this world.
  22271. */
  22272. setTimeStep(newTimeStep: number): void;
  22273. /**
  22274. * Get the time step of the physics engine.
  22275. * @returns the current time step
  22276. */
  22277. getTimeStep(): number;
  22278. /**
  22279. * Release all resources
  22280. */
  22281. dispose(): void;
  22282. /**
  22283. * Gets the name of the current physics plugin
  22284. * @returns the name of the plugin
  22285. */
  22286. getPhysicsPluginName(): string;
  22287. /**
  22288. * Adding a new impostor for the impostor tracking.
  22289. * This will be done by the impostor itself.
  22290. * @param impostor the impostor to add
  22291. */
  22292. addImpostor(impostor: PhysicsImpostor): void;
  22293. /**
  22294. * Remove an impostor from the engine.
  22295. * This impostor and its mesh will not longer be updated by the physics engine.
  22296. * @param impostor the impostor to remove
  22297. */
  22298. removeImpostor(impostor: PhysicsImpostor): void;
  22299. /**
  22300. * Add a joint to the physics engine
  22301. * @param mainImpostor defines the main impostor to which the joint is added.
  22302. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22303. * @param joint defines the joint that will connect both impostors.
  22304. */
  22305. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22306. /**
  22307. * Removes a joint from the simulation
  22308. * @param mainImpostor defines the impostor used with the joint
  22309. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22310. * @param joint defines the joint to remove
  22311. */
  22312. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22313. /**
  22314. * Gets the current plugin used to run the simulation
  22315. * @returns current plugin
  22316. */
  22317. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22318. /**
  22319. * Gets the list of physic impostors
  22320. * @returns an array of PhysicsImpostor
  22321. */
  22322. getImpostors(): Array<PhysicsImpostor>;
  22323. /**
  22324. * Gets the impostor for a physics enabled object
  22325. * @param object defines the object impersonated by the impostor
  22326. * @returns the PhysicsImpostor or null if not found
  22327. */
  22328. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22329. /**
  22330. * Gets the impostor for a physics body object
  22331. * @param body defines physics body used by the impostor
  22332. * @returns the PhysicsImpostor or null if not found
  22333. */
  22334. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22335. /**
  22336. * Does a raycast in the physics world
  22337. * @param from when should the ray start?
  22338. * @param to when should the ray end?
  22339. * @returns PhysicsRaycastResult
  22340. */
  22341. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22342. /**
  22343. * Called by the scene. No need to call it.
  22344. * @param delta defines the timespam between frames
  22345. */ private _step(delta: number): void;
  22346. }
  22347. }
  22348. declare module BABYLON {
  22349. /**
  22350. * The interface for the physics imposter parameters
  22351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22352. */
  22353. export interface PhysicsImpostorParameters {
  22354. /**
  22355. * The mass of the physics imposter
  22356. */
  22357. mass: number;
  22358. /**
  22359. * The friction of the physics imposter
  22360. */
  22361. friction?: number;
  22362. /**
  22363. * The coefficient of restitution of the physics imposter
  22364. */
  22365. restitution?: number;
  22366. /**
  22367. * The native options of the physics imposter
  22368. */
  22369. nativeOptions?: any;
  22370. /**
  22371. * Specifies if the parent should be ignored
  22372. */
  22373. ignoreParent?: boolean;
  22374. /**
  22375. * Specifies if bi-directional transformations should be disabled
  22376. */
  22377. disableBidirectionalTransformation?: boolean;
  22378. /**
  22379. * The pressure inside the physics imposter, soft object only
  22380. */
  22381. pressure?: number;
  22382. /**
  22383. * The stiffness the physics imposter, soft object only
  22384. */
  22385. stiffness?: number;
  22386. /**
  22387. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22388. */
  22389. velocityIterations?: number;
  22390. /**
  22391. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22392. */
  22393. positionIterations?: number;
  22394. /**
  22395. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22396. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22397. * Add to fix multiple points
  22398. */
  22399. fixedPoints?: number;
  22400. /**
  22401. * The collision margin around a soft object
  22402. */
  22403. margin?: number;
  22404. /**
  22405. * The collision margin around a soft object
  22406. */
  22407. damping?: number;
  22408. /**
  22409. * The path for a rope based on an extrusion
  22410. */
  22411. path?: any;
  22412. /**
  22413. * The shape of an extrusion used for a rope based on an extrusion
  22414. */
  22415. shape?: any;
  22416. }
  22417. /**
  22418. * Interface for a physics-enabled object
  22419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22420. */
  22421. export interface IPhysicsEnabledObject {
  22422. /**
  22423. * The position of the physics-enabled object
  22424. */
  22425. position: Vector3;
  22426. /**
  22427. * The rotation of the physics-enabled object
  22428. */
  22429. rotationQuaternion: Nullable<Quaternion>;
  22430. /**
  22431. * The scale of the physics-enabled object
  22432. */
  22433. scaling: Vector3;
  22434. /**
  22435. * The rotation of the physics-enabled object
  22436. */
  22437. rotation?: Vector3;
  22438. /**
  22439. * The parent of the physics-enabled object
  22440. */
  22441. parent?: any;
  22442. /**
  22443. * The bounding info of the physics-enabled object
  22444. * @returns The bounding info of the physics-enabled object
  22445. */
  22446. getBoundingInfo(): BoundingInfo;
  22447. /**
  22448. * Computes the world matrix
  22449. * @param force Specifies if the world matrix should be computed by force
  22450. * @returns A world matrix
  22451. */
  22452. computeWorldMatrix(force: boolean): Matrix;
  22453. /**
  22454. * Gets the world matrix
  22455. * @returns A world matrix
  22456. */
  22457. getWorldMatrix?(): Matrix;
  22458. /**
  22459. * Gets the child meshes
  22460. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22461. * @returns An array of abstract meshes
  22462. */
  22463. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22464. /**
  22465. * Gets the vertex data
  22466. * @param kind The type of vertex data
  22467. * @returns A nullable array of numbers, or a float32 array
  22468. */
  22469. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22470. /**
  22471. * Gets the indices from the mesh
  22472. * @returns A nullable array of index arrays
  22473. */
  22474. getIndices?(): Nullable<IndicesArray>;
  22475. /**
  22476. * Gets the scene from the mesh
  22477. * @returns the indices array or null
  22478. */
  22479. getScene?(): Scene;
  22480. /**
  22481. * Gets the absolute position from the mesh
  22482. * @returns the absolute position
  22483. */
  22484. getAbsolutePosition(): Vector3;
  22485. /**
  22486. * Gets the absolute pivot point from the mesh
  22487. * @returns the absolute pivot point
  22488. */
  22489. getAbsolutePivotPoint(): Vector3;
  22490. /**
  22491. * Rotates the mesh
  22492. * @param axis The axis of rotation
  22493. * @param amount The amount of rotation
  22494. * @param space The space of the rotation
  22495. * @returns The rotation transform node
  22496. */
  22497. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22498. /**
  22499. * Translates the mesh
  22500. * @param axis The axis of translation
  22501. * @param distance The distance of translation
  22502. * @param space The space of the translation
  22503. * @returns The transform node
  22504. */
  22505. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22506. /**
  22507. * Sets the absolute position of the mesh
  22508. * @param absolutePosition The absolute position of the mesh
  22509. * @returns The transform node
  22510. */
  22511. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22512. /**
  22513. * Gets the class name of the mesh
  22514. * @returns The class name
  22515. */
  22516. getClassName(): string;
  22517. }
  22518. /**
  22519. * Represents a physics imposter
  22520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22521. */
  22522. export class PhysicsImpostor {
  22523. /**
  22524. * The physics-enabled object used as the physics imposter
  22525. */
  22526. object: IPhysicsEnabledObject;
  22527. /**
  22528. * The type of the physics imposter
  22529. */
  22530. type: number;
  22531. private _options;
  22532. private _scene?;
  22533. /**
  22534. * The default object size of the imposter
  22535. */
  22536. static DEFAULT_OBJECT_SIZE: Vector3;
  22537. /**
  22538. * The identity quaternion of the imposter
  22539. */
  22540. static IDENTITY_QUATERNION: Quaternion;
  22541. /** @hidden */ private _pluginData: any;
  22542. private _physicsEngine;
  22543. private _physicsBody;
  22544. private _bodyUpdateRequired;
  22545. private _onBeforePhysicsStepCallbacks;
  22546. private _onAfterPhysicsStepCallbacks;
  22547. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22548. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22549. otherImpostors: Array<PhysicsImpostor>;
  22550. }>;
  22551. private _deltaPosition;
  22552. private _deltaRotation;
  22553. private _deltaRotationConjugated;
  22554. /** @hidden */ private _isFromLine: boolean;
  22555. private _parent;
  22556. private _isDisposed;
  22557. private static _tmpVecs;
  22558. private static _tmpQuat;
  22559. /**
  22560. * Specifies if the physics imposter is disposed
  22561. */
  22562. readonly isDisposed: boolean;
  22563. /**
  22564. * Gets the mass of the physics imposter
  22565. */
  22566. mass: number;
  22567. /**
  22568. * Gets the coefficient of friction
  22569. */
  22570. /**
  22571. * Sets the coefficient of friction
  22572. */
  22573. friction: number;
  22574. /**
  22575. * Gets the coefficient of restitution
  22576. */
  22577. /**
  22578. * Sets the coefficient of restitution
  22579. */
  22580. restitution: number;
  22581. /**
  22582. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22583. */
  22584. /**
  22585. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22586. */
  22587. pressure: number;
  22588. /**
  22589. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22590. */
  22591. /**
  22592. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22593. */
  22594. stiffness: number;
  22595. /**
  22596. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22597. */
  22598. /**
  22599. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22600. */
  22601. velocityIterations: number;
  22602. /**
  22603. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22604. */
  22605. /**
  22606. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22607. */
  22608. positionIterations: number;
  22609. /**
  22610. * The unique id of the physics imposter
  22611. * set by the physics engine when adding this impostor to the array
  22612. */
  22613. uniqueId: number;
  22614. /**
  22615. * @hidden
  22616. */
  22617. soft: boolean;
  22618. /**
  22619. * @hidden
  22620. */
  22621. segments: number;
  22622. private _joints;
  22623. /**
  22624. * Initializes the physics imposter
  22625. * @param object The physics-enabled object used as the physics imposter
  22626. * @param type The type of the physics imposter
  22627. * @param _options The options for the physics imposter
  22628. * @param _scene The Babylon scene
  22629. */
  22630. constructor(
  22631. /**
  22632. * The physics-enabled object used as the physics imposter
  22633. */
  22634. object: IPhysicsEnabledObject,
  22635. /**
  22636. * The type of the physics imposter
  22637. */
  22638. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22639. /**
  22640. * This function will completly initialize this impostor.
  22641. * It will create a new body - but only if this mesh has no parent.
  22642. * If it has, this impostor will not be used other than to define the impostor
  22643. * of the child mesh.
  22644. * @hidden
  22645. */ private _init(): void;
  22646. private _getPhysicsParent;
  22647. /**
  22648. * Should a new body be generated.
  22649. * @returns boolean specifying if body initialization is required
  22650. */
  22651. isBodyInitRequired(): boolean;
  22652. /**
  22653. * Sets the updated scaling
  22654. * @param updated Specifies if the scaling is updated
  22655. */
  22656. setScalingUpdated(): void;
  22657. /**
  22658. * Force a regeneration of this or the parent's impostor's body.
  22659. * Use under cautious - This will remove all joints already implemented.
  22660. */
  22661. forceUpdate(): void;
  22662. /**
  22663. * Gets the body that holds this impostor. Either its own, or its parent.
  22664. */
  22665. /**
  22666. * Set the physics body. Used mainly by the physics engine/plugin
  22667. */
  22668. physicsBody: any;
  22669. /**
  22670. * Get the parent of the physics imposter
  22671. * @returns Physics imposter or null
  22672. */
  22673. /**
  22674. * Sets the parent of the physics imposter
  22675. */
  22676. parent: Nullable<PhysicsImpostor>;
  22677. /**
  22678. * Resets the update flags
  22679. */
  22680. resetUpdateFlags(): void;
  22681. /**
  22682. * Gets the object extend size
  22683. * @returns the object extend size
  22684. */
  22685. getObjectExtendSize(): Vector3;
  22686. /**
  22687. * Gets the object center
  22688. * @returns The object center
  22689. */
  22690. getObjectCenter(): Vector3;
  22691. /**
  22692. * Get a specific parametes from the options parameter
  22693. * @param paramName The object parameter name
  22694. * @returns The object parameter
  22695. */
  22696. getParam(paramName: string): any;
  22697. /**
  22698. * Sets a specific parameter in the options given to the physics plugin
  22699. * @param paramName The parameter name
  22700. * @param value The value of the parameter
  22701. */
  22702. setParam(paramName: string, value: number): void;
  22703. /**
  22704. * Specifically change the body's mass option. Won't recreate the physics body object
  22705. * @param mass The mass of the physics imposter
  22706. */
  22707. setMass(mass: number): void;
  22708. /**
  22709. * Gets the linear velocity
  22710. * @returns linear velocity or null
  22711. */
  22712. getLinearVelocity(): Nullable<Vector3>;
  22713. /**
  22714. * Sets the linear velocity
  22715. * @param velocity linear velocity or null
  22716. */
  22717. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22718. /**
  22719. * Gets the angular velocity
  22720. * @returns angular velocity or null
  22721. */
  22722. getAngularVelocity(): Nullable<Vector3>;
  22723. /**
  22724. * Sets the angular velocity
  22725. * @param velocity The velocity or null
  22726. */
  22727. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22728. /**
  22729. * Execute a function with the physics plugin native code
  22730. * Provide a function the will have two variables - the world object and the physics body object
  22731. * @param func The function to execute with the physics plugin native code
  22732. */
  22733. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22734. /**
  22735. * Register a function that will be executed before the physics world is stepping forward
  22736. * @param func The function to execute before the physics world is stepped forward
  22737. */
  22738. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22739. /**
  22740. * Unregister a function that will be executed before the physics world is stepping forward
  22741. * @param func The function to execute before the physics world is stepped forward
  22742. */
  22743. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22744. /**
  22745. * Register a function that will be executed after the physics step
  22746. * @param func The function to execute after physics step
  22747. */
  22748. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22749. /**
  22750. * Unregisters a function that will be executed after the physics step
  22751. * @param func The function to execute after physics step
  22752. */
  22753. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22754. /**
  22755. * register a function that will be executed when this impostor collides against a different body
  22756. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22757. * @param func Callback that is executed on collision
  22758. */
  22759. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22760. /**
  22761. * Unregisters the physics imposter on contact
  22762. * @param collideAgainst The physics object to collide against
  22763. * @param func Callback to execute on collision
  22764. */
  22765. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22766. private _tmpQuat;
  22767. private _tmpQuat2;
  22768. /**
  22769. * Get the parent rotation
  22770. * @returns The parent rotation
  22771. */
  22772. getParentsRotation(): Quaternion;
  22773. /**
  22774. * this function is executed by the physics engine.
  22775. */
  22776. beforeStep: () => void;
  22777. /**
  22778. * this function is executed by the physics engine
  22779. */
  22780. afterStep: () => void;
  22781. /**
  22782. * Legacy collision detection event support
  22783. */
  22784. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22785. /**
  22786. * event and body object due to cannon's event-based architecture.
  22787. */
  22788. onCollide: (e: {
  22789. body: any;
  22790. }) => void;
  22791. /**
  22792. * Apply a force
  22793. * @param force The force to apply
  22794. * @param contactPoint The contact point for the force
  22795. * @returns The physics imposter
  22796. */
  22797. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22798. /**
  22799. * Apply an impulse
  22800. * @param force The impulse force
  22801. * @param contactPoint The contact point for the impulse force
  22802. * @returns The physics imposter
  22803. */
  22804. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22805. /**
  22806. * A help function to create a joint
  22807. * @param otherImpostor A physics imposter used to create a joint
  22808. * @param jointType The type of joint
  22809. * @param jointData The data for the joint
  22810. * @returns The physics imposter
  22811. */
  22812. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22813. /**
  22814. * Add a joint to this impostor with a different impostor
  22815. * @param otherImpostor A physics imposter used to add a joint
  22816. * @param joint The joint to add
  22817. * @returns The physics imposter
  22818. */
  22819. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22820. /**
  22821. * Add an anchor to a cloth impostor
  22822. * @param otherImpostor rigid impostor to anchor to
  22823. * @param width ratio across width from 0 to 1
  22824. * @param height ratio up height from 0 to 1
  22825. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  22826. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  22827. * @returns impostor the soft imposter
  22828. */
  22829. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22830. /**
  22831. * Add a hook to a rope impostor
  22832. * @param otherImpostor rigid impostor to anchor to
  22833. * @param length ratio across rope from 0 to 1
  22834. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  22835. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  22836. * @returns impostor the rope imposter
  22837. */
  22838. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22839. /**
  22840. * Will keep this body still, in a sleep mode.
  22841. * @returns the physics imposter
  22842. */
  22843. sleep(): PhysicsImpostor;
  22844. /**
  22845. * Wake the body up.
  22846. * @returns The physics imposter
  22847. */
  22848. wakeUp(): PhysicsImpostor;
  22849. /**
  22850. * Clones the physics imposter
  22851. * @param newObject The physics imposter clones to this physics-enabled object
  22852. * @returns A nullable physics imposter
  22853. */
  22854. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22855. /**
  22856. * Disposes the physics imposter
  22857. */
  22858. dispose(): void;
  22859. /**
  22860. * Sets the delta position
  22861. * @param position The delta position amount
  22862. */
  22863. setDeltaPosition(position: Vector3): void;
  22864. /**
  22865. * Sets the delta rotation
  22866. * @param rotation The delta rotation amount
  22867. */
  22868. setDeltaRotation(rotation: Quaternion): void;
  22869. /**
  22870. * Gets the box size of the physics imposter and stores the result in the input parameter
  22871. * @param result Stores the box size
  22872. * @returns The physics imposter
  22873. */
  22874. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  22875. /**
  22876. * Gets the radius of the physics imposter
  22877. * @returns Radius of the physics imposter
  22878. */
  22879. getRadius(): number;
  22880. /**
  22881. * Sync a bone with this impostor
  22882. * @param bone The bone to sync to the impostor.
  22883. * @param boneMesh The mesh that the bone is influencing.
  22884. * @param jointPivot The pivot of the joint / bone in local space.
  22885. * @param distToJoint Optional distance from the impostor to the joint.
  22886. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22887. */
  22888. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  22889. /**
  22890. * Sync impostor to a bone
  22891. * @param bone The bone that the impostor will be synced to.
  22892. * @param boneMesh The mesh that the bone is influencing.
  22893. * @param jointPivot The pivot of the joint / bone in local space.
  22894. * @param distToJoint Optional distance from the impostor to the joint.
  22895. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22896. * @param boneAxis Optional vector3 axis the bone is aligned with
  22897. */
  22898. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  22899. /**
  22900. * No-Imposter type
  22901. */
  22902. static NoImpostor: number;
  22903. /**
  22904. * Sphere-Imposter type
  22905. */
  22906. static SphereImpostor: number;
  22907. /**
  22908. * Box-Imposter type
  22909. */
  22910. static BoxImpostor: number;
  22911. /**
  22912. * Plane-Imposter type
  22913. */
  22914. static PlaneImpostor: number;
  22915. /**
  22916. * Mesh-imposter type
  22917. */
  22918. static MeshImpostor: number;
  22919. /**
  22920. * Capsule-Impostor type (Ammo.js plugin only)
  22921. */
  22922. static CapsuleImpostor: number;
  22923. /**
  22924. * Cylinder-Imposter type
  22925. */
  22926. static CylinderImpostor: number;
  22927. /**
  22928. * Particle-Imposter type
  22929. */
  22930. static ParticleImpostor: number;
  22931. /**
  22932. * Heightmap-Imposter type
  22933. */
  22934. static HeightmapImpostor: number;
  22935. /**
  22936. * ConvexHull-Impostor type (Ammo.js plugin only)
  22937. */
  22938. static ConvexHullImpostor: number;
  22939. /**
  22940. * Rope-Imposter type
  22941. */
  22942. static RopeImpostor: number;
  22943. /**
  22944. * Cloth-Imposter type
  22945. */
  22946. static ClothImpostor: number;
  22947. /**
  22948. * Softbody-Imposter type
  22949. */
  22950. static SoftbodyImpostor: number;
  22951. }
  22952. }
  22953. declare module BABYLON {
  22954. /**
  22955. * @hidden
  22956. **/
  22957. export class _CreationDataStorage {
  22958. closePath?: boolean;
  22959. closeArray?: boolean;
  22960. idx: number[];
  22961. dashSize: number;
  22962. gapSize: number;
  22963. path3D: Path3D;
  22964. pathArray: Vector3[][];
  22965. arc: number;
  22966. radius: number;
  22967. cap: number;
  22968. tessellation: number;
  22969. }
  22970. /**
  22971. * @hidden
  22972. **/ private class _InstanceDataStorage {
  22973. visibleInstances: any;
  22974. batchCache: _InstancesBatch;
  22975. instancesBufferSize: number;
  22976. instancesBuffer: Nullable<Buffer>;
  22977. instancesData: Float32Array;
  22978. overridenInstanceCount: number;
  22979. isFrozen: boolean;
  22980. previousBatch: Nullable<_InstancesBatch>;
  22981. hardwareInstancedRendering: boolean;
  22982. sideOrientation: number;
  22983. }
  22984. /**
  22985. * @hidden
  22986. **/
  22987. export class _InstancesBatch {
  22988. mustReturn: boolean;
  22989. visibleInstances: Nullable<InstancedMesh[]>[];
  22990. renderSelf: boolean[];
  22991. hardwareInstancedRendering: boolean[];
  22992. }
  22993. /**
  22994. * Class used to represent renderable models
  22995. */
  22996. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  22997. /**
  22998. * Mesh side orientation : usually the external or front surface
  22999. */
  23000. static readonly FRONTSIDE: number;
  23001. /**
  23002. * Mesh side orientation : usually the internal or back surface
  23003. */
  23004. static readonly BACKSIDE: number;
  23005. /**
  23006. * Mesh side orientation : both internal and external or front and back surfaces
  23007. */
  23008. static readonly DOUBLESIDE: number;
  23009. /**
  23010. * Mesh side orientation : by default, `FRONTSIDE`
  23011. */
  23012. static readonly DEFAULTSIDE: number;
  23013. /**
  23014. * Mesh cap setting : no cap
  23015. */
  23016. static readonly NO_CAP: number;
  23017. /**
  23018. * Mesh cap setting : one cap at the beginning of the mesh
  23019. */
  23020. static readonly CAP_START: number;
  23021. /**
  23022. * Mesh cap setting : one cap at the end of the mesh
  23023. */
  23024. static readonly CAP_END: number;
  23025. /**
  23026. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23027. */
  23028. static readonly CAP_ALL: number;
  23029. /**
  23030. * Mesh pattern setting : no flip or rotate
  23031. */
  23032. static readonly NO_FLIP: number;
  23033. /**
  23034. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23035. */
  23036. static readonly FLIP_TILE: number;
  23037. /**
  23038. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23039. */
  23040. static readonly ROTATE_TILE: number;
  23041. /**
  23042. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23043. */
  23044. static readonly FLIP_ROW: number;
  23045. /**
  23046. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23047. */
  23048. static readonly ROTATE_ROW: number;
  23049. /**
  23050. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23051. */
  23052. static readonly FLIP_N_ROTATE_TILE: number;
  23053. /**
  23054. * Mesh pattern setting : rotate pattern and rotate
  23055. */
  23056. static readonly FLIP_N_ROTATE_ROW: number;
  23057. /**
  23058. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23059. */
  23060. static readonly CENTER: number;
  23061. /**
  23062. * Mesh tile positioning : part tiles on left
  23063. */
  23064. static readonly LEFT: number;
  23065. /**
  23066. * Mesh tile positioning : part tiles on right
  23067. */
  23068. static readonly RIGHT: number;
  23069. /**
  23070. * Mesh tile positioning : part tiles on top
  23071. */
  23072. static readonly TOP: number;
  23073. /**
  23074. * Mesh tile positioning : part tiles on bottom
  23075. */
  23076. static readonly BOTTOM: number;
  23077. /**
  23078. * Gets the default side orientation.
  23079. * @param orientation the orientation to value to attempt to get
  23080. * @returns the default orientation
  23081. * @hidden
  23082. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23083. private _internalMeshDataInfo;
  23084. /**
  23085. * An event triggered before rendering the mesh
  23086. */
  23087. readonly onBeforeRenderObservable: Observable<Mesh>;
  23088. /**
  23089. * An event triggered before binding the mesh
  23090. */
  23091. readonly onBeforeBindObservable: Observable<Mesh>;
  23092. /**
  23093. * An event triggered after rendering the mesh
  23094. */
  23095. readonly onAfterRenderObservable: Observable<Mesh>;
  23096. /**
  23097. * An event triggered before drawing the mesh
  23098. */
  23099. readonly onBeforeDrawObservable: Observable<Mesh>;
  23100. private _onBeforeDrawObserver;
  23101. /**
  23102. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23103. */
  23104. onBeforeDraw: () => void;
  23105. readonly hasInstances: boolean;
  23106. /**
  23107. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23108. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23109. */
  23110. delayLoadState: number;
  23111. /**
  23112. * Gets the list of instances created from this mesh
  23113. * it is not supposed to be modified manually.
  23114. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23115. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23116. */
  23117. instances: InstancedMesh[];
  23118. /**
  23119. * Gets the file containing delay loading data for this mesh
  23120. */
  23121. delayLoadingFile: string;
  23122. /** @hidden */ private _binaryInfo: any;
  23123. /**
  23124. * User defined function used to change how LOD level selection is done
  23125. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23126. */
  23127. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23128. /**
  23129. * Gets or sets the morph target manager
  23130. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23131. */
  23132. morphTargetManager: Nullable<MorphTargetManager>;
  23133. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23134. /** @hidden */ private _geometry: Nullable<Geometry>;
  23135. /** @hidden */ private _delayInfo: Array<string>;
  23136. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23137. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23138. private _effectiveMaterial;
  23139. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23140. /** @hidden */ private _originalBuilderSideOrientation: number;
  23141. /**
  23142. * Use this property to change the original side orientation defined at construction time
  23143. */
  23144. overrideMaterialSideOrientation: Nullable<number>;
  23145. /**
  23146. * Gets the source mesh (the one used to clone this one from)
  23147. */
  23148. readonly source: Nullable<Mesh>;
  23149. /**
  23150. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23151. */
  23152. isUnIndexed: boolean;
  23153. /**
  23154. * @constructor
  23155. * @param name The value used by scene.getMeshByName() to do a lookup.
  23156. * @param scene The scene to add this mesh to.
  23157. * @param parent The parent of this mesh, if it has one
  23158. * @param source An optional Mesh from which geometry is shared, cloned.
  23159. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23160. * When false, achieved by calling a clone(), also passing False.
  23161. * This will make creation of children, recursive.
  23162. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23163. */
  23164. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23165. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23166. /**
  23167. * Gets the class name
  23168. * @returns the string "Mesh".
  23169. */
  23170. getClassName(): string;
  23171. /** @hidden */ protected readonly _isMesh: boolean;
  23172. /**
  23173. * Returns a description of this mesh
  23174. * @param fullDetails define if full details about this mesh must be used
  23175. * @returns a descriptive string representing this mesh
  23176. */
  23177. toString(fullDetails?: boolean): string;
  23178. /** @hidden */ private _unBindEffect(): void;
  23179. /**
  23180. * Gets a boolean indicating if this mesh has LOD
  23181. */
  23182. readonly hasLODLevels: boolean;
  23183. /**
  23184. * Gets the list of MeshLODLevel associated with the current mesh
  23185. * @returns an array of MeshLODLevel
  23186. */
  23187. getLODLevels(): MeshLODLevel[];
  23188. private _sortLODLevels;
  23189. /**
  23190. * Add a mesh as LOD level triggered at the given distance.
  23191. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23192. * @param distance The distance from the center of the object to show this level
  23193. * @param mesh The mesh to be added as LOD level (can be null)
  23194. * @return This mesh (for chaining)
  23195. */
  23196. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23197. /**
  23198. * Returns the LOD level mesh at the passed distance or null if not found.
  23199. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23200. * @param distance The distance from the center of the object to show this level
  23201. * @returns a Mesh or `null`
  23202. */
  23203. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23204. /**
  23205. * Remove a mesh from the LOD array
  23206. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23207. * @param mesh defines the mesh to be removed
  23208. * @return This mesh (for chaining)
  23209. */
  23210. removeLODLevel(mesh: Mesh): Mesh;
  23211. /**
  23212. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23213. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23214. * @param camera defines the camera to use to compute distance
  23215. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23216. * @return This mesh (for chaining)
  23217. */
  23218. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23219. /**
  23220. * Gets the mesh internal Geometry object
  23221. */
  23222. readonly geometry: Nullable<Geometry>;
  23223. /**
  23224. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23225. * @returns the total number of vertices
  23226. */
  23227. getTotalVertices(): number;
  23228. /**
  23229. * Returns the content of an associated vertex buffer
  23230. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23231. * - VertexBuffer.PositionKind
  23232. * - VertexBuffer.UVKind
  23233. * - VertexBuffer.UV2Kind
  23234. * - VertexBuffer.UV3Kind
  23235. * - VertexBuffer.UV4Kind
  23236. * - VertexBuffer.UV5Kind
  23237. * - VertexBuffer.UV6Kind
  23238. * - VertexBuffer.ColorKind
  23239. * - VertexBuffer.MatricesIndicesKind
  23240. * - VertexBuffer.MatricesIndicesExtraKind
  23241. * - VertexBuffer.MatricesWeightsKind
  23242. * - VertexBuffer.MatricesWeightsExtraKind
  23243. * @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
  23244. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23245. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23246. */
  23247. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23248. /**
  23249. * Returns the mesh VertexBuffer object from the requested `kind`
  23250. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23251. * - VertexBuffer.PositionKind
  23252. * - VertexBuffer.NormalKind
  23253. * - VertexBuffer.UVKind
  23254. * - VertexBuffer.UV2Kind
  23255. * - VertexBuffer.UV3Kind
  23256. * - VertexBuffer.UV4Kind
  23257. * - VertexBuffer.UV5Kind
  23258. * - VertexBuffer.UV6Kind
  23259. * - VertexBuffer.ColorKind
  23260. * - VertexBuffer.MatricesIndicesKind
  23261. * - VertexBuffer.MatricesIndicesExtraKind
  23262. * - VertexBuffer.MatricesWeightsKind
  23263. * - VertexBuffer.MatricesWeightsExtraKind
  23264. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23265. */
  23266. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23267. /**
  23268. * Tests if a specific vertex buffer is associated with this mesh
  23269. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23270. * - VertexBuffer.PositionKind
  23271. * - VertexBuffer.NormalKind
  23272. * - VertexBuffer.UVKind
  23273. * - VertexBuffer.UV2Kind
  23274. * - VertexBuffer.UV3Kind
  23275. * - VertexBuffer.UV4Kind
  23276. * - VertexBuffer.UV5Kind
  23277. * - VertexBuffer.UV6Kind
  23278. * - VertexBuffer.ColorKind
  23279. * - VertexBuffer.MatricesIndicesKind
  23280. * - VertexBuffer.MatricesIndicesExtraKind
  23281. * - VertexBuffer.MatricesWeightsKind
  23282. * - VertexBuffer.MatricesWeightsExtraKind
  23283. * @returns a boolean
  23284. */
  23285. isVerticesDataPresent(kind: string): boolean;
  23286. /**
  23287. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23288. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23289. * - VertexBuffer.PositionKind
  23290. * - VertexBuffer.UVKind
  23291. * - VertexBuffer.UV2Kind
  23292. * - VertexBuffer.UV3Kind
  23293. * - VertexBuffer.UV4Kind
  23294. * - VertexBuffer.UV5Kind
  23295. * - VertexBuffer.UV6Kind
  23296. * - VertexBuffer.ColorKind
  23297. * - VertexBuffer.MatricesIndicesKind
  23298. * - VertexBuffer.MatricesIndicesExtraKind
  23299. * - VertexBuffer.MatricesWeightsKind
  23300. * - VertexBuffer.MatricesWeightsExtraKind
  23301. * @returns a boolean
  23302. */
  23303. isVertexBufferUpdatable(kind: string): boolean;
  23304. /**
  23305. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23306. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23307. * - VertexBuffer.PositionKind
  23308. * - VertexBuffer.NormalKind
  23309. * - VertexBuffer.UVKind
  23310. * - VertexBuffer.UV2Kind
  23311. * - VertexBuffer.UV3Kind
  23312. * - VertexBuffer.UV4Kind
  23313. * - VertexBuffer.UV5Kind
  23314. * - VertexBuffer.UV6Kind
  23315. * - VertexBuffer.ColorKind
  23316. * - VertexBuffer.MatricesIndicesKind
  23317. * - VertexBuffer.MatricesIndicesExtraKind
  23318. * - VertexBuffer.MatricesWeightsKind
  23319. * - VertexBuffer.MatricesWeightsExtraKind
  23320. * @returns an array of strings
  23321. */
  23322. getVerticesDataKinds(): string[];
  23323. /**
  23324. * Returns a positive integer : the total number of indices in this mesh geometry.
  23325. * @returns the numner of indices or zero if the mesh has no geometry.
  23326. */
  23327. getTotalIndices(): number;
  23328. /**
  23329. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23330. * @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.
  23331. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23332. * @returns the indices array or an empty array if the mesh has no geometry
  23333. */
  23334. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23335. readonly isBlocked: boolean;
  23336. /**
  23337. * Determine if the current mesh is ready to be rendered
  23338. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23339. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23340. * @returns true if all associated assets are ready (material, textures, shaders)
  23341. */
  23342. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23343. /**
  23344. * 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.
  23345. */
  23346. readonly areNormalsFrozen: boolean;
  23347. /**
  23348. * 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.
  23349. * @returns the current mesh
  23350. */
  23351. freezeNormals(): Mesh;
  23352. /**
  23353. * 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
  23354. * @returns the current mesh
  23355. */
  23356. unfreezeNormals(): Mesh;
  23357. /**
  23358. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23359. */
  23360. overridenInstanceCount: number;
  23361. /** @hidden */ private _preActivate(): Mesh;
  23362. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23363. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23364. /**
  23365. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23366. * This means the mesh underlying bounding box and sphere are recomputed.
  23367. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23368. * @returns the current mesh
  23369. */
  23370. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23371. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23372. /**
  23373. * This function will subdivide the mesh into multiple submeshes
  23374. * @param count defines the expected number of submeshes
  23375. */
  23376. subdivide(count: number): void;
  23377. /**
  23378. * Copy a FloatArray into a specific associated vertex buffer
  23379. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23380. * - VertexBuffer.PositionKind
  23381. * - VertexBuffer.UVKind
  23382. * - VertexBuffer.UV2Kind
  23383. * - VertexBuffer.UV3Kind
  23384. * - VertexBuffer.UV4Kind
  23385. * - VertexBuffer.UV5Kind
  23386. * - VertexBuffer.UV6Kind
  23387. * - VertexBuffer.ColorKind
  23388. * - VertexBuffer.MatricesIndicesKind
  23389. * - VertexBuffer.MatricesIndicesExtraKind
  23390. * - VertexBuffer.MatricesWeightsKind
  23391. * - VertexBuffer.MatricesWeightsExtraKind
  23392. * @param data defines the data source
  23393. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23394. * @param stride defines the data stride size (can be null)
  23395. * @returns the current mesh
  23396. */
  23397. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23398. /**
  23399. * Flags an associated vertex buffer as updatable
  23400. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23401. * - VertexBuffer.PositionKind
  23402. * - VertexBuffer.UVKind
  23403. * - VertexBuffer.UV2Kind
  23404. * - VertexBuffer.UV3Kind
  23405. * - VertexBuffer.UV4Kind
  23406. * - VertexBuffer.UV5Kind
  23407. * - VertexBuffer.UV6Kind
  23408. * - VertexBuffer.ColorKind
  23409. * - VertexBuffer.MatricesIndicesKind
  23410. * - VertexBuffer.MatricesIndicesExtraKind
  23411. * - VertexBuffer.MatricesWeightsKind
  23412. * - VertexBuffer.MatricesWeightsExtraKind
  23413. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23414. */
  23415. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23416. /**
  23417. * Sets the mesh global Vertex Buffer
  23418. * @param buffer defines the buffer to use
  23419. * @returns the current mesh
  23420. */
  23421. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23422. /**
  23423. * Update a specific associated vertex buffer
  23424. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23425. * - VertexBuffer.PositionKind
  23426. * - VertexBuffer.UVKind
  23427. * - VertexBuffer.UV2Kind
  23428. * - VertexBuffer.UV3Kind
  23429. * - VertexBuffer.UV4Kind
  23430. * - VertexBuffer.UV5Kind
  23431. * - VertexBuffer.UV6Kind
  23432. * - VertexBuffer.ColorKind
  23433. * - VertexBuffer.MatricesIndicesKind
  23434. * - VertexBuffer.MatricesIndicesExtraKind
  23435. * - VertexBuffer.MatricesWeightsKind
  23436. * - VertexBuffer.MatricesWeightsExtraKind
  23437. * @param data defines the data source
  23438. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23439. * @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)
  23440. * @returns the current mesh
  23441. */
  23442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23443. /**
  23444. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23445. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23446. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23447. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23448. * @returns the current mesh
  23449. */
  23450. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23451. /**
  23452. * Creates a un-shared specific occurence of the geometry for the mesh.
  23453. * @returns the current mesh
  23454. */
  23455. makeGeometryUnique(): Mesh;
  23456. /**
  23457. * Set the index buffer of this mesh
  23458. * @param indices defines the source data
  23459. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23460. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23461. * @returns the current mesh
  23462. */
  23463. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23464. /**
  23465. * Update the current index buffer
  23466. * @param indices defines the source data
  23467. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23468. * @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)
  23469. * @returns the current mesh
  23470. */
  23471. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23472. /**
  23473. * Invert the geometry to move from a right handed system to a left handed one.
  23474. * @returns the current mesh
  23475. */
  23476. toLeftHanded(): Mesh;
  23477. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23478. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23479. /**
  23480. * Registers for this mesh a javascript function called just before the rendering process
  23481. * @param func defines the function to call before rendering this mesh
  23482. * @returns the current mesh
  23483. */
  23484. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23485. /**
  23486. * Disposes a previously registered javascript function called before the rendering
  23487. * @param func defines the function to remove
  23488. * @returns the current mesh
  23489. */
  23490. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23491. /**
  23492. * Registers for this mesh a javascript function called just after the rendering is complete
  23493. * @param func defines the function to call after rendering this mesh
  23494. * @returns the current mesh
  23495. */
  23496. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23497. /**
  23498. * Disposes a previously registered javascript function called after the rendering.
  23499. * @param func defines the function to remove
  23500. * @returns the current mesh
  23501. */
  23502. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23503. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23504. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23505. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23506. /** @hidden */ private _rebuild(): void;
  23507. /** @hidden */ private _freeze(): void;
  23508. /** @hidden */ private _unFreeze(): void;
  23509. /**
  23510. * 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
  23511. * @param subMesh defines the subMesh to render
  23512. * @param enableAlphaMode defines if alpha mode can be changed
  23513. * @returns the current mesh
  23514. */
  23515. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23516. private _onBeforeDraw;
  23517. /**
  23518. * Renormalize the mesh and patch it up if there are no weights
  23519. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23520. * However in the case of zero weights then we set just a single influence to 1.
  23521. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23522. */
  23523. cleanMatrixWeights(): void;
  23524. private normalizeSkinFourWeights;
  23525. private normalizeSkinWeightsAndExtra;
  23526. /**
  23527. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23528. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23529. * the user know there was an issue with importing the mesh
  23530. * @returns a validation object with skinned, valid and report string
  23531. */
  23532. validateSkinning(): {
  23533. skinned: boolean;
  23534. valid: boolean;
  23535. report: string;
  23536. };
  23537. /** @hidden */ private _checkDelayState(): Mesh;
  23538. private _queueLoad;
  23539. /**
  23540. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23541. * A mesh is in the frustum if its bounding box intersects the frustum
  23542. * @param frustumPlanes defines the frustum to test
  23543. * @returns true if the mesh is in the frustum planes
  23544. */
  23545. isInFrustum(frustumPlanes: Plane[]): boolean;
  23546. /**
  23547. * Sets the mesh material by the material or multiMaterial `id` property
  23548. * @param id is a string identifying the material or the multiMaterial
  23549. * @returns the current mesh
  23550. */
  23551. setMaterialByID(id: string): Mesh;
  23552. /**
  23553. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23554. * @returns an array of IAnimatable
  23555. */
  23556. getAnimatables(): IAnimatable[];
  23557. /**
  23558. * Modifies the mesh geometry according to the passed transformation matrix.
  23559. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23560. * The mesh normals are modified using the same transformation.
  23561. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23562. * @param transform defines the transform matrix to use
  23563. * @see http://doc.babylonjs.com/resources/baking_transformations
  23564. * @returns the current mesh
  23565. */
  23566. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23567. /**
  23568. * Modifies the mesh geometry according to its own current World Matrix.
  23569. * The mesh World Matrix is then reset.
  23570. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23571. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23572. * @see http://doc.babylonjs.com/resources/baking_transformations
  23573. * @returns the current mesh
  23574. */
  23575. bakeCurrentTransformIntoVertices(): Mesh;
  23576. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23577. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23578. /** @hidden */ private _generatePointsArray(): boolean;
  23579. /**
  23580. * Returns a new Mesh object generated from the current mesh properties.
  23581. * This method must not get confused with createInstance()
  23582. * @param name is a string, the name given to the new mesh
  23583. * @param newParent can be any Node object (default `null`)
  23584. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23585. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23586. * @returns a new mesh
  23587. */
  23588. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23589. /**
  23590. * Releases resources associated with this mesh.
  23591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23593. */
  23594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23595. /**
  23596. * Modifies the mesh geometry according to a displacement map.
  23597. * 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.
  23598. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23599. * @param url is a string, the URL from the image file is to be downloaded.
  23600. * @param minHeight is the lower limit of the displacement.
  23601. * @param maxHeight is the upper limit of the displacement.
  23602. * @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.
  23603. * @param uvOffset is an optional vector2 used to offset UV.
  23604. * @param uvScale is an optional vector2 used to scale UV.
  23605. * @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.
  23606. * @returns the Mesh.
  23607. */
  23608. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23609. /**
  23610. * Modifies the mesh geometry according to a displacementMap buffer.
  23611. * 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.
  23612. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23613. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23614. * @param heightMapWidth is the width of the buffer image.
  23615. * @param heightMapHeight is the height of the buffer image.
  23616. * @param minHeight is the lower limit of the displacement.
  23617. * @param maxHeight is the upper limit of the displacement.
  23618. * @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.
  23619. * @param uvOffset is an optional vector2 used to offset UV.
  23620. * @param uvScale is an optional vector2 used to scale UV.
  23621. * @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.
  23622. * @returns the Mesh.
  23623. */
  23624. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23625. /**
  23626. * Modify the mesh to get a flat shading rendering.
  23627. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23628. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23629. * @returns current mesh
  23630. */
  23631. convertToFlatShadedMesh(): Mesh;
  23632. /**
  23633. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23634. * In other words, more vertices, no more indices and a single bigger VBO.
  23635. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23636. * @returns current mesh
  23637. */
  23638. convertToUnIndexedMesh(): Mesh;
  23639. /**
  23640. * Inverses facet orientations.
  23641. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23642. * @param flipNormals will also inverts the normals
  23643. * @returns current mesh
  23644. */
  23645. flipFaces(flipNormals?: boolean): Mesh;
  23646. /**
  23647. * Increase the number of facets and hence vertices in a mesh
  23648. * Vertex normals are interpolated from existing vertex normals
  23649. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23650. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23651. */
  23652. increaseVertices(numberPerEdge: number): void;
  23653. /**
  23654. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23655. * This will undo any application of covertToFlatShadedMesh
  23656. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23657. */
  23658. forceSharedVertices(): void;
  23659. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23660. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23661. /**
  23662. * Creates a new InstancedMesh object from the mesh model.
  23663. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23664. * @param name defines the name of the new instance
  23665. * @returns a new InstancedMesh
  23666. */
  23667. createInstance(name: string): InstancedMesh;
  23668. /**
  23669. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23670. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23671. * @returns the current mesh
  23672. */
  23673. synchronizeInstances(): Mesh;
  23674. /**
  23675. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23676. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23677. * This should be used together with the simplification to avoid disappearing triangles.
  23678. * @param successCallback an optional success callback to be called after the optimization finished.
  23679. * @returns the current mesh
  23680. */
  23681. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23682. /**
  23683. * Serialize current mesh
  23684. * @param serializationObject defines the object which will receive the serialization data
  23685. */
  23686. serialize(serializationObject: any): void;
  23687. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23688. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23689. /**
  23690. * Returns a new Mesh object parsed from the source provided.
  23691. * @param parsedMesh is the source
  23692. * @param scene defines the hosting scene
  23693. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23694. * @returns a new Mesh
  23695. */
  23696. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23697. /**
  23698. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23699. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23700. * @param name defines the name of the mesh to create
  23701. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23702. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23703. * @param closePath creates a seam between the first and the last points of each path of the path array
  23704. * @param offset is taken in account only if the `pathArray` is containing a single path
  23705. * @param scene defines the hosting scene
  23706. * @param updatable defines if the mesh must be flagged as updatable
  23707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23708. * @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)
  23709. * @returns a new Mesh
  23710. */
  23711. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23712. /**
  23713. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23714. * @param name defines the name of the mesh to create
  23715. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23716. * @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
  23717. * @param scene defines the hosting scene
  23718. * @param updatable defines if the mesh must be flagged as updatable
  23719. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23720. * @returns a new Mesh
  23721. */
  23722. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23723. /**
  23724. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23725. * @param name defines the name of the mesh to create
  23726. * @param size sets the size (float) of each box side (default 1)
  23727. * @param scene defines the hosting scene
  23728. * @param updatable defines if the mesh must be flagged as updatable
  23729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23730. * @returns a new Mesh
  23731. */
  23732. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23733. /**
  23734. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23735. * @param name defines the name of the mesh to create
  23736. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23737. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23738. * @param scene defines the hosting scene
  23739. * @param updatable defines if the mesh must be flagged as updatable
  23740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23741. * @returns a new Mesh
  23742. */
  23743. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23744. /**
  23745. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23746. * @param name defines the name of the mesh to create
  23747. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23748. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23749. * @param scene defines the hosting scene
  23750. * @returns a new Mesh
  23751. */
  23752. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23753. /**
  23754. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23755. * @param name defines the name of the mesh to create
  23756. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23757. * @param diameterTop set the top cap diameter (floats, default 1)
  23758. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23759. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23760. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23761. * @param scene defines the hosting scene
  23762. * @param updatable defines if the mesh must be flagged as updatable
  23763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23764. * @returns a new Mesh
  23765. */
  23766. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23767. /**
  23768. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23769. * @param name defines the name of the mesh to create
  23770. * @param diameter sets the diameter size (float) of the torus (default 1)
  23771. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23772. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23773. * @param scene defines the hosting scene
  23774. * @param updatable defines if the mesh must be flagged as updatable
  23775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23776. * @returns a new Mesh
  23777. */
  23778. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23779. /**
  23780. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23781. * @param name defines the name of the mesh to create
  23782. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23783. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23784. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23785. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23786. * @param p the number of windings on X axis (positive integers, default 2)
  23787. * @param q the number of windings on Y axis (positive integers, default 3)
  23788. * @param scene defines the hosting scene
  23789. * @param updatable defines if the mesh must be flagged as updatable
  23790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23791. * @returns a new Mesh
  23792. */
  23793. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23794. /**
  23795. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23796. * @param name defines the name of the mesh to create
  23797. * @param points is an array successive Vector3
  23798. * @param scene defines the hosting scene
  23799. * @param updatable defines if the mesh must be flagged as updatable
  23800. * @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).
  23801. * @returns a new Mesh
  23802. */
  23803. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23804. /**
  23805. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23806. * @param name defines the name of the mesh to create
  23807. * @param points is an array successive Vector3
  23808. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  23809. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23810. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  23811. * @param scene defines the hosting scene
  23812. * @param updatable defines if the mesh must be flagged as updatable
  23813. * @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)
  23814. * @returns a new Mesh
  23815. */
  23816. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23817. /**
  23818. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  23819. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23820. * 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.
  23821. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23822. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23823. * Remember you can only change the shape positions, not their number when updating a polygon.
  23824. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23825. * @param name defines the name of the mesh to create
  23826. * @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
  23827. * @param scene defines the hosting scene
  23828. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23829. * @param updatable defines if the mesh must be flagged as updatable
  23830. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23831. * @param earcutInjection can be used to inject your own earcut reference
  23832. * @returns a new Mesh
  23833. */
  23834. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23835. /**
  23836. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  23837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  23838. * @param name defines the name of the mesh to create
  23839. * @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
  23840. * @param depth defines the height of extrusion
  23841. * @param scene defines the hosting scene
  23842. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23843. * @param updatable defines if the mesh must be flagged as updatable
  23844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23845. * @param earcutInjection can be used to inject your own earcut reference
  23846. * @returns a new Mesh
  23847. */
  23848. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23849. /**
  23850. * Creates an extruded shape mesh.
  23851. * 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
  23852. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23853. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23854. * @param name defines the name of the mesh to create
  23855. * @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
  23856. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23857. * @param scale is the value to scale the shape
  23858. * @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
  23859. * @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
  23860. * @param scene defines the hosting scene
  23861. * @param updatable defines if the mesh must be flagged as updatable
  23862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23863. * @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)
  23864. * @returns a new Mesh
  23865. */
  23866. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23867. /**
  23868. * Creates an custom extruded shape mesh.
  23869. * The custom extrusion is a parametric shape.
  23870. * It has no predefined shape. Its final shape will depend on the input parameters.
  23871. * Please consider using the same method from the MeshBuilder class instead
  23872. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23873. * @param name defines the name of the mesh to create
  23874. * @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
  23875. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23876. * @param scaleFunction is a custom Javascript function called on each path point
  23877. * @param rotationFunction is a custom Javascript function called on each path point
  23878. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23879. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  23880. * @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
  23881. * @param scene defines the hosting scene
  23882. * @param updatable defines if the mesh must be flagged as updatable
  23883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23884. * @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)
  23885. * @returns a new Mesh
  23886. */
  23887. 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;
  23888. /**
  23889. * Creates lathe mesh.
  23890. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23891. * Please consider using the same method from the MeshBuilder class instead
  23892. * @param name defines the name of the mesh to create
  23893. * @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
  23894. * @param radius is the radius value of the lathe
  23895. * @param tessellation is the side number of the lathe.
  23896. * @param scene defines the hosting scene
  23897. * @param updatable defines if the mesh must be flagged as updatable
  23898. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23899. * @returns a new Mesh
  23900. */
  23901. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23902. /**
  23903. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  23904. * @param name defines the name of the mesh to create
  23905. * @param size sets the size (float) of both sides of the plane at once (default 1)
  23906. * @param scene defines the hosting scene
  23907. * @param updatable defines if the mesh must be flagged as updatable
  23908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23909. * @returns a new Mesh
  23910. */
  23911. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23912. /**
  23913. * Creates a ground mesh.
  23914. * Please consider using the same method from the MeshBuilder class instead
  23915. * @param name defines the name of the mesh to create
  23916. * @param width set the width of the ground
  23917. * @param height set the height of the ground
  23918. * @param subdivisions sets the number of subdivisions per side
  23919. * @param scene defines the hosting scene
  23920. * @param updatable defines if the mesh must be flagged as updatable
  23921. * @returns a new Mesh
  23922. */
  23923. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  23924. /**
  23925. * Creates a tiled ground mesh.
  23926. * Please consider using the same method from the MeshBuilder class instead
  23927. * @param name defines the name of the mesh to create
  23928. * @param xmin set the ground minimum X coordinate
  23929. * @param zmin set the ground minimum Y coordinate
  23930. * @param xmax set the ground maximum X coordinate
  23931. * @param zmax set the ground maximum Z coordinate
  23932. * @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
  23933. * @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
  23934. * @param scene defines the hosting scene
  23935. * @param updatable defines if the mesh must be flagged as updatable
  23936. * @returns a new Mesh
  23937. */
  23938. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  23939. w: number;
  23940. h: number;
  23941. }, precision: {
  23942. w: number;
  23943. h: number;
  23944. }, scene: Scene, updatable?: boolean): Mesh;
  23945. /**
  23946. * Creates a ground mesh from a height map.
  23947. * Please consider using the same method from the MeshBuilder class instead
  23948. * @see http://doc.babylonjs.com/babylon101/height_map
  23949. * @param name defines the name of the mesh to create
  23950. * @param url sets the URL of the height map image resource
  23951. * @param width set the ground width size
  23952. * @param height set the ground height size
  23953. * @param subdivisions sets the number of subdivision per side
  23954. * @param minHeight is the minimum altitude on the ground
  23955. * @param maxHeight is the maximum altitude on the ground
  23956. * @param scene defines the hosting scene
  23957. * @param updatable defines if the mesh must be flagged as updatable
  23958. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  23959. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23960. * @returns a new Mesh
  23961. */
  23962. 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;
  23963. /**
  23964. * Creates a tube mesh.
  23965. * The tube is a parametric shape.
  23966. * It has no predefined shape. Its final shape will depend on the input parameters.
  23967. * Please consider using the same method from the MeshBuilder class instead
  23968. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23969. * @param name defines the name of the mesh to create
  23970. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  23971. * @param radius sets the tube radius size
  23972. * @param tessellation is the number of sides on the tubular surface
  23973. * @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
  23974. * @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
  23975. * @param scene defines the hosting scene
  23976. * @param updatable defines if the mesh must be flagged as updatable
  23977. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23978. * @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)
  23979. * @returns a new Mesh
  23980. */
  23981. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  23982. (i: number, distance: number): number;
  23983. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23984. /**
  23985. * Creates a polyhedron mesh.
  23986. * Please consider using the same method from the MeshBuilder class instead.
  23987. * * 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
  23988. * * The parameter `size` (positive float, default 1) sets the polygon size
  23989. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23990. * * 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`
  23991. * * 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
  23992. * * 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)`)
  23993. * * 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
  23994. * * 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
  23995. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23996. * * 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
  23997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23998. * @param name defines the name of the mesh to create
  23999. * @param options defines the options used to create the mesh
  24000. * @param scene defines the hosting scene
  24001. * @returns a new Mesh
  24002. */
  24003. static CreatePolyhedron(name: string, options: {
  24004. type?: number;
  24005. size?: number;
  24006. sizeX?: number;
  24007. sizeY?: number;
  24008. sizeZ?: number;
  24009. custom?: any;
  24010. faceUV?: Vector4[];
  24011. faceColors?: Color4[];
  24012. updatable?: boolean;
  24013. sideOrientation?: number;
  24014. }, scene: Scene): Mesh;
  24015. /**
  24016. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24017. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24018. * * 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`)
  24019. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24020. * * 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
  24021. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24022. * * 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
  24023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24024. * @param name defines the name of the mesh
  24025. * @param options defines the options used to create the mesh
  24026. * @param scene defines the hosting scene
  24027. * @returns a new Mesh
  24028. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24029. */
  24030. static CreateIcoSphere(name: string, options: {
  24031. radius?: number;
  24032. flat?: boolean;
  24033. subdivisions?: number;
  24034. sideOrientation?: number;
  24035. updatable?: boolean;
  24036. }, scene: Scene): Mesh;
  24037. /**
  24038. * Creates a decal mesh.
  24039. * Please consider using the same method from the MeshBuilder class instead.
  24040. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24041. * @param name defines the name of the mesh
  24042. * @param sourceMesh defines the mesh receiving the decal
  24043. * @param position sets the position of the decal in world coordinates
  24044. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24045. * @param size sets the decal scaling
  24046. * @param angle sets the angle to rotate the decal
  24047. * @returns a new Mesh
  24048. */
  24049. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24050. /**
  24051. * Prepare internal position array for software CPU skinning
  24052. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24053. */
  24054. setPositionsForCPUSkinning(): Float32Array;
  24055. /**
  24056. * Prepare internal normal array for software CPU skinning
  24057. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24058. */
  24059. setNormalsForCPUSkinning(): Float32Array;
  24060. /**
  24061. * Updates the vertex buffer by applying transformation from the bones
  24062. * @param skeleton defines the skeleton to apply to current mesh
  24063. * @returns the current mesh
  24064. */
  24065. applySkeleton(skeleton: Skeleton): Mesh;
  24066. /**
  24067. * 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
  24068. * @param meshes defines the list of meshes to scan
  24069. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24070. */
  24071. static MinMax(meshes: AbstractMesh[]): {
  24072. min: Vector3;
  24073. max: Vector3;
  24074. };
  24075. /**
  24076. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24077. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24078. * @returns a vector3
  24079. */
  24080. static Center(meshesOrMinMaxVector: {
  24081. min: Vector3;
  24082. max: Vector3;
  24083. } | AbstractMesh[]): Vector3;
  24084. /**
  24085. * Merge the array of meshes into a single mesh for performance reasons.
  24086. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24087. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24088. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24089. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24090. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24091. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24092. * @returns a new mesh
  24093. */
  24094. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24095. /** @hidden */
  24096. addInstance(instance: InstancedMesh): void;
  24097. /** @hidden */
  24098. removeInstance(instance: InstancedMesh): void;
  24099. }
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * This is the base class of all the camera used in the application.
  24104. * @see http://doc.babylonjs.com/features/cameras
  24105. */
  24106. export class Camera extends Node {
  24107. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24108. /**
  24109. * This is the default projection mode used by the cameras.
  24110. * It helps recreating a feeling of perspective and better appreciate depth.
  24111. * This is the best way to simulate real life cameras.
  24112. */
  24113. static readonly PERSPECTIVE_CAMERA: number;
  24114. /**
  24115. * This helps creating camera with an orthographic mode.
  24116. * 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.
  24117. */
  24118. static readonly ORTHOGRAPHIC_CAMERA: number;
  24119. /**
  24120. * This is the default FOV mode for perspective cameras.
  24121. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24122. */
  24123. static readonly FOVMODE_VERTICAL_FIXED: number;
  24124. /**
  24125. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24126. */
  24127. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24128. /**
  24129. * This specifies ther is no need for a camera rig.
  24130. * Basically only one eye is rendered corresponding to the camera.
  24131. */
  24132. static readonly RIG_MODE_NONE: number;
  24133. /**
  24134. * Simulates a camera Rig with one blue eye and one red eye.
  24135. * This can be use with 3d blue and red glasses.
  24136. */
  24137. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24138. /**
  24139. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24140. */
  24141. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24142. /**
  24143. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24144. */
  24145. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24146. /**
  24147. * Defines that both eyes of the camera will be rendered over under each other.
  24148. */
  24149. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24150. /**
  24151. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24152. */
  24153. static readonly RIG_MODE_VR: number;
  24154. /**
  24155. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24156. */
  24157. static readonly RIG_MODE_WEBVR: number;
  24158. /**
  24159. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24160. */
  24161. static readonly RIG_MODE_CUSTOM: number;
  24162. /**
  24163. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24164. */
  24165. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24166. /**
  24167. * Define the input manager associated with the camera.
  24168. */
  24169. inputs: CameraInputsManager<Camera>;
  24170. /** @hidden */ private _position: Vector3;
  24171. /**
  24172. * Define the current local position of the camera in the scene
  24173. */
  24174. position: Vector3;
  24175. /**
  24176. * The vector the camera should consider as up.
  24177. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24178. */
  24179. upVector: Vector3;
  24180. /**
  24181. * Define the current limit on the left side for an orthographic camera
  24182. * In scene unit
  24183. */
  24184. orthoLeft: Nullable<number>;
  24185. /**
  24186. * Define the current limit on the right side for an orthographic camera
  24187. * In scene unit
  24188. */
  24189. orthoRight: Nullable<number>;
  24190. /**
  24191. * Define the current limit on the bottom side for an orthographic camera
  24192. * In scene unit
  24193. */
  24194. orthoBottom: Nullable<number>;
  24195. /**
  24196. * Define the current limit on the top side for an orthographic camera
  24197. * In scene unit
  24198. */
  24199. orthoTop: Nullable<number>;
  24200. /**
  24201. * Field Of View is set in Radians. (default is 0.8)
  24202. */
  24203. fov: number;
  24204. /**
  24205. * Define the minimum distance the camera can see from.
  24206. * This is important to note that the depth buffer are not infinite and the closer it starts
  24207. * the more your scene might encounter depth fighting issue.
  24208. */
  24209. minZ: number;
  24210. /**
  24211. * Define the maximum distance the camera can see to.
  24212. * This is important to note that the depth buffer are not infinite and the further it end
  24213. * the more your scene might encounter depth fighting issue.
  24214. */
  24215. maxZ: number;
  24216. /**
  24217. * Define the default inertia of the camera.
  24218. * This helps giving a smooth feeling to the camera movement.
  24219. */
  24220. inertia: number;
  24221. /**
  24222. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24223. */
  24224. mode: number;
  24225. /**
  24226. * Define wether the camera is intermediate.
  24227. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24228. */
  24229. isIntermediate: boolean;
  24230. /**
  24231. * Define the viewport of the camera.
  24232. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24233. */
  24234. viewport: Viewport;
  24235. /**
  24236. * Restricts the camera to viewing objects with the same layerMask.
  24237. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24238. */
  24239. layerMask: number;
  24240. /**
  24241. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24242. */
  24243. fovMode: number;
  24244. /**
  24245. * Rig mode of the camera.
  24246. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24247. * This is normally controlled byt the camera themselves as internal use.
  24248. */
  24249. cameraRigMode: number;
  24250. /**
  24251. * Defines the distance between both "eyes" in case of a RIG
  24252. */
  24253. interaxialDistance: number;
  24254. /**
  24255. * Defines if stereoscopic rendering is done side by side or over under.
  24256. */
  24257. isStereoscopicSideBySide: boolean;
  24258. /**
  24259. * 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
  24260. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24261. * else in the scene. (Eg. security camera)
  24262. *
  24263. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24264. */
  24265. customRenderTargets: RenderTargetTexture[];
  24266. /**
  24267. * When set, the camera will render to this render target instead of the default canvas
  24268. *
  24269. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24270. */
  24271. outputRenderTarget: Nullable<RenderTargetTexture>;
  24272. /**
  24273. * Observable triggered when the camera view matrix has changed.
  24274. */
  24275. onViewMatrixChangedObservable: Observable<Camera>;
  24276. /**
  24277. * Observable triggered when the camera Projection matrix has changed.
  24278. */
  24279. onProjectionMatrixChangedObservable: Observable<Camera>;
  24280. /**
  24281. * Observable triggered when the inputs have been processed.
  24282. */
  24283. onAfterCheckInputsObservable: Observable<Camera>;
  24284. /**
  24285. * Observable triggered when reset has been called and applied to the camera.
  24286. */
  24287. onRestoreStateObservable: Observable<Camera>;
  24288. /** @hidden */ private _cameraRigParams: any;
  24289. /** @hidden */ private _rigCameras: Camera[];
  24290. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24291. protected _webvrViewMatrix: Matrix;
  24292. /** @hidden */ private _skipRendering: boolean;
  24293. /** @hidden */ private _projectionMatrix: Matrix;
  24294. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24295. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24296. protected _globalPosition: Vector3;
  24297. /** @hidden */ private _computedViewMatrix: Matrix;
  24298. private _doNotComputeProjectionMatrix;
  24299. private _transformMatrix;
  24300. private _frustumPlanes;
  24301. private _refreshFrustumPlanes;
  24302. private _storedFov;
  24303. private _stateStored;
  24304. /**
  24305. * Instantiates a new camera object.
  24306. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24307. * @see http://doc.babylonjs.com/features/cameras
  24308. * @param name Defines the name of the camera in the scene
  24309. * @param position Defines the position of the camera
  24310. * @param scene Defines the scene the camera belongs too
  24311. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24312. */
  24313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24314. /**
  24315. * Store current camera state (fov, position, etc..)
  24316. * @returns the camera
  24317. */
  24318. storeState(): Camera;
  24319. /**
  24320. * Restores the camera state values if it has been stored. You must call storeState() first
  24321. */
  24322. protected _restoreStateValues(): boolean;
  24323. /**
  24324. * Restored camera state. You must call storeState() first.
  24325. * @returns true if restored and false otherwise
  24326. */
  24327. restoreState(): boolean;
  24328. /**
  24329. * Gets the class name of the camera.
  24330. * @returns the class name
  24331. */
  24332. getClassName(): string;
  24333. /** @hidden */ protected readonly _isCamera: boolean;
  24334. /**
  24335. * Gets a string representation of the camera useful for debug purpose.
  24336. * @param fullDetails Defines that a more verboe level of logging is required
  24337. * @returns the string representation
  24338. */
  24339. toString(fullDetails?: boolean): string;
  24340. /**
  24341. * Gets the current world space position of the camera.
  24342. */
  24343. readonly globalPosition: Vector3;
  24344. /**
  24345. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24346. * @returns the active meshe list
  24347. */
  24348. getActiveMeshes(): SmartArray<AbstractMesh>;
  24349. /**
  24350. * Check wether a mesh is part of the current active mesh list of the camera
  24351. * @param mesh Defines the mesh to check
  24352. * @returns true if active, false otherwise
  24353. */
  24354. isActiveMesh(mesh: Mesh): boolean;
  24355. /**
  24356. * Is this camera ready to be used/rendered
  24357. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24358. * @return true if the camera is ready
  24359. */
  24360. isReady(completeCheck?: boolean): boolean;
  24361. /** @hidden */ private _initCache(): void;
  24362. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24363. /** @hidden */ private _isSynchronized(): boolean;
  24364. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24365. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24366. /**
  24367. * Attach the input controls to a specific dom element to get the input from.
  24368. * @param element Defines the element the controls should be listened from
  24369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24370. */
  24371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24372. /**
  24373. * Detach the current controls from the specified dom element.
  24374. * @param element Defines the element to stop listening the inputs from
  24375. */
  24376. detachControl(element: HTMLElement): void;
  24377. /**
  24378. * Update the camera state according to the different inputs gathered during the frame.
  24379. */
  24380. update(): void;
  24381. /** @hidden */ private _checkInputs(): void;
  24382. /** @hidden */
  24383. readonly rigCameras: Camera[];
  24384. /**
  24385. * Gets the post process used by the rig cameras
  24386. */
  24387. readonly rigPostProcess: Nullable<PostProcess>;
  24388. /**
  24389. * Internal, gets the first post proces.
  24390. * @returns the first post process to be run on this camera.
  24391. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24392. private _cascadePostProcessesToRigCams;
  24393. /**
  24394. * Attach a post process to the camera.
  24395. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24396. * @param postProcess The post process to attach to the camera
  24397. * @param insertAt The position of the post process in case several of them are in use in the scene
  24398. * @returns the position the post process has been inserted at
  24399. */
  24400. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24401. /**
  24402. * Detach a post process to the camera.
  24403. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24404. * @param postProcess The post process to detach from the camera
  24405. */
  24406. detachPostProcess(postProcess: PostProcess): void;
  24407. /**
  24408. * Gets the current world matrix of the camera
  24409. */
  24410. getWorldMatrix(): Matrix;
  24411. /** @hidden */ private _getViewMatrix(): Matrix;
  24412. /**
  24413. * Gets the current view matrix of the camera.
  24414. * @param force forces the camera to recompute the matrix without looking at the cached state
  24415. * @returns the view matrix
  24416. */
  24417. getViewMatrix(force?: boolean): Matrix;
  24418. /**
  24419. * Freeze the projection matrix.
  24420. * It will prevent the cache check of the camera projection compute and can speed up perf
  24421. * if no parameter of the camera are meant to change
  24422. * @param projection Defines manually a projection if necessary
  24423. */
  24424. freezeProjectionMatrix(projection?: Matrix): void;
  24425. /**
  24426. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24427. */
  24428. unfreezeProjectionMatrix(): void;
  24429. /**
  24430. * Gets the current projection matrix of the camera.
  24431. * @param force forces the camera to recompute the matrix without looking at the cached state
  24432. * @returns the projection matrix
  24433. */
  24434. getProjectionMatrix(force?: boolean): Matrix;
  24435. /**
  24436. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24437. * @returns a Matrix
  24438. */
  24439. getTransformationMatrix(): Matrix;
  24440. private _updateFrustumPlanes;
  24441. /**
  24442. * Checks if a cullable object (mesh...) is in the camera frustum
  24443. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24444. * @param target The object to check
  24445. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24446. * @returns true if the object is in frustum otherwise false
  24447. */
  24448. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24449. /**
  24450. * Checks if a cullable object (mesh...) is in the camera frustum
  24451. * Unlike isInFrustum this cheks the full bounding box
  24452. * @param target The object to check
  24453. * @returns true if the object is in frustum otherwise false
  24454. */
  24455. isCompletelyInFrustum(target: ICullable): boolean;
  24456. /**
  24457. * Gets a ray in the forward direction from the camera.
  24458. * @param length Defines the length of the ray to create
  24459. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24460. * @param origin Defines the start point of the ray which defaults to the camera position
  24461. * @returns the forward ray
  24462. */
  24463. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24464. /**
  24465. * Releases resources associated with this node.
  24466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24468. */
  24469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24470. /** @hidden */ private _isLeftCamera: boolean;
  24471. /**
  24472. * Gets the left camera of a rig setup in case of Rigged Camera
  24473. */
  24474. readonly isLeftCamera: boolean;
  24475. /** @hidden */ private _isRightCamera: boolean;
  24476. /**
  24477. * Gets the right camera of a rig setup in case of Rigged Camera
  24478. */
  24479. readonly isRightCamera: boolean;
  24480. /**
  24481. * Gets the left camera of a rig setup in case of Rigged Camera
  24482. */
  24483. readonly leftCamera: Nullable<FreeCamera>;
  24484. /**
  24485. * Gets the right camera of a rig setup in case of Rigged Camera
  24486. */
  24487. readonly rightCamera: Nullable<FreeCamera>;
  24488. /**
  24489. * Gets the left camera target of a rig setup in case of Rigged Camera
  24490. * @returns the target position
  24491. */
  24492. getLeftTarget(): Nullable<Vector3>;
  24493. /**
  24494. * Gets the right camera target of a rig setup in case of Rigged Camera
  24495. * @returns the target position
  24496. */
  24497. getRightTarget(): Nullable<Vector3>;
  24498. /**
  24499. * @hidden
  24500. */
  24501. setCameraRigMode(mode: number, rigParams: any): void;
  24502. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24503. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24504. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24505. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24506. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24507. protected _updateCameraRotationMatrix(): void;
  24508. protected _updateWebVRCameraRotationMatrix(): void;
  24509. /**
  24510. * This function MUST be overwritten by the different WebVR cameras available.
  24511. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24512. * @hidden
  24513. */ private _getWebVRProjectionMatrix(): Matrix;
  24514. /**
  24515. * This function MUST be overwritten by the different WebVR cameras available.
  24516. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24517. * @hidden
  24518. */ private _getWebVRViewMatrix(): Matrix;
  24519. /** @hidden */
  24520. setCameraRigParameter(name: string, value: any): void;
  24521. /**
  24522. * needs to be overridden by children so sub has required properties to be copied
  24523. * @hidden
  24524. */
  24525. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24526. /**
  24527. * May need to be overridden by children
  24528. * @hidden
  24529. */ private _updateRigCameras(): void;
  24530. /** @hidden */ private _setupInputs(): void;
  24531. /**
  24532. * Serialiaze the camera setup to a json represention
  24533. * @returns the JSON representation
  24534. */
  24535. serialize(): any;
  24536. /**
  24537. * Clones the current camera.
  24538. * @param name The cloned camera name
  24539. * @returns the cloned camera
  24540. */
  24541. clone(name: string): Camera;
  24542. /**
  24543. * Gets the direction of the camera relative to a given local axis.
  24544. * @param localAxis Defines the reference axis to provide a relative direction.
  24545. * @return the direction
  24546. */
  24547. getDirection(localAxis: Vector3): Vector3;
  24548. /**
  24549. * Returns the current camera absolute rotation
  24550. */
  24551. readonly absoluteRotation: Quaternion;
  24552. /**
  24553. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24554. * @param localAxis Defines the reference axis to provide a relative direction.
  24555. * @param result Defines the vector to store the result in
  24556. */
  24557. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24558. /**
  24559. * Gets a camera constructor for a given camera type
  24560. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24561. * @param name The name of the camera the result will be able to instantiate
  24562. * @param scene The scene the result will construct the camera in
  24563. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24564. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24565. * @returns a factory method to construc the camera
  24566. */
  24567. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24568. /**
  24569. * Compute the world matrix of the camera.
  24570. * @returns the camera workd matrix
  24571. */
  24572. computeWorldMatrix(): Matrix;
  24573. /**
  24574. * Parse a JSON and creates the camera from the parsed information
  24575. * @param parsedCamera The JSON to parse
  24576. * @param scene The scene to instantiate the camera in
  24577. * @returns the newly constructed camera
  24578. */
  24579. static Parse(parsedCamera: any, scene: Scene): Camera;
  24580. }
  24581. }
  24582. declare module BABYLON {
  24583. /**
  24584. * Class containing static functions to help procedurally build meshes
  24585. */
  24586. export class DiscBuilder {
  24587. /**
  24588. * Creates a plane polygonal mesh. By default, this is a disc
  24589. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24590. * * 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
  24591. * * 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
  24592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24593. * * 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
  24594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24595. * @param name defines the name of the mesh
  24596. * @param options defines the options used to create the mesh
  24597. * @param scene defines the hosting scene
  24598. * @returns the plane polygonal mesh
  24599. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24600. */
  24601. static CreateDisc(name: string, options: {
  24602. radius?: number;
  24603. tessellation?: number;
  24604. arc?: number;
  24605. updatable?: boolean;
  24606. sideOrientation?: number;
  24607. frontUVs?: Vector4;
  24608. backUVs?: Vector4;
  24609. }, scene?: Nullable<Scene>): Mesh;
  24610. }
  24611. }
  24612. declare module BABYLON {
  24613. /**
  24614. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24615. *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.
  24616. * The SPS is also a particle system. It provides some methods to manage the particles.
  24617. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24618. *
  24619. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24620. */
  24621. export class SolidParticleSystem implements IDisposable {
  24622. /**
  24623. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24624. * Example : var p = SPS.particles[i];
  24625. */
  24626. particles: SolidParticle[];
  24627. /**
  24628. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24629. */
  24630. nbParticles: number;
  24631. /**
  24632. * If the particles must ever face the camera (default false). Useful for planar particles.
  24633. */
  24634. billboard: boolean;
  24635. /**
  24636. * Recompute normals when adding a shape
  24637. */
  24638. recomputeNormals: boolean;
  24639. /**
  24640. * This a counter ofr your own usage. It's not set by any SPS functions.
  24641. */
  24642. counter: number;
  24643. /**
  24644. * The SPS name. This name is also given to the underlying mesh.
  24645. */
  24646. name: string;
  24647. /**
  24648. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24649. */
  24650. mesh: Mesh;
  24651. /**
  24652. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24653. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24654. */
  24655. vars: any;
  24656. /**
  24657. * This array is populated when the SPS is set as 'pickable'.
  24658. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24659. * Each element of this array is an object `{idx: int, faceId: int}`.
  24660. * `idx` is the picked particle index in the `SPS.particles` array
  24661. * `faceId` is the picked face index counted within this particle.
  24662. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24663. */
  24664. pickedParticles: {
  24665. idx: number;
  24666. faceId: number;
  24667. }[];
  24668. /**
  24669. * This array is populated when `enableDepthSort` is set to true.
  24670. * Each element of this array is an instance of the class DepthSortedParticle.
  24671. */
  24672. depthSortedParticles: DepthSortedParticle[];
  24673. /**
  24674. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24675. * @hidden
  24676. */ private _bSphereOnly: boolean;
  24677. /**
  24678. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24679. * @hidden
  24680. */ private _bSphereRadiusFactor: number;
  24681. private _scene;
  24682. private _positions;
  24683. private _indices;
  24684. private _normals;
  24685. private _colors;
  24686. private _uvs;
  24687. private _indices32;
  24688. private _positions32;
  24689. private _normals32;
  24690. private _fixedNormal32;
  24691. private _colors32;
  24692. private _uvs32;
  24693. private _index;
  24694. private _updatable;
  24695. private _pickable;
  24696. private _isVisibilityBoxLocked;
  24697. private _alwaysVisible;
  24698. private _depthSort;
  24699. private _shapeCounter;
  24700. private _copy;
  24701. private _color;
  24702. private _computeParticleColor;
  24703. private _computeParticleTexture;
  24704. private _computeParticleRotation;
  24705. private _computeParticleVertex;
  24706. private _computeBoundingBox;
  24707. private _depthSortParticles;
  24708. private _camera;
  24709. private _mustUnrotateFixedNormals;
  24710. private _particlesIntersect;
  24711. private _needs32Bits;
  24712. /**
  24713. * Creates a SPS (Solid Particle System) object.
  24714. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24715. * @param scene (Scene) is the scene in which the SPS is added.
  24716. * @param options defines the options of the sps e.g.
  24717. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24718. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24719. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24720. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24721. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24722. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24723. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24724. */
  24725. constructor(name: string, scene: Scene, options?: {
  24726. updatable?: boolean;
  24727. isPickable?: boolean;
  24728. enableDepthSort?: boolean;
  24729. particleIntersection?: boolean;
  24730. boundingSphereOnly?: boolean;
  24731. bSphereRadiusFactor?: number;
  24732. });
  24733. /**
  24734. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24735. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24736. * @returns the created mesh
  24737. */
  24738. buildMesh(): Mesh;
  24739. /**
  24740. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24741. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24742. * Thus the particles generated from `digest()` have their property `position` set yet.
  24743. * @param mesh ( Mesh ) is the mesh to be digested
  24744. * @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
  24745. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24746. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24747. * @returns the current SPS
  24748. */
  24749. digest(mesh: Mesh, options?: {
  24750. facetNb?: number;
  24751. number?: number;
  24752. delta?: number;
  24753. }): SolidParticleSystem;
  24754. private _unrotateFixedNormals;
  24755. private _resetCopy;
  24756. private _meshBuilder;
  24757. private _posToShape;
  24758. private _uvsToShapeUV;
  24759. private _addParticle;
  24760. /**
  24761. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24762. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24763. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24764. * @param nb (positive integer) the number of particles to be created from this model
  24765. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24766. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24767. * @returns the number of shapes in the system
  24768. */
  24769. addShape(mesh: Mesh, nb: number, options?: {
  24770. positionFunction?: any;
  24771. vertexFunction?: any;
  24772. }): number;
  24773. private _rebuildParticle;
  24774. /**
  24775. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24776. * @returns the SPS.
  24777. */
  24778. rebuildMesh(): SolidParticleSystem;
  24779. /**
  24780. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24781. * This method calls `updateParticle()` for each particle of the SPS.
  24782. * For an animated SPS, it is usually called within the render loop.
  24783. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24784. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24785. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24786. * @returns the SPS.
  24787. */
  24788. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24789. /**
  24790. * Disposes the SPS.
  24791. */
  24792. dispose(): void;
  24793. /**
  24794. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24795. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24796. * @returns the SPS.
  24797. */
  24798. refreshVisibleSize(): SolidParticleSystem;
  24799. /**
  24800. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24801. * @param size the size (float) of the visibility box
  24802. * note : this doesn't lock the SPS mesh bounding box.
  24803. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24804. */
  24805. setVisibilityBox(size: number): void;
  24806. /**
  24807. * Gets whether the SPS as always visible or not
  24808. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24809. */
  24810. /**
  24811. * Sets the SPS as always visible or not
  24812. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24813. */
  24814. isAlwaysVisible: boolean;
  24815. /**
  24816. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24818. */
  24819. /**
  24820. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24821. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24822. */
  24823. isVisibilityBoxLocked: boolean;
  24824. /**
  24825. * Tells to `setParticles()` to compute the particle rotations or not.
  24826. * Default value : true. The SPS is faster when it's set to false.
  24827. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24828. */
  24829. /**
  24830. * Gets if `setParticles()` computes the particle rotations or not.
  24831. * Default value : true. The SPS is faster when it's set to false.
  24832. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24833. */
  24834. computeParticleRotation: boolean;
  24835. /**
  24836. * Tells to `setParticles()` to compute the particle colors or not.
  24837. * Default value : true. The SPS is faster when it's set to false.
  24838. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24839. */
  24840. /**
  24841. * Gets if `setParticles()` computes the particle colors or not.
  24842. * Default value : true. The SPS is faster when it's set to false.
  24843. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24844. */
  24845. computeParticleColor: boolean;
  24846. /**
  24847. * Gets if `setParticles()` computes the particle textures or not.
  24848. * Default value : true. The SPS is faster when it's set to false.
  24849. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24850. */
  24851. computeParticleTexture: boolean;
  24852. /**
  24853. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24854. * Default value : false. The SPS is faster when it's set to false.
  24855. * Note : the particle custom vertex positions aren't stored values.
  24856. */
  24857. /**
  24858. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24859. * Default value : false. The SPS is faster when it's set to false.
  24860. * Note : the particle custom vertex positions aren't stored values.
  24861. */
  24862. computeParticleVertex: boolean;
  24863. /**
  24864. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24865. */
  24866. /**
  24867. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24868. */
  24869. computeBoundingBox: boolean;
  24870. /**
  24871. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24872. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24873. * Default : `true`
  24874. */
  24875. /**
  24876. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24877. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24878. * Default : `true`
  24879. */
  24880. depthSortParticles: boolean;
  24881. /**
  24882. * This function does nothing. It may be overwritten to set all the particle first values.
  24883. * The SPS doesn't call this function, you may have to call it by your own.
  24884. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24885. */
  24886. initParticles(): void;
  24887. /**
  24888. * This function does nothing. It may be overwritten to recycle a particle.
  24889. * The SPS doesn't call this function, you may have to call it by your own.
  24890. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24891. * @param particle The particle to recycle
  24892. * @returns the recycled particle
  24893. */
  24894. recycleParticle(particle: SolidParticle): SolidParticle;
  24895. /**
  24896. * Updates a particle : this function should be overwritten by the user.
  24897. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24898. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24899. * @example : just set a particle position or velocity and recycle conditions
  24900. * @param particle The particle to update
  24901. * @returns the updated particle
  24902. */
  24903. updateParticle(particle: SolidParticle): SolidParticle;
  24904. /**
  24905. * Updates a vertex of a particle : it can be overwritten by the user.
  24906. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24907. * @param particle the current particle
  24908. * @param vertex the current index of the current particle
  24909. * @param pt the index of the current vertex in the particle shape
  24910. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  24911. * @example : just set a vertex particle position
  24912. * @returns the updated vertex
  24913. */
  24914. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24915. /**
  24916. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24917. * This does nothing and may be overwritten by the user.
  24918. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24919. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24920. * @param update the boolean update value actually passed to setParticles()
  24921. */
  24922. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24923. /**
  24924. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24925. * This will be passed three parameters.
  24926. * This does nothing and may be overwritten by the user.
  24927. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24928. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24929. * @param update the boolean update value actually passed to setParticles()
  24930. */
  24931. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24932. }
  24933. }
  24934. declare module BABYLON {
  24935. /**
  24936. * Represents one particle of a solid particle system.
  24937. */
  24938. export class SolidParticle {
  24939. /**
  24940. * particle global index
  24941. */
  24942. idx: number;
  24943. /**
  24944. * The color of the particle
  24945. */
  24946. color: Nullable<Color4>;
  24947. /**
  24948. * The world space position of the particle.
  24949. */
  24950. position: Vector3;
  24951. /**
  24952. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24953. */
  24954. rotation: Vector3;
  24955. /**
  24956. * The world space rotation quaternion of the particle.
  24957. */
  24958. rotationQuaternion: Nullable<Quaternion>;
  24959. /**
  24960. * The scaling of the particle.
  24961. */
  24962. scaling: Vector3;
  24963. /**
  24964. * The uvs of the particle.
  24965. */
  24966. uvs: Vector4;
  24967. /**
  24968. * The current speed of the particle.
  24969. */
  24970. velocity: Vector3;
  24971. /**
  24972. * The pivot point in the particle local space.
  24973. */
  24974. pivot: Vector3;
  24975. /**
  24976. * Must the particle be translated from its pivot point in its local space ?
  24977. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24978. * Default : false
  24979. */
  24980. translateFromPivot: boolean;
  24981. /**
  24982. * Is the particle active or not ?
  24983. */
  24984. alive: boolean;
  24985. /**
  24986. * Is the particle visible or not ?
  24987. */
  24988. isVisible: boolean;
  24989. /**
  24990. * Index of this particle in the global "positions" array (Internal use)
  24991. * @hidden
  24992. */ private _pos: number;
  24993. /**
  24994. * @hidden Index of this particle in the global "indices" array (Internal use)
  24995. */ private _ind: number;
  24996. /**
  24997. * @hidden ModelShape of this particle (Internal use)
  24998. */ private _model: ModelShape;
  24999. /**
  25000. * ModelShape id of this particle
  25001. */
  25002. shapeId: number;
  25003. /**
  25004. * Index of the particle in its shape id
  25005. */
  25006. idxInShape: number;
  25007. /**
  25008. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25009. */ private _modelBoundingInfo: BoundingInfo;
  25010. /**
  25011. * @hidden Particle BoundingInfo object (Internal use)
  25012. */ private _boundingInfo: BoundingInfo;
  25013. /**
  25014. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25015. */ private _sps: SolidParticleSystem;
  25016. /**
  25017. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25018. */ private _stillInvisible: boolean;
  25019. /**
  25020. * @hidden Last computed particle rotation matrix
  25021. */ private _rotationMatrix: number[];
  25022. /**
  25023. * Parent particle Id, if any.
  25024. * Default null.
  25025. */
  25026. parentId: Nullable<number>;
  25027. /**
  25028. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25029. * The possible values are :
  25030. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25031. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25033. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25034. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25035. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25036. * */
  25037. cullingStrategy: number;
  25038. /**
  25039. * @hidden Internal global position in the SPS.
  25040. */ private _globalPosition: Vector3;
  25041. /**
  25042. * Creates a Solid Particle object.
  25043. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25044. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25045. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25046. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25047. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25048. * @param shapeId (integer) is the model shape identifier in the SPS.
  25049. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25050. * @param sps defines the sps it is associated to
  25051. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25052. */
  25053. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25054. /**
  25055. * Legacy support, changed scale to scaling
  25056. */
  25057. /**
  25058. * Legacy support, changed scale to scaling
  25059. */
  25060. scale: Vector3;
  25061. /**
  25062. * Legacy support, changed quaternion to rotationQuaternion
  25063. */
  25064. /**
  25065. * Legacy support, changed quaternion to rotationQuaternion
  25066. */
  25067. quaternion: Nullable<Quaternion>;
  25068. /**
  25069. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25070. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25071. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25072. * @returns true if it intersects
  25073. */
  25074. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25075. /**
  25076. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25077. * A particle is in the frustum if its bounding box intersects the frustum
  25078. * @param frustumPlanes defines the frustum to test
  25079. * @returns true if the particle is in the frustum planes
  25080. */
  25081. isInFrustum(frustumPlanes: Plane[]): boolean;
  25082. /**
  25083. * get the rotation matrix of the particle
  25084. * @hidden
  25085. */
  25086. getRotationMatrix(m: Matrix): void;
  25087. }
  25088. /**
  25089. * Represents the shape of the model used by one particle of a solid particle system.
  25090. * SPS internal tool, don't use it manually.
  25091. */
  25092. export class ModelShape {
  25093. /**
  25094. * The shape id
  25095. * @hidden
  25096. */
  25097. shapeID: number;
  25098. /**
  25099. * flat array of model positions (internal use)
  25100. * @hidden
  25101. */ private _shape: Vector3[];
  25102. /**
  25103. * flat array of model UVs (internal use)
  25104. * @hidden
  25105. */ private _shapeUV: number[];
  25106. /**
  25107. * length of the shape in the model indices array (internal use)
  25108. * @hidden
  25109. */ private _indicesLength: number;
  25110. /**
  25111. * Custom position function (internal use)
  25112. * @hidden
  25113. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25114. /**
  25115. * Custom vertex function (internal use)
  25116. * @hidden
  25117. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25118. /**
  25119. * 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.
  25120. * SPS internal tool, don't use it manually.
  25121. * @hidden
  25122. */
  25123. 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>);
  25124. }
  25125. /**
  25126. * Represents a Depth Sorted Particle in the solid particle system.
  25127. */
  25128. export class DepthSortedParticle {
  25129. /**
  25130. * Index of the particle in the "indices" array
  25131. */
  25132. ind: number;
  25133. /**
  25134. * Length of the particle shape in the "indices" array
  25135. */
  25136. indicesLength: number;
  25137. /**
  25138. * Squared distance from the particle to the camera
  25139. */
  25140. sqDistance: number;
  25141. }
  25142. }
  25143. declare module BABYLON {
  25144. /**
  25145. * @hidden
  25146. */
  25147. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25148. }
  25149. }
  25150. declare module BABYLON {
  25151. /** @hidden */ private class _FacetDataStorage {
  25152. facetPositions: Vector3[];
  25153. facetNormals: Vector3[];
  25154. facetPartitioning: number[][];
  25155. facetNb: number;
  25156. partitioningSubdivisions: number;
  25157. partitioningBBoxRatio: number;
  25158. facetDataEnabled: boolean;
  25159. facetParameters: any;
  25160. bbSize: Vector3;
  25161. subDiv: {
  25162. max: number;
  25163. X: number;
  25164. Y: number;
  25165. Z: number;
  25166. };
  25167. facetDepthSort: boolean;
  25168. facetDepthSortEnabled: boolean;
  25169. depthSortedIndices: IndicesArray;
  25170. depthSortedFacets: {
  25171. ind: number;
  25172. sqDistance: number;
  25173. }[];
  25174. facetDepthSortFunction: (f1: {
  25175. ind: number;
  25176. sqDistance: number;
  25177. }, f2: {
  25178. ind: number;
  25179. sqDistance: number;
  25180. }) => number;
  25181. facetDepthSortFrom: Vector3;
  25182. facetDepthSortOrigin: Vector3;
  25183. invertedMatrix: Matrix;
  25184. }
  25185. /**
  25186. * @hidden
  25187. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  25188. }
  25189. /**
  25190. * Class used to store all common mesh properties
  25191. */
  25192. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25193. /** No occlusion */
  25194. static OCCLUSION_TYPE_NONE: number;
  25195. /** Occlusion set to optimisitic */
  25196. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25197. /** Occlusion set to strict */
  25198. static OCCLUSION_TYPE_STRICT: number;
  25199. /** Use an accurante occlusion algorithm */
  25200. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25201. /** Use a conservative occlusion algorithm */
  25202. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25203. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25204. * Test order :
  25205. * Is the bounding sphere outside the frustum ?
  25206. * If not, are the bounding box vertices outside the frustum ?
  25207. * It not, then the cullable object is in the frustum.
  25208. */
  25209. static readonly CULLINGSTRATEGY_STANDARD: number;
  25210. /** Culling strategy : Bounding Sphere Only.
  25211. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25212. * It's also less accurate than the standard because some not visible objects can still be selected.
  25213. * Test : is the bounding sphere outside the frustum ?
  25214. * If not, then the cullable object is in the frustum.
  25215. */
  25216. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25217. /** Culling strategy : Optimistic Inclusion.
  25218. * This in an inclusion test first, then the standard exclusion test.
  25219. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25220. * 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.
  25221. * Anyway, it's as accurate as the standard strategy.
  25222. * Test :
  25223. * Is the cullable object bounding sphere center in the frustum ?
  25224. * If not, apply the default culling strategy.
  25225. */
  25226. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25227. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25228. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25229. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25230. * 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.
  25231. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25232. * Test :
  25233. * Is the cullable object bounding sphere center in the frustum ?
  25234. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25235. */
  25236. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25237. /**
  25238. * No billboard
  25239. */
  25240. static readonly BILLBOARDMODE_NONE: number;
  25241. /** Billboard on X axis */
  25242. static readonly BILLBOARDMODE_X: number;
  25243. /** Billboard on Y axis */
  25244. static readonly BILLBOARDMODE_Y: number;
  25245. /** Billboard on Z axis */
  25246. static readonly BILLBOARDMODE_Z: number;
  25247. /** Billboard on all axes */
  25248. static readonly BILLBOARDMODE_ALL: number;
  25249. /** Billboard on using position instead of orientation */
  25250. static readonly BILLBOARDMODE_USE_POSITION: number;
  25251. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25252. /**
  25253. * The culling strategy to use to check whether the mesh must be rendered or not.
  25254. * This value can be changed at any time and will be used on the next render mesh selection.
  25255. * The possible values are :
  25256. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25257. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25258. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25259. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25260. * Please read each static variable documentation to get details about the culling process.
  25261. * */
  25262. cullingStrategy: number;
  25263. /**
  25264. * Gets the number of facets in the mesh
  25265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25266. */
  25267. readonly facetNb: number;
  25268. /**
  25269. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25271. */
  25272. partitioningSubdivisions: number;
  25273. /**
  25274. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25275. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25277. */
  25278. partitioningBBoxRatio: number;
  25279. /**
  25280. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25281. * Works only for updatable meshes.
  25282. * Doesn't work with multi-materials
  25283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25284. */
  25285. mustDepthSortFacets: boolean;
  25286. /**
  25287. * The location (Vector3) where the facet depth sort must be computed from.
  25288. * By default, the active camera position.
  25289. * Used only when facet depth sort is enabled
  25290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25291. */
  25292. facetDepthSortFrom: Vector3;
  25293. /**
  25294. * gets a boolean indicating if facetData is enabled
  25295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25296. */
  25297. readonly isFacetDataEnabled: boolean;
  25298. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25299. /**
  25300. * An event triggered when this mesh collides with another one
  25301. */
  25302. onCollideObservable: Observable<AbstractMesh>;
  25303. /** Set a function to call when this mesh collides with another one */
  25304. onCollide: () => void;
  25305. /**
  25306. * An event triggered when the collision's position changes
  25307. */
  25308. onCollisionPositionChangeObservable: Observable<Vector3>;
  25309. /** Set a function to call when the collision's position changes */
  25310. onCollisionPositionChange: () => void;
  25311. /**
  25312. * An event triggered when material is changed
  25313. */
  25314. onMaterialChangedObservable: Observable<AbstractMesh>;
  25315. /**
  25316. * Gets or sets the orientation for POV movement & rotation
  25317. */
  25318. definedFacingForward: boolean;
  25319. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25320. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25321. /**
  25322. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25323. */
  25324. /**
  25325. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25326. */
  25327. visibility: number;
  25328. /** Gets or sets the alpha index used to sort transparent meshes
  25329. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25330. */
  25331. alphaIndex: number;
  25332. /**
  25333. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25334. */
  25335. isVisible: boolean;
  25336. /**
  25337. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25338. */
  25339. isPickable: boolean;
  25340. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25341. showSubMeshesBoundingBox: boolean;
  25342. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25343. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25344. */
  25345. isBlocker: boolean;
  25346. /**
  25347. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25348. */
  25349. enablePointerMoveEvents: boolean;
  25350. /**
  25351. * Specifies the rendering group id for this mesh (0 by default)
  25352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25353. */
  25354. renderingGroupId: number;
  25355. private _material;
  25356. /** Gets or sets current material */
  25357. material: Nullable<Material>;
  25358. /**
  25359. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25360. * @see http://doc.babylonjs.com/babylon101/shadows
  25361. */
  25362. receiveShadows: boolean;
  25363. /** Defines color to use when rendering outline */
  25364. outlineColor: Color3;
  25365. /** Define width to use when rendering outline */
  25366. outlineWidth: number;
  25367. /** Defines color to use when rendering overlay */
  25368. overlayColor: Color3;
  25369. /** Defines alpha to use when rendering overlay */
  25370. overlayAlpha: number;
  25371. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25372. hasVertexAlpha: boolean;
  25373. /** 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) */
  25374. useVertexColors: boolean;
  25375. /**
  25376. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25377. */
  25378. computeBonesUsingShaders: boolean;
  25379. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25380. numBoneInfluencers: number;
  25381. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25382. applyFog: boolean;
  25383. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25384. useOctreeForRenderingSelection: boolean;
  25385. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25386. useOctreeForPicking: boolean;
  25387. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25388. useOctreeForCollisions: boolean;
  25389. /**
  25390. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25391. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25392. */
  25393. layerMask: number;
  25394. /**
  25395. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25396. */
  25397. alwaysSelectAsActiveMesh: boolean;
  25398. /**
  25399. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25400. */
  25401. doNotSyncBoundingInfo: boolean;
  25402. /**
  25403. * Gets or sets the current action manager
  25404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25405. */
  25406. actionManager: Nullable<AbstractActionManager>;
  25407. private _meshCollisionData;
  25408. /**
  25409. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25411. */
  25412. ellipsoid: Vector3;
  25413. /**
  25414. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25416. */
  25417. ellipsoidOffset: Vector3;
  25418. /**
  25419. * Gets or sets a collision mask used to mask collisions (default is -1).
  25420. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25421. */
  25422. collisionMask: number;
  25423. /**
  25424. * Gets or sets the current collision group mask (-1 by default).
  25425. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25426. */
  25427. collisionGroup: number;
  25428. /**
  25429. * Defines edge width used when edgesRenderer is enabled
  25430. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25431. */
  25432. edgesWidth: number;
  25433. /**
  25434. * Defines edge color used when edgesRenderer is enabled
  25435. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25436. */
  25437. edgesColor: Color4;
  25438. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25439. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25440. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25441. /** @hidden */ private _renderId: number;
  25442. /**
  25443. * Gets or sets the list of subMeshes
  25444. * @see http://doc.babylonjs.com/how_to/multi_materials
  25445. */
  25446. subMeshes: SubMesh[];
  25447. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25448. /** @hidden */ private _unIndexed: boolean;
  25449. /** @hidden */ private _lightSources: Light[];
  25450. /** Gets the list of lights affecting that mesh */
  25451. readonly lightSources: Light[];
  25452. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25453. /** @hidden */ private _waitingData: {
  25454. lods: Nullable<any>;
  25455. actions: Nullable<any>;
  25456. freezeWorldMatrix: Nullable<boolean>;
  25457. };
  25458. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25459. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25460. /**
  25461. * Gets or sets a skeleton to apply skining transformations
  25462. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25463. */
  25464. skeleton: Nullable<Skeleton>;
  25465. /**
  25466. * An event triggered when the mesh is rebuilt.
  25467. */
  25468. onRebuildObservable: Observable<AbstractMesh>;
  25469. /**
  25470. * Creates a new AbstractMesh
  25471. * @param name defines the name of the mesh
  25472. * @param scene defines the hosting scene
  25473. */
  25474. constructor(name: string, scene?: Nullable<Scene>);
  25475. /**
  25476. * Returns the string "AbstractMesh"
  25477. * @returns "AbstractMesh"
  25478. */
  25479. getClassName(): string;
  25480. /**
  25481. * Gets a string representation of the current mesh
  25482. * @param fullDetails defines a boolean indicating if full details must be included
  25483. * @returns a string representation of the current mesh
  25484. */
  25485. toString(fullDetails?: boolean): string;
  25486. /**
  25487. * @hidden
  25488. */
  25489. protected _getEffectiveParent(): Nullable<Node>;
  25490. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25491. /** @hidden */ private _rebuild(): void;
  25492. /** @hidden */ private _resyncLightSources(): void;
  25493. /** @hidden */ private _resyncLighSource(light: Light): void;
  25494. /** @hidden */ private _unBindEffect(): void;
  25495. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25496. private _markSubMeshesAsDirty;
  25497. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25498. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25499. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25500. /**
  25501. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25502. */
  25503. scaling: Vector3;
  25504. /**
  25505. * Returns true if the mesh is blocked. Implemented by child classes
  25506. */
  25507. readonly isBlocked: boolean;
  25508. /**
  25509. * Returns the mesh itself by default. Implemented by child classes
  25510. * @param camera defines the camera to use to pick the right LOD level
  25511. * @returns the currentAbstractMesh
  25512. */
  25513. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25514. /**
  25515. * Returns 0 by default. Implemented by child classes
  25516. * @returns an integer
  25517. */
  25518. getTotalVertices(): number;
  25519. /**
  25520. * Returns a positive integer : the total number of indices in this mesh geometry.
  25521. * @returns the numner of indices or zero if the mesh has no geometry.
  25522. */
  25523. getTotalIndices(): number;
  25524. /**
  25525. * Returns null by default. Implemented by child classes
  25526. * @returns null
  25527. */
  25528. getIndices(): Nullable<IndicesArray>;
  25529. /**
  25530. * Returns the array of the requested vertex data kind. Implemented by child classes
  25531. * @param kind defines the vertex data kind to use
  25532. * @returns null
  25533. */
  25534. getVerticesData(kind: string): Nullable<FloatArray>;
  25535. /**
  25536. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25537. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25538. * Note that a new underlying VertexBuffer object is created each call.
  25539. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25540. * @param kind defines vertex data kind:
  25541. * * VertexBuffer.PositionKind
  25542. * * VertexBuffer.UVKind
  25543. * * VertexBuffer.UV2Kind
  25544. * * VertexBuffer.UV3Kind
  25545. * * VertexBuffer.UV4Kind
  25546. * * VertexBuffer.UV5Kind
  25547. * * VertexBuffer.UV6Kind
  25548. * * VertexBuffer.ColorKind
  25549. * * VertexBuffer.MatricesIndicesKind
  25550. * * VertexBuffer.MatricesIndicesExtraKind
  25551. * * VertexBuffer.MatricesWeightsKind
  25552. * * VertexBuffer.MatricesWeightsExtraKind
  25553. * @param data defines the data source
  25554. * @param updatable defines if the data must be flagged as updatable (or static)
  25555. * @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
  25556. * @returns the current mesh
  25557. */
  25558. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25559. /**
  25560. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25561. * If the mesh has no geometry, it is simply returned as it is.
  25562. * @param kind defines vertex data kind:
  25563. * * VertexBuffer.PositionKind
  25564. * * VertexBuffer.UVKind
  25565. * * VertexBuffer.UV2Kind
  25566. * * VertexBuffer.UV3Kind
  25567. * * VertexBuffer.UV4Kind
  25568. * * VertexBuffer.UV5Kind
  25569. * * VertexBuffer.UV6Kind
  25570. * * VertexBuffer.ColorKind
  25571. * * VertexBuffer.MatricesIndicesKind
  25572. * * VertexBuffer.MatricesIndicesExtraKind
  25573. * * VertexBuffer.MatricesWeightsKind
  25574. * * VertexBuffer.MatricesWeightsExtraKind
  25575. * @param data defines the data source
  25576. * @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
  25577. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25578. * @returns the current mesh
  25579. */
  25580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25581. /**
  25582. * Sets the mesh indices,
  25583. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25584. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25585. * @param totalVertices Defines the total number of vertices
  25586. * @returns the current mesh
  25587. */
  25588. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25589. /**
  25590. * Gets a boolean indicating if specific vertex data is present
  25591. * @param kind defines the vertex data kind to use
  25592. * @returns true is data kind is present
  25593. */
  25594. isVerticesDataPresent(kind: string): boolean;
  25595. /**
  25596. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25597. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25598. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25599. * @returns a BoundingInfo
  25600. */
  25601. getBoundingInfo(): BoundingInfo;
  25602. /**
  25603. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25604. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25605. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25606. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25607. * @returns the current mesh
  25608. */
  25609. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25610. /**
  25611. * Overwrite the current bounding info
  25612. * @param boundingInfo defines the new bounding info
  25613. * @returns the current mesh
  25614. */
  25615. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25616. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25617. readonly useBones: boolean;
  25618. /** @hidden */ private _preActivate(): void;
  25619. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25620. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25621. /** @hidden */ private _postActivate(): void;
  25622. /** @hidden */ private _freeze(): void;
  25623. /** @hidden */ private _unFreeze(): void;
  25624. /**
  25625. * Gets the current world matrix
  25626. * @returns a Matrix
  25627. */
  25628. getWorldMatrix(): Matrix;
  25629. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25630. /**
  25631. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25632. */
  25633. readonly isAnInstance: boolean;
  25634. /**
  25635. * Gets a boolean indicating if this mesh has instances
  25636. */
  25637. readonly hasInstances: boolean;
  25638. /**
  25639. * Perform relative position change from the point of view of behind the front of the mesh.
  25640. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25641. * Supports definition of mesh facing forward or backward
  25642. * @param amountRight defines the distance on the right axis
  25643. * @param amountUp defines the distance on the up axis
  25644. * @param amountForward defines the distance on the forward axis
  25645. * @returns the current mesh
  25646. */
  25647. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25648. /**
  25649. * Calculate relative position change from the point of view of behind the front of the mesh.
  25650. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25651. * Supports definition of mesh facing forward or backward
  25652. * @param amountRight defines the distance on the right axis
  25653. * @param amountUp defines the distance on the up axis
  25654. * @param amountForward defines the distance on the forward axis
  25655. * @returns the new displacement vector
  25656. */
  25657. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25658. /**
  25659. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25660. * Supports definition of mesh facing forward or backward
  25661. * @param flipBack defines the flip
  25662. * @param twirlClockwise defines the twirl
  25663. * @param tiltRight defines the tilt
  25664. * @returns the current mesh
  25665. */
  25666. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25667. /**
  25668. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25669. * Supports definition of mesh facing forward or backward.
  25670. * @param flipBack defines the flip
  25671. * @param twirlClockwise defines the twirl
  25672. * @param tiltRight defines the tilt
  25673. * @returns the new rotation vector
  25674. */
  25675. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25676. /**
  25677. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25678. * This means the mesh underlying bounding box and sphere are recomputed.
  25679. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25680. * @returns the current mesh
  25681. */
  25682. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25683. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25684. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25685. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25686. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25687. /** @hidden */
  25688. protected _afterComputeWorldMatrix(): void;
  25689. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25690. /**
  25691. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25692. * A mesh is in the frustum if its bounding box intersects the frustum
  25693. * @param frustumPlanes defines the frustum to test
  25694. * @returns true if the mesh is in the frustum planes
  25695. */
  25696. isInFrustum(frustumPlanes: Plane[]): boolean;
  25697. /**
  25698. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25699. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25700. * @param frustumPlanes defines the frustum to test
  25701. * @returns true if the mesh is completely in the frustum planes
  25702. */
  25703. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25704. /**
  25705. * True if the mesh intersects another mesh or a SolidParticle object
  25706. * @param mesh defines a target mesh or SolidParticle to test
  25707. * @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)
  25708. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25709. * @returns true if there is an intersection
  25710. */
  25711. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25712. /**
  25713. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25714. * @param point defines the point to test
  25715. * @returns true if there is an intersection
  25716. */
  25717. intersectsPoint(point: Vector3): boolean;
  25718. /**
  25719. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25721. */
  25722. checkCollisions: boolean;
  25723. /**
  25724. * Gets Collider object used to compute collisions (not physics)
  25725. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25726. */
  25727. readonly collider: Nullable<Collider>;
  25728. /**
  25729. * Move the mesh using collision engine
  25730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25731. * @param displacement defines the requested displacement vector
  25732. * @returns the current mesh
  25733. */
  25734. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25735. private _onCollisionPositionChange;
  25736. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25737. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25738. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25739. /** @hidden */ private _generatePointsArray(): boolean;
  25740. /**
  25741. * Checks if the passed Ray intersects with the mesh
  25742. * @param ray defines the ray to use
  25743. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25744. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25745. * @returns the picking info
  25746. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25747. */
  25748. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25749. /**
  25750. * Clones the current mesh
  25751. * @param name defines the mesh name
  25752. * @param newParent defines the new mesh parent
  25753. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25754. * @returns the new mesh
  25755. */
  25756. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25757. /**
  25758. * Disposes all the submeshes of the current meshnp
  25759. * @returns the current mesh
  25760. */
  25761. releaseSubMeshes(): AbstractMesh;
  25762. /**
  25763. * Releases resources associated with this abstract mesh.
  25764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25766. */
  25767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25768. /**
  25769. * Adds the passed mesh as a child to the current mesh
  25770. * @param mesh defines the child mesh
  25771. * @returns the current mesh
  25772. */
  25773. addChild(mesh: AbstractMesh): AbstractMesh;
  25774. /**
  25775. * Removes the passed mesh from the current mesh children list
  25776. * @param mesh defines the child mesh
  25777. * @returns the current mesh
  25778. */
  25779. removeChild(mesh: AbstractMesh): AbstractMesh;
  25780. /** @hidden */
  25781. private _initFacetData;
  25782. /**
  25783. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25784. * This method can be called within the render loop.
  25785. * 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
  25786. * @returns the current mesh
  25787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25788. */
  25789. updateFacetData(): AbstractMesh;
  25790. /**
  25791. * Returns the facetLocalNormals array.
  25792. * The normals are expressed in the mesh local spac
  25793. * @returns an array of Vector3
  25794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25795. */
  25796. getFacetLocalNormals(): Vector3[];
  25797. /**
  25798. * Returns the facetLocalPositions array.
  25799. * The facet positions are expressed in the mesh local space
  25800. * @returns an array of Vector3
  25801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25802. */
  25803. getFacetLocalPositions(): Vector3[];
  25804. /**
  25805. * Returns the facetLocalPartioning array
  25806. * @returns an array of array of numbers
  25807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25808. */
  25809. getFacetLocalPartitioning(): number[][];
  25810. /**
  25811. * Returns the i-th facet position in the world system.
  25812. * This method allocates a new Vector3 per call
  25813. * @param i defines the facet index
  25814. * @returns a new Vector3
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25816. */
  25817. getFacetPosition(i: number): Vector3;
  25818. /**
  25819. * Sets the reference Vector3 with the i-th facet position in the world system
  25820. * @param i defines the facet index
  25821. * @param ref defines the target vector
  25822. * @returns the current mesh
  25823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25824. */
  25825. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25826. /**
  25827. * Returns the i-th facet normal in the world system.
  25828. * This method allocates a new Vector3 per call
  25829. * @param i defines the facet index
  25830. * @returns a new Vector3
  25831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25832. */
  25833. getFacetNormal(i: number): Vector3;
  25834. /**
  25835. * Sets the reference Vector3 with the i-th facet normal in the world system
  25836. * @param i defines the facet index
  25837. * @param ref defines the target vector
  25838. * @returns the current mesh
  25839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25840. */
  25841. getFacetNormalToRef(i: number, ref: Vector3): this;
  25842. /**
  25843. * 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)
  25844. * @param x defines x coordinate
  25845. * @param y defines y coordinate
  25846. * @param z defines z coordinate
  25847. * @returns the array of facet indexes
  25848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25849. */
  25850. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25851. /**
  25852. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25853. * @param projected sets as the (x,y,z) world projection on the facet
  25854. * @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
  25855. * @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
  25856. * @param x defines x coordinate
  25857. * @param y defines y coordinate
  25858. * @param z defines z coordinate
  25859. * @returns the face index if found (or null instead)
  25860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25861. */
  25862. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25863. /**
  25864. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25865. * @param projected sets as the (x,y,z) local projection on the facet
  25866. * @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
  25867. * @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
  25868. * @param x defines x coordinate
  25869. * @param y defines y coordinate
  25870. * @param z defines z coordinate
  25871. * @returns the face index if found (or null instead)
  25872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25873. */
  25874. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25875. /**
  25876. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25877. * @returns the parameters
  25878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25879. */
  25880. getFacetDataParameters(): any;
  25881. /**
  25882. * Disables the feature FacetData and frees the related memory
  25883. * @returns the current mesh
  25884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25885. */
  25886. disableFacetData(): AbstractMesh;
  25887. /**
  25888. * Updates the AbstractMesh indices array
  25889. * @param indices defines the data source
  25890. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25891. * @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)
  25892. * @returns the current mesh
  25893. */
  25894. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25895. /**
  25896. * Creates new normals data for the mesh
  25897. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25898. * @returns the current mesh
  25899. */
  25900. createNormals(updatable: boolean): AbstractMesh;
  25901. /**
  25902. * Align the mesh with a normal
  25903. * @param normal defines the normal to use
  25904. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25905. * @returns the current mesh
  25906. */
  25907. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25908. /** @hidden */ private _checkOcclusionQuery(): boolean;
  25909. /**
  25910. * Disables the mesh edge rendering mode
  25911. * @returns the currentAbstractMesh
  25912. */
  25913. disableEdgesRendering(): AbstractMesh;
  25914. /**
  25915. * Enables the edge rendering mode on the mesh.
  25916. * This mode makes the mesh edges visible
  25917. * @param epsilon defines the maximal distance between two angles to detect a face
  25918. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25919. * @returns the currentAbstractMesh
  25920. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25921. */
  25922. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25923. }
  25924. }
  25925. declare module BABYLON {
  25926. /**
  25927. * Interface used to define ActionEvent
  25928. */
  25929. export interface IActionEvent {
  25930. /** The mesh or sprite that triggered the action */
  25931. source: any;
  25932. /** The X mouse cursor position at the time of the event */
  25933. pointerX: number;
  25934. /** The Y mouse cursor position at the time of the event */
  25935. pointerY: number;
  25936. /** The mesh that is currently pointed at (can be null) */
  25937. meshUnderPointer: Nullable<AbstractMesh>;
  25938. /** the original (browser) event that triggered the ActionEvent */
  25939. sourceEvent?: any;
  25940. /** additional data for the event */
  25941. additionalData?: any;
  25942. }
  25943. /**
  25944. * ActionEvent is the event being sent when an action is triggered.
  25945. */
  25946. export class ActionEvent implements IActionEvent {
  25947. /** The mesh or sprite that triggered the action */
  25948. source: any;
  25949. /** The X mouse cursor position at the time of the event */
  25950. pointerX: number;
  25951. /** The Y mouse cursor position at the time of the event */
  25952. pointerY: number;
  25953. /** The mesh that is currently pointed at (can be null) */
  25954. meshUnderPointer: Nullable<AbstractMesh>;
  25955. /** the original (browser) event that triggered the ActionEvent */
  25956. sourceEvent?: any;
  25957. /** additional data for the event */
  25958. additionalData?: any;
  25959. /**
  25960. * Creates a new ActionEvent
  25961. * @param source The mesh or sprite that triggered the action
  25962. * @param pointerX The X mouse cursor position at the time of the event
  25963. * @param pointerY The Y mouse cursor position at the time of the event
  25964. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25965. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25966. * @param additionalData additional data for the event
  25967. */
  25968. constructor(
  25969. /** The mesh or sprite that triggered the action */
  25970. source: any,
  25971. /** The X mouse cursor position at the time of the event */
  25972. pointerX: number,
  25973. /** The Y mouse cursor position at the time of the event */
  25974. pointerY: number,
  25975. /** The mesh that is currently pointed at (can be null) */
  25976. meshUnderPointer: Nullable<AbstractMesh>,
  25977. /** the original (browser) event that triggered the ActionEvent */
  25978. sourceEvent?: any,
  25979. /** additional data for the event */
  25980. additionalData?: any);
  25981. /**
  25982. * Helper function to auto-create an ActionEvent from a source mesh.
  25983. * @param source The source mesh that triggered the event
  25984. * @param evt The original (browser) event
  25985. * @param additionalData additional data for the event
  25986. * @returns the new ActionEvent
  25987. */
  25988. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25989. /**
  25990. * Helper function to auto-create an ActionEvent from a source sprite
  25991. * @param source The source sprite that triggered the event
  25992. * @param scene Scene associated with the sprite
  25993. * @param evt The original (browser) event
  25994. * @param additionalData additional data for the event
  25995. * @returns the new ActionEvent
  25996. */
  25997. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25998. /**
  25999. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26000. * @param scene the scene where the event occurred
  26001. * @param evt The original (browser) event
  26002. * @returns the new ActionEvent
  26003. */
  26004. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26005. /**
  26006. * Helper function to auto-create an ActionEvent from a primitive
  26007. * @param prim defines the target primitive
  26008. * @param pointerPos defines the pointer position
  26009. * @param evt The original (browser) event
  26010. * @param additionalData additional data for the event
  26011. * @returns the new ActionEvent
  26012. */
  26013. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26014. }
  26015. }
  26016. declare module BABYLON {
  26017. /**
  26018. * Abstract class used to decouple action Manager from scene and meshes.
  26019. * Do not instantiate.
  26020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26021. */
  26022. export abstract class AbstractActionManager implements IDisposable {
  26023. /** Gets the list of active triggers */
  26024. static Triggers: {
  26025. [key: string]: number;
  26026. };
  26027. /** Gets the cursor to use when hovering items */
  26028. hoverCursor: string;
  26029. /** Gets the list of actions */
  26030. actions: IAction[];
  26031. /**
  26032. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26033. */
  26034. isRecursive: boolean;
  26035. /**
  26036. * Releases all associated resources
  26037. */
  26038. abstract dispose(): void;
  26039. /**
  26040. * Does this action manager has pointer triggers
  26041. */
  26042. abstract readonly hasPointerTriggers: boolean;
  26043. /**
  26044. * Does this action manager has pick triggers
  26045. */
  26046. abstract readonly hasPickTriggers: boolean;
  26047. /**
  26048. * Process a specific trigger
  26049. * @param trigger defines the trigger to process
  26050. * @param evt defines the event details to be processed
  26051. */
  26052. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26053. /**
  26054. * Does this action manager handles actions of any of the given triggers
  26055. * @param triggers defines the triggers to be tested
  26056. * @return a boolean indicating whether one (or more) of the triggers is handled
  26057. */
  26058. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26059. /**
  26060. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26061. * speed.
  26062. * @param triggerA defines the trigger to be tested
  26063. * @param triggerB defines the trigger to be tested
  26064. * @return a boolean indicating whether one (or more) of the triggers is handled
  26065. */
  26066. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26067. /**
  26068. * Does this action manager handles actions of a given trigger
  26069. * @param trigger defines the trigger to be tested
  26070. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26071. * @return whether the trigger is handled
  26072. */
  26073. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26074. /**
  26075. * Serialize this manager to a JSON object
  26076. * @param name defines the property name to store this manager
  26077. * @returns a JSON representation of this manager
  26078. */
  26079. abstract serialize(name: string): any;
  26080. /**
  26081. * Registers an action to this action manager
  26082. * @param action defines the action to be registered
  26083. * @return the action amended (prepared) after registration
  26084. */
  26085. abstract registerAction(action: IAction): Nullable<IAction>;
  26086. /**
  26087. * Unregisters an action to this action manager
  26088. * @param action defines the action to be unregistered
  26089. * @return a boolean indicating whether the action has been unregistered
  26090. */
  26091. abstract unregisterAction(action: IAction): Boolean;
  26092. /**
  26093. * Does exist one action manager with at least one trigger
  26094. **/
  26095. static readonly HasTriggers: boolean;
  26096. /**
  26097. * Does exist one action manager with at least one pick trigger
  26098. **/
  26099. static readonly HasPickTriggers: boolean;
  26100. /**
  26101. * Does exist one action manager that handles actions of a given trigger
  26102. * @param trigger defines the trigger to be tested
  26103. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26104. **/
  26105. static HasSpecificTrigger(trigger: number): boolean;
  26106. }
  26107. }
  26108. declare module BABYLON {
  26109. /**
  26110. * Defines how a node can be built from a string name.
  26111. */
  26112. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26113. /**
  26114. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26115. */
  26116. export class Node implements IBehaviorAware<Node> {
  26117. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26118. private static _NodeConstructors;
  26119. /**
  26120. * Add a new node constructor
  26121. * @param type defines the type name of the node to construct
  26122. * @param constructorFunc defines the constructor function
  26123. */
  26124. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26125. /**
  26126. * Returns a node constructor based on type name
  26127. * @param type defines the type name
  26128. * @param name defines the new node name
  26129. * @param scene defines the hosting scene
  26130. * @param options defines optional options to transmit to constructors
  26131. * @returns the new constructor or null
  26132. */
  26133. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26134. /**
  26135. * Gets or sets the name of the node
  26136. */
  26137. name: string;
  26138. /**
  26139. * Gets or sets the id of the node
  26140. */
  26141. id: string;
  26142. /**
  26143. * Gets or sets the unique id of the node
  26144. */
  26145. uniqueId: number;
  26146. /**
  26147. * Gets or sets a string used to store user defined state for the node
  26148. */
  26149. state: string;
  26150. /**
  26151. * Gets or sets an object used to store user defined information for the node
  26152. */
  26153. metadata: any;
  26154. /**
  26155. * For internal use only. Please do not use.
  26156. */
  26157. reservedDataStore: any;
  26158. /**
  26159. * List of inspectable custom properties (used by the Inspector)
  26160. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26161. */
  26162. inspectableCustomProperties: IInspectable[];
  26163. /**
  26164. * Gets or sets a boolean used to define if the node must be serialized
  26165. */
  26166. doNotSerialize: boolean;
  26167. /** @hidden */ private _isDisposed: boolean;
  26168. /**
  26169. * Gets a list of Animations associated with the node
  26170. */
  26171. animations: Animation[];
  26172. protected _ranges: {
  26173. [name: string]: Nullable<AnimationRange>;
  26174. };
  26175. /**
  26176. * Callback raised when the node is ready to be used
  26177. */
  26178. onReady: Nullable<(node: Node) => void>;
  26179. private _isEnabled;
  26180. private _isParentEnabled;
  26181. private _isReady;
  26182. /** @hidden */ private _currentRenderId: number;
  26183. private _parentUpdateId;
  26184. /** @hidden */ private _childUpdateId: number;
  26185. /** @hidden */ private _waitingParentId: Nullable<string>;
  26186. /** @hidden */ private _scene: Scene;
  26187. /** @hidden */ private _cache: any;
  26188. private _parentNode;
  26189. private _children;
  26190. /** @hidden */ private _worldMatrix: Matrix;
  26191. /** @hidden */ private _worldMatrixDeterminant: number;
  26192. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26193. /** @hidden */
  26194. private _sceneRootNodesIndex;
  26195. /**
  26196. * Gets a boolean indicating if the node has been disposed
  26197. * @returns true if the node was disposed
  26198. */
  26199. isDisposed(): boolean;
  26200. /**
  26201. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26202. * @see https://doc.babylonjs.com/how_to/parenting
  26203. */
  26204. parent: Nullable<Node>;
  26205. private addToSceneRootNodes;
  26206. private removeFromSceneRootNodes;
  26207. private _animationPropertiesOverride;
  26208. /**
  26209. * Gets or sets the animation properties override
  26210. */
  26211. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26212. /**
  26213. * Gets a string idenfifying the name of the class
  26214. * @returns "Node" string
  26215. */
  26216. getClassName(): string;
  26217. /** @hidden */ protected readonly _isNode: boolean;
  26218. /**
  26219. * An event triggered when the mesh is disposed
  26220. */
  26221. onDisposeObservable: Observable<Node>;
  26222. private _onDisposeObserver;
  26223. /**
  26224. * Sets a callback that will be raised when the node will be disposed
  26225. */
  26226. onDispose: () => void;
  26227. /**
  26228. * Creates a new Node
  26229. * @param name the name and id to be given to this node
  26230. * @param scene the scene this node will be added to
  26231. * @param addToRootNodes the node will be added to scene.rootNodes
  26232. */
  26233. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26234. /**
  26235. * Gets the scene of the node
  26236. * @returns a scene
  26237. */
  26238. getScene(): Scene;
  26239. /**
  26240. * Gets the engine of the node
  26241. * @returns a Engine
  26242. */
  26243. getEngine(): Engine;
  26244. private _behaviors;
  26245. /**
  26246. * Attach a behavior to the node
  26247. * @see http://doc.babylonjs.com/features/behaviour
  26248. * @param behavior defines the behavior to attach
  26249. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26250. * @returns the current Node
  26251. */
  26252. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26253. /**
  26254. * Remove an attached behavior
  26255. * @see http://doc.babylonjs.com/features/behaviour
  26256. * @param behavior defines the behavior to attach
  26257. * @returns the current Node
  26258. */
  26259. removeBehavior(behavior: Behavior<Node>): Node;
  26260. /**
  26261. * Gets the list of attached behaviors
  26262. * @see http://doc.babylonjs.com/features/behaviour
  26263. */
  26264. readonly behaviors: Behavior<Node>[];
  26265. /**
  26266. * Gets an attached behavior by name
  26267. * @param name defines the name of the behavior to look for
  26268. * @see http://doc.babylonjs.com/features/behaviour
  26269. * @returns null if behavior was not found else the requested behavior
  26270. */
  26271. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26272. /**
  26273. * Returns the latest update of the World matrix
  26274. * @returns a Matrix
  26275. */
  26276. getWorldMatrix(): Matrix;
  26277. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26278. /**
  26279. * Returns directly the latest state of the mesh World matrix.
  26280. * A Matrix is returned.
  26281. */
  26282. readonly worldMatrixFromCache: Matrix;
  26283. /** @hidden */ private _initCache(): void;
  26284. /** @hidden */
  26285. updateCache(force?: boolean): void;
  26286. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26287. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26288. /** @hidden */ private _isSynchronized(): boolean;
  26289. /** @hidden */ private _markSyncedWithParent(): void;
  26290. /** @hidden */
  26291. isSynchronizedWithParent(): boolean;
  26292. /** @hidden */
  26293. isSynchronized(): boolean;
  26294. /**
  26295. * Is this node ready to be used/rendered
  26296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26297. * @return true if the node is ready
  26298. */
  26299. isReady(completeCheck?: boolean): boolean;
  26300. /**
  26301. * Is this node enabled?
  26302. * 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
  26303. * @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
  26304. * @return whether this node (and its parent) is enabled
  26305. */
  26306. isEnabled(checkAncestors?: boolean): boolean;
  26307. /** @hidden */
  26308. protected _syncParentEnabledState(): void;
  26309. /**
  26310. * Set the enabled state of this node
  26311. * @param value defines the new enabled state
  26312. */
  26313. setEnabled(value: boolean): void;
  26314. /**
  26315. * Is this node a descendant of the given node?
  26316. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26317. * @param ancestor defines the parent node to inspect
  26318. * @returns a boolean indicating if this node is a descendant of the given node
  26319. */
  26320. isDescendantOf(ancestor: Node): boolean;
  26321. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26322. /**
  26323. * Will return all nodes that have this node as ascendant
  26324. * @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
  26325. * @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
  26326. * @return all children nodes of all types
  26327. */
  26328. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26329. /**
  26330. * Get all child-meshes of this node
  26331. * @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)
  26332. * @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
  26333. * @returns an array of AbstractMesh
  26334. */
  26335. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26336. /**
  26337. * Get all direct children of this node
  26338. * @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
  26339. * @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)
  26340. * @returns an array of Node
  26341. */
  26342. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26343. /** @hidden */ private _setReady(state: boolean): void;
  26344. /**
  26345. * Get an animation by name
  26346. * @param name defines the name of the animation to look for
  26347. * @returns null if not found else the requested animation
  26348. */
  26349. getAnimationByName(name: string): Nullable<Animation>;
  26350. /**
  26351. * Creates an animation range for this node
  26352. * @param name defines the name of the range
  26353. * @param from defines the starting key
  26354. * @param to defines the end key
  26355. */
  26356. createAnimationRange(name: string, from: number, to: number): void;
  26357. /**
  26358. * Delete a specific animation range
  26359. * @param name defines the name of the range to delete
  26360. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26361. */
  26362. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26363. /**
  26364. * Get an animation range by name
  26365. * @param name defines the name of the animation range to look for
  26366. * @returns null if not found else the requested animation range
  26367. */
  26368. getAnimationRange(name: string): Nullable<AnimationRange>;
  26369. /**
  26370. * Gets the list of all animation ranges defined on this node
  26371. * @returns an array
  26372. */
  26373. getAnimationRanges(): Nullable<AnimationRange>[];
  26374. /**
  26375. * Will start the animation sequence
  26376. * @param name defines the range frames for animation sequence
  26377. * @param loop defines if the animation should loop (false by default)
  26378. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26379. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26380. * @returns the object created for this animation. If range does not exist, it will return null
  26381. */
  26382. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26383. /**
  26384. * Serialize animation ranges into a JSON compatible object
  26385. * @returns serialization object
  26386. */
  26387. serializeAnimationRanges(): any;
  26388. /**
  26389. * Computes the world matrix of the node
  26390. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26391. * @returns the world matrix
  26392. */
  26393. computeWorldMatrix(force?: boolean): Matrix;
  26394. /**
  26395. * Releases resources associated with this node.
  26396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26398. */
  26399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26400. /**
  26401. * Parse animation range data from a serialization object and store them into a given node
  26402. * @param node defines where to store the animation ranges
  26403. * @param parsedNode defines the serialization object to read data from
  26404. * @param scene defines the hosting scene
  26405. */
  26406. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26407. /**
  26408. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26409. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26410. * @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
  26411. * @returns the new bounding vectors
  26412. */
  26413. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26414. min: Vector3;
  26415. max: Vector3;
  26416. };
  26417. }
  26418. }
  26419. declare module BABYLON {
  26420. /**
  26421. * @hidden
  26422. */
  26423. export class _IAnimationState {
  26424. key: number;
  26425. repeatCount: number;
  26426. workValue?: any;
  26427. loopMode?: number;
  26428. offsetValue?: any;
  26429. highLimitValue?: any;
  26430. }
  26431. /**
  26432. * Class used to store any kind of animation
  26433. */
  26434. export class Animation {
  26435. /**Name of the animation */
  26436. name: string;
  26437. /**Property to animate */
  26438. targetProperty: string;
  26439. /**The frames per second of the animation */
  26440. framePerSecond: number;
  26441. /**The data type of the animation */
  26442. dataType: number;
  26443. /**The loop mode of the animation */
  26444. loopMode?: number | undefined;
  26445. /**Specifies if blending should be enabled */
  26446. enableBlending?: boolean | undefined;
  26447. /**
  26448. * Use matrix interpolation instead of using direct key value when animating matrices
  26449. */
  26450. static AllowMatricesInterpolation: boolean;
  26451. /**
  26452. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26453. */
  26454. static AllowMatrixDecomposeForInterpolation: boolean;
  26455. /**
  26456. * Stores the key frames of the animation
  26457. */
  26458. private _keys;
  26459. /**
  26460. * Stores the easing function of the animation
  26461. */
  26462. private _easingFunction;
  26463. /**
  26464. * @hidden Internal use only
  26465. */ private _runtimeAnimations: RuntimeAnimation[];
  26466. /**
  26467. * The set of event that will be linked to this animation
  26468. */
  26469. private _events;
  26470. /**
  26471. * Stores an array of target property paths
  26472. */
  26473. targetPropertyPath: string[];
  26474. /**
  26475. * Stores the blending speed of the animation
  26476. */
  26477. blendingSpeed: number;
  26478. /**
  26479. * Stores the animation ranges for the animation
  26480. */
  26481. private _ranges;
  26482. /**
  26483. * @hidden Internal use
  26484. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26485. /**
  26486. * Sets up an animation
  26487. * @param property The property to animate
  26488. * @param animationType The animation type to apply
  26489. * @param framePerSecond The frames per second of the animation
  26490. * @param easingFunction The easing function used in the animation
  26491. * @returns The created animation
  26492. */
  26493. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26494. /**
  26495. * Create and start an animation on a node
  26496. * @param name defines the name of the global animation that will be run on all nodes
  26497. * @param node defines the root node where the animation will take place
  26498. * @param targetProperty defines property to animate
  26499. * @param framePerSecond defines the number of frame per second yo use
  26500. * @param totalFrame defines the number of frames in total
  26501. * @param from defines the initial value
  26502. * @param to defines the final value
  26503. * @param loopMode defines which loop mode you want to use (off by default)
  26504. * @param easingFunction defines the easing function to use (linear by default)
  26505. * @param onAnimationEnd defines the callback to call when animation end
  26506. * @returns the animatable created for this animation
  26507. */
  26508. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26509. /**
  26510. * Create and start an animation on a node and its descendants
  26511. * @param name defines the name of the global animation that will be run on all nodes
  26512. * @param node defines the root node where the animation will take place
  26513. * @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
  26514. * @param targetProperty defines property to animate
  26515. * @param framePerSecond defines the number of frame per second to use
  26516. * @param totalFrame defines the number of frames in total
  26517. * @param from defines the initial value
  26518. * @param to defines the final value
  26519. * @param loopMode defines which loop mode you want to use (off by default)
  26520. * @param easingFunction defines the easing function to use (linear by default)
  26521. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26522. * @returns the list of animatables created for all nodes
  26523. * @example https://www.babylonjs-playground.com/#MH0VLI
  26524. */
  26525. 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[]>;
  26526. /**
  26527. * Creates a new animation, merges it with the existing animations and starts it
  26528. * @param name Name of the animation
  26529. * @param node Node which contains the scene that begins the animations
  26530. * @param targetProperty Specifies which property to animate
  26531. * @param framePerSecond The frames per second of the animation
  26532. * @param totalFrame The total number of frames
  26533. * @param from The frame at the beginning of the animation
  26534. * @param to The frame at the end of the animation
  26535. * @param loopMode Specifies the loop mode of the animation
  26536. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26537. * @param onAnimationEnd Callback to run once the animation is complete
  26538. * @returns Nullable animation
  26539. */
  26540. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26541. /**
  26542. * Transition property of an host to the target Value
  26543. * @param property The property to transition
  26544. * @param targetValue The target Value of the property
  26545. * @param host The object where the property to animate belongs
  26546. * @param scene Scene used to run the animation
  26547. * @param frameRate Framerate (in frame/s) to use
  26548. * @param transition The transition type we want to use
  26549. * @param duration The duration of the animation, in milliseconds
  26550. * @param onAnimationEnd Callback trigger at the end of the animation
  26551. * @returns Nullable animation
  26552. */
  26553. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26554. /**
  26555. * Return the array of runtime animations currently using this animation
  26556. */
  26557. readonly runtimeAnimations: RuntimeAnimation[];
  26558. /**
  26559. * Specifies if any of the runtime animations are currently running
  26560. */
  26561. readonly hasRunningRuntimeAnimations: boolean;
  26562. /**
  26563. * Initializes the animation
  26564. * @param name Name of the animation
  26565. * @param targetProperty Property to animate
  26566. * @param framePerSecond The frames per second of the animation
  26567. * @param dataType The data type of the animation
  26568. * @param loopMode The loop mode of the animation
  26569. * @param enableBlending Specifies if blending should be enabled
  26570. */
  26571. constructor(
  26572. /**Name of the animation */
  26573. name: string,
  26574. /**Property to animate */
  26575. targetProperty: string,
  26576. /**The frames per second of the animation */
  26577. framePerSecond: number,
  26578. /**The data type of the animation */
  26579. dataType: number,
  26580. /**The loop mode of the animation */
  26581. loopMode?: number | undefined,
  26582. /**Specifies if blending should be enabled */
  26583. enableBlending?: boolean | undefined);
  26584. /**
  26585. * Converts the animation to a string
  26586. * @param fullDetails support for multiple levels of logging within scene loading
  26587. * @returns String form of the animation
  26588. */
  26589. toString(fullDetails?: boolean): string;
  26590. /**
  26591. * Add an event to this animation
  26592. * @param event Event to add
  26593. */
  26594. addEvent(event: AnimationEvent): void;
  26595. /**
  26596. * Remove all events found at the given frame
  26597. * @param frame The frame to remove events from
  26598. */
  26599. removeEvents(frame: number): void;
  26600. /**
  26601. * Retrieves all the events from the animation
  26602. * @returns Events from the animation
  26603. */
  26604. getEvents(): AnimationEvent[];
  26605. /**
  26606. * Creates an animation range
  26607. * @param name Name of the animation range
  26608. * @param from Starting frame of the animation range
  26609. * @param to Ending frame of the animation
  26610. */
  26611. createRange(name: string, from: number, to: number): void;
  26612. /**
  26613. * Deletes an animation range by name
  26614. * @param name Name of the animation range to delete
  26615. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26616. */
  26617. deleteRange(name: string, deleteFrames?: boolean): void;
  26618. /**
  26619. * Gets the animation range by name, or null if not defined
  26620. * @param name Name of the animation range
  26621. * @returns Nullable animation range
  26622. */
  26623. getRange(name: string): Nullable<AnimationRange>;
  26624. /**
  26625. * Gets the key frames from the animation
  26626. * @returns The key frames of the animation
  26627. */
  26628. getKeys(): Array<IAnimationKey>;
  26629. /**
  26630. * Gets the highest frame rate of the animation
  26631. * @returns Highest frame rate of the animation
  26632. */
  26633. getHighestFrame(): number;
  26634. /**
  26635. * Gets the easing function of the animation
  26636. * @returns Easing function of the animation
  26637. */
  26638. getEasingFunction(): IEasingFunction;
  26639. /**
  26640. * Sets the easing function of the animation
  26641. * @param easingFunction A custom mathematical formula for animation
  26642. */
  26643. setEasingFunction(easingFunction: EasingFunction): void;
  26644. /**
  26645. * Interpolates a scalar linearly
  26646. * @param startValue Start value of the animation curve
  26647. * @param endValue End value of the animation curve
  26648. * @param gradient Scalar amount to interpolate
  26649. * @returns Interpolated scalar value
  26650. */
  26651. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26652. /**
  26653. * Interpolates a scalar cubically
  26654. * @param startValue Start value of the animation curve
  26655. * @param outTangent End tangent of the animation
  26656. * @param endValue End value of the animation curve
  26657. * @param inTangent Start tangent of the animation curve
  26658. * @param gradient Scalar amount to interpolate
  26659. * @returns Interpolated scalar value
  26660. */
  26661. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26662. /**
  26663. * Interpolates a quaternion using a spherical linear interpolation
  26664. * @param startValue Start value of the animation curve
  26665. * @param endValue End value of the animation curve
  26666. * @param gradient Scalar amount to interpolate
  26667. * @returns Interpolated quaternion value
  26668. */
  26669. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26670. /**
  26671. * Interpolates a quaternion cubically
  26672. * @param startValue Start value of the animation curve
  26673. * @param outTangent End tangent of the animation curve
  26674. * @param endValue End value of the animation curve
  26675. * @param inTangent Start tangent of the animation curve
  26676. * @param gradient Scalar amount to interpolate
  26677. * @returns Interpolated quaternion value
  26678. */
  26679. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26680. /**
  26681. * Interpolates a Vector3 linearl
  26682. * @param startValue Start value of the animation curve
  26683. * @param endValue End value of the animation curve
  26684. * @param gradient Scalar amount to interpolate
  26685. * @returns Interpolated scalar value
  26686. */
  26687. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26688. /**
  26689. * Interpolates a Vector3 cubically
  26690. * @param startValue Start value of the animation curve
  26691. * @param outTangent End tangent of the animation
  26692. * @param endValue End value of the animation curve
  26693. * @param inTangent Start tangent of the animation curve
  26694. * @param gradient Scalar amount to interpolate
  26695. * @returns InterpolatedVector3 value
  26696. */
  26697. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26698. /**
  26699. * Interpolates a Vector2 linearly
  26700. * @param startValue Start value of the animation curve
  26701. * @param endValue End value of the animation curve
  26702. * @param gradient Scalar amount to interpolate
  26703. * @returns Interpolated Vector2 value
  26704. */
  26705. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26706. /**
  26707. * Interpolates a Vector2 cubically
  26708. * @param startValue Start value of the animation curve
  26709. * @param outTangent End tangent of the animation
  26710. * @param endValue End value of the animation curve
  26711. * @param inTangent Start tangent of the animation curve
  26712. * @param gradient Scalar amount to interpolate
  26713. * @returns Interpolated Vector2 value
  26714. */
  26715. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26716. /**
  26717. * Interpolates a size linearly
  26718. * @param startValue Start value of the animation curve
  26719. * @param endValue End value of the animation curve
  26720. * @param gradient Scalar amount to interpolate
  26721. * @returns Interpolated Size value
  26722. */
  26723. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26724. /**
  26725. * Interpolates a Color3 linearly
  26726. * @param startValue Start value of the animation curve
  26727. * @param endValue End value of the animation curve
  26728. * @param gradient Scalar amount to interpolate
  26729. * @returns Interpolated Color3 value
  26730. */
  26731. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26732. /**
  26733. * @hidden Internal use only
  26734. */ private _getKeyValue(value: any): any;
  26735. /**
  26736. * @hidden Internal use only
  26737. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26738. /**
  26739. * Defines the function to use to interpolate matrices
  26740. * @param startValue defines the start matrix
  26741. * @param endValue defines the end matrix
  26742. * @param gradient defines the gradient between both matrices
  26743. * @param result defines an optional target matrix where to store the interpolation
  26744. * @returns the interpolated matrix
  26745. */
  26746. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26747. /**
  26748. * Makes a copy of the animation
  26749. * @returns Cloned animation
  26750. */
  26751. clone(): Animation;
  26752. /**
  26753. * Sets the key frames of the animation
  26754. * @param values The animation key frames to set
  26755. */
  26756. setKeys(values: Array<IAnimationKey>): void;
  26757. /**
  26758. * Serializes the animation to an object
  26759. * @returns Serialized object
  26760. */
  26761. serialize(): any;
  26762. /**
  26763. * Float animation type
  26764. */
  26765. private static _ANIMATIONTYPE_FLOAT;
  26766. /**
  26767. * Vector3 animation type
  26768. */
  26769. private static _ANIMATIONTYPE_VECTOR3;
  26770. /**
  26771. * Quaternion animation type
  26772. */
  26773. private static _ANIMATIONTYPE_QUATERNION;
  26774. /**
  26775. * Matrix animation type
  26776. */
  26777. private static _ANIMATIONTYPE_MATRIX;
  26778. /**
  26779. * Color3 animation type
  26780. */
  26781. private static _ANIMATIONTYPE_COLOR3;
  26782. /**
  26783. * Vector2 animation type
  26784. */
  26785. private static _ANIMATIONTYPE_VECTOR2;
  26786. /**
  26787. * Size animation type
  26788. */
  26789. private static _ANIMATIONTYPE_SIZE;
  26790. /**
  26791. * Relative Loop Mode
  26792. */
  26793. private static _ANIMATIONLOOPMODE_RELATIVE;
  26794. /**
  26795. * Cycle Loop Mode
  26796. */
  26797. private static _ANIMATIONLOOPMODE_CYCLE;
  26798. /**
  26799. * Constant Loop Mode
  26800. */
  26801. private static _ANIMATIONLOOPMODE_CONSTANT;
  26802. /**
  26803. * Get the float animation type
  26804. */
  26805. static readonly ANIMATIONTYPE_FLOAT: number;
  26806. /**
  26807. * Get the Vector3 animation type
  26808. */
  26809. static readonly ANIMATIONTYPE_VECTOR3: number;
  26810. /**
  26811. * Get the Vector2 animation type
  26812. */
  26813. static readonly ANIMATIONTYPE_VECTOR2: number;
  26814. /**
  26815. * Get the Size animation type
  26816. */
  26817. static readonly ANIMATIONTYPE_SIZE: number;
  26818. /**
  26819. * Get the Quaternion animation type
  26820. */
  26821. static readonly ANIMATIONTYPE_QUATERNION: number;
  26822. /**
  26823. * Get the Matrix animation type
  26824. */
  26825. static readonly ANIMATIONTYPE_MATRIX: number;
  26826. /**
  26827. * Get the Color3 animation type
  26828. */
  26829. static readonly ANIMATIONTYPE_COLOR3: number;
  26830. /**
  26831. * Get the Relative Loop Mode
  26832. */
  26833. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26834. /**
  26835. * Get the Cycle Loop Mode
  26836. */
  26837. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26838. /**
  26839. * Get the Constant Loop Mode
  26840. */
  26841. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26842. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  26843. /**
  26844. * Parses an animation object and creates an animation
  26845. * @param parsedAnimation Parsed animation object
  26846. * @returns Animation object
  26847. */
  26848. static Parse(parsedAnimation: any): Animation;
  26849. /**
  26850. * Appends the serialized animations from the source animations
  26851. * @param source Source containing the animations
  26852. * @param destination Target to store the animations
  26853. */
  26854. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26855. }
  26856. }
  26857. declare module BABYLON {
  26858. /**
  26859. * Interface containing an array of animations
  26860. */
  26861. export interface IAnimatable {
  26862. /**
  26863. * Array of animations
  26864. */
  26865. animations: Nullable<Array<Animation>>;
  26866. }
  26867. }
  26868. declare module BABYLON {
  26869. /**
  26870. * This represents all the required information to add a fresnel effect on a material:
  26871. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26872. */
  26873. export class FresnelParameters {
  26874. private _isEnabled;
  26875. /**
  26876. * Define if the fresnel effect is enable or not.
  26877. */
  26878. isEnabled: boolean;
  26879. /**
  26880. * Define the color used on edges (grazing angle)
  26881. */
  26882. leftColor: Color3;
  26883. /**
  26884. * Define the color used on center
  26885. */
  26886. rightColor: Color3;
  26887. /**
  26888. * Define bias applied to computed fresnel term
  26889. */
  26890. bias: number;
  26891. /**
  26892. * Defined the power exponent applied to fresnel term
  26893. */
  26894. power: number;
  26895. /**
  26896. * Clones the current fresnel and its valuues
  26897. * @returns a clone fresnel configuration
  26898. */
  26899. clone(): FresnelParameters;
  26900. /**
  26901. * Serializes the current fresnel parameters to a JSON representation.
  26902. * @return the JSON serialization
  26903. */
  26904. serialize(): any;
  26905. /**
  26906. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26907. * @param parsedFresnelParameters Define the JSON representation
  26908. * @returns the parsed parameters
  26909. */
  26910. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26911. }
  26912. }
  26913. declare module BABYLON {
  26914. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  26915. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26916. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26917. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26918. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26919. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26920. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26921. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26922. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26923. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26924. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26925. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26926. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26927. /**
  26928. * Decorator used to define property that can be serialized as reference to a camera
  26929. * @param sourceName defines the name of the property to decorate
  26930. */
  26931. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26932. /**
  26933. * Class used to help serialization objects
  26934. */
  26935. export class SerializationHelper {
  26936. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  26937. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  26938. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  26939. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  26940. /**
  26941. * Appends the serialized animations from the source animations
  26942. * @param source Source containing the animations
  26943. * @param destination Target to store the animations
  26944. */
  26945. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26946. /**
  26947. * Static function used to serialized a specific entity
  26948. * @param entity defines the entity to serialize
  26949. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  26950. * @returns a JSON compatible object representing the serialization of the entity
  26951. */
  26952. static Serialize<T>(entity: T, serializationObject?: any): any;
  26953. /**
  26954. * Creates a new entity from a serialization data object
  26955. * @param creationFunction defines a function used to instanciated the new entity
  26956. * @param source defines the source serialization data
  26957. * @param scene defines the hosting scene
  26958. * @param rootUrl defines the root url for resources
  26959. * @returns a new entity
  26960. */
  26961. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  26962. /**
  26963. * Clones an object
  26964. * @param creationFunction defines the function used to instanciate the new object
  26965. * @param source defines the source object
  26966. * @returns the cloned object
  26967. */
  26968. static Clone<T>(creationFunction: () => T, source: T): T;
  26969. /**
  26970. * Instanciates a new object based on a source one (some data will be shared between both object)
  26971. * @param creationFunction defines the function used to instanciate the new object
  26972. * @param source defines the source object
  26973. * @returns the new object
  26974. */
  26975. static Instanciate<T>(creationFunction: () => T, source: T): T;
  26976. }
  26977. }
  26978. declare module BABYLON {
  26979. /**
  26980. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26981. */
  26982. export interface CubeMapInfo {
  26983. /**
  26984. * The pixel array for the front face.
  26985. * This is stored in format, left to right, up to down format.
  26986. */
  26987. front: Nullable<ArrayBufferView>;
  26988. /**
  26989. * The pixel array for the back face.
  26990. * This is stored in format, left to right, up to down format.
  26991. */
  26992. back: Nullable<ArrayBufferView>;
  26993. /**
  26994. * The pixel array for the left face.
  26995. * This is stored in format, left to right, up to down format.
  26996. */
  26997. left: Nullable<ArrayBufferView>;
  26998. /**
  26999. * The pixel array for the right face.
  27000. * This is stored in format, left to right, up to down format.
  27001. */
  27002. right: Nullable<ArrayBufferView>;
  27003. /**
  27004. * The pixel array for the up face.
  27005. * This is stored in format, left to right, up to down format.
  27006. */
  27007. up: Nullable<ArrayBufferView>;
  27008. /**
  27009. * The pixel array for the down face.
  27010. * This is stored in format, left to right, up to down format.
  27011. */
  27012. down: Nullable<ArrayBufferView>;
  27013. /**
  27014. * The size of the cubemap stored.
  27015. *
  27016. * Each faces will be size * size pixels.
  27017. */
  27018. size: number;
  27019. /**
  27020. * The format of the texture.
  27021. *
  27022. * RGBA, RGB.
  27023. */
  27024. format: number;
  27025. /**
  27026. * The type of the texture data.
  27027. *
  27028. * UNSIGNED_INT, FLOAT.
  27029. */
  27030. type: number;
  27031. /**
  27032. * Specifies whether the texture is in gamma space.
  27033. */
  27034. gammaSpace: boolean;
  27035. }
  27036. /**
  27037. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27038. */
  27039. export class PanoramaToCubeMapTools {
  27040. private static FACE_FRONT;
  27041. private static FACE_BACK;
  27042. private static FACE_RIGHT;
  27043. private static FACE_LEFT;
  27044. private static FACE_DOWN;
  27045. private static FACE_UP;
  27046. /**
  27047. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27048. *
  27049. * @param float32Array The source data.
  27050. * @param inputWidth The width of the input panorama.
  27051. * @param inputHeight The height of the input panorama.
  27052. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27053. * @return The cubemap data
  27054. */
  27055. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27056. private static CreateCubemapTexture;
  27057. private static CalcProjectionSpherical;
  27058. }
  27059. }
  27060. declare module BABYLON {
  27061. /**
  27062. * Helper class dealing with the extraction of spherical polynomial dataArray
  27063. * from a cube map.
  27064. */
  27065. export class CubeMapToSphericalPolynomialTools {
  27066. private static FileFaces;
  27067. /**
  27068. * Converts a texture to the according Spherical Polynomial data.
  27069. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27070. *
  27071. * @param texture The texture to extract the information from.
  27072. * @return The Spherical Polynomial data.
  27073. */
  27074. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27075. /**
  27076. * Converts a cubemap to the according Spherical Polynomial data.
  27077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27078. *
  27079. * @param cubeInfo The Cube map to extract the information from.
  27080. * @return The Spherical Polynomial data.
  27081. */
  27082. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27083. }
  27084. }
  27085. declare module BABYLON {
  27086. /**
  27087. * Class used to manipulate GUIDs
  27088. */
  27089. export class GUID {
  27090. /**
  27091. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27092. * Be aware Math.random() could cause collisions, but:
  27093. * "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"
  27094. * @returns a pseudo random id
  27095. */
  27096. static RandomId(): string;
  27097. }
  27098. }
  27099. declare module BABYLON {
  27100. /**
  27101. * Base class of all the textures in babylon.
  27102. * It groups all the common properties the materials, post process, lights... might need
  27103. * in order to make a correct use of the texture.
  27104. */
  27105. export class BaseTexture implements IAnimatable {
  27106. /**
  27107. * Default anisotropic filtering level for the application.
  27108. * It is set to 4 as a good tradeoff between perf and quality.
  27109. */
  27110. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27111. /**
  27112. * Gets or sets the unique id of the texture
  27113. */
  27114. uniqueId: number;
  27115. /**
  27116. * Define the name of the texture.
  27117. */
  27118. name: string;
  27119. /**
  27120. * Gets or sets an object used to store user defined information.
  27121. */
  27122. metadata: any;
  27123. /**
  27124. * For internal use only. Please do not use.
  27125. */
  27126. reservedDataStore: any;
  27127. private _hasAlpha;
  27128. /**
  27129. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27130. */
  27131. hasAlpha: boolean;
  27132. /**
  27133. * Defines if the alpha value should be determined via the rgb values.
  27134. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27135. */
  27136. getAlphaFromRGB: boolean;
  27137. /**
  27138. * Intensity or strength of the texture.
  27139. * It is commonly used by materials to fine tune the intensity of the texture
  27140. */
  27141. level: number;
  27142. /**
  27143. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27144. * This is part of the texture as textures usually maps to one uv set.
  27145. */
  27146. coordinatesIndex: number;
  27147. private _coordinatesMode;
  27148. /**
  27149. * How a texture is mapped.
  27150. *
  27151. * | Value | Type | Description |
  27152. * | ----- | ----------------------------------- | ----------- |
  27153. * | 0 | EXPLICIT_MODE | |
  27154. * | 1 | SPHERICAL_MODE | |
  27155. * | 2 | PLANAR_MODE | |
  27156. * | 3 | CUBIC_MODE | |
  27157. * | 4 | PROJECTION_MODE | |
  27158. * | 5 | SKYBOX_MODE | |
  27159. * | 6 | INVCUBIC_MODE | |
  27160. * | 7 | EQUIRECTANGULAR_MODE | |
  27161. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27162. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27163. */
  27164. coordinatesMode: number;
  27165. /**
  27166. * | Value | Type | Description |
  27167. * | ----- | ------------------ | ----------- |
  27168. * | 0 | CLAMP_ADDRESSMODE | |
  27169. * | 1 | WRAP_ADDRESSMODE | |
  27170. * | 2 | MIRROR_ADDRESSMODE | |
  27171. */
  27172. wrapU: number;
  27173. /**
  27174. * | Value | Type | Description |
  27175. * | ----- | ------------------ | ----------- |
  27176. * | 0 | CLAMP_ADDRESSMODE | |
  27177. * | 1 | WRAP_ADDRESSMODE | |
  27178. * | 2 | MIRROR_ADDRESSMODE | |
  27179. */
  27180. wrapV: number;
  27181. /**
  27182. * | Value | Type | Description |
  27183. * | ----- | ------------------ | ----------- |
  27184. * | 0 | CLAMP_ADDRESSMODE | |
  27185. * | 1 | WRAP_ADDRESSMODE | |
  27186. * | 2 | MIRROR_ADDRESSMODE | |
  27187. */
  27188. wrapR: number;
  27189. /**
  27190. * With compliant hardware and browser (supporting anisotropic filtering)
  27191. * this defines the level of anisotropic filtering in the texture.
  27192. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27193. */
  27194. anisotropicFilteringLevel: number;
  27195. /**
  27196. * Define if the texture is a cube texture or if false a 2d texture.
  27197. */
  27198. isCube: boolean;
  27199. /**
  27200. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27201. */
  27202. is3D: boolean;
  27203. /**
  27204. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27205. * HDR texture are usually stored in linear space.
  27206. * This only impacts the PBR and Background materials
  27207. */
  27208. gammaSpace: boolean;
  27209. /**
  27210. * Gets or sets whether or not the texture contains RGBD data.
  27211. */
  27212. isRGBD: boolean;
  27213. /**
  27214. * Is Z inverted in the texture (useful in a cube texture).
  27215. */
  27216. invertZ: boolean;
  27217. /**
  27218. * Are mip maps generated for this texture or not.
  27219. */
  27220. readonly noMipmap: boolean;
  27221. /**
  27222. * @hidden
  27223. */
  27224. lodLevelInAlpha: boolean;
  27225. /**
  27226. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27227. */
  27228. lodGenerationOffset: number;
  27229. /**
  27230. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27231. */
  27232. lodGenerationScale: number;
  27233. /**
  27234. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27235. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27236. * average roughness values.
  27237. */
  27238. linearSpecularLOD: boolean;
  27239. /**
  27240. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27241. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27242. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27243. */
  27244. irradianceTexture: Nullable<BaseTexture>;
  27245. /**
  27246. * Define if the texture is a render target.
  27247. */
  27248. isRenderTarget: boolean;
  27249. /**
  27250. * Define the unique id of the texture in the scene.
  27251. */
  27252. readonly uid: string;
  27253. /**
  27254. * Return a string representation of the texture.
  27255. * @returns the texture as a string
  27256. */
  27257. toString(): string;
  27258. /**
  27259. * Get the class name of the texture.
  27260. * @returns "BaseTexture"
  27261. */
  27262. getClassName(): string;
  27263. /**
  27264. * Define the list of animation attached to the texture.
  27265. */
  27266. animations: Animation[];
  27267. /**
  27268. * An event triggered when the texture is disposed.
  27269. */
  27270. onDisposeObservable: Observable<BaseTexture>;
  27271. private _onDisposeObserver;
  27272. /**
  27273. * Callback triggered when the texture has been disposed.
  27274. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27275. */
  27276. onDispose: () => void;
  27277. /**
  27278. * Define the current state of the loading sequence when in delayed load mode.
  27279. */
  27280. delayLoadState: number;
  27281. private _scene;
  27282. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27283. private _uid;
  27284. /**
  27285. * Define if the texture is preventinga material to render or not.
  27286. * If not and the texture is not ready, the engine will use a default black texture instead.
  27287. */
  27288. readonly isBlocking: boolean;
  27289. /**
  27290. * Instantiates a new BaseTexture.
  27291. * Base class of all the textures in babylon.
  27292. * It groups all the common properties the materials, post process, lights... might need
  27293. * in order to make a correct use of the texture.
  27294. * @param scene Define the scene the texture blongs to
  27295. */
  27296. constructor(scene: Nullable<Scene>);
  27297. /**
  27298. * Get the scene the texture belongs to.
  27299. * @returns the scene or null if undefined
  27300. */
  27301. getScene(): Nullable<Scene>;
  27302. /**
  27303. * Get the texture transform matrix used to offset tile the texture for istance.
  27304. * @returns the transformation matrix
  27305. */
  27306. getTextureMatrix(): Matrix;
  27307. /**
  27308. * Get the texture reflection matrix used to rotate/transform the reflection.
  27309. * @returns the reflection matrix
  27310. */
  27311. getReflectionTextureMatrix(): Matrix;
  27312. /**
  27313. * Get the underlying lower level texture from Babylon.
  27314. * @returns the insternal texture
  27315. */
  27316. getInternalTexture(): Nullable<InternalTexture>;
  27317. /**
  27318. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27319. * @returns true if ready or not blocking
  27320. */
  27321. isReadyOrNotBlocking(): boolean;
  27322. /**
  27323. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27324. * @returns true if fully ready
  27325. */
  27326. isReady(): boolean;
  27327. private _cachedSize;
  27328. /**
  27329. * Get the size of the texture.
  27330. * @returns the texture size.
  27331. */
  27332. getSize(): ISize;
  27333. /**
  27334. * Get the base size of the texture.
  27335. * It can be different from the size if the texture has been resized for POT for instance
  27336. * @returns the base size
  27337. */
  27338. getBaseSize(): ISize;
  27339. /**
  27340. * Update the sampling mode of the texture.
  27341. * Default is Trilinear mode.
  27342. *
  27343. * | Value | Type | Description |
  27344. * | ----- | ------------------ | ----------- |
  27345. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27346. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27347. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27348. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27349. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27350. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27351. * | 7 | NEAREST_LINEAR | |
  27352. * | 8 | NEAREST_NEAREST | |
  27353. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27354. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27355. * | 11 | LINEAR_LINEAR | |
  27356. * | 12 | LINEAR_NEAREST | |
  27357. *
  27358. * > _mag_: magnification filter (close to the viewer)
  27359. * > _min_: minification filter (far from the viewer)
  27360. * > _mip_: filter used between mip map levels
  27361. *@param samplingMode Define the new sampling mode of the texture
  27362. */
  27363. updateSamplingMode(samplingMode: number): void;
  27364. /**
  27365. * Scales the texture if is `canRescale()`
  27366. * @param ratio the resize factor we want to use to rescale
  27367. */
  27368. scale(ratio: number): void;
  27369. /**
  27370. * Get if the texture can rescale.
  27371. */
  27372. readonly canRescale: boolean;
  27373. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27374. /** @hidden */ private _rebuild(): void;
  27375. /**
  27376. * Triggers the load sequence in delayed load mode.
  27377. */
  27378. delayLoad(): void;
  27379. /**
  27380. * Clones the texture.
  27381. * @returns the cloned texture
  27382. */
  27383. clone(): Nullable<BaseTexture>;
  27384. /**
  27385. * Get the texture underlying type (INT, FLOAT...)
  27386. */
  27387. readonly textureType: number;
  27388. /**
  27389. * Get the texture underlying format (RGB, RGBA...)
  27390. */
  27391. readonly textureFormat: number;
  27392. /**
  27393. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27394. * This will returns an RGBA array buffer containing either in values (0-255) or
  27395. * float values (0-1) depending of the underlying buffer type.
  27396. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27397. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27398. * @param buffer defines a user defined buffer to fill with data (can be null)
  27399. * @returns The Array buffer containing the pixels data.
  27400. */
  27401. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27402. /**
  27403. * Release and destroy the underlying lower level texture aka internalTexture.
  27404. */
  27405. releaseInternalTexture(): void;
  27406. /**
  27407. * Get the polynomial representation of the texture data.
  27408. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27409. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27410. */
  27411. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27412. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27413. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27414. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27415. /**
  27416. * Dispose the texture and release its associated resources.
  27417. */
  27418. dispose(): void;
  27419. /**
  27420. * Serialize the texture into a JSON representation that can be parsed later on.
  27421. * @returns the JSON representation of the texture
  27422. */
  27423. serialize(): any;
  27424. /**
  27425. * Helper function to be called back once a list of texture contains only ready textures.
  27426. * @param textures Define the list of textures to wait for
  27427. * @param callback Define the callback triggered once the entire list will be ready
  27428. */
  27429. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27430. }
  27431. }
  27432. declare module BABYLON {
  27433. /**
  27434. * Class used to store data associated with WebGL texture data for the engine
  27435. * This class should not be used directly
  27436. */
  27437. export class InternalTexture {
  27438. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27439. /**
  27440. * The source of the texture data is unknown
  27441. */
  27442. static DATASOURCE_UNKNOWN: number;
  27443. /**
  27444. * Texture data comes from an URL
  27445. */
  27446. static DATASOURCE_URL: number;
  27447. /**
  27448. * Texture data is only used for temporary storage
  27449. */
  27450. static DATASOURCE_TEMP: number;
  27451. /**
  27452. * Texture data comes from raw data (ArrayBuffer)
  27453. */
  27454. static DATASOURCE_RAW: number;
  27455. /**
  27456. * Texture content is dynamic (video or dynamic texture)
  27457. */
  27458. static DATASOURCE_DYNAMIC: number;
  27459. /**
  27460. * Texture content is generated by rendering to it
  27461. */
  27462. static DATASOURCE_RENDERTARGET: number;
  27463. /**
  27464. * Texture content is part of a multi render target process
  27465. */
  27466. static DATASOURCE_MULTIRENDERTARGET: number;
  27467. /**
  27468. * Texture data comes from a cube data file
  27469. */
  27470. static DATASOURCE_CUBE: number;
  27471. /**
  27472. * Texture data comes from a raw cube data
  27473. */
  27474. static DATASOURCE_CUBERAW: number;
  27475. /**
  27476. * Texture data come from a prefiltered cube data file
  27477. */
  27478. static DATASOURCE_CUBEPREFILTERED: number;
  27479. /**
  27480. * Texture content is raw 3D data
  27481. */
  27482. static DATASOURCE_RAW3D: number;
  27483. /**
  27484. * Texture content is a depth texture
  27485. */
  27486. static DATASOURCE_DEPTHTEXTURE: number;
  27487. /**
  27488. * Texture data comes from a raw cube data encoded with RGBD
  27489. */
  27490. static DATASOURCE_CUBERAW_RGBD: number;
  27491. /**
  27492. * Defines if the texture is ready
  27493. */
  27494. isReady: boolean;
  27495. /**
  27496. * Defines if the texture is a cube texture
  27497. */
  27498. isCube: boolean;
  27499. /**
  27500. * Defines if the texture contains 3D data
  27501. */
  27502. is3D: boolean;
  27503. /**
  27504. * Defines if the texture contains multiview data
  27505. */
  27506. isMultiview: boolean;
  27507. /**
  27508. * Gets the URL used to load this texture
  27509. */
  27510. url: string;
  27511. /**
  27512. * Gets the sampling mode of the texture
  27513. */
  27514. samplingMode: number;
  27515. /**
  27516. * Gets a boolean indicating if the texture needs mipmaps generation
  27517. */
  27518. generateMipMaps: boolean;
  27519. /**
  27520. * Gets the number of samples used by the texture (WebGL2+ only)
  27521. */
  27522. samples: number;
  27523. /**
  27524. * Gets the type of the texture (int, float...)
  27525. */
  27526. type: number;
  27527. /**
  27528. * Gets the format of the texture (RGB, RGBA...)
  27529. */
  27530. format: number;
  27531. /**
  27532. * Observable called when the texture is loaded
  27533. */
  27534. onLoadedObservable: Observable<InternalTexture>;
  27535. /**
  27536. * Gets the width of the texture
  27537. */
  27538. width: number;
  27539. /**
  27540. * Gets the height of the texture
  27541. */
  27542. height: number;
  27543. /**
  27544. * Gets the depth of the texture
  27545. */
  27546. depth: number;
  27547. /**
  27548. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27549. */
  27550. baseWidth: number;
  27551. /**
  27552. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27553. */
  27554. baseHeight: number;
  27555. /**
  27556. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27557. */
  27558. baseDepth: number;
  27559. /**
  27560. * Gets a boolean indicating if the texture is inverted on Y axis
  27561. */
  27562. invertY: boolean;
  27563. /** @hidden */ private _invertVScale: boolean;
  27564. /** @hidden */ private _associatedChannel: number;
  27565. /** @hidden */ private _dataSource: number;
  27566. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  27567. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  27568. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  27569. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27570. /** @hidden */ private _size: number;
  27571. /** @hidden */ private _extension: string;
  27572. /** @hidden */ private _files: Nullable<string[]>;
  27573. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27574. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27575. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  27576. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27577. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27578. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27579. /** @hidden */ private _attachments: Nullable<number[]>;
  27580. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  27581. /** @hidden */ private _cachedWrapU: Nullable<number>;
  27582. /** @hidden */ private _cachedWrapV: Nullable<number>;
  27583. /** @hidden */ private _cachedWrapR: Nullable<number>;
  27584. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  27585. /** @hidden */ private _isDisabled: boolean;
  27586. /** @hidden */ private _compression: Nullable<string>;
  27587. /** @hidden */ private _generateStencilBuffer: boolean;
  27588. /** @hidden */ private _generateDepthBuffer: boolean;
  27589. /** @hidden */ private _comparisonFunction: number;
  27590. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27591. /** @hidden */ private _lodGenerationScale: number;
  27592. /** @hidden */ private _lodGenerationOffset: number;
  27593. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  27594. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  27595. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  27596. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  27597. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  27598. /** @hidden */ private _isRGBD: boolean;
  27599. /** @hidden */ private _linearSpecularLOD: boolean;
  27600. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  27601. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  27602. /** @hidden */ private _references: number;
  27603. private _engine;
  27604. /**
  27605. * Gets the Engine the texture belongs to.
  27606. * @returns The babylon engine
  27607. */
  27608. getEngine(): Engine;
  27609. /**
  27610. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  27611. */
  27612. readonly dataSource: number;
  27613. /**
  27614. * Creates a new InternalTexture
  27615. * @param engine defines the engine to use
  27616. * @param dataSource defines the type of data that will be used
  27617. * @param delayAllocation if the texture allocation should be delayed (default: false)
  27618. */
  27619. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  27620. /**
  27621. * Increments the number of references (ie. the number of Texture that point to it)
  27622. */
  27623. incrementReferences(): void;
  27624. /**
  27625. * Change the size of the texture (not the size of the content)
  27626. * @param width defines the new width
  27627. * @param height defines the new height
  27628. * @param depth defines the new depth (1 by default)
  27629. */
  27630. updateSize(width: int, height: int, depth?: int): void;
  27631. /** @hidden */ private _rebuild(): void;
  27632. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  27633. /**
  27634. * Dispose the current allocated resources
  27635. */
  27636. dispose(): void;
  27637. }
  27638. }
  27639. declare module BABYLON {
  27640. /**
  27641. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27642. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27643. */
  27644. export class EffectFallbacks {
  27645. private _defines;
  27646. private _currentRank;
  27647. private _maxRank;
  27648. private _mesh;
  27649. /**
  27650. * Removes the fallback from the bound mesh.
  27651. */
  27652. unBindMesh(): void;
  27653. /**
  27654. * Adds a fallback on the specified property.
  27655. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27656. * @param define The name of the define in the shader
  27657. */
  27658. addFallback(rank: number, define: string): void;
  27659. /**
  27660. * Sets the mesh to use CPU skinning when needing to fallback.
  27661. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27662. * @param mesh The mesh to use the fallbacks.
  27663. */
  27664. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27665. /**
  27666. * Checks to see if more fallbacks are still availible.
  27667. */
  27668. readonly hasMoreFallbacks: boolean;
  27669. /**
  27670. * Removes the defines that should be removed when falling back.
  27671. * @param currentDefines defines the current define statements for the shader.
  27672. * @param effect defines the current effect we try to compile
  27673. * @returns The resulting defines with defines of the current rank removed.
  27674. */
  27675. reduce(currentDefines: string, effect: Effect): string;
  27676. }
  27677. /**
  27678. * Options to be used when creating an effect.
  27679. */
  27680. export class EffectCreationOptions {
  27681. /**
  27682. * Atrributes that will be used in the shader.
  27683. */
  27684. attributes: string[];
  27685. /**
  27686. * Uniform varible names that will be set in the shader.
  27687. */
  27688. uniformsNames: string[];
  27689. /**
  27690. * Uniform buffer varible names that will be set in the shader.
  27691. */
  27692. uniformBuffersNames: string[];
  27693. /**
  27694. * Sampler texture variable names that will be set in the shader.
  27695. */
  27696. samplers: string[];
  27697. /**
  27698. * Define statements that will be set in the shader.
  27699. */
  27700. defines: any;
  27701. /**
  27702. * Possible fallbacks for this effect to improve performance when needed.
  27703. */
  27704. fallbacks: Nullable<EffectFallbacks>;
  27705. /**
  27706. * Callback that will be called when the shader is compiled.
  27707. */
  27708. onCompiled: Nullable<(effect: Effect) => void>;
  27709. /**
  27710. * Callback that will be called if an error occurs during shader compilation.
  27711. */
  27712. onError: Nullable<(effect: Effect, errors: string) => void>;
  27713. /**
  27714. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27715. */
  27716. indexParameters: any;
  27717. /**
  27718. * Max number of lights that can be used in the shader.
  27719. */
  27720. maxSimultaneousLights: number;
  27721. /**
  27722. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27723. */
  27724. transformFeedbackVaryings: Nullable<string[]>;
  27725. }
  27726. /**
  27727. * Effect containing vertex and fragment shader that can be executed on an object.
  27728. */
  27729. export class Effect implements IDisposable {
  27730. /**
  27731. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27732. */
  27733. static ShadersRepository: string;
  27734. /**
  27735. * Name of the effect.
  27736. */
  27737. name: any;
  27738. /**
  27739. * String container all the define statements that should be set on the shader.
  27740. */
  27741. defines: string;
  27742. /**
  27743. * Callback that will be called when the shader is compiled.
  27744. */
  27745. onCompiled: Nullable<(effect: Effect) => void>;
  27746. /**
  27747. * Callback that will be called if an error occurs during shader compilation.
  27748. */
  27749. onError: Nullable<(effect: Effect, errors: string) => void>;
  27750. /**
  27751. * Callback that will be called when effect is bound.
  27752. */
  27753. onBind: Nullable<(effect: Effect) => void>;
  27754. /**
  27755. * Unique ID of the effect.
  27756. */
  27757. uniqueId: number;
  27758. /**
  27759. * Observable that will be called when the shader is compiled.
  27760. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27761. */
  27762. onCompileObservable: Observable<Effect>;
  27763. /**
  27764. * Observable that will be called if an error occurs during shader compilation.
  27765. */
  27766. onErrorObservable: Observable<Effect>;
  27767. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27768. /**
  27769. * Observable that will be called when effect is bound.
  27770. */
  27771. readonly onBindObservable: Observable<Effect>;
  27772. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27773. private static _uniqueIdSeed;
  27774. private _engine;
  27775. private _uniformBuffersNames;
  27776. private _uniformsNames;
  27777. private _samplerList;
  27778. private _samplers;
  27779. private _isReady;
  27780. private _compilationError;
  27781. private _attributesNames;
  27782. private _attributes;
  27783. private _uniforms;
  27784. /**
  27785. * Key for the effect.
  27786. * @hidden
  27787. */ private _key: string;
  27788. private _indexParameters;
  27789. private _fallbacks;
  27790. private _vertexSourceCode;
  27791. private _fragmentSourceCode;
  27792. private _vertexSourceCodeOverride;
  27793. private _fragmentSourceCodeOverride;
  27794. private _transformFeedbackVaryings;
  27795. /**
  27796. * Compiled shader to webGL program.
  27797. * @hidden
  27798. */ private _pipelineContext: Nullable<IPipelineContext>;
  27799. private _valueCache;
  27800. private static _baseCache;
  27801. /**
  27802. * Instantiates an effect.
  27803. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27804. * @param baseName Name of the effect.
  27805. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27806. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27807. * @param samplers List of sampler variables that will be passed to the shader.
  27808. * @param engine Engine to be used to render the effect
  27809. * @param defines Define statements to be added to the shader.
  27810. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27811. * @param onCompiled Callback that will be called when the shader is compiled.
  27812. * @param onError Callback that will be called if an error occurs during shader compilation.
  27813. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27814. */
  27815. 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);
  27816. private _useFinalCode;
  27817. /**
  27818. * Unique key for this effect
  27819. */
  27820. readonly key: string;
  27821. /**
  27822. * If the effect has been compiled and prepared.
  27823. * @returns if the effect is compiled and prepared.
  27824. */
  27825. isReady(): boolean;
  27826. private _isReadyInternal;
  27827. /**
  27828. * The engine the effect was initialized with.
  27829. * @returns the engine.
  27830. */
  27831. getEngine(): Engine;
  27832. /**
  27833. * The pipeline context for this effect
  27834. * @returns the associated pipeline context
  27835. */
  27836. getPipelineContext(): Nullable<IPipelineContext>;
  27837. /**
  27838. * The set of names of attribute variables for the shader.
  27839. * @returns An array of attribute names.
  27840. */
  27841. getAttributesNames(): string[];
  27842. /**
  27843. * Returns the attribute at the given index.
  27844. * @param index The index of the attribute.
  27845. * @returns The location of the attribute.
  27846. */
  27847. getAttributeLocation(index: number): number;
  27848. /**
  27849. * Returns the attribute based on the name of the variable.
  27850. * @param name of the attribute to look up.
  27851. * @returns the attribute location.
  27852. */
  27853. getAttributeLocationByName(name: string): number;
  27854. /**
  27855. * The number of attributes.
  27856. * @returns the numnber of attributes.
  27857. */
  27858. getAttributesCount(): number;
  27859. /**
  27860. * Gets the index of a uniform variable.
  27861. * @param uniformName of the uniform to look up.
  27862. * @returns the index.
  27863. */
  27864. getUniformIndex(uniformName: string): number;
  27865. /**
  27866. * Returns the attribute based on the name of the variable.
  27867. * @param uniformName of the uniform to look up.
  27868. * @returns the location of the uniform.
  27869. */
  27870. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27871. /**
  27872. * Returns an array of sampler variable names
  27873. * @returns The array of sampler variable neames.
  27874. */
  27875. getSamplers(): string[];
  27876. /**
  27877. * The error from the last compilation.
  27878. * @returns the error string.
  27879. */
  27880. getCompilationError(): string;
  27881. /**
  27882. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27883. * @param func The callback to be used.
  27884. */
  27885. executeWhenCompiled(func: (effect: Effect) => void): void;
  27886. private _checkIsReady;
  27887. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27888. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27889. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27890. /**
  27891. * Recompiles the webGL program
  27892. * @param vertexSourceCode The source code for the vertex shader.
  27893. * @param fragmentSourceCode The source code for the fragment shader.
  27894. * @param onCompiled Callback called when completed.
  27895. * @param onError Callback called on error.
  27896. * @hidden
  27897. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27898. /**
  27899. * Prepares the effect
  27900. * @hidden
  27901. */ private _prepareEffect(): void;
  27902. private _processCompilationErrors;
  27903. /**
  27904. * Checks if the effect is supported. (Must be called after compilation)
  27905. */
  27906. readonly isSupported: boolean;
  27907. /**
  27908. * Binds a texture to the engine to be used as output of the shader.
  27909. * @param channel Name of the output variable.
  27910. * @param texture Texture to bind.
  27911. * @hidden
  27912. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27913. /**
  27914. * Sets a texture on the engine to be used in the shader.
  27915. * @param channel Name of the sampler variable.
  27916. * @param texture Texture to set.
  27917. */
  27918. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27919. /**
  27920. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27921. * @param channel Name of the sampler variable.
  27922. * @param texture Texture to set.
  27923. */
  27924. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27925. /**
  27926. * Sets an array of textures on the engine to be used in the shader.
  27927. * @param channel Name of the variable.
  27928. * @param textures Textures to set.
  27929. */
  27930. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27931. /**
  27932. * 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)
  27933. * @param channel Name of the sampler variable.
  27934. * @param postProcess Post process to get the input texture from.
  27935. */
  27936. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27937. /**
  27938. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27939. * 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)
  27940. * @param channel Name of the sampler variable.
  27941. * @param postProcess Post process to get the output texture from.
  27942. */
  27943. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27944. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27945. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27946. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27947. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27948. /**
  27949. * Binds a buffer to a uniform.
  27950. * @param buffer Buffer to bind.
  27951. * @param name Name of the uniform variable to bind to.
  27952. */
  27953. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27954. /**
  27955. * Binds block to a uniform.
  27956. * @param blockName Name of the block to bind.
  27957. * @param index Index to bind.
  27958. */
  27959. bindUniformBlock(blockName: string, index: number): void;
  27960. /**
  27961. * Sets an interger value on a uniform variable.
  27962. * @param uniformName Name of the variable.
  27963. * @param value Value to be set.
  27964. * @returns this effect.
  27965. */
  27966. setInt(uniformName: string, value: number): Effect;
  27967. /**
  27968. * Sets an int array on a uniform variable.
  27969. * @param uniformName Name of the variable.
  27970. * @param array array to be set.
  27971. * @returns this effect.
  27972. */
  27973. setIntArray(uniformName: string, array: Int32Array): Effect;
  27974. /**
  27975. * 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)
  27976. * @param uniformName Name of the variable.
  27977. * @param array array to be set.
  27978. * @returns this effect.
  27979. */
  27980. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27981. /**
  27982. * 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)
  27983. * @param uniformName Name of the variable.
  27984. * @param array array to be set.
  27985. * @returns this effect.
  27986. */
  27987. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27988. /**
  27989. * 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)
  27990. * @param uniformName Name of the variable.
  27991. * @param array array to be set.
  27992. * @returns this effect.
  27993. */
  27994. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27995. /**
  27996. * Sets an float array on a uniform variable.
  27997. * @param uniformName Name of the variable.
  27998. * @param array array to be set.
  27999. * @returns this effect.
  28000. */
  28001. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28002. /**
  28003. * 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)
  28004. * @param uniformName Name of the variable.
  28005. * @param array array to be set.
  28006. * @returns this effect.
  28007. */
  28008. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28009. /**
  28010. * 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)
  28011. * @param uniformName Name of the variable.
  28012. * @param array array to be set.
  28013. * @returns this effect.
  28014. */
  28015. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28016. /**
  28017. * 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)
  28018. * @param uniformName Name of the variable.
  28019. * @param array array to be set.
  28020. * @returns this effect.
  28021. */
  28022. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28023. /**
  28024. * Sets an array on a uniform variable.
  28025. * @param uniformName Name of the variable.
  28026. * @param array array to be set.
  28027. * @returns this effect.
  28028. */
  28029. setArray(uniformName: string, array: number[]): Effect;
  28030. /**
  28031. * 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)
  28032. * @param uniformName Name of the variable.
  28033. * @param array array to be set.
  28034. * @returns this effect.
  28035. */
  28036. setArray2(uniformName: string, array: number[]): Effect;
  28037. /**
  28038. * 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)
  28039. * @param uniformName Name of the variable.
  28040. * @param array array to be set.
  28041. * @returns this effect.
  28042. */
  28043. setArray3(uniformName: string, array: number[]): Effect;
  28044. /**
  28045. * 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)
  28046. * @param uniformName Name of the variable.
  28047. * @param array array to be set.
  28048. * @returns this effect.
  28049. */
  28050. setArray4(uniformName: string, array: number[]): Effect;
  28051. /**
  28052. * Sets matrices on a uniform variable.
  28053. * @param uniformName Name of the variable.
  28054. * @param matrices matrices to be set.
  28055. * @returns this effect.
  28056. */
  28057. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28058. /**
  28059. * Sets matrix on a uniform variable.
  28060. * @param uniformName Name of the variable.
  28061. * @param matrix matrix to be set.
  28062. * @returns this effect.
  28063. */
  28064. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28065. /**
  28066. * 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)
  28067. * @param uniformName Name of the variable.
  28068. * @param matrix matrix to be set.
  28069. * @returns this effect.
  28070. */
  28071. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28072. /**
  28073. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28074. * @param uniformName Name of the variable.
  28075. * @param matrix matrix to be set.
  28076. * @returns this effect.
  28077. */
  28078. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28079. /**
  28080. * Sets a float on a uniform variable.
  28081. * @param uniformName Name of the variable.
  28082. * @param value value to be set.
  28083. * @returns this effect.
  28084. */
  28085. setFloat(uniformName: string, value: number): Effect;
  28086. /**
  28087. * Sets a boolean on a uniform variable.
  28088. * @param uniformName Name of the variable.
  28089. * @param bool value to be set.
  28090. * @returns this effect.
  28091. */
  28092. setBool(uniformName: string, bool: boolean): Effect;
  28093. /**
  28094. * Sets a Vector2 on a uniform variable.
  28095. * @param uniformName Name of the variable.
  28096. * @param vector2 vector2 to be set.
  28097. * @returns this effect.
  28098. */
  28099. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28100. /**
  28101. * Sets a float2 on a uniform variable.
  28102. * @param uniformName Name of the variable.
  28103. * @param x First float in float2.
  28104. * @param y Second float in float2.
  28105. * @returns this effect.
  28106. */
  28107. setFloat2(uniformName: string, x: number, y: number): Effect;
  28108. /**
  28109. * Sets a Vector3 on a uniform variable.
  28110. * @param uniformName Name of the variable.
  28111. * @param vector3 Value to be set.
  28112. * @returns this effect.
  28113. */
  28114. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28115. /**
  28116. * Sets a float3 on a uniform variable.
  28117. * @param uniformName Name of the variable.
  28118. * @param x First float in float3.
  28119. * @param y Second float in float3.
  28120. * @param z Third float in float3.
  28121. * @returns this effect.
  28122. */
  28123. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28124. /**
  28125. * Sets a Vector4 on a uniform variable.
  28126. * @param uniformName Name of the variable.
  28127. * @param vector4 Value to be set.
  28128. * @returns this effect.
  28129. */
  28130. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28131. /**
  28132. * Sets a float4 on a uniform variable.
  28133. * @param uniformName Name of the variable.
  28134. * @param x First float in float4.
  28135. * @param y Second float in float4.
  28136. * @param z Third float in float4.
  28137. * @param w Fourth float in float4.
  28138. * @returns this effect.
  28139. */
  28140. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28141. /**
  28142. * Sets a Color3 on a uniform variable.
  28143. * @param uniformName Name of the variable.
  28144. * @param color3 Value to be set.
  28145. * @returns this effect.
  28146. */
  28147. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28148. /**
  28149. * Sets a Color4 on a uniform variable.
  28150. * @param uniformName Name of the variable.
  28151. * @param color3 Value to be set.
  28152. * @param alpha Alpha value to be set.
  28153. * @returns this effect.
  28154. */
  28155. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28156. /**
  28157. * Sets a Color4 on a uniform variable
  28158. * @param uniformName defines the name of the variable
  28159. * @param color4 defines the value to be set
  28160. * @returns this effect.
  28161. */
  28162. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28163. /** Release all associated resources */
  28164. dispose(): void;
  28165. /**
  28166. * This function will add a new shader to the shader store
  28167. * @param name the name of the shader
  28168. * @param pixelShader optional pixel shader content
  28169. * @param vertexShader optional vertex shader content
  28170. */
  28171. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28172. /**
  28173. * Store of each shader (The can be looked up using effect.key)
  28174. */
  28175. static ShadersStore: {
  28176. [key: string]: string;
  28177. };
  28178. /**
  28179. * Store of each included file for a shader (The can be looked up using effect.key)
  28180. */
  28181. static IncludesShadersStore: {
  28182. [key: string]: string;
  28183. };
  28184. /**
  28185. * Resets the cache of effects.
  28186. */
  28187. static ResetCache(): void;
  28188. }
  28189. }
  28190. declare module BABYLON {
  28191. /**
  28192. * Uniform buffer objects.
  28193. *
  28194. * Handles blocks of uniform on the GPU.
  28195. *
  28196. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28197. *
  28198. * For more information, please refer to :
  28199. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28200. */
  28201. export class UniformBuffer {
  28202. private _engine;
  28203. private _buffer;
  28204. private _data;
  28205. private _bufferData;
  28206. private _dynamic?;
  28207. private _uniformLocations;
  28208. private _uniformSizes;
  28209. private _uniformLocationPointer;
  28210. private _needSync;
  28211. private _noUBO;
  28212. private _currentEffect;
  28213. private static _MAX_UNIFORM_SIZE;
  28214. private static _tempBuffer;
  28215. /**
  28216. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28217. * This is dynamic to allow compat with webgl 1 and 2.
  28218. * You will need to pass the name of the uniform as well as the value.
  28219. */
  28220. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28221. /**
  28222. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28223. * This is dynamic to allow compat with webgl 1 and 2.
  28224. * You will need to pass the name of the uniform as well as the value.
  28225. */
  28226. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28227. /**
  28228. * Lambda to Update a single float in a uniform buffer.
  28229. * This is dynamic to allow compat with webgl 1 and 2.
  28230. * You will need to pass the name of the uniform as well as the value.
  28231. */
  28232. updateFloat: (name: string, x: number) => void;
  28233. /**
  28234. * Lambda to Update a vec2 of float in a uniform buffer.
  28235. * This is dynamic to allow compat with webgl 1 and 2.
  28236. * You will need to pass the name of the uniform as well as the value.
  28237. */
  28238. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28239. /**
  28240. * Lambda to Update a vec3 of float in a uniform buffer.
  28241. * This is dynamic to allow compat with webgl 1 and 2.
  28242. * You will need to pass the name of the uniform as well as the value.
  28243. */
  28244. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28245. /**
  28246. * Lambda to Update a vec4 of float in a uniform buffer.
  28247. * This is dynamic to allow compat with webgl 1 and 2.
  28248. * You will need to pass the name of the uniform as well as the value.
  28249. */
  28250. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28251. /**
  28252. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28253. * This is dynamic to allow compat with webgl 1 and 2.
  28254. * You will need to pass the name of the uniform as well as the value.
  28255. */
  28256. updateMatrix: (name: string, mat: Matrix) => void;
  28257. /**
  28258. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28259. * This is dynamic to allow compat with webgl 1 and 2.
  28260. * You will need to pass the name of the uniform as well as the value.
  28261. */
  28262. updateVector3: (name: string, vector: Vector3) => void;
  28263. /**
  28264. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28265. * This is dynamic to allow compat with webgl 1 and 2.
  28266. * You will need to pass the name of the uniform as well as the value.
  28267. */
  28268. updateVector4: (name: string, vector: Vector4) => void;
  28269. /**
  28270. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28271. * This is dynamic to allow compat with webgl 1 and 2.
  28272. * You will need to pass the name of the uniform as well as the value.
  28273. */
  28274. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28275. /**
  28276. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28277. * This is dynamic to allow compat with webgl 1 and 2.
  28278. * You will need to pass the name of the uniform as well as the value.
  28279. */
  28280. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28281. /**
  28282. * Instantiates a new Uniform buffer objects.
  28283. *
  28284. * Handles blocks of uniform on the GPU.
  28285. *
  28286. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28287. *
  28288. * For more information, please refer to :
  28289. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28290. * @param engine Define the engine the buffer is associated with
  28291. * @param data Define the data contained in the buffer
  28292. * @param dynamic Define if the buffer is updatable
  28293. */
  28294. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28295. /**
  28296. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28297. * or just falling back on setUniformXXX calls.
  28298. */
  28299. readonly useUbo: boolean;
  28300. /**
  28301. * Indicates if the WebGL underlying uniform buffer is in sync
  28302. * with the javascript cache data.
  28303. */
  28304. readonly isSync: boolean;
  28305. /**
  28306. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28307. * Also, a dynamic UniformBuffer will disable cache verification and always
  28308. * update the underlying WebGL uniform buffer to the GPU.
  28309. * @returns if Dynamic, otherwise false
  28310. */
  28311. isDynamic(): boolean;
  28312. /**
  28313. * The data cache on JS side.
  28314. * @returns the underlying data as a float array
  28315. */
  28316. getData(): Float32Array;
  28317. /**
  28318. * The underlying WebGL Uniform buffer.
  28319. * @returns the webgl buffer
  28320. */
  28321. getBuffer(): Nullable<DataBuffer>;
  28322. /**
  28323. * std140 layout specifies how to align data within an UBO structure.
  28324. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28325. * for specs.
  28326. */
  28327. private _fillAlignment;
  28328. /**
  28329. * Adds an uniform in the buffer.
  28330. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28331. * for the layout to be correct !
  28332. * @param name Name of the uniform, as used in the uniform block in the shader.
  28333. * @param size Data size, or data directly.
  28334. */
  28335. addUniform(name: string, size: number | number[]): void;
  28336. /**
  28337. * Adds a Matrix 4x4 to the uniform buffer.
  28338. * @param name Name of the uniform, as used in the uniform block in the shader.
  28339. * @param mat A 4x4 matrix.
  28340. */
  28341. addMatrix(name: string, mat: Matrix): void;
  28342. /**
  28343. * Adds a vec2 to the uniform buffer.
  28344. * @param name Name of the uniform, as used in the uniform block in the shader.
  28345. * @param x Define the x component value of the vec2
  28346. * @param y Define the y component value of the vec2
  28347. */
  28348. addFloat2(name: string, x: number, y: number): void;
  28349. /**
  28350. * Adds a vec3 to the uniform buffer.
  28351. * @param name Name of the uniform, as used in the uniform block in the shader.
  28352. * @param x Define the x component value of the vec3
  28353. * @param y Define the y component value of the vec3
  28354. * @param z Define the z component value of the vec3
  28355. */
  28356. addFloat3(name: string, x: number, y: number, z: number): void;
  28357. /**
  28358. * Adds a vec3 to the uniform buffer.
  28359. * @param name Name of the uniform, as used in the uniform block in the shader.
  28360. * @param color Define the vec3 from a Color
  28361. */
  28362. addColor3(name: string, color: Color3): void;
  28363. /**
  28364. * Adds a vec4 to the uniform buffer.
  28365. * @param name Name of the uniform, as used in the uniform block in the shader.
  28366. * @param color Define the rgb components from a Color
  28367. * @param alpha Define the a component of the vec4
  28368. */
  28369. addColor4(name: string, color: Color3, alpha: number): void;
  28370. /**
  28371. * Adds a vec3 to the uniform buffer.
  28372. * @param name Name of the uniform, as used in the uniform block in the shader.
  28373. * @param vector Define the vec3 components from a Vector
  28374. */
  28375. addVector3(name: string, vector: Vector3): void;
  28376. /**
  28377. * Adds a Matrix 3x3 to the uniform buffer.
  28378. * @param name Name of the uniform, as used in the uniform block in the shader.
  28379. */
  28380. addMatrix3x3(name: string): void;
  28381. /**
  28382. * Adds a Matrix 2x2 to the uniform buffer.
  28383. * @param name Name of the uniform, as used in the uniform block in the shader.
  28384. */
  28385. addMatrix2x2(name: string): void;
  28386. /**
  28387. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28388. */
  28389. create(): void;
  28390. /** @hidden */ private _rebuild(): void;
  28391. /**
  28392. * Updates the WebGL Uniform Buffer on the GPU.
  28393. * If the `dynamic` flag is set to true, no cache comparison is done.
  28394. * Otherwise, the buffer will be updated only if the cache differs.
  28395. */
  28396. update(): void;
  28397. /**
  28398. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28399. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28400. * @param data Define the flattened data
  28401. * @param size Define the size of the data.
  28402. */
  28403. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28404. private _valueCache;
  28405. private _cacheMatrix;
  28406. private _updateMatrix3x3ForUniform;
  28407. private _updateMatrix3x3ForEffect;
  28408. private _updateMatrix2x2ForEffect;
  28409. private _updateMatrix2x2ForUniform;
  28410. private _updateFloatForEffect;
  28411. private _updateFloatForUniform;
  28412. private _updateFloat2ForEffect;
  28413. private _updateFloat2ForUniform;
  28414. private _updateFloat3ForEffect;
  28415. private _updateFloat3ForUniform;
  28416. private _updateFloat4ForEffect;
  28417. private _updateFloat4ForUniform;
  28418. private _updateMatrixForEffect;
  28419. private _updateMatrixForUniform;
  28420. private _updateVector3ForEffect;
  28421. private _updateVector3ForUniform;
  28422. private _updateVector4ForEffect;
  28423. private _updateVector4ForUniform;
  28424. private _updateColor3ForEffect;
  28425. private _updateColor3ForUniform;
  28426. private _updateColor4ForEffect;
  28427. private _updateColor4ForUniform;
  28428. /**
  28429. * Sets a sampler uniform on the effect.
  28430. * @param name Define the name of the sampler.
  28431. * @param texture Define the texture to set in the sampler
  28432. */
  28433. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28434. /**
  28435. * Directly updates the value of the uniform in the cache AND on the GPU.
  28436. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28437. * @param data Define the flattened data
  28438. */
  28439. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28440. /**
  28441. * Binds this uniform buffer to an effect.
  28442. * @param effect Define the effect to bind the buffer to
  28443. * @param name Name of the uniform block in the shader.
  28444. */
  28445. bindToEffect(effect: Effect, name: string): void;
  28446. /**
  28447. * Disposes the uniform buffer.
  28448. */
  28449. dispose(): void;
  28450. }
  28451. }
  28452. declare module BABYLON {
  28453. /**
  28454. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28456. */
  28457. export class Analyser {
  28458. /**
  28459. * Gets or sets the smoothing
  28460. * @ignorenaming
  28461. */
  28462. SMOOTHING: number;
  28463. /**
  28464. * Gets or sets the FFT table size
  28465. * @ignorenaming
  28466. */
  28467. FFT_SIZE: number;
  28468. /**
  28469. * Gets or sets the bar graph amplitude
  28470. * @ignorenaming
  28471. */
  28472. BARGRAPHAMPLITUDE: number;
  28473. /**
  28474. * Gets or sets the position of the debug canvas
  28475. * @ignorenaming
  28476. */
  28477. DEBUGCANVASPOS: {
  28478. x: number;
  28479. y: number;
  28480. };
  28481. /**
  28482. * Gets or sets the debug canvas size
  28483. * @ignorenaming
  28484. */
  28485. DEBUGCANVASSIZE: {
  28486. width: number;
  28487. height: number;
  28488. };
  28489. private _byteFreqs;
  28490. private _byteTime;
  28491. private _floatFreqs;
  28492. private _webAudioAnalyser;
  28493. private _debugCanvas;
  28494. private _debugCanvasContext;
  28495. private _scene;
  28496. private _registerFunc;
  28497. private _audioEngine;
  28498. /**
  28499. * Creates a new analyser
  28500. * @param scene defines hosting scene
  28501. */
  28502. constructor(scene: Scene);
  28503. /**
  28504. * Get the number of data values you will have to play with for the visualization
  28505. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28506. * @returns a number
  28507. */
  28508. getFrequencyBinCount(): number;
  28509. /**
  28510. * Gets the current frequency data as a byte array
  28511. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28512. * @returns a Uint8Array
  28513. */
  28514. getByteFrequencyData(): Uint8Array;
  28515. /**
  28516. * Gets the current waveform as a byte array
  28517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28518. * @returns a Uint8Array
  28519. */
  28520. getByteTimeDomainData(): Uint8Array;
  28521. /**
  28522. * Gets the current frequency data as a float array
  28523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28524. * @returns a Float32Array
  28525. */
  28526. getFloatFrequencyData(): Float32Array;
  28527. /**
  28528. * Renders the debug canvas
  28529. */
  28530. drawDebugCanvas(): void;
  28531. /**
  28532. * Stops rendering the debug canvas and removes it
  28533. */
  28534. stopDebugCanvas(): void;
  28535. /**
  28536. * Connects two audio nodes
  28537. * @param inputAudioNode defines first node to connect
  28538. * @param outputAudioNode defines second node to connect
  28539. */
  28540. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28541. /**
  28542. * Releases all associated resources
  28543. */
  28544. dispose(): void;
  28545. }
  28546. }
  28547. declare module BABYLON {
  28548. /**
  28549. * This represents an audio engine and it is responsible
  28550. * to play, synchronize and analyse sounds throughout the application.
  28551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28552. */
  28553. export interface IAudioEngine extends IDisposable {
  28554. /**
  28555. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28556. */
  28557. readonly canUseWebAudio: boolean;
  28558. /**
  28559. * Gets the current AudioContext if available.
  28560. */
  28561. readonly audioContext: Nullable<AudioContext>;
  28562. /**
  28563. * The master gain node defines the global audio volume of your audio engine.
  28564. */
  28565. readonly masterGain: GainNode;
  28566. /**
  28567. * Gets whether or not mp3 are supported by your browser.
  28568. */
  28569. readonly isMP3supported: boolean;
  28570. /**
  28571. * Gets whether or not ogg are supported by your browser.
  28572. */
  28573. readonly isOGGsupported: boolean;
  28574. /**
  28575. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28576. * @ignoreNaming
  28577. */
  28578. WarnedWebAudioUnsupported: boolean;
  28579. /**
  28580. * Defines if the audio engine relies on a custom unlocked button.
  28581. * In this case, the embedded button will not be displayed.
  28582. */
  28583. useCustomUnlockedButton: boolean;
  28584. /**
  28585. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  28586. */
  28587. readonly unlocked: boolean;
  28588. /**
  28589. * Event raised when audio has been unlocked on the browser.
  28590. */
  28591. onAudioUnlockedObservable: Observable<AudioEngine>;
  28592. /**
  28593. * Event raised when audio has been locked on the browser.
  28594. */
  28595. onAudioLockedObservable: Observable<AudioEngine>;
  28596. /**
  28597. * Flags the audio engine in Locked state.
  28598. * This happens due to new browser policies preventing audio to autoplay.
  28599. */
  28600. lock(): void;
  28601. /**
  28602. * Unlocks the audio engine once a user action has been done on the dom.
  28603. * This is helpful to resume play once browser policies have been satisfied.
  28604. */
  28605. unlock(): void;
  28606. }
  28607. /**
  28608. * This represents the default audio engine used in babylon.
  28609. * It is responsible to play, synchronize and analyse sounds throughout the application.
  28610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28611. */
  28612. export class AudioEngine implements IAudioEngine {
  28613. private _audioContext;
  28614. private _audioContextInitialized;
  28615. private _muteButton;
  28616. private _hostElement;
  28617. /**
  28618. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28619. */
  28620. canUseWebAudio: boolean;
  28621. /**
  28622. * The master gain node defines the global audio volume of your audio engine.
  28623. */
  28624. masterGain: GainNode;
  28625. /**
  28626. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28627. * @ignoreNaming
  28628. */
  28629. WarnedWebAudioUnsupported: boolean;
  28630. /**
  28631. * Gets whether or not mp3 are supported by your browser.
  28632. */
  28633. isMP3supported: boolean;
  28634. /**
  28635. * Gets whether or not ogg are supported by your browser.
  28636. */
  28637. isOGGsupported: boolean;
  28638. /**
  28639. * Gets whether audio has been unlocked on the device.
  28640. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  28641. * a user interaction has happened.
  28642. */
  28643. unlocked: boolean;
  28644. /**
  28645. * Defines if the audio engine relies on a custom unlocked button.
  28646. * In this case, the embedded button will not be displayed.
  28647. */
  28648. useCustomUnlockedButton: boolean;
  28649. /**
  28650. * Event raised when audio has been unlocked on the browser.
  28651. */
  28652. onAudioUnlockedObservable: Observable<AudioEngine>;
  28653. /**
  28654. * Event raised when audio has been locked on the browser.
  28655. */
  28656. onAudioLockedObservable: Observable<AudioEngine>;
  28657. /**
  28658. * Gets the current AudioContext if available.
  28659. */
  28660. readonly audioContext: Nullable<AudioContext>;
  28661. private _connectedAnalyser;
  28662. /**
  28663. * Instantiates a new audio engine.
  28664. *
  28665. * There should be only one per page as some browsers restrict the number
  28666. * of audio contexts you can create.
  28667. * @param hostElement defines the host element where to display the mute icon if necessary
  28668. */
  28669. constructor(hostElement?: Nullable<HTMLElement>);
  28670. /**
  28671. * Flags the audio engine in Locked state.
  28672. * This happens due to new browser policies preventing audio to autoplay.
  28673. */
  28674. lock(): void;
  28675. /**
  28676. * Unlocks the audio engine once a user action has been done on the dom.
  28677. * This is helpful to resume play once browser policies have been satisfied.
  28678. */
  28679. unlock(): void;
  28680. private _resumeAudioContext;
  28681. private _initializeAudioContext;
  28682. private _tryToRun;
  28683. private _triggerRunningState;
  28684. private _triggerSuspendedState;
  28685. private _displayMuteButton;
  28686. private _moveButtonToTopLeft;
  28687. private _onResize;
  28688. private _hideMuteButton;
  28689. /**
  28690. * Destroy and release the resources associated with the audio ccontext.
  28691. */
  28692. dispose(): void;
  28693. /**
  28694. * Gets the global volume sets on the master gain.
  28695. * @returns the global volume if set or -1 otherwise
  28696. */
  28697. getGlobalVolume(): number;
  28698. /**
  28699. * Sets the global volume of your experience (sets on the master gain).
  28700. * @param newVolume Defines the new global volume of the application
  28701. */
  28702. setGlobalVolume(newVolume: number): void;
  28703. /**
  28704. * Connect the audio engine to an audio analyser allowing some amazing
  28705. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  28706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  28707. * @param analyser The analyser to connect to the engine
  28708. */
  28709. connectToAnalyser(analyser: Analyser): void;
  28710. }
  28711. }
  28712. declare module BABYLON {
  28713. /**
  28714. * Interface used to present a loading screen while loading a scene
  28715. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28716. */
  28717. export interface ILoadingScreen {
  28718. /**
  28719. * Function called to display the loading screen
  28720. */
  28721. displayLoadingUI: () => void;
  28722. /**
  28723. * Function called to hide the loading screen
  28724. */
  28725. hideLoadingUI: () => void;
  28726. /**
  28727. * Gets or sets the color to use for the background
  28728. */
  28729. loadingUIBackgroundColor: string;
  28730. /**
  28731. * Gets or sets the text to display while loading
  28732. */
  28733. loadingUIText: string;
  28734. }
  28735. /**
  28736. * Class used for the default loading screen
  28737. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28738. */
  28739. export class DefaultLoadingScreen implements ILoadingScreen {
  28740. private _renderingCanvas;
  28741. private _loadingText;
  28742. private _loadingDivBackgroundColor;
  28743. private _loadingDiv;
  28744. private _loadingTextDiv;
  28745. /** Gets or sets the logo url to use for the default loading screen */
  28746. static DefaultLogoUrl: string;
  28747. /** Gets or sets the spinner url to use for the default loading screen */
  28748. static DefaultSpinnerUrl: string;
  28749. /**
  28750. * Creates a new default loading screen
  28751. * @param _renderingCanvas defines the canvas used to render the scene
  28752. * @param _loadingText defines the default text to display
  28753. * @param _loadingDivBackgroundColor defines the default background color
  28754. */
  28755. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  28756. /**
  28757. * Function called to display the loading screen
  28758. */
  28759. displayLoadingUI(): void;
  28760. /**
  28761. * Function called to hide the loading screen
  28762. */
  28763. hideLoadingUI(): void;
  28764. /**
  28765. * Gets or sets the text to display while loading
  28766. */
  28767. loadingUIText: string;
  28768. /**
  28769. * Gets or sets the color to use for the background
  28770. */
  28771. loadingUIBackgroundColor: string;
  28772. private _resizeLoadingUI;
  28773. }
  28774. }
  28775. declare module BABYLON {
  28776. /** @hidden */
  28777. export class WebGLPipelineContext implements IPipelineContext {
  28778. engine: Engine;
  28779. program: Nullable<WebGLProgram>;
  28780. context?: WebGLRenderingContext;
  28781. vertexShader?: WebGLShader;
  28782. fragmentShader?: WebGLShader;
  28783. isParallelCompiled: boolean;
  28784. onCompiled?: () => void;
  28785. transformFeedback?: WebGLTransformFeedback | null;
  28786. readonly isAsync: boolean;
  28787. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28788. }
  28789. }
  28790. declare module BABYLON {
  28791. /** @hidden */
  28792. export class WebGLDataBuffer extends DataBuffer {
  28793. private _buffer;
  28794. constructor(resource: WebGLBuffer);
  28795. readonly underlyingResource: any;
  28796. }
  28797. }
  28798. declare module BABYLON {
  28799. /** @hidden */
  28800. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28801. attributeProcessor(attribute: string): string;
  28802. varyingProcessor(varying: string, isFragment: boolean): string;
  28803. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28804. }
  28805. }
  28806. declare module BABYLON {
  28807. /**
  28808. * This class is used to track a performance counter which is number based.
  28809. * The user has access to many properties which give statistics of different nature.
  28810. *
  28811. * The implementer can track two kinds of Performance Counter: time and count.
  28812. * 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.
  28813. * 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.
  28814. */
  28815. export class PerfCounter {
  28816. /**
  28817. * Gets or sets a global boolean to turn on and off all the counters
  28818. */
  28819. static Enabled: boolean;
  28820. /**
  28821. * Returns the smallest value ever
  28822. */
  28823. readonly min: number;
  28824. /**
  28825. * Returns the biggest value ever
  28826. */
  28827. readonly max: number;
  28828. /**
  28829. * Returns the average value since the performance counter is running
  28830. */
  28831. readonly average: number;
  28832. /**
  28833. * Returns the average value of the last second the counter was monitored
  28834. */
  28835. readonly lastSecAverage: number;
  28836. /**
  28837. * Returns the current value
  28838. */
  28839. readonly current: number;
  28840. /**
  28841. * Gets the accumulated total
  28842. */
  28843. readonly total: number;
  28844. /**
  28845. * Gets the total value count
  28846. */
  28847. readonly count: number;
  28848. /**
  28849. * Creates a new counter
  28850. */
  28851. constructor();
  28852. /**
  28853. * Call this method to start monitoring a new frame.
  28854. * 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.
  28855. */
  28856. fetchNewFrame(): void;
  28857. /**
  28858. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28859. * @param newCount the count value to add to the monitored count
  28860. * @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.
  28861. */
  28862. addCount(newCount: number, fetchResult: boolean): void;
  28863. /**
  28864. * Start monitoring this performance counter
  28865. */
  28866. beginMonitoring(): void;
  28867. /**
  28868. * Compute the time lapsed since the previous beginMonitoring() call.
  28869. * @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
  28870. */
  28871. endMonitoring(newFrame?: boolean): void;
  28872. private _fetchResult;
  28873. private _startMonitoringTime;
  28874. private _min;
  28875. private _max;
  28876. private _average;
  28877. private _current;
  28878. private _totalValueCount;
  28879. private _totalAccumulated;
  28880. private _lastSecAverage;
  28881. private _lastSecAccumulated;
  28882. private _lastSecTime;
  28883. private _lastSecValueCount;
  28884. }
  28885. }
  28886. declare module BABYLON {
  28887. /**
  28888. * Interface for any object that can request an animation frame
  28889. */
  28890. export interface ICustomAnimationFrameRequester {
  28891. /**
  28892. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  28893. */
  28894. renderFunction?: Function;
  28895. /**
  28896. * Called to request the next frame to render to
  28897. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  28898. */
  28899. requestAnimationFrame: Function;
  28900. /**
  28901. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  28902. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  28903. */
  28904. requestID?: number;
  28905. }
  28906. }
  28907. declare module BABYLON {
  28908. /**
  28909. * Settings for finer control over video usage
  28910. */
  28911. export interface VideoTextureSettings {
  28912. /**
  28913. * Applies `autoplay` to video, if specified
  28914. */
  28915. autoPlay?: boolean;
  28916. /**
  28917. * Applies `loop` to video, if specified
  28918. */
  28919. loop?: boolean;
  28920. /**
  28921. * Automatically updates internal texture from video at every frame in the render loop
  28922. */
  28923. autoUpdateTexture: boolean;
  28924. /**
  28925. * Image src displayed during the video loading or until the user interacts with the video.
  28926. */
  28927. poster?: string;
  28928. }
  28929. /**
  28930. * If you want to display a video in your scene, this is the special texture for that.
  28931. * This special texture works similar to other textures, with the exception of a few parameters.
  28932. * @see https://doc.babylonjs.com/how_to/video_texture
  28933. */
  28934. export class VideoTexture extends Texture {
  28935. /**
  28936. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28937. */
  28938. readonly autoUpdateTexture: boolean;
  28939. /**
  28940. * The video instance used by the texture internally
  28941. */
  28942. readonly video: HTMLVideoElement;
  28943. private _onUserActionRequestedObservable;
  28944. /**
  28945. * Event triggerd when a dom action is required by the user to play the video.
  28946. * This happens due to recent changes in browser policies preventing video to auto start.
  28947. */
  28948. readonly onUserActionRequestedObservable: Observable<Texture>;
  28949. private _generateMipMaps;
  28950. private _engine;
  28951. private _stillImageCaptured;
  28952. private _displayingPosterTexture;
  28953. private _settings;
  28954. private _createInternalTextureOnEvent;
  28955. private _frameId;
  28956. /**
  28957. * Creates a video texture.
  28958. * If you want to display a video in your scene, this is the special texture for that.
  28959. * This special texture works similar to other textures, with the exception of a few parameters.
  28960. * @see https://doc.babylonjs.com/how_to/video_texture
  28961. * @param name optional name, will detect from video source, if not defined
  28962. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28963. * @param scene is obviously the current scene.
  28964. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28965. * @param invertY is false by default but can be used to invert video on Y axis
  28966. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28967. * @param settings allows finer control over video usage
  28968. */
  28969. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28970. private _getName;
  28971. private _getVideo;
  28972. private _createInternalTexture;
  28973. private reset;
  28974. /**
  28975. * @hidden Internal method to initiate `update`.
  28976. */ private _rebuild(): void;
  28977. /**
  28978. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28979. */
  28980. update(): void;
  28981. /**
  28982. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28983. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28984. */
  28985. updateTexture(isVisible: boolean): void;
  28986. protected _updateInternalTexture: () => void;
  28987. /**
  28988. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28989. * @param url New url.
  28990. */
  28991. updateURL(url: string): void;
  28992. /**
  28993. * Dispose the texture and release its associated resources.
  28994. */
  28995. dispose(): void;
  28996. /**
  28997. * Creates a video texture straight from a stream.
  28998. * @param scene Define the scene the texture should be created in
  28999. * @param stream Define the stream the texture should be created from
  29000. * @returns The created video texture as a promise
  29001. */
  29002. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29003. /**
  29004. * Creates a video texture straight from your WebCam video feed.
  29005. * @param scene Define the scene the texture should be created in
  29006. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29007. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29008. * @returns The created video texture as a promise
  29009. */
  29010. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29011. minWidth: number;
  29012. maxWidth: number;
  29013. minHeight: number;
  29014. maxHeight: number;
  29015. deviceId: string;
  29016. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29017. /**
  29018. * Creates a video texture straight from your WebCam video feed.
  29019. * @param scene Define the scene the texture should be created in
  29020. * @param onReady Define a callback to triggered once the texture will be ready
  29021. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29022. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29023. */
  29024. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29025. minWidth: number;
  29026. maxWidth: number;
  29027. minHeight: number;
  29028. maxHeight: number;
  29029. deviceId: string;
  29030. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29031. }
  29032. }
  29033. declare module BABYLON {
  29034. /**
  29035. * Defines the interface used by objects containing a viewport (like a camera)
  29036. */
  29037. interface IViewportOwnerLike {
  29038. /**
  29039. * Gets or sets the viewport
  29040. */
  29041. viewport: IViewportLike;
  29042. }
  29043. /**
  29044. * Interface for attribute information associated with buffer instanciation
  29045. */
  29046. export class InstancingAttributeInfo {
  29047. /**
  29048. * Index/offset of the attribute in the vertex shader
  29049. */
  29050. index: number;
  29051. /**
  29052. * size of the attribute, 1, 2, 3 or 4
  29053. */
  29054. attributeSize: number;
  29055. /**
  29056. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29057. * default is FLOAT
  29058. */
  29059. attribyteType: number;
  29060. /**
  29061. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29062. */
  29063. normalized: boolean;
  29064. /**
  29065. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29066. */
  29067. offset: number;
  29068. /**
  29069. * Name of the GLSL attribute, for debugging purpose only
  29070. */
  29071. attributeName: string;
  29072. }
  29073. /**
  29074. * Define options used to create a depth texture
  29075. */
  29076. export class DepthTextureCreationOptions {
  29077. /** Specifies whether or not a stencil should be allocated in the texture */
  29078. generateStencil?: boolean;
  29079. /** Specifies whether or not bilinear filtering is enable on the texture */
  29080. bilinearFiltering?: boolean;
  29081. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29082. comparisonFunction?: number;
  29083. /** Specifies if the created texture is a cube texture */
  29084. isCube?: boolean;
  29085. }
  29086. /**
  29087. * Class used to describe the capabilities of the engine relatively to the current browser
  29088. */
  29089. export class EngineCapabilities {
  29090. /** Maximum textures units per fragment shader */
  29091. maxTexturesImageUnits: number;
  29092. /** Maximum texture units per vertex shader */
  29093. maxVertexTextureImageUnits: number;
  29094. /** Maximum textures units in the entire pipeline */
  29095. maxCombinedTexturesImageUnits: number;
  29096. /** Maximum texture size */
  29097. maxTextureSize: number;
  29098. /** Maximum cube texture size */
  29099. maxCubemapTextureSize: number;
  29100. /** Maximum render texture size */
  29101. maxRenderTextureSize: number;
  29102. /** Maximum number of vertex attributes */
  29103. maxVertexAttribs: number;
  29104. /** Maximum number of varyings */
  29105. maxVaryingVectors: number;
  29106. /** Maximum number of uniforms per vertex shader */
  29107. maxVertexUniformVectors: number;
  29108. /** Maximum number of uniforms per fragment shader */
  29109. maxFragmentUniformVectors: number;
  29110. /** Defines if standard derivates (dx/dy) are supported */
  29111. standardDerivatives: boolean;
  29112. /** Defines if s3tc texture compression is supported */
  29113. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29114. /** Defines if pvrtc texture compression is supported */
  29115. pvrtc: any;
  29116. /** Defines if etc1 texture compression is supported */
  29117. etc1: any;
  29118. /** Defines if etc2 texture compression is supported */
  29119. etc2: any;
  29120. /** Defines if astc texture compression is supported */
  29121. astc: any;
  29122. /** Defines if float textures are supported */
  29123. textureFloat: boolean;
  29124. /** Defines if vertex array objects are supported */
  29125. vertexArrayObject: boolean;
  29126. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29127. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29128. /** Gets the maximum level of anisotropy supported */
  29129. maxAnisotropy: number;
  29130. /** Defines if instancing is supported */
  29131. instancedArrays: boolean;
  29132. /** Defines if 32 bits indices are supported */
  29133. uintIndices: boolean;
  29134. /** Defines if high precision shaders are supported */
  29135. highPrecisionShaderSupported: boolean;
  29136. /** Defines if depth reading in the fragment shader is supported */
  29137. fragmentDepthSupported: boolean;
  29138. /** Defines if float texture linear filtering is supported*/
  29139. textureFloatLinearFiltering: boolean;
  29140. /** Defines if rendering to float textures is supported */
  29141. textureFloatRender: boolean;
  29142. /** Defines if half float textures are supported*/
  29143. textureHalfFloat: boolean;
  29144. /** Defines if half float texture linear filtering is supported*/
  29145. textureHalfFloatLinearFiltering: boolean;
  29146. /** Defines if rendering to half float textures is supported */
  29147. textureHalfFloatRender: boolean;
  29148. /** Defines if textureLOD shader command is supported */
  29149. textureLOD: boolean;
  29150. /** Defines if draw buffers extension is supported */
  29151. drawBuffersExtension: boolean;
  29152. /** Defines if depth textures are supported */
  29153. depthTextureExtension: boolean;
  29154. /** Defines if float color buffer are supported */
  29155. colorBufferFloat: boolean;
  29156. /** Gets disjoint timer query extension (null if not supported) */
  29157. timerQuery: EXT_disjoint_timer_query;
  29158. /** Defines if timestamp can be used with timer query */
  29159. canUseTimestampForTimerQuery: boolean;
  29160. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29161. multiview: any;
  29162. /** Function used to let the system compiles shaders in background */
  29163. parallelShaderCompile: {
  29164. COMPLETION_STATUS_KHR: number;
  29165. };
  29166. /** Max number of texture samples for MSAA */
  29167. maxMSAASamples: number;
  29168. }
  29169. /** Interface defining initialization parameters for Engine class */
  29170. export interface EngineOptions extends WebGLContextAttributes {
  29171. /**
  29172. * Defines if the engine should no exceed a specified device ratio
  29173. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29174. */
  29175. limitDeviceRatio?: number;
  29176. /**
  29177. * Defines if webvr should be enabled automatically
  29178. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29179. */
  29180. autoEnableWebVR?: boolean;
  29181. /**
  29182. * Defines if webgl2 should be turned off even if supported
  29183. * @see http://doc.babylonjs.com/features/webgl2
  29184. */
  29185. disableWebGL2Support?: boolean;
  29186. /**
  29187. * Defines if webaudio should be initialized as well
  29188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29189. */
  29190. audioEngine?: boolean;
  29191. /**
  29192. * Defines if animations should run using a deterministic lock step
  29193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29194. */
  29195. deterministicLockstep?: boolean;
  29196. /** Defines the maximum steps to use with deterministic lock step mode */
  29197. lockstepMaxSteps?: number;
  29198. /**
  29199. * Defines that engine should ignore context lost events
  29200. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29201. */
  29202. doNotHandleContextLost?: boolean;
  29203. /**
  29204. * Defines that engine should ignore modifying touch action attribute and style
  29205. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29206. */
  29207. doNotHandleTouchAction?: boolean;
  29208. /**
  29209. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29210. */
  29211. useHighPrecisionFloats?: boolean;
  29212. }
  29213. /**
  29214. * Defines the interface used by display changed events
  29215. */
  29216. export interface IDisplayChangedEventArgs {
  29217. /** Gets the vrDisplay object (if any) */
  29218. vrDisplay: Nullable<any>;
  29219. /** Gets a boolean indicating if webVR is supported */
  29220. vrSupported: boolean;
  29221. }
  29222. /**
  29223. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29224. */
  29225. export class Engine {
  29226. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29227. static ExceptionList: ({
  29228. key: string;
  29229. capture: string;
  29230. captureConstraint: number;
  29231. targets: string[];
  29232. } | {
  29233. key: string;
  29234. capture: null;
  29235. captureConstraint: null;
  29236. targets: string[];
  29237. })[];
  29238. /** Gets the list of created engines */
  29239. static readonly Instances: Engine[];
  29240. /**
  29241. * Gets the latest created engine
  29242. */
  29243. static readonly LastCreatedEngine: Nullable<Engine>;
  29244. /**
  29245. * Gets the latest created scene
  29246. */
  29247. static readonly LastCreatedScene: Nullable<Scene>;
  29248. /**
  29249. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29250. * @param flag defines which part of the materials must be marked as dirty
  29251. * @param predicate defines a predicate used to filter which materials should be affected
  29252. */
  29253. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29254. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  29255. /** Defines that alpha blending is disabled */
  29256. static readonly ALPHA_DISABLE: number;
  29257. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29258. static readonly ALPHA_ADD: number;
  29259. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29260. static readonly ALPHA_COMBINE: number;
  29261. /** Defines that alpha blending to DEST - SRC * DEST */
  29262. static readonly ALPHA_SUBTRACT: number;
  29263. /** Defines that alpha blending to SRC * DEST */
  29264. static readonly ALPHA_MULTIPLY: number;
  29265. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29266. static readonly ALPHA_MAXIMIZED: number;
  29267. /** Defines that alpha blending to SRC + DEST */
  29268. static readonly ALPHA_ONEONE: number;
  29269. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29270. static readonly ALPHA_PREMULTIPLIED: number;
  29271. /**
  29272. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29273. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29274. */
  29275. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29276. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29277. static readonly ALPHA_INTERPOLATE: number;
  29278. /**
  29279. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29280. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29281. */
  29282. static readonly ALPHA_SCREENMODE: number;
  29283. /** Defines that the ressource is not delayed*/
  29284. static readonly DELAYLOADSTATE_NONE: number;
  29285. /** Defines that the ressource was successfully delay loaded */
  29286. static readonly DELAYLOADSTATE_LOADED: number;
  29287. /** Defines that the ressource is currently delay loading */
  29288. static readonly DELAYLOADSTATE_LOADING: number;
  29289. /** Defines that the ressource is delayed and has not started loading */
  29290. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29292. static readonly NEVER: number;
  29293. /** 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 */
  29294. static readonly ALWAYS: number;
  29295. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29296. static readonly LESS: number;
  29297. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29298. static readonly EQUAL: number;
  29299. /** 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 */
  29300. static readonly LEQUAL: number;
  29301. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29302. static readonly GREATER: number;
  29303. /** 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 */
  29304. static readonly GEQUAL: number;
  29305. /** 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 */
  29306. static readonly NOTEQUAL: number;
  29307. /** Passed to stencilOperation to specify that stencil value must be kept */
  29308. static readonly KEEP: number;
  29309. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29310. static readonly REPLACE: number;
  29311. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29312. static readonly INCR: number;
  29313. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29314. static readonly DECR: number;
  29315. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29316. static readonly INVERT: number;
  29317. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29318. static readonly INCR_WRAP: number;
  29319. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29320. static readonly DECR_WRAP: number;
  29321. /** Texture is not repeating outside of 0..1 UVs */
  29322. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29323. /** Texture is repeating outside of 0..1 UVs */
  29324. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29325. /** Texture is repeating and mirrored */
  29326. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29327. /** ALPHA */
  29328. static readonly TEXTUREFORMAT_ALPHA: number;
  29329. /** LUMINANCE */
  29330. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29331. /** LUMINANCE_ALPHA */
  29332. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29333. /** RGB */
  29334. static readonly TEXTUREFORMAT_RGB: number;
  29335. /** RGBA */
  29336. static readonly TEXTUREFORMAT_RGBA: number;
  29337. /** RED */
  29338. static readonly TEXTUREFORMAT_RED: number;
  29339. /** RED (2nd reference) */
  29340. static readonly TEXTUREFORMAT_R: number;
  29341. /** RG */
  29342. static readonly TEXTUREFORMAT_RG: number;
  29343. /** RED_INTEGER */
  29344. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29345. /** RED_INTEGER (2nd reference) */
  29346. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29347. /** RG_INTEGER */
  29348. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29349. /** RGB_INTEGER */
  29350. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29351. /** RGBA_INTEGER */
  29352. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29353. /** UNSIGNED_BYTE */
  29354. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29355. /** UNSIGNED_BYTE (2nd reference) */
  29356. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29357. /** FLOAT */
  29358. static readonly TEXTURETYPE_FLOAT: number;
  29359. /** HALF_FLOAT */
  29360. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29361. /** BYTE */
  29362. static readonly TEXTURETYPE_BYTE: number;
  29363. /** SHORT */
  29364. static readonly TEXTURETYPE_SHORT: number;
  29365. /** UNSIGNED_SHORT */
  29366. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29367. /** INT */
  29368. static readonly TEXTURETYPE_INT: number;
  29369. /** UNSIGNED_INT */
  29370. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29371. /** UNSIGNED_SHORT_4_4_4_4 */
  29372. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29373. /** UNSIGNED_SHORT_5_5_5_1 */
  29374. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29375. /** UNSIGNED_SHORT_5_6_5 */
  29376. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29377. /** UNSIGNED_INT_2_10_10_10_REV */
  29378. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29379. /** UNSIGNED_INT_24_8 */
  29380. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29381. /** UNSIGNED_INT_10F_11F_11F_REV */
  29382. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29383. /** UNSIGNED_INT_5_9_9_9_REV */
  29384. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29385. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29386. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29387. /** nearest is mag = nearest and min = nearest and mip = linear */
  29388. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29390. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29391. /** Trilinear is mag = linear and min = linear and mip = linear */
  29392. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29393. /** nearest is mag = nearest and min = nearest and mip = linear */
  29394. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29395. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29396. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29397. /** Trilinear is mag = linear and min = linear and mip = linear */
  29398. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29399. /** mag = nearest and min = nearest and mip = nearest */
  29400. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29401. /** mag = nearest and min = linear and mip = nearest */
  29402. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29403. /** mag = nearest and min = linear and mip = linear */
  29404. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29405. /** mag = nearest and min = linear and mip = none */
  29406. static readonly TEXTURE_NEAREST_LINEAR: number;
  29407. /** mag = nearest and min = nearest and mip = none */
  29408. static readonly TEXTURE_NEAREST_NEAREST: number;
  29409. /** mag = linear and min = nearest and mip = nearest */
  29410. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29411. /** mag = linear and min = nearest and mip = linear */
  29412. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29413. /** mag = linear and min = linear and mip = none */
  29414. static readonly TEXTURE_LINEAR_LINEAR: number;
  29415. /** mag = linear and min = nearest and mip = none */
  29416. static readonly TEXTURE_LINEAR_NEAREST: number;
  29417. /** Explicit coordinates mode */
  29418. static readonly TEXTURE_EXPLICIT_MODE: number;
  29419. /** Spherical coordinates mode */
  29420. static readonly TEXTURE_SPHERICAL_MODE: number;
  29421. /** Planar coordinates mode */
  29422. static readonly TEXTURE_PLANAR_MODE: number;
  29423. /** Cubic coordinates mode */
  29424. static readonly TEXTURE_CUBIC_MODE: number;
  29425. /** Projection coordinates mode */
  29426. static readonly TEXTURE_PROJECTION_MODE: number;
  29427. /** Skybox coordinates mode */
  29428. static readonly TEXTURE_SKYBOX_MODE: number;
  29429. /** Inverse Cubic coordinates mode */
  29430. static readonly TEXTURE_INVCUBIC_MODE: number;
  29431. /** Equirectangular coordinates mode */
  29432. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29433. /** Equirectangular Fixed coordinates mode */
  29434. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29435. /** Equirectangular Fixed Mirrored coordinates mode */
  29436. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29437. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29438. static readonly SCALEMODE_FLOOR: number;
  29439. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29440. static readonly SCALEMODE_NEAREST: number;
  29441. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29442. static readonly SCALEMODE_CEILING: number;
  29443. /**
  29444. * Returns the current npm package of the sdk
  29445. */
  29446. static readonly NpmPackage: string;
  29447. /**
  29448. * Returns the current version of the framework
  29449. */
  29450. static readonly Version: string;
  29451. /**
  29452. * Returns a string describing the current engine
  29453. */
  29454. readonly description: string;
  29455. /**
  29456. * Gets or sets the epsilon value used by collision engine
  29457. */
  29458. static CollisionsEpsilon: number;
  29459. /**
  29460. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29461. */
  29462. static ShadersRepository: string;
  29463. /**
  29464. * Method called to create the default loading screen.
  29465. * This can be overriden in your own app.
  29466. * @param canvas The rendering canvas element
  29467. * @returns The loading screen
  29468. */
  29469. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29470. /**
  29471. * Method called to create the default rescale post process on each engine.
  29472. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29473. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  29474. /**
  29475. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29476. */
  29477. forcePOTTextures: boolean;
  29478. /**
  29479. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29480. */
  29481. isFullscreen: boolean;
  29482. /**
  29483. * Gets a boolean indicating if the pointer is currently locked
  29484. */
  29485. isPointerLock: boolean;
  29486. /**
  29487. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29488. */
  29489. cullBackFaces: boolean;
  29490. /**
  29491. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29492. */
  29493. renderEvenInBackground: boolean;
  29494. /**
  29495. * Gets or sets a boolean indicating that cache can be kept between frames
  29496. */
  29497. preventCacheWipeBetweenFrames: boolean;
  29498. /**
  29499. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29500. **/
  29501. enableOfflineSupport: boolean;
  29502. /**
  29503. * 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)
  29504. **/
  29505. disableManifestCheck: boolean;
  29506. /**
  29507. * Gets the list of created scenes
  29508. */
  29509. scenes: Scene[];
  29510. /**
  29511. * Event raised when a new scene is created
  29512. */
  29513. onNewSceneAddedObservable: Observable<Scene>;
  29514. /**
  29515. * Gets the list of created postprocesses
  29516. */
  29517. postProcesses: PostProcess[];
  29518. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29519. validateShaderPrograms: boolean;
  29520. /**
  29521. * Observable event triggered each time the rendering canvas is resized
  29522. */
  29523. onResizeObservable: Observable<Engine>;
  29524. /**
  29525. * Observable event triggered each time the canvas loses focus
  29526. */
  29527. onCanvasBlurObservable: Observable<Engine>;
  29528. /**
  29529. * Observable event triggered each time the canvas gains focus
  29530. */
  29531. onCanvasFocusObservable: Observable<Engine>;
  29532. /**
  29533. * Observable event triggered each time the canvas receives pointerout event
  29534. */
  29535. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29536. /**
  29537. * Observable event triggered before each texture is initialized
  29538. */
  29539. onBeforeTextureInitObservable: Observable<Texture>;
  29540. /**
  29541. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29542. */
  29543. disableUniformBuffers: boolean;
  29544. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  29545. /**
  29546. * Gets a boolean indicating that the engine supports uniform buffers
  29547. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29548. */
  29549. readonly supportsUniformBuffers: boolean;
  29550. /**
  29551. * Observable raised when the engine begins a new frame
  29552. */
  29553. onBeginFrameObservable: Observable<Engine>;
  29554. /**
  29555. * If set, will be used to request the next animation frame for the render loop
  29556. */
  29557. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29558. /**
  29559. * Observable raised when the engine ends the current frame
  29560. */
  29561. onEndFrameObservable: Observable<Engine>;
  29562. /**
  29563. * Observable raised when the engine is about to compile a shader
  29564. */
  29565. onBeforeShaderCompilationObservable: Observable<Engine>;
  29566. /**
  29567. * Observable raised when the engine has jsut compiled a shader
  29568. */
  29569. onAfterShaderCompilationObservable: Observable<Engine>;
  29570. /** @hidden */ private _gl: WebGLRenderingContext;
  29571. private _renderingCanvas;
  29572. private _windowIsBackground;
  29573. protected _webGLVersion: number;
  29574. protected _highPrecisionShadersAllowed: boolean;
  29575. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  29576. /**
  29577. * Gets a boolean indicating that only power of 2 textures are supported
  29578. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29579. */
  29580. readonly needPOTTextures: boolean;
  29581. /** @hidden */ private _badOS: boolean;
  29582. /** @hidden */ private _badDesktopOS: boolean;
  29583. /**
  29584. * Gets the audio engine
  29585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29586. * @ignorenaming
  29587. */
  29588. static audioEngine: IAudioEngine;
  29589. /**
  29590. * Default AudioEngine factory responsible of creating the Audio Engine.
  29591. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  29592. */
  29593. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  29594. /**
  29595. * Default offline support factory responsible of creating a tool used to store data locally.
  29596. * By default, this will create a Database object if the workload has been embedded.
  29597. */
  29598. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  29599. private _onFocus;
  29600. private _onBlur;
  29601. private _onCanvasPointerOut;
  29602. private _onCanvasBlur;
  29603. private _onCanvasFocus;
  29604. private _onFullscreenChange;
  29605. private _onPointerLockChange;
  29606. private _hardwareScalingLevel;
  29607. /** @hidden */ private _caps: EngineCapabilities;
  29608. private _pointerLockRequested;
  29609. private _isStencilEnable;
  29610. protected _colorWrite: boolean;
  29611. private _loadingScreen;
  29612. /** @hidden */ private _drawCalls: PerfCounter;
  29613. private _glVersion;
  29614. private _glRenderer;
  29615. private _glVendor;
  29616. private _videoTextureSupported;
  29617. private _renderingQueueLaunched;
  29618. private _activeRenderLoops;
  29619. private _deterministicLockstep;
  29620. private _lockstepMaxSteps;
  29621. /**
  29622. * Observable signaled when a context lost event is raised
  29623. */
  29624. onContextLostObservable: Observable<Engine>;
  29625. /**
  29626. * Observable signaled when a context restored event is raised
  29627. */
  29628. onContextRestoredObservable: Observable<Engine>;
  29629. private _onContextLost;
  29630. private _onContextRestored;
  29631. private _contextWasLost;
  29632. /** @hidden */ private _doNotHandleContextLost: boolean;
  29633. /**
  29634. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29636. */
  29637. doNotHandleContextLost: boolean;
  29638. private _performanceMonitor;
  29639. private _fps;
  29640. private _deltaTime;
  29641. /**
  29642. * Turn this value on if you want to pause FPS computation when in background
  29643. */
  29644. disablePerformanceMonitorInBackground: boolean;
  29645. /**
  29646. * Gets the performance monitor attached to this engine
  29647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  29648. */
  29649. readonly performanceMonitor: PerformanceMonitor;
  29650. /**
  29651. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29652. */
  29653. disableVertexArrayObjects: boolean;
  29654. /** @hidden */
  29655. protected _depthCullingState: _DepthCullingState;
  29656. /** @hidden */
  29657. protected _stencilState: _StencilState;
  29658. /** @hidden */
  29659. protected _alphaState: _AlphaState;
  29660. /** @hidden */
  29661. protected _alphaMode: number;
  29662. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  29663. /** @hidden */
  29664. protected _activeChannel: number;
  29665. private _currentTextureChannel;
  29666. /** @hidden */
  29667. protected _boundTexturesCache: {
  29668. [key: string]: Nullable<InternalTexture>;
  29669. };
  29670. /** @hidden */
  29671. protected _currentEffect: Nullable<Effect>;
  29672. /** @hidden */
  29673. protected _currentProgram: Nullable<WebGLProgram>;
  29674. private _compiledEffects;
  29675. private _vertexAttribArraysEnabled;
  29676. /** @hidden */
  29677. protected _cachedViewport: Nullable<IViewportLike>;
  29678. private _cachedVertexArrayObject;
  29679. /** @hidden */
  29680. protected _cachedVertexBuffers: any;
  29681. /** @hidden */
  29682. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29683. /** @hidden */
  29684. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29685. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  29686. private _uintIndicesCurrentlySet;
  29687. private _currentBoundBuffer;
  29688. /** @hidden */
  29689. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29690. private _currentBufferPointers;
  29691. private _currentInstanceLocations;
  29692. private _currentInstanceBuffers;
  29693. private _textureUnits;
  29694. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29695. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29696. private _rescalePostProcess;
  29697. private _dummyFramebuffer;
  29698. private _externalData;
  29699. /** @hidden */ private _bindedRenderFunction: any;
  29700. private _vaoRecordInProgress;
  29701. private _mustWipeVertexAttributes;
  29702. private _emptyTexture;
  29703. private _emptyCubeTexture;
  29704. private _emptyTexture3D;
  29705. /** @hidden */ private _frameHandler: number;
  29706. private _nextFreeTextureSlots;
  29707. private _maxSimultaneousTextures;
  29708. private _activeRequests;
  29709. private _texturesSupported;
  29710. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  29711. /**
  29712. * Gets the list of texture formats supported
  29713. */
  29714. readonly texturesSupported: Array<string>;
  29715. /**
  29716. * Gets the list of texture formats in use
  29717. */
  29718. readonly textureFormatInUse: Nullable<string>;
  29719. /**
  29720. * Gets the current viewport
  29721. */
  29722. readonly currentViewport: Nullable<IViewportLike>;
  29723. /**
  29724. * Gets the default empty texture
  29725. */
  29726. readonly emptyTexture: InternalTexture;
  29727. /**
  29728. * Gets the default empty 3D texture
  29729. */
  29730. readonly emptyTexture3D: InternalTexture;
  29731. /**
  29732. * Gets the default empty cube texture
  29733. */
  29734. readonly emptyCubeTexture: InternalTexture;
  29735. /**
  29736. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29737. */
  29738. readonly premultipliedAlpha: boolean;
  29739. /**
  29740. * Creates a new engine
  29741. * @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
  29742. * @param antialias defines enable antialiasing (default: false)
  29743. * @param options defines further options to be sent to the getContext() function
  29744. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29745. */
  29746. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29747. /**
  29748. * Initializes a webVR display and starts listening to display change events
  29749. * The onVRDisplayChangedObservable will be notified upon these changes
  29750. * @returns The onVRDisplayChangedObservable
  29751. */
  29752. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29753. /** @hidden */ private _prepareVRComponent(): void;
  29754. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  29755. /** @hidden */ private _submitVRFrame(): void;
  29756. /**
  29757. * Call this function to leave webVR mode
  29758. * Will do nothing if webVR is not supported or if there is no webVR device
  29759. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29760. */
  29761. disableVR(): void;
  29762. /**
  29763. * Gets a boolean indicating that the system is in VR mode and is presenting
  29764. * @returns true if VR mode is engaged
  29765. */
  29766. isVRPresenting(): boolean;
  29767. /** @hidden */ private _requestVRFrame(): void;
  29768. private _disableTouchAction;
  29769. private _rebuildInternalTextures;
  29770. private _rebuildEffects;
  29771. /**
  29772. * Gets a boolean indicating if all created effects are ready
  29773. * @returns true if all effects are ready
  29774. */
  29775. areAllEffectsReady(): boolean;
  29776. private _rebuildBuffers;
  29777. private _initGLContext;
  29778. /**
  29779. * Gets version of the current webGL context
  29780. */
  29781. readonly webGLVersion: number;
  29782. /**
  29783. * Gets a string idenfifying the name of the class
  29784. * @returns "Engine" string
  29785. */
  29786. getClassName(): string;
  29787. /**
  29788. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29789. */
  29790. readonly isStencilEnable: boolean;
  29791. /** @hidden */ private _prepareWorkingCanvas(): void;
  29792. /**
  29793. * Reset the texture cache to empty state
  29794. */
  29795. resetTextureCache(): void;
  29796. /**
  29797. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29798. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29799. * @returns true if engine is in deterministic lock step mode
  29800. */
  29801. isDeterministicLockStep(): boolean;
  29802. /**
  29803. * Gets the max steps when engine is running in deterministic lock step
  29804. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29805. * @returns the max steps
  29806. */
  29807. getLockstepMaxSteps(): number;
  29808. /**
  29809. * Gets an object containing information about the current webGL context
  29810. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29811. */
  29812. getGlInfo(): {
  29813. vendor: string;
  29814. renderer: string;
  29815. version: string;
  29816. };
  29817. /**
  29818. * Gets current aspect ratio
  29819. * @param viewportOwner defines the camera to use to get the aspect ratio
  29820. * @param useScreen defines if screen size must be used (or the current render target if any)
  29821. * @returns a number defining the aspect ratio
  29822. */
  29823. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  29824. /**
  29825. * Gets current screen aspect ratio
  29826. * @returns a number defining the aspect ratio
  29827. */
  29828. getScreenAspectRatio(): number;
  29829. /**
  29830. * Gets the current render width
  29831. * @param useScreen defines if screen size must be used (or the current render target if any)
  29832. * @returns a number defining the current render width
  29833. */
  29834. getRenderWidth(useScreen?: boolean): number;
  29835. /**
  29836. * Gets the current render height
  29837. * @param useScreen defines if screen size must be used (or the current render target if any)
  29838. * @returns a number defining the current render height
  29839. */
  29840. getRenderHeight(useScreen?: boolean): number;
  29841. /**
  29842. * Gets the HTML canvas attached with the current webGL context
  29843. * @returns a HTML canvas
  29844. */
  29845. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29846. /**
  29847. * Gets host window
  29848. * @returns the host window object
  29849. */
  29850. getHostWindow(): Window;
  29851. /**
  29852. * Gets host document
  29853. * @returns the host document object
  29854. */
  29855. getHostDocument(): Document;
  29856. /**
  29857. * Gets the client rect of the HTML canvas attached with the current webGL context
  29858. * @returns a client rectanglee
  29859. */
  29860. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  29861. /**
  29862. * Defines the hardware scaling level.
  29863. * By default the hardware scaling level is computed from the window device ratio.
  29864. * 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.
  29865. * @param level defines the level to use
  29866. */
  29867. setHardwareScalingLevel(level: number): void;
  29868. /**
  29869. * Gets the current hardware scaling level.
  29870. * By default the hardware scaling level is computed from the window device ratio.
  29871. * 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.
  29872. * @returns a number indicating the current hardware scaling level
  29873. */
  29874. getHardwareScalingLevel(): number;
  29875. /**
  29876. * Gets the list of loaded textures
  29877. * @returns an array containing all loaded textures
  29878. */
  29879. getLoadedTexturesCache(): InternalTexture[];
  29880. /**
  29881. * Gets the object containing all engine capabilities
  29882. * @returns the EngineCapabilities object
  29883. */
  29884. getCaps(): EngineCapabilities;
  29885. /**
  29886. * Gets the current depth function
  29887. * @returns a number defining the depth function
  29888. */
  29889. getDepthFunction(): Nullable<number>;
  29890. /**
  29891. * Sets the current depth function
  29892. * @param depthFunc defines the function to use
  29893. */
  29894. setDepthFunction(depthFunc: number): void;
  29895. /**
  29896. * Sets the current depth function to GREATER
  29897. */
  29898. setDepthFunctionToGreater(): void;
  29899. /**
  29900. * Sets the current depth function to GEQUAL
  29901. */
  29902. setDepthFunctionToGreaterOrEqual(): void;
  29903. /**
  29904. * Sets the current depth function to LESS
  29905. */
  29906. setDepthFunctionToLess(): void;
  29907. private _cachedStencilBuffer;
  29908. private _cachedStencilFunction;
  29909. private _cachedStencilMask;
  29910. private _cachedStencilOperationPass;
  29911. private _cachedStencilOperationFail;
  29912. private _cachedStencilOperationDepthFail;
  29913. private _cachedStencilReference;
  29914. /**
  29915. * Caches the the state of the stencil buffer
  29916. */
  29917. cacheStencilState(): void;
  29918. /**
  29919. * Restores the state of the stencil buffer
  29920. */
  29921. restoreStencilState(): void;
  29922. /**
  29923. * Sets the current depth function to LEQUAL
  29924. */
  29925. setDepthFunctionToLessOrEqual(): void;
  29926. /**
  29927. * Gets a boolean indicating if stencil buffer is enabled
  29928. * @returns the current stencil buffer state
  29929. */
  29930. getStencilBuffer(): boolean;
  29931. /**
  29932. * Enable or disable the stencil buffer
  29933. * @param enable defines if the stencil buffer must be enabled or disabled
  29934. */
  29935. setStencilBuffer(enable: boolean): void;
  29936. /**
  29937. * Gets the current stencil mask
  29938. * @returns a number defining the new stencil mask to use
  29939. */
  29940. getStencilMask(): number;
  29941. /**
  29942. * Sets the current stencil mask
  29943. * @param mask defines the new stencil mask to use
  29944. */
  29945. setStencilMask(mask: number): void;
  29946. /**
  29947. * Gets the current stencil function
  29948. * @returns a number defining the stencil function to use
  29949. */
  29950. getStencilFunction(): number;
  29951. /**
  29952. * Gets the current stencil reference value
  29953. * @returns a number defining the stencil reference value to use
  29954. */
  29955. getStencilFunctionReference(): number;
  29956. /**
  29957. * Gets the current stencil mask
  29958. * @returns a number defining the stencil mask to use
  29959. */
  29960. getStencilFunctionMask(): number;
  29961. /**
  29962. * Sets the current stencil function
  29963. * @param stencilFunc defines the new stencil function to use
  29964. */
  29965. setStencilFunction(stencilFunc: number): void;
  29966. /**
  29967. * Sets the current stencil reference
  29968. * @param reference defines the new stencil reference to use
  29969. */
  29970. setStencilFunctionReference(reference: number): void;
  29971. /**
  29972. * Sets the current stencil mask
  29973. * @param mask defines the new stencil mask to use
  29974. */
  29975. setStencilFunctionMask(mask: number): void;
  29976. /**
  29977. * Gets the current stencil operation when stencil fails
  29978. * @returns a number defining stencil operation to use when stencil fails
  29979. */
  29980. getStencilOperationFail(): number;
  29981. /**
  29982. * Gets the current stencil operation when depth fails
  29983. * @returns a number defining stencil operation to use when depth fails
  29984. */
  29985. getStencilOperationDepthFail(): number;
  29986. /**
  29987. * Gets the current stencil operation when stencil passes
  29988. * @returns a number defining stencil operation to use when stencil passes
  29989. */
  29990. getStencilOperationPass(): number;
  29991. /**
  29992. * Sets the stencil operation to use when stencil fails
  29993. * @param operation defines the stencil operation to use when stencil fails
  29994. */
  29995. setStencilOperationFail(operation: number): void;
  29996. /**
  29997. * Sets the stencil operation to use when depth fails
  29998. * @param operation defines the stencil operation to use when depth fails
  29999. */
  30000. setStencilOperationDepthFail(operation: number): void;
  30001. /**
  30002. * Sets the stencil operation to use when stencil passes
  30003. * @param operation defines the stencil operation to use when stencil passes
  30004. */
  30005. setStencilOperationPass(operation: number): void;
  30006. /**
  30007. * Sets a boolean indicating if the dithering state is enabled or disabled
  30008. * @param value defines the dithering state
  30009. */
  30010. setDitheringState(value: boolean): void;
  30011. /**
  30012. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30013. * @param value defines the rasterizer state
  30014. */
  30015. setRasterizerState(value: boolean): void;
  30016. /**
  30017. * stop executing a render loop function and remove it from the execution array
  30018. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30019. */
  30020. stopRenderLoop(renderFunction?: () => void): void;
  30021. /** @hidden */ private _renderLoop(): void;
  30022. /**
  30023. * Can be used to override the current requestAnimationFrame requester.
  30024. * @hidden
  30025. */
  30026. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30027. /**
  30028. * Register and execute a render loop. The engine can have more than one render function
  30029. * @param renderFunction defines the function to continuously execute
  30030. */
  30031. runRenderLoop(renderFunction: () => void): void;
  30032. /**
  30033. * Toggle full screen mode
  30034. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30035. */
  30036. switchFullscreen(requestPointerLock: boolean): void;
  30037. /**
  30038. * Enters full screen mode
  30039. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30040. */
  30041. enterFullscreen(requestPointerLock: boolean): void;
  30042. /**
  30043. * Exits full screen mode
  30044. */
  30045. exitFullscreen(): void;
  30046. /**
  30047. * Enters Pointerlock mode
  30048. */
  30049. enterPointerlock(): void;
  30050. /**
  30051. * Exits Pointerlock mode
  30052. */
  30053. exitPointerlock(): void;
  30054. /**
  30055. * Clear the current render buffer or the current render target (if any is set up)
  30056. * @param color defines the color to use
  30057. * @param backBuffer defines if the back buffer must be cleared
  30058. * @param depth defines if the depth buffer must be cleared
  30059. * @param stencil defines if the stencil buffer must be cleared
  30060. */
  30061. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30062. /**
  30063. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30064. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30065. * @param y defines the y-coordinate of the corner of the clear rectangle
  30066. * @param width defines the width of the clear rectangle
  30067. * @param height defines the height of the clear rectangle
  30068. * @param clearColor defines the clear color
  30069. */
  30070. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30071. /**
  30072. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30073. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30074. * @param y defines the y-coordinate of the corner of the clear rectangle
  30075. * @param width defines the width of the clear rectangle
  30076. * @param height defines the height of the clear rectangle
  30077. */
  30078. enableScissor(x: number, y: number, width: number, height: number): void;
  30079. /**
  30080. * Disable previously set scissor test rectangle
  30081. */
  30082. disableScissor(): void;
  30083. private _viewportCached;
  30084. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  30085. /**
  30086. * Set the WebGL's viewport
  30087. * @param viewport defines the viewport element to be used
  30088. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30089. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30090. */
  30091. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30092. /**
  30093. * Directly set the WebGL Viewport
  30094. * @param x defines the x coordinate of the viewport (in screen space)
  30095. * @param y defines the y coordinate of the viewport (in screen space)
  30096. * @param width defines the width of the viewport (in screen space)
  30097. * @param height defines the height of the viewport (in screen space)
  30098. * @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
  30099. */
  30100. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30101. /**
  30102. * Begin a new frame
  30103. */
  30104. beginFrame(): void;
  30105. /**
  30106. * Enf the current frame
  30107. */
  30108. endFrame(): void;
  30109. /**
  30110. * Resize the view according to the canvas' size
  30111. */
  30112. resize(): void;
  30113. /**
  30114. * Force a specific size of the canvas
  30115. * @param width defines the new canvas' width
  30116. * @param height defines the new canvas' height
  30117. */
  30118. setSize(width: number, height: number): void;
  30119. /**
  30120. * Binds the frame buffer to the specified texture.
  30121. * @param texture The texture to render to or null for the default canvas
  30122. * @param faceIndex The face of the texture to render to in case of cube texture
  30123. * @param requiredWidth The width of the target to render to
  30124. * @param requiredHeight The height of the target to render to
  30125. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30126. * @param depthStencilTexture The depth stencil texture to use to render
  30127. * @param lodLevel defines le lod level to bind to the frame buffer
  30128. */
  30129. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30130. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30131. /**
  30132. * Unbind the current render target texture from the webGL context
  30133. * @param texture defines the render target texture to unbind
  30134. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30135. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30136. */
  30137. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30138. /**
  30139. * Force the mipmap generation for the given render target texture
  30140. * @param texture defines the render target texture to use
  30141. */
  30142. generateMipMapsForCubemap(texture: InternalTexture): void;
  30143. /**
  30144. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30145. */
  30146. flushFramebuffer(): void;
  30147. /**
  30148. * Unbind the current render target and bind the default framebuffer
  30149. */
  30150. restoreDefaultFramebuffer(): void;
  30151. /**
  30152. * Create an uniform buffer
  30153. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30154. * @param elements defines the content of the uniform buffer
  30155. * @returns the webGL uniform buffer
  30156. */
  30157. createUniformBuffer(elements: FloatArray): DataBuffer;
  30158. /**
  30159. * Create a dynamic uniform buffer
  30160. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30161. * @param elements defines the content of the uniform buffer
  30162. * @returns the webGL uniform buffer
  30163. */
  30164. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30165. /**
  30166. * Update an existing uniform buffer
  30167. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30168. * @param uniformBuffer defines the target uniform buffer
  30169. * @param elements defines the content to update
  30170. * @param offset defines the offset in the uniform buffer where update should start
  30171. * @param count defines the size of the data to update
  30172. */
  30173. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30174. private _resetVertexBufferBinding;
  30175. /**
  30176. * Creates a vertex buffer
  30177. * @param data the data for the vertex buffer
  30178. * @returns the new WebGL static buffer
  30179. */
  30180. createVertexBuffer(data: DataArray): DataBuffer;
  30181. /**
  30182. * Creates a dynamic vertex buffer
  30183. * @param data the data for the dynamic vertex buffer
  30184. * @returns the new WebGL dynamic buffer
  30185. */
  30186. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30187. /**
  30188. * Update a dynamic index buffer
  30189. * @param indexBuffer defines the target index buffer
  30190. * @param indices defines the data to update
  30191. * @param offset defines the offset in the target index buffer where update should start
  30192. */
  30193. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30194. /**
  30195. * Updates a dynamic vertex buffer.
  30196. * @param vertexBuffer the vertex buffer to update
  30197. * @param data the data used to update the vertex buffer
  30198. * @param byteOffset the byte offset of the data
  30199. * @param byteLength the byte length of the data
  30200. */
  30201. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30202. private _resetIndexBufferBinding;
  30203. /**
  30204. * Creates a new index buffer
  30205. * @param indices defines the content of the index buffer
  30206. * @param updatable defines if the index buffer must be updatable
  30207. * @returns a new webGL buffer
  30208. */
  30209. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30210. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30211. /**
  30212. * Bind a webGL buffer to the webGL context
  30213. * @param buffer defines the buffer to bind
  30214. */
  30215. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30216. /**
  30217. * Bind an uniform buffer to the current webGL context
  30218. * @param buffer defines the buffer to bind
  30219. */
  30220. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30221. /**
  30222. * Bind a buffer to the current webGL context at a given location
  30223. * @param buffer defines the buffer to bind
  30224. * @param location defines the index where to bind the buffer
  30225. */
  30226. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30227. /**
  30228. * Bind a specific block at a given index in a specific shader program
  30229. * @param pipelineContext defines the pipeline context to use
  30230. * @param blockName defines the block name
  30231. * @param index defines the index where to bind the block
  30232. */
  30233. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30234. private bindIndexBuffer;
  30235. private bindBuffer;
  30236. /**
  30237. * update the bound buffer with the given data
  30238. * @param data defines the data to update
  30239. */
  30240. updateArrayBuffer(data: Float32Array): void;
  30241. private _vertexAttribPointer;
  30242. private _bindIndexBufferWithCache;
  30243. private _bindVertexBuffersAttributes;
  30244. /**
  30245. * Records a vertex array object
  30246. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30247. * @param vertexBuffers defines the list of vertex buffers to store
  30248. * @param indexBuffer defines the index buffer to store
  30249. * @param effect defines the effect to store
  30250. * @returns the new vertex array object
  30251. */
  30252. recordVertexArrayObject(vertexBuffers: {
  30253. [key: string]: VertexBuffer;
  30254. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30255. /**
  30256. * Bind a specific vertex array object
  30257. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30258. * @param vertexArrayObject defines the vertex array object to bind
  30259. * @param indexBuffer defines the index buffer to bind
  30260. */
  30261. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30262. /**
  30263. * Bind webGl buffers directly to the webGL context
  30264. * @param vertexBuffer defines the vertex buffer to bind
  30265. * @param indexBuffer defines the index buffer to bind
  30266. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30267. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30268. * @param effect defines the effect associated with the vertex buffer
  30269. */
  30270. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30271. private _unbindVertexArrayObject;
  30272. /**
  30273. * Bind a list of vertex buffers to the webGL context
  30274. * @param vertexBuffers defines the list of vertex buffers to bind
  30275. * @param indexBuffer defines the index buffer to bind
  30276. * @param effect defines the effect associated with the vertex buffers
  30277. */
  30278. bindBuffers(vertexBuffers: {
  30279. [key: string]: Nullable<VertexBuffer>;
  30280. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30281. /**
  30282. * Unbind all instance attributes
  30283. */
  30284. unbindInstanceAttributes(): void;
  30285. /**
  30286. * Release and free the memory of a vertex array object
  30287. * @param vao defines the vertex array object to delete
  30288. */
  30289. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30290. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  30291. protected _deleteBuffer(buffer: DataBuffer): void;
  30292. /**
  30293. * Creates a webGL buffer to use with instanciation
  30294. * @param capacity defines the size of the buffer
  30295. * @returns the webGL buffer
  30296. */
  30297. createInstancesBuffer(capacity: number): DataBuffer;
  30298. /**
  30299. * Delete a webGL buffer used with instanciation
  30300. * @param buffer defines the webGL buffer to delete
  30301. */
  30302. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30303. /**
  30304. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30305. * @param instancesBuffer defines the webGL buffer to update and bind
  30306. * @param data defines the data to store in the buffer
  30307. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30308. */
  30309. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30310. /**
  30311. * Apply all cached states (depth, culling, stencil and alpha)
  30312. */
  30313. applyStates(): void;
  30314. /**
  30315. * Send a draw order
  30316. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30317. * @param indexStart defines the starting index
  30318. * @param indexCount defines the number of index to draw
  30319. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30320. */
  30321. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30322. /**
  30323. * Draw a list of points
  30324. * @param verticesStart defines the index of first vertex to draw
  30325. * @param verticesCount defines the count of vertices to draw
  30326. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30327. */
  30328. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30329. /**
  30330. * Draw a list of unindexed primitives
  30331. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30332. * @param verticesStart defines the index of first vertex to draw
  30333. * @param verticesCount defines the count of vertices to draw
  30334. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30335. */
  30336. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30337. /**
  30338. * Draw a list of indexed primitives
  30339. * @param fillMode defines the primitive to use
  30340. * @param indexStart defines the starting index
  30341. * @param indexCount defines the number of index to draw
  30342. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30343. */
  30344. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30345. /**
  30346. * Draw a list of unindexed primitives
  30347. * @param fillMode defines the primitive to use
  30348. * @param verticesStart defines the index of first vertex to draw
  30349. * @param verticesCount defines the count of vertices to draw
  30350. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30351. */
  30352. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30353. private _drawMode;
  30354. /** @hidden */ private _releaseEffect(effect: Effect): void;
  30355. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30356. /**
  30357. * Create a new effect (used to store vertex/fragment shaders)
  30358. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30359. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30360. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30361. * @param samplers defines an array of string used to represent textures
  30362. * @param defines defines the string containing the defines to use to compile the shaders
  30363. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30364. * @param onCompiled defines a function to call when the effect creation is successful
  30365. * @param onError defines a function to call when the effect creation has failed
  30366. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30367. * @returns the new Effect
  30368. */
  30369. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30370. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30371. private _compileShader;
  30372. private _compileRawShader;
  30373. /**
  30374. * Directly creates a webGL program
  30375. * @param pipelineContext defines the pipeline context to attach to
  30376. * @param vertexCode defines the vertex shader code to use
  30377. * @param fragmentCode defines the fragment shader code to use
  30378. * @param context defines the webGL context to use (if not set, the current one will be used)
  30379. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30380. * @returns the new webGL program
  30381. */
  30382. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30383. /**
  30384. * Creates a webGL program
  30385. * @param pipelineContext defines the pipeline context to attach to
  30386. * @param vertexCode defines the vertex shader code to use
  30387. * @param fragmentCode defines the fragment shader code to use
  30388. * @param defines defines the string containing the defines to use to compile the shaders
  30389. * @param context defines the webGL context to use (if not set, the current one will be used)
  30390. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30391. * @returns the new webGL program
  30392. */
  30393. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30394. /**
  30395. * Creates a new pipeline context
  30396. * @returns the new pipeline
  30397. */
  30398. createPipelineContext(): IPipelineContext;
  30399. private _createShaderProgram;
  30400. private _finalizePipelineContext;
  30401. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30402. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30403. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30404. /**
  30405. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30406. * @param pipelineContext defines the pipeline context to use
  30407. * @param uniformsNames defines the list of uniform names
  30408. * @returns an array of webGL uniform locations
  30409. */
  30410. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30411. /**
  30412. * Gets the lsit of active attributes for a given webGL program
  30413. * @param pipelineContext defines the pipeline context to use
  30414. * @param attributesNames defines the list of attribute names to get
  30415. * @returns an array of indices indicating the offset of each attribute
  30416. */
  30417. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30418. /**
  30419. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30420. * @param effect defines the effect to activate
  30421. */
  30422. enableEffect(effect: Nullable<Effect>): void;
  30423. /**
  30424. * Set the value of an uniform to an array of int32
  30425. * @param uniform defines the webGL uniform location where to store the value
  30426. * @param array defines the array of int32 to store
  30427. */
  30428. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30429. /**
  30430. * Set the value of an uniform to an array of int32 (stored as vec2)
  30431. * @param uniform defines the webGL uniform location where to store the value
  30432. * @param array defines the array of int32 to store
  30433. */
  30434. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30435. /**
  30436. * Set the value of an uniform to an array of int32 (stored as vec3)
  30437. * @param uniform defines the webGL uniform location where to store the value
  30438. * @param array defines the array of int32 to store
  30439. */
  30440. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30441. /**
  30442. * Set the value of an uniform to an array of int32 (stored as vec4)
  30443. * @param uniform defines the webGL uniform location where to store the value
  30444. * @param array defines the array of int32 to store
  30445. */
  30446. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30447. /**
  30448. * Set the value of an uniform to an array of float32
  30449. * @param uniform defines the webGL uniform location where to store the value
  30450. * @param array defines the array of float32 to store
  30451. */
  30452. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30453. /**
  30454. * Set the value of an uniform to an array of float32 (stored as vec2)
  30455. * @param uniform defines the webGL uniform location where to store the value
  30456. * @param array defines the array of float32 to store
  30457. */
  30458. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30459. /**
  30460. * Set the value of an uniform to an array of float32 (stored as vec3)
  30461. * @param uniform defines the webGL uniform location where to store the value
  30462. * @param array defines the array of float32 to store
  30463. */
  30464. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30465. /**
  30466. * Set the value of an uniform to an array of float32 (stored as vec4)
  30467. * @param uniform defines the webGL uniform location where to store the value
  30468. * @param array defines the array of float32 to store
  30469. */
  30470. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30471. /**
  30472. * Set the value of an uniform to an array of number
  30473. * @param uniform defines the webGL uniform location where to store the value
  30474. * @param array defines the array of number to store
  30475. */
  30476. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30477. /**
  30478. * Set the value of an uniform to an array of number (stored as vec2)
  30479. * @param uniform defines the webGL uniform location where to store the value
  30480. * @param array defines the array of number to store
  30481. */
  30482. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30483. /**
  30484. * Set the value of an uniform to an array of number (stored as vec3)
  30485. * @param uniform defines the webGL uniform location where to store the value
  30486. * @param array defines the array of number to store
  30487. */
  30488. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30489. /**
  30490. * Set the value of an uniform to an array of number (stored as vec4)
  30491. * @param uniform defines the webGL uniform location where to store the value
  30492. * @param array defines the array of number to store
  30493. */
  30494. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30495. /**
  30496. * Set the value of an uniform to an array of float32 (stored as matrices)
  30497. * @param uniform defines the webGL uniform location where to store the value
  30498. * @param matrices defines the array of float32 to store
  30499. */
  30500. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30501. /**
  30502. * Set the value of an uniform to a matrix (3x3)
  30503. * @param uniform defines the webGL uniform location where to store the value
  30504. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30505. */
  30506. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30507. /**
  30508. * Set the value of an uniform to a matrix (2x2)
  30509. * @param uniform defines the webGL uniform location where to store the value
  30510. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30511. */
  30512. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30513. /**
  30514. * Set the value of an uniform to a number (int)
  30515. * @param uniform defines the webGL uniform location where to store the value
  30516. * @param value defines the int number to store
  30517. */
  30518. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30519. /**
  30520. * Set the value of an uniform to a number (float)
  30521. * @param uniform defines the webGL uniform location where to store the value
  30522. * @param value defines the float number to store
  30523. */
  30524. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30525. /**
  30526. * Set the value of an uniform to a vec2
  30527. * @param uniform defines the webGL uniform location where to store the value
  30528. * @param x defines the 1st component of the value
  30529. * @param y defines the 2nd component of the value
  30530. */
  30531. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30532. /**
  30533. * Set the value of an uniform to a vec3
  30534. * @param uniform defines the webGL uniform location where to store the value
  30535. * @param x defines the 1st component of the value
  30536. * @param y defines the 2nd component of the value
  30537. * @param z defines the 3rd component of the value
  30538. */
  30539. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30540. /**
  30541. * Set the value of an uniform to a boolean
  30542. * @param uniform defines the webGL uniform location where to store the value
  30543. * @param bool defines the boolean to store
  30544. */
  30545. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30546. /**
  30547. * Set the value of an uniform to a vec4
  30548. * @param uniform defines the webGL uniform location where to store the value
  30549. * @param x defines the 1st component of the value
  30550. * @param y defines the 2nd component of the value
  30551. * @param z defines the 3rd component of the value
  30552. * @param w defines the 4th component of the value
  30553. */
  30554. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30555. /**
  30556. * Sets a Color4 on a uniform variable
  30557. * @param uniform defines the uniform location
  30558. * @param color4 defines the value to be set
  30559. */
  30560. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30561. /**
  30562. * Set various states to the webGL context
  30563. * @param culling defines backface culling state
  30564. * @param zOffset defines the value to apply to zOffset (0 by default)
  30565. * @param force defines if states must be applied even if cache is up to date
  30566. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30567. */
  30568. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30569. /**
  30570. * Set the z offset to apply to current rendering
  30571. * @param value defines the offset to apply
  30572. */
  30573. setZOffset(value: number): void;
  30574. /**
  30575. * Gets the current value of the zOffset
  30576. * @returns the current zOffset state
  30577. */
  30578. getZOffset(): number;
  30579. /**
  30580. * Enable or disable depth buffering
  30581. * @param enable defines the state to set
  30582. */
  30583. setDepthBuffer(enable: boolean): void;
  30584. /**
  30585. * Gets a boolean indicating if depth writing is enabled
  30586. * @returns the current depth writing state
  30587. */
  30588. getDepthWrite(): boolean;
  30589. /**
  30590. * Enable or disable depth writing
  30591. * @param enable defines the state to set
  30592. */
  30593. setDepthWrite(enable: boolean): void;
  30594. /**
  30595. * Enable or disable color writing
  30596. * @param enable defines the state to set
  30597. */
  30598. setColorWrite(enable: boolean): void;
  30599. /**
  30600. * Gets a boolean indicating if color writing is enabled
  30601. * @returns the current color writing state
  30602. */
  30603. getColorWrite(): boolean;
  30604. /**
  30605. * Sets alpha constants used by some alpha blending modes
  30606. * @param r defines the red component
  30607. * @param g defines the green component
  30608. * @param b defines the blue component
  30609. * @param a defines the alpha component
  30610. */
  30611. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30612. /**
  30613. * Sets the current alpha mode
  30614. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30615. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30616. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30617. */
  30618. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30619. /**
  30620. * Gets the current alpha mode
  30621. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30622. * @returns the current alpha mode
  30623. */
  30624. getAlphaMode(): number;
  30625. /**
  30626. * Clears the list of texture accessible through engine.
  30627. * This can help preventing texture load conflict due to name collision.
  30628. */
  30629. clearInternalTexturesCache(): void;
  30630. /**
  30631. * Force the entire cache to be cleared
  30632. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30633. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30634. */
  30635. wipeCaches(bruteForce?: boolean): void;
  30636. /**
  30637. * Set the compressed texture format to use, based on the formats you have, and the formats
  30638. * supported by the hardware / browser.
  30639. *
  30640. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30641. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30642. * to API arguments needed to compressed textures. This puts the burden on the container
  30643. * generator to house the arcane code for determining these for current & future formats.
  30644. *
  30645. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30646. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30647. *
  30648. * Note: The result of this call is not taken into account when a texture is base64.
  30649. *
  30650. * @param formatsAvailable defines the list of those format families you have created
  30651. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30652. *
  30653. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30654. * @returns The extension selected.
  30655. */
  30656. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30657. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30658. min: number;
  30659. mag: number;
  30660. };
  30661. /** @hidden */ private _createTexture(): WebGLTexture;
  30662. /**
  30663. * Usually called from Texture.ts.
  30664. * Passed information to create a WebGLTexture
  30665. * @param urlArg defines a value which contains one of the following:
  30666. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30667. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30668. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30670. * @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)
  30671. * @param scene needed for loading to the correct scene
  30672. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30673. * @param onLoad optional callback to be called upon successful completion
  30674. * @param onError optional callback to be called upon failure
  30675. * @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
  30676. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30677. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30678. * @param forcedExtension defines the extension to use to pick the right loader
  30679. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30680. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30681. */
  30682. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30683. /**
  30684. * @hidden
  30685. * Rescales a texture
  30686. * @param source input texutre
  30687. * @param destination destination texture
  30688. * @param scene scene to use to render the resize
  30689. * @param internalFormat format to use when resizing
  30690. * @param onComplete callback to be called when resize has completed
  30691. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  30692. private _unpackFlipYCached;
  30693. /**
  30694. * In case you are sharing the context with other applications, it might
  30695. * be interested to not cache the unpack flip y state to ensure a consistent
  30696. * value would be set.
  30697. */
  30698. enableUnpackFlipYCached: boolean;
  30699. /** @hidden */ private _unpackFlipY(value: boolean): void;
  30700. /** @hidden */ private _getUnpackAlignement(): number;
  30701. /**
  30702. * Creates a dynamic texture
  30703. * @param width defines the width of the texture
  30704. * @param height defines the height of the texture
  30705. * @param generateMipMaps defines if the engine should generate the mip levels
  30706. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30707. * @returns the dynamic texture inside an InternalTexture
  30708. */
  30709. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  30710. /**
  30711. * Update the sampling mode of a given texture
  30712. * @param samplingMode defines the required sampling mode
  30713. * @param texture defines the texture to update
  30714. */
  30715. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30716. /**
  30717. * Update the content of a dynamic texture
  30718. * @param texture defines the texture to update
  30719. * @param canvas defines the canvas containing the source
  30720. * @param invertY defines if data must be stored with Y axis inverted
  30721. * @param premulAlpha defines if alpha is stored as premultiplied
  30722. * @param format defines the format of the data
  30723. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30724. */
  30725. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  30726. /**
  30727. * Update a video texture
  30728. * @param texture defines the texture to update
  30729. * @param video defines the video element to use
  30730. * @param invertY defines if data must be stored with Y axis inverted
  30731. */
  30732. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30733. /**
  30734. * Updates a depth texture Comparison Mode and Function.
  30735. * If the comparison Function is equal to 0, the mode will be set to none.
  30736. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30737. * @param texture The texture to set the comparison function for
  30738. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30739. */
  30740. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30741. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30742. width: number;
  30743. height: number;
  30744. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30745. /**
  30746. * Creates a depth stencil texture.
  30747. * This is only available in WebGL 2 or with the depth texture extension available.
  30748. * @param size The size of face edge in the texture.
  30749. * @param options The options defining the texture.
  30750. * @returns The texture
  30751. */
  30752. createDepthStencilTexture(size: number | {
  30753. width: number;
  30754. height: number;
  30755. }, options: DepthTextureCreationOptions): InternalTexture;
  30756. /**
  30757. * Creates a depth stencil texture.
  30758. * This is only available in WebGL 2 or with the depth texture extension available.
  30759. * @param size The size of face edge in the texture.
  30760. * @param options The options defining the texture.
  30761. * @returns The texture
  30762. */
  30763. private _createDepthStencilTexture;
  30764. /**
  30765. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30766. * @param renderTarget The render target to set the frame buffer for
  30767. */
  30768. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30769. /**
  30770. * Creates a new render target texture
  30771. * @param size defines the size of the texture
  30772. * @param options defines the options used to create the texture
  30773. * @returns a new render target texture stored in an InternalTexture
  30774. */
  30775. createRenderTargetTexture(size: number | {
  30776. width: number;
  30777. height: number;
  30778. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  30779. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30780. /**
  30781. * Updates the sample count of a render target texture
  30782. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30783. * @param texture defines the texture to update
  30784. * @param samples defines the sample count to set
  30785. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30786. */
  30787. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  30788. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30789. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30790. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30791. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30792. /**
  30793. * @hidden
  30794. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  30795. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30796. private _prepareWebGLTexture;
  30797. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30798. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  30799. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  30800. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30801. protected _setProgram(program: WebGLProgram): void;
  30802. protected _boundUniforms: {
  30803. [key: number]: WebGLUniformLocation;
  30804. };
  30805. /**
  30806. * Binds an effect to the webGL context
  30807. * @param effect defines the effect to bind
  30808. */
  30809. bindSamplers(effect: Effect): void;
  30810. private _activateCurrentTexture;
  30811. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30812. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30813. /**
  30814. * Sets a texture to the webGL context from a postprocess
  30815. * @param channel defines the channel to use
  30816. * @param postProcess defines the source postprocess
  30817. */
  30818. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30819. /**
  30820. * Binds the output of the passed in post process to the texture channel specified
  30821. * @param channel The channel the texture should be bound to
  30822. * @param postProcess The post process which's output should be bound
  30823. */
  30824. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30825. /**
  30826. * Unbind all textures from the webGL context
  30827. */
  30828. unbindAllTextures(): void;
  30829. /**
  30830. * Sets a texture to the according uniform.
  30831. * @param channel The texture channel
  30832. * @param uniform The uniform to set
  30833. * @param texture The texture to apply
  30834. */
  30835. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30836. /**
  30837. * Sets a depth stencil texture from a render target to the according uniform.
  30838. * @param channel The texture channel
  30839. * @param uniform The uniform to set
  30840. * @param texture The render target texture containing the depth stencil texture to apply
  30841. */
  30842. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30843. private _bindSamplerUniformToChannel;
  30844. private _getTextureWrapMode;
  30845. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30846. /**
  30847. * Sets an array of texture to the webGL context
  30848. * @param channel defines the channel where the texture array must be set
  30849. * @param uniform defines the associated uniform location
  30850. * @param textures defines the array of textures to bind
  30851. */
  30852. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30853. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30854. private _setTextureParameterFloat;
  30855. private _setTextureParameterInteger;
  30856. /**
  30857. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30858. * @param x defines the x coordinate of the rectangle where pixels must be read
  30859. * @param y defines the y coordinate of the rectangle where pixels must be read
  30860. * @param width defines the width of the rectangle where pixels must be read
  30861. * @param height defines the height of the rectangle where pixels must be read
  30862. * @returns a Uint8Array containing RGBA colors
  30863. */
  30864. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30865. /**
  30866. * Add an externaly attached data from its key.
  30867. * This method call will fail and return false, if such key already exists.
  30868. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  30869. * @param key the unique key that identifies the data
  30870. * @param data the data object to associate to the key for this Engine instance
  30871. * @return true if no such key were already present and the data was added successfully, false otherwise
  30872. */
  30873. addExternalData<T>(key: string, data: T): boolean;
  30874. /**
  30875. * Get an externaly attached data from its key
  30876. * @param key the unique key that identifies the data
  30877. * @return the associated data, if present (can be null), or undefined if not present
  30878. */
  30879. getExternalData<T>(key: string): T;
  30880. /**
  30881. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30882. * @param key the unique key that identifies the data
  30883. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30884. * @return the associated data, can be null if the factory returned null.
  30885. */
  30886. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30887. /**
  30888. * Remove an externaly attached data from the Engine instance
  30889. * @param key the unique key that identifies the data
  30890. * @return true if the data was successfully removed, false if it doesn't exist
  30891. */
  30892. removeExternalData(key: string): boolean;
  30893. /**
  30894. * Unbind all vertex attributes from the webGL context
  30895. */
  30896. unbindAllAttributes(): void;
  30897. /**
  30898. * 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
  30899. */
  30900. releaseEffects(): void;
  30901. /**
  30902. * Dispose and release all associated resources
  30903. */
  30904. dispose(): void;
  30905. /**
  30906. * Display the loading screen
  30907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30908. */
  30909. displayLoadingUI(): void;
  30910. /**
  30911. * Hide the loading screen
  30912. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30913. */
  30914. hideLoadingUI(): void;
  30915. /**
  30916. * Gets the current loading screen object
  30917. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30918. */
  30919. /**
  30920. * Sets the current loading screen object
  30921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30922. */
  30923. loadingScreen: ILoadingScreen;
  30924. /**
  30925. * Sets the current loading screen text
  30926. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30927. */
  30928. loadingUIText: string;
  30929. /**
  30930. * Sets the current loading screen background color
  30931. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30932. */
  30933. loadingUIBackgroundColor: string;
  30934. /**
  30935. * Attach a new callback raised when context lost event is fired
  30936. * @param callback defines the callback to call
  30937. */
  30938. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30939. /**
  30940. * Attach a new callback raised when context restored event is fired
  30941. * @param callback defines the callback to call
  30942. */
  30943. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30944. /**
  30945. * Gets the source code of the vertex shader associated with a specific webGL program
  30946. * @param program defines the program to use
  30947. * @returns a string containing the source code of the vertex shader associated with the program
  30948. */
  30949. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30950. /**
  30951. * Gets the source code of the fragment shader associated with a specific webGL program
  30952. * @param program defines the program to use
  30953. * @returns a string containing the source code of the fragment shader associated with the program
  30954. */
  30955. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30956. /**
  30957. * Get the current error code of the webGL context
  30958. * @returns the error code
  30959. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30960. */
  30961. getError(): number;
  30962. /**
  30963. * Gets the current framerate
  30964. * @returns a number representing the framerate
  30965. */
  30966. getFps(): number;
  30967. /**
  30968. * Gets the time spent between current and previous frame
  30969. * @returns a number representing the delta time in ms
  30970. */
  30971. getDeltaTime(): number;
  30972. private _measureFps;
  30973. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30974. private _canRenderToFloatFramebuffer;
  30975. private _canRenderToHalfFloatFramebuffer;
  30976. private _canRenderToFramebuffer;
  30977. /** @hidden */ private _getWebGLTextureType(type: number): number;
  30978. /** @hidden */ private _getInternalFormat(format: number): number;
  30979. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30980. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  30981. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30982. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30983. /**
  30984. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30985. * @returns true if the engine can be created
  30986. * @ignorenaming
  30987. */
  30988. static isSupported(): boolean;
  30989. /**
  30990. * Find the next highest power of two.
  30991. * @param x Number to start search from.
  30992. * @return Next highest power of two.
  30993. */
  30994. static CeilingPOT(x: number): number;
  30995. /**
  30996. * Find the next lowest power of two.
  30997. * @param x Number to start search from.
  30998. * @return Next lowest power of two.
  30999. */
  31000. static FloorPOT(x: number): number;
  31001. /**
  31002. * Find the nearest power of two.
  31003. * @param x Number to start search from.
  31004. * @return Next nearest power of two.
  31005. */
  31006. static NearestPOT(x: number): number;
  31007. /**
  31008. * Get the closest exponent of two
  31009. * @param value defines the value to approximate
  31010. * @param max defines the maximum value to return
  31011. * @param mode defines how to define the closest value
  31012. * @returns closest exponent of two of the given value
  31013. */
  31014. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31015. /**
  31016. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31017. * @param func - the function to be called
  31018. * @param requester - the object that will request the next frame. Falls back to window.
  31019. * @returns frame number
  31020. */
  31021. static QueueNewFrame(func: () => void, requester?: any): number;
  31022. /**
  31023. * Ask the browser to promote the current element to pointerlock mode
  31024. * @param element defines the DOM element to promote
  31025. */ private static _RequestPointerlock(element: HTMLElement): void;
  31026. /**
  31027. * Asks the browser to exit pointerlock mode
  31028. */ private static _ExitPointerlock(): void;
  31029. /**
  31030. * Ask the browser to promote the current element to fullscreen rendering mode
  31031. * @param element defines the DOM element to promote
  31032. */ private static _RequestFullscreen(element: HTMLElement): void;
  31033. /**
  31034. * Asks the browser to exit fullscreen mode
  31035. */ private static _ExitFullscreen(): void;
  31036. }
  31037. }
  31038. declare module BABYLON {
  31039. /**
  31040. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31041. * during the life time of the application.
  31042. */
  31043. export class EngineStore {
  31044. /** Gets the list of created engines */
  31045. static Instances: Engine[];
  31046. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31047. /**
  31048. * Gets the latest created engine
  31049. */
  31050. static readonly LastCreatedEngine: Nullable<Engine>;
  31051. /**
  31052. * Gets the latest created scene
  31053. */
  31054. static readonly LastCreatedScene: Nullable<Scene>;
  31055. /**
  31056. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31057. * @ignorenaming
  31058. */
  31059. static UseFallbackTexture: boolean;
  31060. /**
  31061. * Texture content used if a texture cannot loaded
  31062. * @ignorenaming
  31063. */
  31064. static FallbackTexture: string;
  31065. }
  31066. }
  31067. declare module BABYLON {
  31068. /**
  31069. * Helper class that provides a small promise polyfill
  31070. */
  31071. export class PromisePolyfill {
  31072. /**
  31073. * Static function used to check if the polyfill is required
  31074. * If this is the case then the function will inject the polyfill to window.Promise
  31075. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31076. */
  31077. static Apply(force?: boolean): void;
  31078. }
  31079. }
  31080. declare module BABYLON {
  31081. /**
  31082. * Interface for screenshot methods with describe argument called `size` as object with options
  31083. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31084. */
  31085. export interface IScreenshotSize {
  31086. /**
  31087. * number in pixels for canvas height
  31088. */
  31089. height?: number;
  31090. /**
  31091. * multiplier allowing render at a higher or lower resolution
  31092. * If value is defined then height and width will be ignored and taken from camera
  31093. */
  31094. precision?: number;
  31095. /**
  31096. * number in pixels for canvas width
  31097. */
  31098. width?: number;
  31099. }
  31100. }
  31101. declare module BABYLON {
  31102. interface IColor4Like {
  31103. r: float;
  31104. g: float;
  31105. b: float;
  31106. a: float;
  31107. }
  31108. /**
  31109. * Class containing a set of static utilities functions
  31110. */
  31111. export class Tools {
  31112. /**
  31113. * Gets or sets the base URL to use to load assets
  31114. */
  31115. static BaseUrl: string;
  31116. /**
  31117. * Enable/Disable Custom HTTP Request Headers globally.
  31118. * default = false
  31119. * @see CustomRequestHeaders
  31120. */
  31121. static UseCustomRequestHeaders: boolean;
  31122. /**
  31123. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31124. * i.e. when loading files, where the server/service expects an Authorization header
  31125. */
  31126. static CustomRequestHeaders: {
  31127. [key: string]: string;
  31128. };
  31129. /**
  31130. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31131. */
  31132. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31133. /**
  31134. * Default behaviour for cors in the application.
  31135. * It can be a string if the expected behavior is identical in the entire app.
  31136. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31137. */
  31138. static CorsBehavior: string | ((url: string | string[]) => string);
  31139. /**
  31140. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31141. * @ignorenaming
  31142. */
  31143. static UseFallbackTexture: boolean;
  31144. /**
  31145. * Use this object to register external classes like custom textures or material
  31146. * to allow the laoders to instantiate them
  31147. */
  31148. static RegisteredExternalClasses: {
  31149. [key: string]: Object;
  31150. };
  31151. /**
  31152. * Texture content used if a texture cannot loaded
  31153. * @ignorenaming
  31154. */
  31155. static fallbackTexture: string;
  31156. /**
  31157. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31158. * @param u defines the coordinate on X axis
  31159. * @param v defines the coordinate on Y axis
  31160. * @param width defines the width of the source data
  31161. * @param height defines the height of the source data
  31162. * @param pixels defines the source byte array
  31163. * @param color defines the output color
  31164. */
  31165. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31166. /**
  31167. * Interpolates between a and b via alpha
  31168. * @param a The lower value (returned when alpha = 0)
  31169. * @param b The upper value (returned when alpha = 1)
  31170. * @param alpha The interpolation-factor
  31171. * @return The mixed value
  31172. */
  31173. static Mix(a: number, b: number, alpha: number): number;
  31174. /**
  31175. * Tries to instantiate a new object from a given class name
  31176. * @param className defines the class name to instantiate
  31177. * @returns the new object or null if the system was not able to do the instantiation
  31178. */
  31179. static Instantiate(className: string): any;
  31180. /**
  31181. * Provides a slice function that will work even on IE
  31182. * @param data defines the array to slice
  31183. * @param start defines the start of the data (optional)
  31184. * @param end defines the end of the data (optional)
  31185. * @returns the new sliced array
  31186. */
  31187. static Slice<T>(data: T, start?: number, end?: number): T;
  31188. /**
  31189. * Polyfill for setImmediate
  31190. * @param action defines the action to execute after the current execution block
  31191. */
  31192. static SetImmediate(action: () => void): void;
  31193. /**
  31194. * Function indicating if a number is an exponent of 2
  31195. * @param value defines the value to test
  31196. * @returns true if the value is an exponent of 2
  31197. */
  31198. static IsExponentOfTwo(value: number): boolean;
  31199. private static _tmpFloatArray;
  31200. /**
  31201. * Returns the nearest 32-bit single precision float representation of a Number
  31202. * @param value A Number. If the parameter is of a different type, it will get converted
  31203. * to a number or to NaN if it cannot be converted
  31204. * @returns number
  31205. */
  31206. static FloatRound(value: number): number;
  31207. /**
  31208. * Extracts the filename from a path
  31209. * @param path defines the path to use
  31210. * @returns the filename
  31211. */
  31212. static GetFilename(path: string): string;
  31213. /**
  31214. * Extracts the "folder" part of a path (everything before the filename).
  31215. * @param uri The URI to extract the info from
  31216. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31217. * @returns The "folder" part of the path
  31218. */
  31219. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31220. /**
  31221. * Extracts text content from a DOM element hierarchy
  31222. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31223. */
  31224. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31225. /**
  31226. * Convert an angle in radians to degrees
  31227. * @param angle defines the angle to convert
  31228. * @returns the angle in degrees
  31229. */
  31230. static ToDegrees(angle: number): number;
  31231. /**
  31232. * Convert an angle in degrees to radians
  31233. * @param angle defines the angle to convert
  31234. * @returns the angle in radians
  31235. */
  31236. static ToRadians(angle: number): number;
  31237. /**
  31238. * Encode a buffer to a base64 string
  31239. * @param buffer defines the buffer to encode
  31240. * @returns the encoded string
  31241. */
  31242. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31243. /**
  31244. * Returns an array if obj is not an array
  31245. * @param obj defines the object to evaluate as an array
  31246. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31247. * @returns either obj directly if obj is an array or a new array containing obj
  31248. */
  31249. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31250. /**
  31251. * Gets the pointer prefix to use
  31252. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31253. */
  31254. static GetPointerPrefix(): string;
  31255. /**
  31256. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31257. * @param url define the url we are trying
  31258. * @param element define the dom element where to configure the cors policy
  31259. */
  31260. static SetCorsBehavior(url: string | string[], element: {
  31261. crossOrigin: string | null;
  31262. }): void;
  31263. /**
  31264. * Removes unwanted characters from an url
  31265. * @param url defines the url to clean
  31266. * @returns the cleaned url
  31267. */
  31268. static CleanUrl(url: string): string;
  31269. /**
  31270. * Gets or sets a function used to pre-process url before using them to load assets
  31271. */
  31272. static PreprocessUrl: (url: string) => string;
  31273. /**
  31274. * Loads an image as an HTMLImageElement.
  31275. * @param input url string, ArrayBuffer, or Blob to load
  31276. * @param onLoad callback called when the image successfully loads
  31277. * @param onError callback called when the image fails to load
  31278. * @param offlineProvider offline provider for caching
  31279. * @returns the HTMLImageElement of the loaded image
  31280. */
  31281. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31282. /**
  31283. * Loads a file
  31284. * @param url url string, ArrayBuffer, or Blob to load
  31285. * @param onSuccess callback called when the file successfully loads
  31286. * @param onProgress callback called while file is loading (if the server supports this mode)
  31287. * @param offlineProvider defines the offline provider for caching
  31288. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31289. * @param onError callback called when the file fails to load
  31290. * @returns a file request object
  31291. */
  31292. 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;
  31293. /**
  31294. * Loads a file from a url
  31295. * @param url the file url to load
  31296. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31297. */
  31298. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31299. /**
  31300. * Load a script (identified by an url). When the url returns, the
  31301. * content of this file is added into a new script element, attached to the DOM (body element)
  31302. * @param scriptUrl defines the url of the script to laod
  31303. * @param onSuccess defines the callback called when the script is loaded
  31304. * @param onError defines the callback to call if an error occurs
  31305. * @param scriptId defines the id of the script element
  31306. */
  31307. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31308. /**
  31309. * Load an asynchronous script (identified by an url). When the url returns, the
  31310. * content of this file is added into a new script element, attached to the DOM (body element)
  31311. * @param scriptUrl defines the url of the script to laod
  31312. * @param scriptId defines the id of the script element
  31313. * @returns a promise request object
  31314. */
  31315. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31316. /**
  31317. * Loads a file from a blob
  31318. * @param fileToLoad defines the blob to use
  31319. * @param callback defines the callback to call when data is loaded
  31320. * @param progressCallback defines the callback to call during loading process
  31321. * @returns a file request object
  31322. */
  31323. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31324. /**
  31325. * Loads a file
  31326. * @param fileToLoad defines the file to load
  31327. * @param callback defines the callback to call when data is loaded
  31328. * @param progressCallBack defines the callback to call during loading process
  31329. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31330. * @returns a file request object
  31331. */
  31332. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31333. /**
  31334. * Creates a data url from a given string content
  31335. * @param content defines the content to convert
  31336. * @returns the new data url link
  31337. */
  31338. static FileAsURL(content: string): string;
  31339. /**
  31340. * Format the given number to a specific decimal format
  31341. * @param value defines the number to format
  31342. * @param decimals defines the number of decimals to use
  31343. * @returns the formatted string
  31344. */
  31345. static Format(value: number, decimals?: number): string;
  31346. /**
  31347. * Tries to copy an object by duplicating every property
  31348. * @param source defines the source object
  31349. * @param destination defines the target object
  31350. * @param doNotCopyList defines a list of properties to avoid
  31351. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31352. */
  31353. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31354. /**
  31355. * Gets a boolean indicating if the given object has no own property
  31356. * @param obj defines the object to test
  31357. * @returns true if object has no own property
  31358. */
  31359. static IsEmpty(obj: any): boolean;
  31360. /**
  31361. * Function used to register events at window level
  31362. * @param windowElement defines the Window object to use
  31363. * @param events defines the events to register
  31364. */
  31365. static RegisterTopRootEvents(windowElement: Window, events: {
  31366. name: string;
  31367. handler: Nullable<(e: FocusEvent) => any>;
  31368. }[]): void;
  31369. /**
  31370. * Function used to unregister events from window level
  31371. * @param windowElement defines the Window object to use
  31372. * @param events defines the events to unregister
  31373. */
  31374. static UnregisterTopRootEvents(windowElement: Window, events: {
  31375. name: string;
  31376. handler: Nullable<(e: FocusEvent) => any>;
  31377. }[]): void;
  31378. /**
  31379. * @ignore
  31380. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31381. /**
  31382. * Dumps the current bound framebuffer
  31383. * @param width defines the rendering width
  31384. * @param height defines the rendering height
  31385. * @param engine defines the hosting engine
  31386. * @param successCallback defines the callback triggered once the data are available
  31387. * @param mimeType defines the mime type of the result
  31388. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31389. */
  31390. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31391. /**
  31392. * Converts the canvas data to blob.
  31393. * This acts as a polyfill for browsers not supporting the to blob function.
  31394. * @param canvas Defines the canvas to extract the data from
  31395. * @param successCallback Defines the callback triggered once the data are available
  31396. * @param mimeType Defines the mime type of the result
  31397. */
  31398. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31399. /**
  31400. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31401. * @param successCallback defines the callback triggered once the data are available
  31402. * @param mimeType defines the mime type of the result
  31403. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31404. */
  31405. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31406. /**
  31407. * Downloads a blob in the browser
  31408. * @param blob defines the blob to download
  31409. * @param fileName defines the name of the downloaded file
  31410. */
  31411. static Download(blob: Blob, fileName: string): void;
  31412. /**
  31413. * Captures a screenshot of the current rendering
  31414. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31415. * @param engine defines the rendering engine
  31416. * @param camera defines the source camera
  31417. * @param size This parameter can be set to a single number or to an object with the
  31418. * following (optional) properties: precision, width, height. If a single number is passed,
  31419. * it will be used for both width and height. If an object is passed, the screenshot size
  31420. * will be derived from the parameters. The precision property is a multiplier allowing
  31421. * rendering at a higher or lower resolution
  31422. * @param successCallback defines the callback receives a single parameter which contains the
  31423. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31424. * src parameter of an <img> to display it
  31425. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31426. * Check your browser for supported MIME types
  31427. */
  31428. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31429. /**
  31430. * Captures a screenshot of the current rendering
  31431. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31432. * @param engine defines the rendering engine
  31433. * @param camera defines the source camera
  31434. * @param size This parameter can be set to a single number or to an object with the
  31435. * following (optional) properties: precision, width, height. If a single number is passed,
  31436. * it will be used for both width and height. If an object is passed, the screenshot size
  31437. * will be derived from the parameters. The precision property is a multiplier allowing
  31438. * rendering at a higher or lower resolution
  31439. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31440. * Check your browser for supported MIME types
  31441. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31442. * to the src parameter of an <img> to display it
  31443. */
  31444. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31445. /**
  31446. * Generates an image screenshot from the specified camera.
  31447. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31448. * @param engine The engine to use for rendering
  31449. * @param camera The camera to use for rendering
  31450. * @param size This parameter can be set to a single number or to an object with the
  31451. * following (optional) properties: precision, width, height. If a single number is passed,
  31452. * it will be used for both width and height. If an object is passed, the screenshot size
  31453. * will be derived from the parameters. The precision property is a multiplier allowing
  31454. * rendering at a higher or lower resolution
  31455. * @param successCallback The callback receives a single parameter which contains the
  31456. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31457. * src parameter of an <img> to display it
  31458. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31459. * Check your browser for supported MIME types
  31460. * @param samples Texture samples (default: 1)
  31461. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31462. * @param fileName A name for for the downloaded file.
  31463. */
  31464. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31465. /**
  31466. * Generates an image screenshot from the specified camera.
  31467. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31468. * @param engine The engine to use for rendering
  31469. * @param camera The camera to use for rendering
  31470. * @param size This parameter can be set to a single number or to an object with the
  31471. * following (optional) properties: precision, width, height. If a single number is passed,
  31472. * it will be used for both width and height. If an object is passed, the screenshot size
  31473. * will be derived from the parameters. The precision property is a multiplier allowing
  31474. * rendering at a higher or lower resolution
  31475. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31476. * Check your browser for supported MIME types
  31477. * @param samples Texture samples (default: 1)
  31478. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31479. * @param fileName A name for for the downloaded file.
  31480. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31481. * to the src parameter of an <img> to display it
  31482. */
  31483. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31484. /**
  31485. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31486. * Be aware Math.random() could cause collisions, but:
  31487. * "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"
  31488. * @returns a pseudo random id
  31489. */
  31490. static RandomId(): string;
  31491. /**
  31492. * Test if the given uri is a base64 string
  31493. * @param uri The uri to test
  31494. * @return True if the uri is a base64 string or false otherwise
  31495. */
  31496. static IsBase64(uri: string): boolean;
  31497. /**
  31498. * Decode the given base64 uri.
  31499. * @param uri The uri to decode
  31500. * @return The decoded base64 data.
  31501. */
  31502. static DecodeBase64(uri: string): ArrayBuffer;
  31503. /**
  31504. * Gets the absolute url.
  31505. * @param url the input url
  31506. * @return the absolute url
  31507. */
  31508. static GetAbsoluteUrl(url: string): string;
  31509. /**
  31510. * No log
  31511. */
  31512. static readonly NoneLogLevel: number;
  31513. /**
  31514. * Only message logs
  31515. */
  31516. static readonly MessageLogLevel: number;
  31517. /**
  31518. * Only warning logs
  31519. */
  31520. static readonly WarningLogLevel: number;
  31521. /**
  31522. * Only error logs
  31523. */
  31524. static readonly ErrorLogLevel: number;
  31525. /**
  31526. * All logs
  31527. */
  31528. static readonly AllLogLevel: number;
  31529. /**
  31530. * Gets a value indicating the number of loading errors
  31531. * @ignorenaming
  31532. */
  31533. static readonly errorsCount: number;
  31534. /**
  31535. * Callback called when a new log is added
  31536. */
  31537. static OnNewCacheEntry: (entry: string) => void;
  31538. /**
  31539. * Log a message to the console
  31540. * @param message defines the message to log
  31541. */
  31542. static Log(message: string): void;
  31543. /**
  31544. * Write a warning message to the console
  31545. * @param message defines the message to log
  31546. */
  31547. static Warn(message: string): void;
  31548. /**
  31549. * Write an error message to the console
  31550. * @param message defines the message to log
  31551. */
  31552. static Error(message: string): void;
  31553. /**
  31554. * Gets current log cache (list of logs)
  31555. */
  31556. static readonly LogCache: string;
  31557. /**
  31558. * Clears the log cache
  31559. */
  31560. static ClearLogCache(): void;
  31561. /**
  31562. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31563. */
  31564. static LogLevels: number;
  31565. /**
  31566. * Checks if the window object exists
  31567. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31568. */
  31569. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31570. /**
  31571. * No performance log
  31572. */
  31573. static readonly PerformanceNoneLogLevel: number;
  31574. /**
  31575. * Use user marks to log performance
  31576. */
  31577. static readonly PerformanceUserMarkLogLevel: number;
  31578. /**
  31579. * Log performance to the console
  31580. */
  31581. static readonly PerformanceConsoleLogLevel: number;
  31582. private static _performance;
  31583. /**
  31584. * Sets the current performance log level
  31585. */
  31586. static PerformanceLogLevel: number;
  31587. private static _StartPerformanceCounterDisabled;
  31588. private static _EndPerformanceCounterDisabled;
  31589. private static _StartUserMark;
  31590. private static _EndUserMark;
  31591. private static _StartPerformanceConsole;
  31592. private static _EndPerformanceConsole;
  31593. /**
  31594. * Starts a performance counter
  31595. */
  31596. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31597. /**
  31598. * Ends a specific performance coutner
  31599. */
  31600. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31601. /**
  31602. * Gets either window.performance.now() if supported or Date.now() else
  31603. */
  31604. static readonly Now: number;
  31605. /**
  31606. * This method will return the name of the class used to create the instance of the given object.
  31607. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31608. * @param object the object to get the class name from
  31609. * @param isType defines if the object is actually a type
  31610. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31611. */
  31612. static GetClassName(object: any, isType?: boolean): string;
  31613. /**
  31614. * Gets the first element of an array satisfying a given predicate
  31615. * @param array defines the array to browse
  31616. * @param predicate defines the predicate to use
  31617. * @returns null if not found or the element
  31618. */
  31619. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31620. /**
  31621. * This method will return the name of the full name of the class, including its owning module (if any).
  31622. * 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).
  31623. * @param object the object to get the class name from
  31624. * @param isType defines if the object is actually a type
  31625. * @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.
  31626. * @ignorenaming
  31627. */
  31628. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31629. /**
  31630. * Returns a promise that resolves after the given amount of time.
  31631. * @param delay Number of milliseconds to delay
  31632. * @returns Promise that resolves after the given amount of time
  31633. */
  31634. static DelayAsync(delay: number): Promise<void>;
  31635. }
  31636. /**
  31637. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31638. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31639. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31640. * @param name The name of the class, case should be preserved
  31641. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31642. */
  31643. export function className(name: string, module?: string): (target: Object) => void;
  31644. /**
  31645. * An implementation of a loop for asynchronous functions.
  31646. */
  31647. export class AsyncLoop {
  31648. /**
  31649. * Defines the number of iterations for the loop
  31650. */
  31651. iterations: number;
  31652. /**
  31653. * Defines the current index of the loop.
  31654. */
  31655. index: number;
  31656. private _done;
  31657. private _fn;
  31658. private _successCallback;
  31659. /**
  31660. * Constructor.
  31661. * @param iterations the number of iterations.
  31662. * @param func the function to run each iteration
  31663. * @param successCallback the callback that will be called upon succesful execution
  31664. * @param offset starting offset.
  31665. */
  31666. constructor(
  31667. /**
  31668. * Defines the number of iterations for the loop
  31669. */
  31670. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31671. /**
  31672. * Execute the next iteration. Must be called after the last iteration was finished.
  31673. */
  31674. executeNext(): void;
  31675. /**
  31676. * Break the loop and run the success callback.
  31677. */
  31678. breakLoop(): void;
  31679. /**
  31680. * Create and run an async loop.
  31681. * @param iterations the number of iterations.
  31682. * @param fn the function to run each iteration
  31683. * @param successCallback the callback that will be called upon succesful execution
  31684. * @param offset starting offset.
  31685. * @returns the created async loop object
  31686. */
  31687. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31688. /**
  31689. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31690. * @param iterations total number of iterations
  31691. * @param syncedIterations number of synchronous iterations in each async iteration.
  31692. * @param fn the function to call each iteration.
  31693. * @param callback a success call back that will be called when iterating stops.
  31694. * @param breakFunction a break condition (optional)
  31695. * @param timeout timeout settings for the setTimeout function. default - 0.
  31696. * @returns the created async loop object
  31697. */
  31698. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31699. }
  31700. }
  31701. declare module BABYLON {
  31702. /** @hidden */
  31703. export interface ICollisionCoordinator {
  31704. createCollider(): Collider;
  31705. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31706. init(scene: Scene): void;
  31707. }
  31708. /** @hidden */
  31709. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31710. private _scene;
  31711. private _scaledPosition;
  31712. private _scaledVelocity;
  31713. private _finalPosition;
  31714. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31715. createCollider(): Collider;
  31716. init(scene: Scene): void;
  31717. private _collideWithWorld;
  31718. }
  31719. }
  31720. declare module BABYLON {
  31721. /**
  31722. * Class used to manage all inputs for the scene.
  31723. */
  31724. export class InputManager {
  31725. /** The distance in pixel that you have to move to prevent some events */
  31726. static DragMovementThreshold: number;
  31727. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31728. static LongPressDelay: number;
  31729. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31730. static DoubleClickDelay: number;
  31731. /** If you need to check double click without raising a single click at first click, enable this flag */
  31732. static ExclusiveDoubleClickMode: boolean;
  31733. private _wheelEventName;
  31734. private _onPointerMove;
  31735. private _onPointerDown;
  31736. private _onPointerUp;
  31737. private _initClickEvent;
  31738. private _initActionManager;
  31739. private _delayedSimpleClick;
  31740. private _delayedSimpleClickTimeout;
  31741. private _previousDelayedSimpleClickTimeout;
  31742. private _meshPickProceed;
  31743. private _previousButtonPressed;
  31744. private _currentPickResult;
  31745. private _previousPickResult;
  31746. private _totalPointersPressed;
  31747. private _doubleClickOccured;
  31748. private _pointerOverMesh;
  31749. private _pickedDownMesh;
  31750. private _pickedUpMesh;
  31751. private _pointerX;
  31752. private _pointerY;
  31753. private _unTranslatedPointerX;
  31754. private _unTranslatedPointerY;
  31755. private _startingPointerPosition;
  31756. private _previousStartingPointerPosition;
  31757. private _startingPointerTime;
  31758. private _previousStartingPointerTime;
  31759. private _pointerCaptures;
  31760. private _onKeyDown;
  31761. private _onKeyUp;
  31762. private _onCanvasFocusObserver;
  31763. private _onCanvasBlurObserver;
  31764. private _scene;
  31765. /**
  31766. * Creates a new InputManager
  31767. * @param scene defines the hosting scene
  31768. */
  31769. constructor(scene: Scene);
  31770. /**
  31771. * Gets the mesh that is currently under the pointer
  31772. */
  31773. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31774. /**
  31775. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31776. */
  31777. readonly unTranslatedPointer: Vector2;
  31778. /**
  31779. * Gets or sets the current on-screen X position of the pointer
  31780. */
  31781. pointerX: number;
  31782. /**
  31783. * Gets or sets the current on-screen Y position of the pointer
  31784. */
  31785. pointerY: number;
  31786. private _updatePointerPosition;
  31787. private _processPointerMove;
  31788. private _setRayOnPointerInfo;
  31789. private _checkPrePointerObservable;
  31790. /**
  31791. * Use this method to simulate a pointer move on a mesh
  31792. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31793. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31794. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31795. */
  31796. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31797. /**
  31798. * Use this method to simulate a pointer down on a mesh
  31799. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31800. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31801. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31802. */
  31803. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31804. private _processPointerDown;
  31805. /** @hidden */ private _isPointerSwiping(): boolean;
  31806. /**
  31807. * Use this method to simulate a pointer up on a mesh
  31808. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31809. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31810. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31811. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31812. */
  31813. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31814. private _processPointerUp;
  31815. /**
  31816. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31817. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31818. * @returns true if the pointer was captured
  31819. */
  31820. isPointerCaptured(pointerId?: number): boolean;
  31821. /**
  31822. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31823. * @param attachUp defines if you want to attach events to pointerup
  31824. * @param attachDown defines if you want to attach events to pointerdown
  31825. * @param attachMove defines if you want to attach events to pointermove
  31826. */
  31827. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31828. /**
  31829. * Detaches all event handlers
  31830. */
  31831. detachControl(): void;
  31832. /**
  31833. * Force the value of meshUnderPointer
  31834. * @param mesh defines the mesh to use
  31835. */
  31836. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31837. /**
  31838. * Gets the mesh under the pointer
  31839. * @returns a Mesh or null if no mesh is under the pointer
  31840. */
  31841. getPointerOverMesh(): Nullable<AbstractMesh>;
  31842. }
  31843. }
  31844. declare module BABYLON {
  31845. /**
  31846. * Helper class used to generate session unique ID
  31847. */
  31848. export class UniqueIdGenerator {
  31849. private static _UniqueIdCounter;
  31850. /**
  31851. * Gets an unique (relatively to the current scene) Id
  31852. */
  31853. static readonly UniqueId: number;
  31854. }
  31855. }
  31856. declare module BABYLON {
  31857. /**
  31858. * This class defines the direct association between an animation and a target
  31859. */
  31860. export class TargetedAnimation {
  31861. /**
  31862. * Animation to perform
  31863. */
  31864. animation: Animation;
  31865. /**
  31866. * Target to animate
  31867. */
  31868. target: any;
  31869. /**
  31870. * Serialize the object
  31871. * @returns the JSON object representing the current entity
  31872. */
  31873. serialize(): any;
  31874. }
  31875. /**
  31876. * Use this class to create coordinated animations on multiple targets
  31877. */
  31878. export class AnimationGroup implements IDisposable {
  31879. /** The name of the animation group */
  31880. name: string;
  31881. private _scene;
  31882. private _targetedAnimations;
  31883. private _animatables;
  31884. private _from;
  31885. private _to;
  31886. private _isStarted;
  31887. private _isPaused;
  31888. private _speedRatio;
  31889. private _loopAnimation;
  31890. /**
  31891. * Gets or sets the unique id of the node
  31892. */
  31893. uniqueId: number;
  31894. /**
  31895. * This observable will notify when one animation have ended
  31896. */
  31897. onAnimationEndObservable: Observable<TargetedAnimation>;
  31898. /**
  31899. * Observer raised when one animation loops
  31900. */
  31901. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31902. /**
  31903. * This observable will notify when all animations have ended.
  31904. */
  31905. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31906. /**
  31907. * This observable will notify when all animations have paused.
  31908. */
  31909. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31910. /**
  31911. * This observable will notify when all animations are playing.
  31912. */
  31913. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31914. /**
  31915. * Gets the first frame
  31916. */
  31917. readonly from: number;
  31918. /**
  31919. * Gets the last frame
  31920. */
  31921. readonly to: number;
  31922. /**
  31923. * Define if the animations are started
  31924. */
  31925. readonly isStarted: boolean;
  31926. /**
  31927. * Gets a value indicating that the current group is playing
  31928. */
  31929. readonly isPlaying: boolean;
  31930. /**
  31931. * Gets or sets the speed ratio to use for all animations
  31932. */
  31933. /**
  31934. * Gets or sets the speed ratio to use for all animations
  31935. */
  31936. speedRatio: number;
  31937. /**
  31938. * Gets or sets if all animations should loop or not
  31939. */
  31940. loopAnimation: boolean;
  31941. /**
  31942. * Gets the targeted animations for this animation group
  31943. */
  31944. readonly targetedAnimations: Array<TargetedAnimation>;
  31945. /**
  31946. * returning the list of animatables controlled by this animation group.
  31947. */
  31948. readonly animatables: Array<Animatable>;
  31949. /**
  31950. * Instantiates a new Animation Group.
  31951. * This helps managing several animations at once.
  31952. * @see http://doc.babylonjs.com/how_to/group
  31953. * @param name Defines the name of the group
  31954. * @param scene Defines the scene the group belongs to
  31955. */
  31956. constructor(
  31957. /** The name of the animation group */
  31958. name: string, scene?: Nullable<Scene>);
  31959. /**
  31960. * Add an animation (with its target) in the group
  31961. * @param animation defines the animation we want to add
  31962. * @param target defines the target of the animation
  31963. * @returns the TargetedAnimation object
  31964. */
  31965. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31966. /**
  31967. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31968. * It can add constant keys at begin or end
  31969. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31970. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31971. * @returns the animation group
  31972. */
  31973. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31974. /**
  31975. * Start all animations on given targets
  31976. * @param loop defines if animations must loop
  31977. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31978. * @param from defines the from key (optional)
  31979. * @param to defines the to key (optional)
  31980. * @returns the current animation group
  31981. */
  31982. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31983. /**
  31984. * Pause all animations
  31985. * @returns the animation group
  31986. */
  31987. pause(): AnimationGroup;
  31988. /**
  31989. * Play all animations to initial state
  31990. * This function will start() the animations if they were not started or will restart() them if they were paused
  31991. * @param loop defines if animations must loop
  31992. * @returns the animation group
  31993. */
  31994. play(loop?: boolean): AnimationGroup;
  31995. /**
  31996. * Reset all animations to initial state
  31997. * @returns the animation group
  31998. */
  31999. reset(): AnimationGroup;
  32000. /**
  32001. * Restart animations from key 0
  32002. * @returns the animation group
  32003. */
  32004. restart(): AnimationGroup;
  32005. /**
  32006. * Stop all animations
  32007. * @returns the animation group
  32008. */
  32009. stop(): AnimationGroup;
  32010. /**
  32011. * Set animation weight for all animatables
  32012. * @param weight defines the weight to use
  32013. * @return the animationGroup
  32014. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32015. */
  32016. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32017. /**
  32018. * Synchronize and normalize all animatables with a source animatable
  32019. * @param root defines the root animatable to synchronize with
  32020. * @return the animationGroup
  32021. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32022. */
  32023. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32024. /**
  32025. * Goes to a specific frame in this animation group
  32026. * @param frame the frame number to go to
  32027. * @return the animationGroup
  32028. */
  32029. goToFrame(frame: number): AnimationGroup;
  32030. /**
  32031. * Dispose all associated resources
  32032. */
  32033. dispose(): void;
  32034. private _checkAnimationGroupEnded;
  32035. /**
  32036. * Clone the current animation group and returns a copy
  32037. * @param newName defines the name of the new group
  32038. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32039. * @returns the new aniamtion group
  32040. */
  32041. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32042. /**
  32043. * Serializes the animationGroup to an object
  32044. * @returns Serialized object
  32045. */
  32046. serialize(): any;
  32047. /**
  32048. * Returns a new AnimationGroup object parsed from the source provided.
  32049. * @param parsedAnimationGroup defines the source
  32050. * @param scene defines the scene that will receive the animationGroup
  32051. * @returns a new AnimationGroup
  32052. */
  32053. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32054. /**
  32055. * Returns the string "AnimationGroup"
  32056. * @returns "AnimationGroup"
  32057. */
  32058. getClassName(): string;
  32059. /**
  32060. * Creates a detailled string about the object
  32061. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32062. * @returns a string representing the object
  32063. */
  32064. toString(fullDetails?: boolean): string;
  32065. }
  32066. }
  32067. declare module BABYLON {
  32068. /**
  32069. * Define an interface for all classes that will hold resources
  32070. */
  32071. export interface IDisposable {
  32072. /**
  32073. * Releases all held resources
  32074. */
  32075. dispose(): void;
  32076. }
  32077. /** Interface defining initialization parameters for Scene class */
  32078. export interface SceneOptions {
  32079. /**
  32080. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32081. * It will improve performance when the number of geometries becomes important.
  32082. */
  32083. useGeometryUniqueIdsMap?: boolean;
  32084. /**
  32085. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32086. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32087. */
  32088. useMaterialMeshMap?: boolean;
  32089. /**
  32090. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32091. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32092. */
  32093. useClonedMeshhMap?: boolean;
  32094. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32095. virtual?: boolean;
  32096. }
  32097. /**
  32098. * Represents a scene to be rendered by the engine.
  32099. * @see http://doc.babylonjs.com/features/scene
  32100. */
  32101. export class Scene extends AbstractScene implements IAnimatable {
  32102. /** The fog is deactivated */
  32103. static readonly FOGMODE_NONE: number;
  32104. /** The fog density is following an exponential function */
  32105. static readonly FOGMODE_EXP: number;
  32106. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32107. static readonly FOGMODE_EXP2: number;
  32108. /** The fog density is following a linear function. */
  32109. static readonly FOGMODE_LINEAR: number;
  32110. /**
  32111. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32112. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32113. */
  32114. static MinDeltaTime: number;
  32115. /**
  32116. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32117. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32118. */
  32119. static MaxDeltaTime: number;
  32120. /**
  32121. * Factory used to create the default material.
  32122. * @param name The name of the material to create
  32123. * @param scene The scene to create the material for
  32124. * @returns The default material
  32125. */
  32126. static DefaultMaterialFactory(scene: Scene): Material;
  32127. /**
  32128. * Factory used to create the a collision coordinator.
  32129. * @returns The collision coordinator
  32130. */
  32131. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32132. /** @hidden */ private _inputManager: InputManager;
  32133. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32134. cameraToUseForPointers: Nullable<Camera>;
  32135. /** @hidden */ protected readonly _isScene: boolean;
  32136. /**
  32137. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32138. */
  32139. autoClear: boolean;
  32140. /**
  32141. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32142. */
  32143. autoClearDepthAndStencil: boolean;
  32144. /**
  32145. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32146. */
  32147. clearColor: Color4;
  32148. /**
  32149. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32150. */
  32151. ambientColor: Color3;
  32152. /**
  32153. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32154. * It should only be one of the following (if not the default embedded one):
  32155. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32156. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32157. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32158. * The material properties need to be setup according to the type of texture in use.
  32159. */
  32160. environmentBRDFTexture: BaseTexture;
  32161. /** @hidden */
  32162. protected _environmentTexture: Nullable<BaseTexture>;
  32163. /**
  32164. * Texture used in all pbr material as the reflection texture.
  32165. * As in the majority of the scene they are the same (exception for multi room and so on),
  32166. * this is easier to reference from here than from all the materials.
  32167. */
  32168. /**
  32169. * Texture used in all pbr material as the reflection texture.
  32170. * As in the majority of the scene they are the same (exception for multi room and so on),
  32171. * this is easier to set here than in all the materials.
  32172. */
  32173. environmentTexture: Nullable<BaseTexture>;
  32174. /** @hidden */
  32175. protected _environmentIntensity: number;
  32176. /**
  32177. * Intensity of the environment in all pbr material.
  32178. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32179. * As in the majority of the scene they are the same (exception for multi room and so on),
  32180. * this is easier to reference from here than from all the materials.
  32181. */
  32182. /**
  32183. * Intensity of the environment in all pbr material.
  32184. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32185. * As in the majority of the scene they are the same (exception for multi room and so on),
  32186. * this is easier to set here than in all the materials.
  32187. */
  32188. environmentIntensity: number;
  32189. /** @hidden */
  32190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32191. /**
  32192. * Default image processing configuration used either in the rendering
  32193. * Forward main pass or through the imageProcessingPostProcess if present.
  32194. * As in the majority of the scene they are the same (exception for multi camera),
  32195. * this is easier to reference from here than from all the materials and post process.
  32196. *
  32197. * No setter as we it is a shared configuration, you can set the values instead.
  32198. */
  32199. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32200. private _forceWireframe;
  32201. /**
  32202. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32203. */
  32204. forceWireframe: boolean;
  32205. private _forcePointsCloud;
  32206. /**
  32207. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32208. */
  32209. forcePointsCloud: boolean;
  32210. /**
  32211. * Gets or sets the active clipplane 1
  32212. */
  32213. clipPlane: Nullable<Plane>;
  32214. /**
  32215. * Gets or sets the active clipplane 2
  32216. */
  32217. clipPlane2: Nullable<Plane>;
  32218. /**
  32219. * Gets or sets the active clipplane 3
  32220. */
  32221. clipPlane3: Nullable<Plane>;
  32222. /**
  32223. * Gets or sets the active clipplane 4
  32224. */
  32225. clipPlane4: Nullable<Plane>;
  32226. /**
  32227. * Gets or sets a boolean indicating if animations are enabled
  32228. */
  32229. animationsEnabled: boolean;
  32230. private _animationPropertiesOverride;
  32231. /**
  32232. * Gets or sets the animation properties override
  32233. */
  32234. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32235. /**
  32236. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32237. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32238. */
  32239. useConstantAnimationDeltaTime: boolean;
  32240. /**
  32241. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32242. * Please note that it requires to run a ray cast through the scene on every frame
  32243. */
  32244. constantlyUpdateMeshUnderPointer: boolean;
  32245. /**
  32246. * Defines the HTML cursor to use when hovering over interactive elements
  32247. */
  32248. hoverCursor: string;
  32249. /**
  32250. * Defines the HTML default cursor to use (empty by default)
  32251. */
  32252. defaultCursor: string;
  32253. /**
  32254. * This is used to call preventDefault() on pointer down
  32255. * in order to block unwanted artifacts like system double clicks
  32256. */
  32257. preventDefaultOnPointerDown: boolean;
  32258. /**
  32259. * This is used to call preventDefault() on pointer up
  32260. * in order to block unwanted artifacts like system double clicks
  32261. */
  32262. preventDefaultOnPointerUp: boolean;
  32263. /**
  32264. * Gets or sets user defined metadata
  32265. */
  32266. metadata: any;
  32267. /**
  32268. * For internal use only. Please do not use.
  32269. */
  32270. reservedDataStore: any;
  32271. /**
  32272. * Gets the name of the plugin used to load this scene (null by default)
  32273. */
  32274. loadingPluginName: string;
  32275. /**
  32276. * Use this array to add regular expressions used to disable offline support for specific urls
  32277. */
  32278. disableOfflineSupportExceptionRules: RegExp[];
  32279. /**
  32280. * An event triggered when the scene is disposed.
  32281. */
  32282. onDisposeObservable: Observable<Scene>;
  32283. private _onDisposeObserver;
  32284. /** Sets a function to be executed when this scene is disposed. */
  32285. onDispose: () => void;
  32286. /**
  32287. * An event triggered before rendering the scene (right after animations and physics)
  32288. */
  32289. onBeforeRenderObservable: Observable<Scene>;
  32290. private _onBeforeRenderObserver;
  32291. /** Sets a function to be executed before rendering this scene */
  32292. beforeRender: Nullable<() => void>;
  32293. /**
  32294. * An event triggered after rendering the scene
  32295. */
  32296. onAfterRenderObservable: Observable<Scene>;
  32297. /**
  32298. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32299. */
  32300. onAfterRenderCameraObservable: Observable<Camera>;
  32301. private _onAfterRenderObserver;
  32302. /** Sets a function to be executed after rendering this scene */
  32303. afterRender: Nullable<() => void>;
  32304. /**
  32305. * An event triggered before animating the scene
  32306. */
  32307. onBeforeAnimationsObservable: Observable<Scene>;
  32308. /**
  32309. * An event triggered after animations processing
  32310. */
  32311. onAfterAnimationsObservable: Observable<Scene>;
  32312. /**
  32313. * An event triggered before draw calls are ready to be sent
  32314. */
  32315. onBeforeDrawPhaseObservable: Observable<Scene>;
  32316. /**
  32317. * An event triggered after draw calls have been sent
  32318. */
  32319. onAfterDrawPhaseObservable: Observable<Scene>;
  32320. /**
  32321. * An event triggered when the scene is ready
  32322. */
  32323. onReadyObservable: Observable<Scene>;
  32324. /**
  32325. * An event triggered before rendering a camera
  32326. */
  32327. onBeforeCameraRenderObservable: Observable<Camera>;
  32328. private _onBeforeCameraRenderObserver;
  32329. /** Sets a function to be executed before rendering a camera*/
  32330. beforeCameraRender: () => void;
  32331. /**
  32332. * An event triggered after rendering a camera
  32333. */
  32334. onAfterCameraRenderObservable: Observable<Camera>;
  32335. private _onAfterCameraRenderObserver;
  32336. /** Sets a function to be executed after rendering a camera*/
  32337. afterCameraRender: () => void;
  32338. /**
  32339. * An event triggered when active meshes evaluation is about to start
  32340. */
  32341. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32342. /**
  32343. * An event triggered when active meshes evaluation is done
  32344. */
  32345. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32346. /**
  32347. * An event triggered when particles rendering is about to start
  32348. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32349. */
  32350. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32351. /**
  32352. * An event triggered when particles rendering is done
  32353. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32354. */
  32355. onAfterParticlesRenderingObservable: Observable<Scene>;
  32356. /**
  32357. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32358. */
  32359. onDataLoadedObservable: Observable<Scene>;
  32360. /**
  32361. * An event triggered when a camera is created
  32362. */
  32363. onNewCameraAddedObservable: Observable<Camera>;
  32364. /**
  32365. * An event triggered when a camera is removed
  32366. */
  32367. onCameraRemovedObservable: Observable<Camera>;
  32368. /**
  32369. * An event triggered when a light is created
  32370. */
  32371. onNewLightAddedObservable: Observable<Light>;
  32372. /**
  32373. * An event triggered when a light is removed
  32374. */
  32375. onLightRemovedObservable: Observable<Light>;
  32376. /**
  32377. * An event triggered when a geometry is created
  32378. */
  32379. onNewGeometryAddedObservable: Observable<Geometry>;
  32380. /**
  32381. * An event triggered when a geometry is removed
  32382. */
  32383. onGeometryRemovedObservable: Observable<Geometry>;
  32384. /**
  32385. * An event triggered when a transform node is created
  32386. */
  32387. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32388. /**
  32389. * An event triggered when a transform node is removed
  32390. */
  32391. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32392. /**
  32393. * An event triggered when a mesh is created
  32394. */
  32395. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32396. /**
  32397. * An event triggered when a mesh is removed
  32398. */
  32399. onMeshRemovedObservable: Observable<AbstractMesh>;
  32400. /**
  32401. * An event triggered when a skeleton is created
  32402. */
  32403. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32404. /**
  32405. * An event triggered when a skeleton is removed
  32406. */
  32407. onSkeletonRemovedObservable: Observable<Skeleton>;
  32408. /**
  32409. * An event triggered when a material is created
  32410. */
  32411. onNewMaterialAddedObservable: Observable<Material>;
  32412. /**
  32413. * An event triggered when a material is removed
  32414. */
  32415. onMaterialRemovedObservable: Observable<Material>;
  32416. /**
  32417. * An event triggered when a texture is created
  32418. */
  32419. onNewTextureAddedObservable: Observable<BaseTexture>;
  32420. /**
  32421. * An event triggered when a texture is removed
  32422. */
  32423. onTextureRemovedObservable: Observable<BaseTexture>;
  32424. /**
  32425. * An event triggered when render targets are about to be rendered
  32426. * Can happen multiple times per frame.
  32427. */
  32428. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32429. /**
  32430. * An event triggered when render targets were rendered.
  32431. * Can happen multiple times per frame.
  32432. */
  32433. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32434. /**
  32435. * An event triggered before calculating deterministic simulation step
  32436. */
  32437. onBeforeStepObservable: Observable<Scene>;
  32438. /**
  32439. * An event triggered after calculating deterministic simulation step
  32440. */
  32441. onAfterStepObservable: Observable<Scene>;
  32442. /**
  32443. * An event triggered when the activeCamera property is updated
  32444. */
  32445. onActiveCameraChanged: Observable<Scene>;
  32446. /**
  32447. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32448. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32449. * 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)
  32450. */
  32451. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32452. /**
  32453. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32454. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32455. * 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)
  32456. */
  32457. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32458. /**
  32459. * This Observable will when a mesh has been imported into the scene.
  32460. */
  32461. onMeshImportedObservable: Observable<AbstractMesh>;
  32462. /**
  32463. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32464. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32465. */
  32466. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32467. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32468. /**
  32469. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32470. */
  32471. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32472. /**
  32473. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32474. */
  32475. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32476. /**
  32477. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32478. */
  32479. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32480. /** Callback called when a pointer move is detected */
  32481. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32482. /** Callback called when a pointer down is detected */
  32483. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32484. /** Callback called when a pointer up is detected */
  32485. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32486. /** Callback called when a pointer pick is detected */
  32487. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32488. /**
  32489. * 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).
  32490. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32491. */
  32492. onPrePointerObservable: Observable<PointerInfoPre>;
  32493. /**
  32494. * Observable event triggered each time an input event is received from the rendering canvas
  32495. */
  32496. onPointerObservable: Observable<PointerInfo>;
  32497. /**
  32498. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32499. */
  32500. readonly unTranslatedPointer: Vector2;
  32501. /**
  32502. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32503. */
  32504. static DragMovementThreshold: number;
  32505. /**
  32506. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32507. */
  32508. static LongPressDelay: number;
  32509. /**
  32510. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32511. */
  32512. static DoubleClickDelay: number;
  32513. /** If you need to check double click without raising a single click at first click, enable this flag */
  32514. static ExclusiveDoubleClickMode: boolean;
  32515. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32516. /**
  32517. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32518. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32519. */
  32520. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32521. /**
  32522. * Observable event triggered each time an keyboard event is received from the hosting window
  32523. */
  32524. onKeyboardObservable: Observable<KeyboardInfo>;
  32525. private _useRightHandedSystem;
  32526. /**
  32527. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32528. */
  32529. useRightHandedSystem: boolean;
  32530. private _timeAccumulator;
  32531. private _currentStepId;
  32532. private _currentInternalStep;
  32533. /**
  32534. * Sets the step Id used by deterministic lock step
  32535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32536. * @param newStepId defines the step Id
  32537. */
  32538. setStepId(newStepId: number): void;
  32539. /**
  32540. * Gets the step Id used by deterministic lock step
  32541. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32542. * @returns the step Id
  32543. */
  32544. getStepId(): number;
  32545. /**
  32546. * Gets the internal step used by deterministic lock step
  32547. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32548. * @returns the internal step
  32549. */
  32550. getInternalStep(): number;
  32551. private _fogEnabled;
  32552. /**
  32553. * Gets or sets a boolean indicating if fog is enabled on this scene
  32554. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32555. * (Default is true)
  32556. */
  32557. fogEnabled: boolean;
  32558. private _fogMode;
  32559. /**
  32560. * Gets or sets the fog mode to use
  32561. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32562. * | mode | value |
  32563. * | --- | --- |
  32564. * | FOGMODE_NONE | 0 |
  32565. * | FOGMODE_EXP | 1 |
  32566. * | FOGMODE_EXP2 | 2 |
  32567. * | FOGMODE_LINEAR | 3 |
  32568. */
  32569. fogMode: number;
  32570. /**
  32571. * Gets or sets the fog color to use
  32572. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32573. * (Default is Color3(0.2, 0.2, 0.3))
  32574. */
  32575. fogColor: Color3;
  32576. /**
  32577. * Gets or sets the fog density to use
  32578. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32579. * (Default is 0.1)
  32580. */
  32581. fogDensity: number;
  32582. /**
  32583. * Gets or sets the fog start distance to use
  32584. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32585. * (Default is 0)
  32586. */
  32587. fogStart: number;
  32588. /**
  32589. * Gets or sets the fog end distance to use
  32590. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32591. * (Default is 1000)
  32592. */
  32593. fogEnd: number;
  32594. private _shadowsEnabled;
  32595. /**
  32596. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32597. */
  32598. shadowsEnabled: boolean;
  32599. private _lightsEnabled;
  32600. /**
  32601. * Gets or sets a boolean indicating if lights are enabled on this scene
  32602. */
  32603. lightsEnabled: boolean;
  32604. /** All of the active cameras added to this scene. */
  32605. activeCameras: Camera[];
  32606. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32607. /** Gets or sets the current active camera */
  32608. activeCamera: Nullable<Camera>;
  32609. private _defaultMaterial;
  32610. /** The default material used on meshes when no material is affected */
  32611. /** The default material used on meshes when no material is affected */
  32612. defaultMaterial: Material;
  32613. private _texturesEnabled;
  32614. /**
  32615. * Gets or sets a boolean indicating if textures are enabled on this scene
  32616. */
  32617. texturesEnabled: boolean;
  32618. /**
  32619. * Gets or sets a boolean indicating if particles are enabled on this scene
  32620. */
  32621. particlesEnabled: boolean;
  32622. /**
  32623. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32624. */
  32625. spritesEnabled: boolean;
  32626. private _skeletonsEnabled;
  32627. /**
  32628. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32629. */
  32630. skeletonsEnabled: boolean;
  32631. /**
  32632. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32633. */
  32634. lensFlaresEnabled: boolean;
  32635. /**
  32636. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32638. */
  32639. collisionsEnabled: boolean;
  32640. private _collisionCoordinator;
  32641. /** @hidden */
  32642. readonly collisionCoordinator: ICollisionCoordinator;
  32643. /**
  32644. * Defines the gravity applied to this scene (used only for collisions)
  32645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32646. */
  32647. gravity: Vector3;
  32648. /**
  32649. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32650. */
  32651. postProcessesEnabled: boolean;
  32652. /**
  32653. * The list of postprocesses added to the scene
  32654. */
  32655. postProcesses: PostProcess[];
  32656. /**
  32657. * Gets the current postprocess manager
  32658. */
  32659. postProcessManager: PostProcessManager;
  32660. /**
  32661. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32662. */
  32663. renderTargetsEnabled: boolean;
  32664. /**
  32665. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32666. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32667. */
  32668. dumpNextRenderTargets: boolean;
  32669. /**
  32670. * The list of user defined render targets added to the scene
  32671. */
  32672. customRenderTargets: RenderTargetTexture[];
  32673. /**
  32674. * Defines if texture loading must be delayed
  32675. * If true, textures will only be loaded when they need to be rendered
  32676. */
  32677. useDelayedTextureLoading: boolean;
  32678. /**
  32679. * Gets the list of meshes imported to the scene through SceneLoader
  32680. */
  32681. importedMeshesFiles: String[];
  32682. /**
  32683. * Gets or sets a boolean indicating if probes are enabled on this scene
  32684. */
  32685. probesEnabled: boolean;
  32686. /**
  32687. * Gets or sets the current offline provider to use to store scene data
  32688. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32689. */
  32690. offlineProvider: IOfflineProvider;
  32691. /**
  32692. * Gets or sets the action manager associated with the scene
  32693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32694. */
  32695. actionManager: AbstractActionManager;
  32696. private _meshesForIntersections;
  32697. /**
  32698. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32699. */
  32700. proceduralTexturesEnabled: boolean;
  32701. private _engine;
  32702. private _totalVertices;
  32703. /** @hidden */ private _activeIndices: PerfCounter;
  32704. /** @hidden */ private _activeParticles: PerfCounter;
  32705. /** @hidden */ private _activeBones: PerfCounter;
  32706. private _animationRatio;
  32707. /** @hidden */ private _animationTimeLast: number;
  32708. /** @hidden */ private _animationTime: number;
  32709. /**
  32710. * Gets or sets a general scale for animation speed
  32711. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32712. */
  32713. animationTimeScale: number;
  32714. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32715. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32716. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32717. private _renderId;
  32718. private _frameId;
  32719. private _executeWhenReadyTimeoutId;
  32720. private _intermediateRendering;
  32721. private _viewUpdateFlag;
  32722. private _projectionUpdateFlag;
  32723. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32724. private _activeRequests;
  32725. /** @hidden */ private _pendingData: any[];
  32726. private _isDisposed;
  32727. /**
  32728. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32729. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32730. */
  32731. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32732. private _activeMeshes;
  32733. private _processedMaterials;
  32734. private _renderTargets;
  32735. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32736. private _activeSkeletons;
  32737. private _softwareSkinnedMeshes;
  32738. private _renderingManager;
  32739. /** @hidden */ private _activeAnimatables: Animatable[];
  32740. private _transformMatrix;
  32741. private _sceneUbo;
  32742. /** @hidden */ private _viewMatrix: Matrix;
  32743. private _projectionMatrix;
  32744. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32745. /** @hidden */ private _frustumPlanes: Plane[];
  32746. /**
  32747. * Gets the list of frustum planes (built from the active camera)
  32748. */
  32749. readonly frustumPlanes: Plane[];
  32750. /**
  32751. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32752. * This is useful if there are more lights that the maximum simulteanous authorized
  32753. */
  32754. requireLightSorting: boolean;
  32755. /** @hidden */
  32756. readonly useMaterialMeshMap: boolean;
  32757. /** @hidden */
  32758. readonly useClonedMeshhMap: boolean;
  32759. private _externalData;
  32760. private _uid;
  32761. /**
  32762. * @hidden
  32763. * Backing store of defined scene components.
  32764. */ private _components: ISceneComponent[];
  32765. /**
  32766. * @hidden
  32767. * Backing store of defined scene components.
  32768. */ private _serializableComponents: ISceneSerializableComponent[];
  32769. /**
  32770. * List of components to register on the next registration step.
  32771. */
  32772. private _transientComponents;
  32773. /**
  32774. * Registers the transient components if needed.
  32775. */
  32776. private _registerTransientComponents;
  32777. /**
  32778. * @hidden
  32779. * Add a component to the scene.
  32780. * Note that the ccomponent could be registered on th next frame if this is called after
  32781. * the register component stage.
  32782. * @param component Defines the component to add to the scene
  32783. */ private _addComponent(component: ISceneComponent): void;
  32784. /**
  32785. * @hidden
  32786. * Gets a component from the scene.
  32787. * @param name defines the name of the component to retrieve
  32788. * @returns the component or null if not present
  32789. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32790. /**
  32791. * @hidden
  32792. * Defines the actions happening before camera updates.
  32793. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32794. /**
  32795. * @hidden
  32796. * Defines the actions happening before clear the canvas.
  32797. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32798. /**
  32799. * @hidden
  32800. * Defines the actions when collecting render targets for the frame.
  32801. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32802. /**
  32803. * @hidden
  32804. * Defines the actions happening for one camera in the frame.
  32805. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32806. /**
  32807. * @hidden
  32808. * Defines the actions happening during the per mesh ready checks.
  32809. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32810. /**
  32811. * @hidden
  32812. * Defines the actions happening before evaluate active mesh checks.
  32813. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32814. /**
  32815. * @hidden
  32816. * Defines the actions happening during the evaluate sub mesh checks.
  32817. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32818. /**
  32819. * @hidden
  32820. * Defines the actions happening during the active mesh stage.
  32821. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32822. /**
  32823. * @hidden
  32824. * Defines the actions happening during the per camera render target step.
  32825. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32826. /**
  32827. * @hidden
  32828. * Defines the actions happening just before the active camera is drawing.
  32829. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32830. /**
  32831. * @hidden
  32832. * Defines the actions happening just before a render target is drawing.
  32833. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32834. /**
  32835. * @hidden
  32836. * Defines the actions happening just before a rendering group is drawing.
  32837. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32838. /**
  32839. * @hidden
  32840. * Defines the actions happening just before a mesh is drawing.
  32841. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32842. /**
  32843. * @hidden
  32844. * Defines the actions happening just after a mesh has been drawn.
  32845. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32846. /**
  32847. * @hidden
  32848. * Defines the actions happening just after a rendering group has been drawn.
  32849. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32850. /**
  32851. * @hidden
  32852. * Defines the actions happening just after the active camera has been drawn.
  32853. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32854. /**
  32855. * @hidden
  32856. * Defines the actions happening just after a render target has been drawn.
  32857. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32858. /**
  32859. * @hidden
  32860. * Defines the actions happening just after rendering all cameras and computing intersections.
  32861. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32862. /**
  32863. * @hidden
  32864. * Defines the actions happening when a pointer move event happens.
  32865. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32866. /**
  32867. * @hidden
  32868. * Defines the actions happening when a pointer down event happens.
  32869. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32870. /**
  32871. * @hidden
  32872. * Defines the actions happening when a pointer up event happens.
  32873. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32874. /**
  32875. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32876. */
  32877. private geometriesByUniqueId;
  32878. /**
  32879. * Creates a new Scene
  32880. * @param engine defines the engine to use to render this scene
  32881. * @param options defines the scene options
  32882. */
  32883. constructor(engine: Engine, options?: SceneOptions);
  32884. /**
  32885. * Gets a string idenfifying the name of the class
  32886. * @returns "Scene" string
  32887. */
  32888. getClassName(): string;
  32889. private _defaultMeshCandidates;
  32890. /**
  32891. * @hidden
  32892. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32893. private _defaultSubMeshCandidates;
  32894. /**
  32895. * @hidden
  32896. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32897. /**
  32898. * Sets the default candidate providers for the scene.
  32899. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32900. * and getCollidingSubMeshCandidates to their default function
  32901. */
  32902. setDefaultCandidateProviders(): void;
  32903. /**
  32904. * Gets the mesh that is currently under the pointer
  32905. */
  32906. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32907. /**
  32908. * Gets or sets the current on-screen X position of the pointer
  32909. */
  32910. pointerX: number;
  32911. /**
  32912. * Gets or sets the current on-screen Y position of the pointer
  32913. */
  32914. pointerY: number;
  32915. /**
  32916. * Gets the cached material (ie. the latest rendered one)
  32917. * @returns the cached material
  32918. */
  32919. getCachedMaterial(): Nullable<Material>;
  32920. /**
  32921. * Gets the cached effect (ie. the latest rendered one)
  32922. * @returns the cached effect
  32923. */
  32924. getCachedEffect(): Nullable<Effect>;
  32925. /**
  32926. * Gets the cached visibility state (ie. the latest rendered one)
  32927. * @returns the cached visibility state
  32928. */
  32929. getCachedVisibility(): Nullable<number>;
  32930. /**
  32931. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32932. * @param material defines the current material
  32933. * @param effect defines the current effect
  32934. * @param visibility defines the current visibility state
  32935. * @returns true if one parameter is not cached
  32936. */
  32937. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32938. /**
  32939. * Gets the engine associated with the scene
  32940. * @returns an Engine
  32941. */
  32942. getEngine(): Engine;
  32943. /**
  32944. * Gets the total number of vertices rendered per frame
  32945. * @returns the total number of vertices rendered per frame
  32946. */
  32947. getTotalVertices(): number;
  32948. /**
  32949. * Gets the performance counter for total vertices
  32950. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32951. */
  32952. readonly totalVerticesPerfCounter: PerfCounter;
  32953. /**
  32954. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32955. * @returns the total number of active indices rendered per frame
  32956. */
  32957. getActiveIndices(): number;
  32958. /**
  32959. * Gets the performance counter for active indices
  32960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32961. */
  32962. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32963. /**
  32964. * Gets the total number of active particles rendered per frame
  32965. * @returns the total number of active particles rendered per frame
  32966. */
  32967. getActiveParticles(): number;
  32968. /**
  32969. * Gets the performance counter for active particles
  32970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32971. */
  32972. readonly activeParticlesPerfCounter: PerfCounter;
  32973. /**
  32974. * Gets the total number of active bones rendered per frame
  32975. * @returns the total number of active bones rendered per frame
  32976. */
  32977. getActiveBones(): number;
  32978. /**
  32979. * Gets the performance counter for active bones
  32980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32981. */
  32982. readonly activeBonesPerfCounter: PerfCounter;
  32983. /**
  32984. * Gets the array of active meshes
  32985. * @returns an array of AbstractMesh
  32986. */
  32987. getActiveMeshes(): SmartArray<AbstractMesh>;
  32988. /**
  32989. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32990. * @returns a number
  32991. */
  32992. getAnimationRatio(): number;
  32993. /**
  32994. * Gets an unique Id for the current render phase
  32995. * @returns a number
  32996. */
  32997. getRenderId(): number;
  32998. /**
  32999. * Gets an unique Id for the current frame
  33000. * @returns a number
  33001. */
  33002. getFrameId(): number;
  33003. /** Call this function if you want to manually increment the render Id*/
  33004. incrementRenderId(): void;
  33005. private _createUbo;
  33006. /**
  33007. * Use this method to simulate a pointer move on a mesh
  33008. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33009. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33010. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33011. * @returns the current scene
  33012. */
  33013. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33014. /**
  33015. * Use this method to simulate a pointer down on a mesh
  33016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33019. * @returns the current scene
  33020. */
  33021. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33022. /**
  33023. * Use this method to simulate a pointer up on a mesh
  33024. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33025. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33026. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33027. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33028. * @returns the current scene
  33029. */
  33030. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33031. /**
  33032. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33033. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33034. * @returns true if the pointer was captured
  33035. */
  33036. isPointerCaptured(pointerId?: number): boolean;
  33037. /**
  33038. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33039. * @param attachUp defines if you want to attach events to pointerup
  33040. * @param attachDown defines if you want to attach events to pointerdown
  33041. * @param attachMove defines if you want to attach events to pointermove
  33042. */
  33043. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33044. /** Detaches all event handlers*/
  33045. detachControl(): void;
  33046. /**
  33047. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33048. * Delay loaded resources are not taking in account
  33049. * @return true if all required resources are ready
  33050. */
  33051. isReady(): boolean;
  33052. /** Resets all cached information relative to material (including effect and visibility) */
  33053. resetCachedMaterial(): void;
  33054. /**
  33055. * Registers a function to be called before every frame render
  33056. * @param func defines the function to register
  33057. */
  33058. registerBeforeRender(func: () => void): void;
  33059. /**
  33060. * Unregisters a function called before every frame render
  33061. * @param func defines the function to unregister
  33062. */
  33063. unregisterBeforeRender(func: () => void): void;
  33064. /**
  33065. * Registers a function to be called after every frame render
  33066. * @param func defines the function to register
  33067. */
  33068. registerAfterRender(func: () => void): void;
  33069. /**
  33070. * Unregisters a function called after every frame render
  33071. * @param func defines the function to unregister
  33072. */
  33073. unregisterAfterRender(func: () => void): void;
  33074. private _executeOnceBeforeRender;
  33075. /**
  33076. * The provided function will run before render once and will be disposed afterwards.
  33077. * A timeout delay can be provided so that the function will be executed in N ms.
  33078. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33079. * @param func The function to be executed.
  33080. * @param timeout optional delay in ms
  33081. */
  33082. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33083. /** @hidden */ private _addPendingData(data: any): void;
  33084. /** @hidden */ private _removePendingData(data: any): void;
  33085. /**
  33086. * Returns the number of items waiting to be loaded
  33087. * @returns the number of items waiting to be loaded
  33088. */
  33089. getWaitingItemsCount(): number;
  33090. /**
  33091. * Returns a boolean indicating if the scene is still loading data
  33092. */
  33093. readonly isLoading: boolean;
  33094. /**
  33095. * Registers a function to be executed when the scene is ready
  33096. * @param {Function} func - the function to be executed
  33097. */
  33098. executeWhenReady(func: () => void): void;
  33099. /**
  33100. * Returns a promise that resolves when the scene is ready
  33101. * @returns A promise that resolves when the scene is ready
  33102. */
  33103. whenReadyAsync(): Promise<void>;
  33104. /** @hidden */ private _checkIsReady(): void;
  33105. /**
  33106. * Gets all animatable attached to the scene
  33107. */
  33108. readonly animatables: Animatable[];
  33109. /**
  33110. * Resets the last animation time frame.
  33111. * Useful to override when animations start running when loading a scene for the first time.
  33112. */
  33113. resetLastAnimationTimeFrame(): void;
  33114. /**
  33115. * Gets the current view matrix
  33116. * @returns a Matrix
  33117. */
  33118. getViewMatrix(): Matrix;
  33119. /**
  33120. * Gets the current projection matrix
  33121. * @returns a Matrix
  33122. */
  33123. getProjectionMatrix(): Matrix;
  33124. /**
  33125. * Gets the current transform matrix
  33126. * @returns a Matrix made of View * Projection
  33127. */
  33128. getTransformMatrix(): Matrix;
  33129. /**
  33130. * Sets the current transform matrix
  33131. * @param viewL defines the View matrix to use
  33132. * @param projectionL defines the Projection matrix to use
  33133. * @param viewR defines the right View matrix to use (if provided)
  33134. * @param projectionR defines the right Projection matrix to use (if provided)
  33135. */
  33136. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33137. /**
  33138. * Gets the uniform buffer used to store scene data
  33139. * @returns a UniformBuffer
  33140. */
  33141. getSceneUniformBuffer(): UniformBuffer;
  33142. /**
  33143. * Gets an unique (relatively to the current scene) Id
  33144. * @returns an unique number for the scene
  33145. */
  33146. getUniqueId(): number;
  33147. /**
  33148. * Add a mesh to the list of scene's meshes
  33149. * @param newMesh defines the mesh to add
  33150. * @param recursive if all child meshes should also be added to the scene
  33151. */
  33152. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33153. /**
  33154. * Remove a mesh for the list of scene's meshes
  33155. * @param toRemove defines the mesh to remove
  33156. * @param recursive if all child meshes should also be removed from the scene
  33157. * @returns the index where the mesh was in the mesh list
  33158. */
  33159. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33160. /**
  33161. * Add a transform node to the list of scene's transform nodes
  33162. * @param newTransformNode defines the transform node to add
  33163. */
  33164. addTransformNode(newTransformNode: TransformNode): void;
  33165. /**
  33166. * Remove a transform node for the list of scene's transform nodes
  33167. * @param toRemove defines the transform node to remove
  33168. * @returns the index where the transform node was in the transform node list
  33169. */
  33170. removeTransformNode(toRemove: TransformNode): number;
  33171. /**
  33172. * Remove a skeleton for the list of scene's skeletons
  33173. * @param toRemove defines the skeleton to remove
  33174. * @returns the index where the skeleton was in the skeleton list
  33175. */
  33176. removeSkeleton(toRemove: Skeleton): number;
  33177. /**
  33178. * Remove a morph target for the list of scene's morph targets
  33179. * @param toRemove defines the morph target to remove
  33180. * @returns the index where the morph target was in the morph target list
  33181. */
  33182. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33183. /**
  33184. * Remove a light for the list of scene's lights
  33185. * @param toRemove defines the light to remove
  33186. * @returns the index where the light was in the light list
  33187. */
  33188. removeLight(toRemove: Light): number;
  33189. /**
  33190. * Remove a camera for the list of scene's cameras
  33191. * @param toRemove defines the camera to remove
  33192. * @returns the index where the camera was in the camera list
  33193. */
  33194. removeCamera(toRemove: Camera): number;
  33195. /**
  33196. * Remove a particle system for the list of scene's particle systems
  33197. * @param toRemove defines the particle system to remove
  33198. * @returns the index where the particle system was in the particle system list
  33199. */
  33200. removeParticleSystem(toRemove: IParticleSystem): number;
  33201. /**
  33202. * Remove a animation for the list of scene's animations
  33203. * @param toRemove defines the animation to remove
  33204. * @returns the index where the animation was in the animation list
  33205. */
  33206. removeAnimation(toRemove: Animation): number;
  33207. /**
  33208. * Will stop the animation of the given target
  33209. * @param target - the target
  33210. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33211. * @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)
  33212. */
  33213. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33214. /**
  33215. * Removes the given animation group from this scene.
  33216. * @param toRemove The animation group to remove
  33217. * @returns The index of the removed animation group
  33218. */
  33219. removeAnimationGroup(toRemove: AnimationGroup): number;
  33220. /**
  33221. * Removes the given multi-material from this scene.
  33222. * @param toRemove The multi-material to remove
  33223. * @returns The index of the removed multi-material
  33224. */
  33225. removeMultiMaterial(toRemove: MultiMaterial): number;
  33226. /**
  33227. * Removes the given material from this scene.
  33228. * @param toRemove The material to remove
  33229. * @returns The index of the removed material
  33230. */
  33231. removeMaterial(toRemove: Material): number;
  33232. /**
  33233. * Removes the given action manager from this scene.
  33234. * @param toRemove The action manager to remove
  33235. * @returns The index of the removed action manager
  33236. */
  33237. removeActionManager(toRemove: AbstractActionManager): number;
  33238. /**
  33239. * Removes the given texture from this scene.
  33240. * @param toRemove The texture to remove
  33241. * @returns The index of the removed texture
  33242. */
  33243. removeTexture(toRemove: BaseTexture): number;
  33244. /**
  33245. * Adds the given light to this scene
  33246. * @param newLight The light to add
  33247. */
  33248. addLight(newLight: Light): void;
  33249. /**
  33250. * Sorts the list list based on light priorities
  33251. */
  33252. sortLightsByPriority(): void;
  33253. /**
  33254. * Adds the given camera to this scene
  33255. * @param newCamera The camera to add
  33256. */
  33257. addCamera(newCamera: Camera): void;
  33258. /**
  33259. * Adds the given skeleton to this scene
  33260. * @param newSkeleton The skeleton to add
  33261. */
  33262. addSkeleton(newSkeleton: Skeleton): void;
  33263. /**
  33264. * Adds the given particle system to this scene
  33265. * @param newParticleSystem The particle system to add
  33266. */
  33267. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33268. /**
  33269. * Adds the given animation to this scene
  33270. * @param newAnimation The animation to add
  33271. */
  33272. addAnimation(newAnimation: Animation): void;
  33273. /**
  33274. * Adds the given animation group to this scene.
  33275. * @param newAnimationGroup The animation group to add
  33276. */
  33277. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33278. /**
  33279. * Adds the given multi-material to this scene
  33280. * @param newMultiMaterial The multi-material to add
  33281. */
  33282. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33283. /**
  33284. * Adds the given material to this scene
  33285. * @param newMaterial The material to add
  33286. */
  33287. addMaterial(newMaterial: Material): void;
  33288. /**
  33289. * Adds the given morph target to this scene
  33290. * @param newMorphTargetManager The morph target to add
  33291. */
  33292. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33293. /**
  33294. * Adds the given geometry to this scene
  33295. * @param newGeometry The geometry to add
  33296. */
  33297. addGeometry(newGeometry: Geometry): void;
  33298. /**
  33299. * Adds the given action manager to this scene
  33300. * @param newActionManager The action manager to add
  33301. */
  33302. addActionManager(newActionManager: AbstractActionManager): void;
  33303. /**
  33304. * Adds the given texture to this scene.
  33305. * @param newTexture The texture to add
  33306. */
  33307. addTexture(newTexture: BaseTexture): void;
  33308. /**
  33309. * Switch active camera
  33310. * @param newCamera defines the new active camera
  33311. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33312. */
  33313. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33314. /**
  33315. * sets the active camera of the scene using its ID
  33316. * @param id defines the camera's ID
  33317. * @return the new active camera or null if none found.
  33318. */
  33319. setActiveCameraByID(id: string): Nullable<Camera>;
  33320. /**
  33321. * sets the active camera of the scene using its name
  33322. * @param name defines the camera's name
  33323. * @returns the new active camera or null if none found.
  33324. */
  33325. setActiveCameraByName(name: string): Nullable<Camera>;
  33326. /**
  33327. * get an animation group using its name
  33328. * @param name defines the material's name
  33329. * @return the animation group or null if none found.
  33330. */
  33331. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33332. /**
  33333. * Get a material using its unique id
  33334. * @param uniqueId defines the material's unique id
  33335. * @return the material or null if none found.
  33336. */
  33337. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33338. /**
  33339. * get a material using its id
  33340. * @param id defines the material's ID
  33341. * @return the material or null if none found.
  33342. */
  33343. getMaterialByID(id: string): Nullable<Material>;
  33344. /**
  33345. * Gets a the last added material using a given id
  33346. * @param id defines the material's ID
  33347. * @return the last material with the given id or null if none found.
  33348. */
  33349. getLastMaterialByID(id: string): Nullable<Material>;
  33350. /**
  33351. * Gets a material using its name
  33352. * @param name defines the material's name
  33353. * @return the material or null if none found.
  33354. */
  33355. getMaterialByName(name: string): Nullable<Material>;
  33356. /**
  33357. * Get a texture using its unique id
  33358. * @param uniqueId defines the texture's unique id
  33359. * @return the texture or null if none found.
  33360. */
  33361. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33362. /**
  33363. * Gets a camera using its id
  33364. * @param id defines the id to look for
  33365. * @returns the camera or null if not found
  33366. */
  33367. getCameraByID(id: string): Nullable<Camera>;
  33368. /**
  33369. * Gets a camera using its unique id
  33370. * @param uniqueId defines the unique id to look for
  33371. * @returns the camera or null if not found
  33372. */
  33373. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33374. /**
  33375. * Gets a camera using its name
  33376. * @param name defines the camera's name
  33377. * @return the camera or null if none found.
  33378. */
  33379. getCameraByName(name: string): Nullable<Camera>;
  33380. /**
  33381. * Gets a bone using its id
  33382. * @param id defines the bone's id
  33383. * @return the bone or null if not found
  33384. */
  33385. getBoneByID(id: string): Nullable<Bone>;
  33386. /**
  33387. * Gets a bone using its id
  33388. * @param name defines the bone's name
  33389. * @return the bone or null if not found
  33390. */
  33391. getBoneByName(name: string): Nullable<Bone>;
  33392. /**
  33393. * Gets a light node using its name
  33394. * @param name defines the the light's name
  33395. * @return the light or null if none found.
  33396. */
  33397. getLightByName(name: string): Nullable<Light>;
  33398. /**
  33399. * Gets a light node using its id
  33400. * @param id defines the light's id
  33401. * @return the light or null if none found.
  33402. */
  33403. getLightByID(id: string): Nullable<Light>;
  33404. /**
  33405. * Gets a light node using its scene-generated unique ID
  33406. * @param uniqueId defines the light's unique id
  33407. * @return the light or null if none found.
  33408. */
  33409. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33410. /**
  33411. * Gets a particle system by id
  33412. * @param id defines the particle system id
  33413. * @return the corresponding system or null if none found
  33414. */
  33415. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33416. /**
  33417. * Gets a geometry using its ID
  33418. * @param id defines the geometry's id
  33419. * @return the geometry or null if none found.
  33420. */
  33421. getGeometryByID(id: string): Nullable<Geometry>;
  33422. private _getGeometryByUniqueID;
  33423. /**
  33424. * Add a new geometry to this scene
  33425. * @param geometry defines the geometry to be added to the scene.
  33426. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33427. * @return a boolean defining if the geometry was added or not
  33428. */
  33429. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33430. /**
  33431. * Removes an existing geometry
  33432. * @param geometry defines the geometry to be removed from the scene
  33433. * @return a boolean defining if the geometry was removed or not
  33434. */
  33435. removeGeometry(geometry: Geometry): boolean;
  33436. /**
  33437. * Gets the list of geometries attached to the scene
  33438. * @returns an array of Geometry
  33439. */
  33440. getGeometries(): Geometry[];
  33441. /**
  33442. * Gets the first added mesh found of a given ID
  33443. * @param id defines the id to search for
  33444. * @return the mesh found or null if not found at all
  33445. */
  33446. getMeshByID(id: string): Nullable<AbstractMesh>;
  33447. /**
  33448. * Gets a list of meshes using their id
  33449. * @param id defines the id to search for
  33450. * @returns a list of meshes
  33451. */
  33452. getMeshesByID(id: string): Array<AbstractMesh>;
  33453. /**
  33454. * Gets the first added transform node found of a given ID
  33455. * @param id defines the id to search for
  33456. * @return the found transform node or null if not found at all.
  33457. */
  33458. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33459. /**
  33460. * Gets a transform node with its auto-generated unique id
  33461. * @param uniqueId efines the unique id to search for
  33462. * @return the found transform node or null if not found at all.
  33463. */
  33464. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33465. /**
  33466. * Gets a list of transform nodes using their id
  33467. * @param id defines the id to search for
  33468. * @returns a list of transform nodes
  33469. */
  33470. getTransformNodesByID(id: string): Array<TransformNode>;
  33471. /**
  33472. * Gets a mesh with its auto-generated unique id
  33473. * @param uniqueId defines the unique id to search for
  33474. * @return the found mesh or null if not found at all.
  33475. */
  33476. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33477. /**
  33478. * Gets a the last added mesh using a given id
  33479. * @param id defines the id to search for
  33480. * @return the found mesh or null if not found at all.
  33481. */
  33482. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33483. /**
  33484. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33485. * @param id defines the id to search for
  33486. * @return the found node or null if not found at all
  33487. */
  33488. getLastEntryByID(id: string): Nullable<Node>;
  33489. /**
  33490. * Gets a node (Mesh, Camera, Light) using a given id
  33491. * @param id defines the id to search for
  33492. * @return the found node or null if not found at all
  33493. */
  33494. getNodeByID(id: string): Nullable<Node>;
  33495. /**
  33496. * Gets a node (Mesh, Camera, Light) using a given name
  33497. * @param name defines the name to search for
  33498. * @return the found node or null if not found at all.
  33499. */
  33500. getNodeByName(name: string): Nullable<Node>;
  33501. /**
  33502. * Gets a mesh using a given name
  33503. * @param name defines the name to search for
  33504. * @return the found mesh or null if not found at all.
  33505. */
  33506. getMeshByName(name: string): Nullable<AbstractMesh>;
  33507. /**
  33508. * Gets a transform node using a given name
  33509. * @param name defines the name to search for
  33510. * @return the found transform node or null if not found at all.
  33511. */
  33512. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33513. /**
  33514. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33515. * @param id defines the id to search for
  33516. * @return the found skeleton or null if not found at all.
  33517. */
  33518. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33519. /**
  33520. * Gets a skeleton using a given auto generated unique id
  33521. * @param uniqueId defines the unique id to search for
  33522. * @return the found skeleton or null if not found at all.
  33523. */
  33524. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33525. /**
  33526. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33527. * @param id defines the id to search for
  33528. * @return the found skeleton or null if not found at all.
  33529. */
  33530. getSkeletonById(id: string): Nullable<Skeleton>;
  33531. /**
  33532. * Gets a skeleton using a given name
  33533. * @param name defines the name to search for
  33534. * @return the found skeleton or null if not found at all.
  33535. */
  33536. getSkeletonByName(name: string): Nullable<Skeleton>;
  33537. /**
  33538. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33539. * @param id defines the id to search for
  33540. * @return the found morph target manager or null if not found at all.
  33541. */
  33542. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33543. /**
  33544. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33545. * @param id defines the id to search for
  33546. * @return the found morph target or null if not found at all.
  33547. */
  33548. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33549. /**
  33550. * Gets a boolean indicating if the given mesh is active
  33551. * @param mesh defines the mesh to look for
  33552. * @returns true if the mesh is in the active list
  33553. */
  33554. isActiveMesh(mesh: AbstractMesh): boolean;
  33555. /**
  33556. * Return a unique id as a string which can serve as an identifier for the scene
  33557. */
  33558. readonly uid: string;
  33559. /**
  33560. * Add an externaly attached data from its key.
  33561. * This method call will fail and return false, if such key already exists.
  33562. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33563. * @param key the unique key that identifies the data
  33564. * @param data the data object to associate to the key for this Engine instance
  33565. * @return true if no such key were already present and the data was added successfully, false otherwise
  33566. */
  33567. addExternalData<T>(key: string, data: T): boolean;
  33568. /**
  33569. * Get an externaly attached data from its key
  33570. * @param key the unique key that identifies the data
  33571. * @return the associated data, if present (can be null), or undefined if not present
  33572. */
  33573. getExternalData<T>(key: string): Nullable<T>;
  33574. /**
  33575. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33576. * @param key the unique key that identifies the data
  33577. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33578. * @return the associated data, can be null if the factory returned null.
  33579. */
  33580. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33581. /**
  33582. * Remove an externaly attached data from the Engine instance
  33583. * @param key the unique key that identifies the data
  33584. * @return true if the data was successfully removed, false if it doesn't exist
  33585. */
  33586. removeExternalData(key: string): boolean;
  33587. private _evaluateSubMesh;
  33588. /**
  33589. * Clear the processed materials smart array preventing retention point in material dispose.
  33590. */
  33591. freeProcessedMaterials(): void;
  33592. private _preventFreeActiveMeshesAndRenderingGroups;
  33593. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33594. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33595. * when disposing several meshes in a row or a hierarchy of meshes.
  33596. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33597. */
  33598. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33599. /**
  33600. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33601. */
  33602. freeActiveMeshes(): void;
  33603. /**
  33604. * Clear the info related to rendering groups preventing retention points during dispose.
  33605. */
  33606. freeRenderingGroups(): void;
  33607. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33608. /**
  33609. * Lambda returning the list of potentially active meshes.
  33610. */
  33611. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33612. /**
  33613. * Lambda returning the list of potentially active sub meshes.
  33614. */
  33615. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33616. /**
  33617. * Lambda returning the list of potentially intersecting sub meshes.
  33618. */
  33619. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33620. /**
  33621. * Lambda returning the list of potentially colliding sub meshes.
  33622. */
  33623. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33624. private _activeMeshesFrozen;
  33625. /**
  33626. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33627. * @returns the current scene
  33628. */
  33629. freezeActiveMeshes(): Scene;
  33630. /**
  33631. * Use this function to restart evaluating active meshes on every frame
  33632. * @returns the current scene
  33633. */
  33634. unfreezeActiveMeshes(): Scene;
  33635. private _evaluateActiveMeshes;
  33636. private _activeMesh;
  33637. /**
  33638. * Update the transform matrix to update from the current active camera
  33639. * @param force defines a boolean used to force the update even if cache is up to date
  33640. */
  33641. updateTransformMatrix(force?: boolean): void;
  33642. private _bindFrameBuffer;
  33643. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33644. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33645. private _processSubCameras;
  33646. private _checkIntersections;
  33647. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33648. /**
  33649. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33650. */
  33651. getDeterministicFrameTime: () => number;
  33652. /** @hidden */ private _animate(): void;
  33653. /** Execute all animations (for a frame) */
  33654. animate(): void;
  33655. /**
  33656. * Render the scene
  33657. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33658. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33659. */
  33660. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33661. /**
  33662. * Freeze all materials
  33663. * A frozen material will not be updatable but should be faster to render
  33664. */
  33665. freezeMaterials(): void;
  33666. /**
  33667. * Unfreeze all materials
  33668. * A frozen material will not be updatable but should be faster to render
  33669. */
  33670. unfreezeMaterials(): void;
  33671. /**
  33672. * Releases all held ressources
  33673. */
  33674. dispose(): void;
  33675. /**
  33676. * Gets if the scene is already disposed
  33677. */
  33678. readonly isDisposed: boolean;
  33679. /**
  33680. * Call this function to reduce memory footprint of the scene.
  33681. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33682. */
  33683. clearCachedVertexData(): void;
  33684. /**
  33685. * This function will remove the local cached buffer data from texture.
  33686. * It will save memory but will prevent the texture from being rebuilt
  33687. */
  33688. cleanCachedTextureBuffer(): void;
  33689. /**
  33690. * Get the world extend vectors with an optional filter
  33691. *
  33692. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33693. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33694. */
  33695. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33696. min: Vector3;
  33697. max: Vector3;
  33698. };
  33699. /**
  33700. * Creates a ray that can be used to pick in the scene
  33701. * @param x defines the x coordinate of the origin (on-screen)
  33702. * @param y defines the y coordinate of the origin (on-screen)
  33703. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33704. * @param camera defines the camera to use for the picking
  33705. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33706. * @returns a Ray
  33707. */
  33708. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33709. /**
  33710. * Creates a ray that can be used to pick in the scene
  33711. * @param x defines the x coordinate of the origin (on-screen)
  33712. * @param y defines the y coordinate of the origin (on-screen)
  33713. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33714. * @param result defines the ray where to store the picking ray
  33715. * @param camera defines the camera to use for the picking
  33716. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33717. * @returns the current scene
  33718. */
  33719. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33720. /**
  33721. * Creates a ray that can be used to pick in the scene
  33722. * @param x defines the x coordinate of the origin (on-screen)
  33723. * @param y defines the y coordinate of the origin (on-screen)
  33724. * @param camera defines the camera to use for the picking
  33725. * @returns a Ray
  33726. */
  33727. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33728. /**
  33729. * Creates a ray that can be used to pick in the scene
  33730. * @param x defines the x coordinate of the origin (on-screen)
  33731. * @param y defines the y coordinate of the origin (on-screen)
  33732. * @param result defines the ray where to store the picking ray
  33733. * @param camera defines the camera to use for the picking
  33734. * @returns the current scene
  33735. */
  33736. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33737. /** Launch a ray to try to pick a mesh in the scene
  33738. * @param x position on screen
  33739. * @param y position on screen
  33740. * @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
  33741. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33742. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33743. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33744. * @returns a PickingInfo
  33745. */
  33746. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33747. /** Use the given ray to pick a mesh in the scene
  33748. * @param ray The ray to use to pick meshes
  33749. * @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
  33750. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33751. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33752. * @returns a PickingInfo
  33753. */
  33754. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33755. /**
  33756. * Launch a ray to try to pick a mesh in the scene
  33757. * @param x X position on screen
  33758. * @param y Y position on screen
  33759. * @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
  33760. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33761. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33762. * @returns an array of PickingInfo
  33763. */
  33764. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33765. /**
  33766. * Launch a ray to try to pick a mesh in the scene
  33767. * @param ray Ray to use
  33768. * @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
  33769. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33770. * @returns an array of PickingInfo
  33771. */
  33772. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33773. /**
  33774. * Force the value of meshUnderPointer
  33775. * @param mesh defines the mesh to use
  33776. */
  33777. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33778. /**
  33779. * Gets the mesh under the pointer
  33780. * @returns a Mesh or null if no mesh is under the pointer
  33781. */
  33782. getPointerOverMesh(): Nullable<AbstractMesh>;
  33783. /** @hidden */ private _rebuildGeometries(): void;
  33784. /** @hidden */ private _rebuildTextures(): void;
  33785. private _getByTags;
  33786. /**
  33787. * Get a list of meshes by tags
  33788. * @param tagsQuery defines the tags query to use
  33789. * @param forEach defines a predicate used to filter results
  33790. * @returns an array of Mesh
  33791. */
  33792. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33793. /**
  33794. * Get a list of cameras by tags
  33795. * @param tagsQuery defines the tags query to use
  33796. * @param forEach defines a predicate used to filter results
  33797. * @returns an array of Camera
  33798. */
  33799. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33800. /**
  33801. * Get a list of lights by tags
  33802. * @param tagsQuery defines the tags query to use
  33803. * @param forEach defines a predicate used to filter results
  33804. * @returns an array of Light
  33805. */
  33806. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33807. /**
  33808. * Get a list of materials by tags
  33809. * @param tagsQuery defines the tags query to use
  33810. * @param forEach defines a predicate used to filter results
  33811. * @returns an array of Material
  33812. */
  33813. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33814. /**
  33815. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33816. * This allowed control for front to back rendering or reversly depending of the special needs.
  33817. *
  33818. * @param renderingGroupId The rendering group id corresponding to its index
  33819. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33820. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33821. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33822. */
  33823. 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;
  33824. /**
  33825. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33826. *
  33827. * @param renderingGroupId The rendering group id corresponding to its index
  33828. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33829. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33830. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33831. */
  33832. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33833. /**
  33834. * Gets the current auto clear configuration for one rendering group of the rendering
  33835. * manager.
  33836. * @param index the rendering group index to get the information for
  33837. * @returns The auto clear setup for the requested rendering group
  33838. */
  33839. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33840. private _blockMaterialDirtyMechanism;
  33841. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33842. blockMaterialDirtyMechanism: boolean;
  33843. /**
  33844. * Will flag all materials as dirty to trigger new shader compilation
  33845. * @param flag defines the flag used to specify which material part must be marked as dirty
  33846. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33847. */
  33848. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33849. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33850. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33851. }
  33852. }
  33853. declare module BABYLON {
  33854. /**
  33855. * Set of assets to keep when moving a scene into an asset container.
  33856. */
  33857. export class KeepAssets extends AbstractScene {
  33858. }
  33859. /**
  33860. * Container with a set of assets that can be added or removed from a scene.
  33861. */
  33862. export class AssetContainer extends AbstractScene {
  33863. /**
  33864. * The scene the AssetContainer belongs to.
  33865. */
  33866. scene: Scene;
  33867. /**
  33868. * Instantiates an AssetContainer.
  33869. * @param scene The scene the AssetContainer belongs to.
  33870. */
  33871. constructor(scene: Scene);
  33872. /**
  33873. * Adds all the assets from the container to the scene.
  33874. */
  33875. addAllToScene(): void;
  33876. /**
  33877. * Removes all the assets in the container from the scene
  33878. */
  33879. removeAllFromScene(): void;
  33880. /**
  33881. * Disposes all the assets in the container
  33882. */
  33883. dispose(): void;
  33884. private _moveAssets;
  33885. /**
  33886. * Removes all the assets contained in the scene and adds them to the container.
  33887. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33888. */
  33889. moveAllFromScene(keepAssets?: KeepAssets): void;
  33890. /**
  33891. * 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.
  33892. * @returns the root mesh
  33893. */
  33894. createRootMesh(): Mesh;
  33895. }
  33896. }
  33897. declare module BABYLON {
  33898. /**
  33899. * Defines how the parser contract is defined.
  33900. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33901. */
  33902. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33903. /**
  33904. * Defines how the individual parser contract is defined.
  33905. * These parser can parse an individual asset
  33906. */
  33907. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33908. /**
  33909. * Base class of the scene acting as a container for the different elements composing a scene.
  33910. * This class is dynamically extended by the different components of the scene increasing
  33911. * flexibility and reducing coupling
  33912. */
  33913. export abstract class AbstractScene {
  33914. /**
  33915. * Stores the list of available parsers in the application.
  33916. */
  33917. private static _BabylonFileParsers;
  33918. /**
  33919. * Stores the list of available individual parsers in the application.
  33920. */
  33921. private static _IndividualBabylonFileParsers;
  33922. /**
  33923. * Adds a parser in the list of available ones
  33924. * @param name Defines the name of the parser
  33925. * @param parser Defines the parser to add
  33926. */
  33927. static AddParser(name: string, parser: BabylonFileParser): void;
  33928. /**
  33929. * Gets a general parser from the list of avaialble ones
  33930. * @param name Defines the name of the parser
  33931. * @returns the requested parser or null
  33932. */
  33933. static GetParser(name: string): Nullable<BabylonFileParser>;
  33934. /**
  33935. * Adds n individual parser in the list of available ones
  33936. * @param name Defines the name of the parser
  33937. * @param parser Defines the parser to add
  33938. */
  33939. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33940. /**
  33941. * Gets an individual parser from the list of avaialble ones
  33942. * @param name Defines the name of the parser
  33943. * @returns the requested parser or null
  33944. */
  33945. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33946. /**
  33947. * Parser json data and populate both a scene and its associated container object
  33948. * @param jsonData Defines the data to parse
  33949. * @param scene Defines the scene to parse the data for
  33950. * @param container Defines the container attached to the parsing sequence
  33951. * @param rootUrl Defines the root url of the data
  33952. */
  33953. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33954. /**
  33955. * Gets the list of root nodes (ie. nodes with no parent)
  33956. */
  33957. rootNodes: Node[];
  33958. /** All of the cameras added to this scene
  33959. * @see http://doc.babylonjs.com/babylon101/cameras
  33960. */
  33961. cameras: Camera[];
  33962. /**
  33963. * All of the lights added to this scene
  33964. * @see http://doc.babylonjs.com/babylon101/lights
  33965. */
  33966. lights: Light[];
  33967. /**
  33968. * All of the (abstract) meshes added to this scene
  33969. */
  33970. meshes: AbstractMesh[];
  33971. /**
  33972. * The list of skeletons added to the scene
  33973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33974. */
  33975. skeletons: Skeleton[];
  33976. /**
  33977. * All of the particle systems added to this scene
  33978. * @see http://doc.babylonjs.com/babylon101/particles
  33979. */
  33980. particleSystems: IParticleSystem[];
  33981. /**
  33982. * Gets a list of Animations associated with the scene
  33983. */
  33984. animations: Animation[];
  33985. /**
  33986. * All of the animation groups added to this scene
  33987. * @see http://doc.babylonjs.com/how_to/group
  33988. */
  33989. animationGroups: AnimationGroup[];
  33990. /**
  33991. * All of the multi-materials added to this scene
  33992. * @see http://doc.babylonjs.com/how_to/multi_materials
  33993. */
  33994. multiMaterials: MultiMaterial[];
  33995. /**
  33996. * All of the materials added to this scene
  33997. * In the context of a Scene, it is not supposed to be modified manually.
  33998. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33999. * Note also that the order of the Material wihin the array is not significant and might change.
  34000. * @see http://doc.babylonjs.com/babylon101/materials
  34001. */
  34002. materials: Material[];
  34003. /**
  34004. * The list of morph target managers added to the scene
  34005. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34006. */
  34007. morphTargetManagers: MorphTargetManager[];
  34008. /**
  34009. * The list of geometries used in the scene.
  34010. */
  34011. geometries: Geometry[];
  34012. /**
  34013. * All of the tranform nodes added to this scene
  34014. * In the context of a Scene, it is not supposed to be modified manually.
  34015. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34016. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34017. * @see http://doc.babylonjs.com/how_to/transformnode
  34018. */
  34019. transformNodes: TransformNode[];
  34020. /**
  34021. * ActionManagers available on the scene.
  34022. */
  34023. actionManagers: AbstractActionManager[];
  34024. /**
  34025. * Textures to keep.
  34026. */
  34027. textures: BaseTexture[];
  34028. /**
  34029. * Environment texture for the scene
  34030. */
  34031. environmentTexture: Nullable<BaseTexture>;
  34032. }
  34033. }
  34034. declare module BABYLON {
  34035. /**
  34036. * Interface used to define options for Sound class
  34037. */
  34038. export interface ISoundOptions {
  34039. /**
  34040. * Does the sound autoplay once loaded.
  34041. */
  34042. autoplay?: boolean;
  34043. /**
  34044. * Does the sound loop after it finishes playing once.
  34045. */
  34046. loop?: boolean;
  34047. /**
  34048. * Sound's volume
  34049. */
  34050. volume?: number;
  34051. /**
  34052. * Is it a spatial sound?
  34053. */
  34054. spatialSound?: boolean;
  34055. /**
  34056. * Maximum distance to hear that sound
  34057. */
  34058. maxDistance?: number;
  34059. /**
  34060. * Uses user defined attenuation function
  34061. */
  34062. useCustomAttenuation?: boolean;
  34063. /**
  34064. * Define the roll off factor of spatial sounds.
  34065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34066. */
  34067. rolloffFactor?: number;
  34068. /**
  34069. * Define the reference distance the sound should be heard perfectly.
  34070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34071. */
  34072. refDistance?: number;
  34073. /**
  34074. * Define the distance attenuation model the sound will follow.
  34075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34076. */
  34077. distanceModel?: string;
  34078. /**
  34079. * Defines the playback speed (1 by default)
  34080. */
  34081. playbackRate?: number;
  34082. /**
  34083. * Defines if the sound is from a streaming source
  34084. */
  34085. streaming?: boolean;
  34086. /**
  34087. * Defines an optional length (in seconds) inside the sound file
  34088. */
  34089. length?: number;
  34090. /**
  34091. * Defines an optional offset (in seconds) inside the sound file
  34092. */
  34093. offset?: number;
  34094. /**
  34095. * If true, URLs will not be required to state the audio file codec to use.
  34096. */
  34097. skipCodecCheck?: boolean;
  34098. }
  34099. /**
  34100. * Defines a sound that can be played in the application.
  34101. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34103. */
  34104. export class Sound {
  34105. /**
  34106. * The name of the sound in the scene.
  34107. */
  34108. name: string;
  34109. /**
  34110. * Does the sound autoplay once loaded.
  34111. */
  34112. autoplay: boolean;
  34113. /**
  34114. * Does the sound loop after it finishes playing once.
  34115. */
  34116. loop: boolean;
  34117. /**
  34118. * Does the sound use a custom attenuation curve to simulate the falloff
  34119. * happening when the source gets further away from the camera.
  34120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34121. */
  34122. useCustomAttenuation: boolean;
  34123. /**
  34124. * The sound track id this sound belongs to.
  34125. */
  34126. soundTrackId: number;
  34127. /**
  34128. * Is this sound currently played.
  34129. */
  34130. isPlaying: boolean;
  34131. /**
  34132. * Is this sound currently paused.
  34133. */
  34134. isPaused: boolean;
  34135. /**
  34136. * Does this sound enables spatial sound.
  34137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34138. */
  34139. spatialSound: boolean;
  34140. /**
  34141. * Define the reference distance the sound should be heard perfectly.
  34142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34143. */
  34144. refDistance: number;
  34145. /**
  34146. * Define the roll off factor of spatial sounds.
  34147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34148. */
  34149. rolloffFactor: number;
  34150. /**
  34151. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34153. */
  34154. maxDistance: number;
  34155. /**
  34156. * Define the distance attenuation model the sound will follow.
  34157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34158. */
  34159. distanceModel: string;
  34160. /**
  34161. * @hidden
  34162. * Back Compat
  34163. **/
  34164. onended: () => any;
  34165. /**
  34166. * Observable event when the current playing sound finishes.
  34167. */
  34168. onEndedObservable: Observable<Sound>;
  34169. private _panningModel;
  34170. private _playbackRate;
  34171. private _streaming;
  34172. private _startTime;
  34173. private _startOffset;
  34174. private _position;
  34175. /** @hidden */ private _positionInEmitterSpace: boolean;
  34176. private _localDirection;
  34177. private _volume;
  34178. private _isReadyToPlay;
  34179. private _isDirectional;
  34180. private _readyToPlayCallback;
  34181. private _audioBuffer;
  34182. private _soundSource;
  34183. private _streamingSource;
  34184. private _soundPanner;
  34185. private _soundGain;
  34186. private _inputAudioNode;
  34187. private _outputAudioNode;
  34188. private _coneInnerAngle;
  34189. private _coneOuterAngle;
  34190. private _coneOuterGain;
  34191. private _scene;
  34192. private _connectedTransformNode;
  34193. private _customAttenuationFunction;
  34194. private _registerFunc;
  34195. private _isOutputConnected;
  34196. private _htmlAudioElement;
  34197. private _urlType;
  34198. private _length?;
  34199. private _offset?;
  34200. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34201. /**
  34202. * Create a sound and attach it to a scene
  34203. * @param name Name of your sound
  34204. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34205. * @param scene defines the scene the sound belongs to
  34206. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34207. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34208. */
  34209. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34210. /**
  34211. * Release the sound and its associated resources
  34212. */
  34213. dispose(): void;
  34214. /**
  34215. * Gets if the sounds is ready to be played or not.
  34216. * @returns true if ready, otherwise false
  34217. */
  34218. isReady(): boolean;
  34219. private _soundLoaded;
  34220. /**
  34221. * Sets the data of the sound from an audiobuffer
  34222. * @param audioBuffer The audioBuffer containing the data
  34223. */
  34224. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34225. /**
  34226. * Updates the current sounds options such as maxdistance, loop...
  34227. * @param options A JSON object containing values named as the object properties
  34228. */
  34229. updateOptions(options: ISoundOptions): void;
  34230. private _createSpatialParameters;
  34231. private _updateSpatialParameters;
  34232. /**
  34233. * Switch the panning model to HRTF:
  34234. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34236. */
  34237. switchPanningModelToHRTF(): void;
  34238. /**
  34239. * Switch the panning model to Equal Power:
  34240. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34242. */
  34243. switchPanningModelToEqualPower(): void;
  34244. private _switchPanningModel;
  34245. /**
  34246. * Connect this sound to a sound track audio node like gain...
  34247. * @param soundTrackAudioNode the sound track audio node to connect to
  34248. */
  34249. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34250. /**
  34251. * Transform this sound into a directional source
  34252. * @param coneInnerAngle Size of the inner cone in degree
  34253. * @param coneOuterAngle Size of the outer cone in degree
  34254. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34255. */
  34256. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34257. /**
  34258. * Gets or sets the inner angle for the directional cone.
  34259. */
  34260. /**
  34261. * Gets or sets the inner angle for the directional cone.
  34262. */
  34263. directionalConeInnerAngle: number;
  34264. /**
  34265. * Gets or sets the outer angle for the directional cone.
  34266. */
  34267. /**
  34268. * Gets or sets the outer angle for the directional cone.
  34269. */
  34270. directionalConeOuterAngle: number;
  34271. /**
  34272. * Sets the position of the emitter if spatial sound is enabled
  34273. * @param newPosition Defines the new posisiton
  34274. */
  34275. setPosition(newPosition: Vector3): void;
  34276. /**
  34277. * Sets the local direction of the emitter if spatial sound is enabled
  34278. * @param newLocalDirection Defines the new local direction
  34279. */
  34280. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34281. private _updateDirection;
  34282. /** @hidden */
  34283. updateDistanceFromListener(): void;
  34284. /**
  34285. * Sets a new custom attenuation function for the sound.
  34286. * @param callback Defines the function used for the attenuation
  34287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34288. */
  34289. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34290. /**
  34291. * Play the sound
  34292. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34293. * @param offset (optional) Start the sound at a specific time in seconds
  34294. * @param length (optional) Sound duration (in seconds)
  34295. */
  34296. play(time?: number, offset?: number, length?: number): void;
  34297. private _onended;
  34298. /**
  34299. * Stop the sound
  34300. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34301. */
  34302. stop(time?: number): void;
  34303. /**
  34304. * Put the sound in pause
  34305. */
  34306. pause(): void;
  34307. /**
  34308. * Sets a dedicated volume for this sounds
  34309. * @param newVolume Define the new volume of the sound
  34310. * @param time Define time for gradual change to new volume
  34311. */
  34312. setVolume(newVolume: number, time?: number): void;
  34313. /**
  34314. * Set the sound play back rate
  34315. * @param newPlaybackRate Define the playback rate the sound should be played at
  34316. */
  34317. setPlaybackRate(newPlaybackRate: number): void;
  34318. /**
  34319. * Gets the volume of the sound.
  34320. * @returns the volume of the sound
  34321. */
  34322. getVolume(): number;
  34323. /**
  34324. * Attach the sound to a dedicated mesh
  34325. * @param transformNode The transform node to connect the sound with
  34326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34327. */
  34328. attachToMesh(transformNode: TransformNode): void;
  34329. /**
  34330. * Detach the sound from the previously attached mesh
  34331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34332. */
  34333. detachFromMesh(): void;
  34334. private _onRegisterAfterWorldMatrixUpdate;
  34335. /**
  34336. * Clone the current sound in the scene.
  34337. * @returns the new sound clone
  34338. */
  34339. clone(): Nullable<Sound>;
  34340. /**
  34341. * Gets the current underlying audio buffer containing the data
  34342. * @returns the audio buffer
  34343. */
  34344. getAudioBuffer(): Nullable<AudioBuffer>;
  34345. /**
  34346. * Serializes the Sound in a JSON representation
  34347. * @returns the JSON representation of the sound
  34348. */
  34349. serialize(): any;
  34350. /**
  34351. * Parse a JSON representation of a sound to innstantiate in a given scene
  34352. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34353. * @param scene Define the scene the new parsed sound should be created in
  34354. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34355. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34356. * @returns the newly parsed sound
  34357. */
  34358. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34359. }
  34360. }
  34361. declare module BABYLON {
  34362. /**
  34363. * This defines an action helpful to play a defined sound on a triggered action.
  34364. */
  34365. export class PlaySoundAction extends Action {
  34366. private _sound;
  34367. /**
  34368. * Instantiate the action
  34369. * @param triggerOptions defines the trigger options
  34370. * @param sound defines the sound to play
  34371. * @param condition defines the trigger related conditions
  34372. */
  34373. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34374. /** @hidden */ private _prepare(): void;
  34375. /**
  34376. * Execute the action and play the sound.
  34377. */
  34378. execute(): void;
  34379. /**
  34380. * Serializes the actions and its related information.
  34381. * @param parent defines the object to serialize in
  34382. * @returns the serialized object
  34383. */
  34384. serialize(parent: any): any;
  34385. }
  34386. /**
  34387. * This defines an action helpful to stop a defined sound on a triggered action.
  34388. */
  34389. export class StopSoundAction extends Action {
  34390. private _sound;
  34391. /**
  34392. * Instantiate the action
  34393. * @param triggerOptions defines the trigger options
  34394. * @param sound defines the sound to stop
  34395. * @param condition defines the trigger related conditions
  34396. */
  34397. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34398. /** @hidden */ private _prepare(): void;
  34399. /**
  34400. * Execute the action and stop the sound.
  34401. */
  34402. execute(): void;
  34403. /**
  34404. * Serializes the actions and its related information.
  34405. * @param parent defines the object to serialize in
  34406. * @returns the serialized object
  34407. */
  34408. serialize(parent: any): any;
  34409. }
  34410. }
  34411. declare module BABYLON {
  34412. /**
  34413. * This defines an action responsible to change the value of a property
  34414. * by interpolating between its current value and the newly set one once triggered.
  34415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34416. */
  34417. export class InterpolateValueAction extends Action {
  34418. /**
  34419. * Defines the path of the property where the value should be interpolated
  34420. */
  34421. propertyPath: string;
  34422. /**
  34423. * Defines the target value at the end of the interpolation.
  34424. */
  34425. value: any;
  34426. /**
  34427. * Defines the time it will take for the property to interpolate to the value.
  34428. */
  34429. duration: number;
  34430. /**
  34431. * Defines if the other scene animations should be stopped when the action has been triggered
  34432. */
  34433. stopOtherAnimations?: boolean;
  34434. /**
  34435. * Defines a callback raised once the interpolation animation has been done.
  34436. */
  34437. onInterpolationDone?: () => void;
  34438. /**
  34439. * Observable triggered once the interpolation animation has been done.
  34440. */
  34441. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34442. private _target;
  34443. private _effectiveTarget;
  34444. private _property;
  34445. /**
  34446. * Instantiate the action
  34447. * @param triggerOptions defines the trigger options
  34448. * @param target defines the object containing the value to interpolate
  34449. * @param propertyPath defines the path to the property in the target object
  34450. * @param value defines the target value at the end of the interpolation
  34451. * @param duration deines the time it will take for the property to interpolate to the value.
  34452. * @param condition defines the trigger related conditions
  34453. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34454. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34455. */
  34456. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34457. /** @hidden */ private _prepare(): void;
  34458. /**
  34459. * Execute the action starts the value interpolation.
  34460. */
  34461. execute(): void;
  34462. /**
  34463. * Serializes the actions and its related information.
  34464. * @param parent defines the object to serialize in
  34465. * @returns the serialized object
  34466. */
  34467. serialize(parent: any): any;
  34468. }
  34469. }
  34470. declare module BABYLON {
  34471. /**
  34472. * Options allowed during the creation of a sound track.
  34473. */
  34474. export interface ISoundTrackOptions {
  34475. /**
  34476. * The volume the sound track should take during creation
  34477. */
  34478. volume?: number;
  34479. /**
  34480. * Define if the sound track is the main sound track of the scene
  34481. */
  34482. mainTrack?: boolean;
  34483. }
  34484. /**
  34485. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34486. * It will be also used in a future release to apply effects on a specific track.
  34487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34488. */
  34489. export class SoundTrack {
  34490. /**
  34491. * The unique identifier of the sound track in the scene.
  34492. */
  34493. id: number;
  34494. /**
  34495. * The list of sounds included in the sound track.
  34496. */
  34497. soundCollection: Array<Sound>;
  34498. private _outputAudioNode;
  34499. private _scene;
  34500. private _isMainTrack;
  34501. private _connectedAnalyser;
  34502. private _options;
  34503. private _isInitialized;
  34504. /**
  34505. * Creates a new sound track.
  34506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34507. * @param scene Define the scene the sound track belongs to
  34508. * @param options
  34509. */
  34510. constructor(scene: Scene, options?: ISoundTrackOptions);
  34511. private _initializeSoundTrackAudioGraph;
  34512. /**
  34513. * Release the sound track and its associated resources
  34514. */
  34515. dispose(): void;
  34516. /**
  34517. * Adds a sound to this sound track
  34518. * @param sound define the cound to add
  34519. * @ignoreNaming
  34520. */
  34521. AddSound(sound: Sound): void;
  34522. /**
  34523. * Removes a sound to this sound track
  34524. * @param sound define the cound to remove
  34525. * @ignoreNaming
  34526. */
  34527. RemoveSound(sound: Sound): void;
  34528. /**
  34529. * Set a global volume for the full sound track.
  34530. * @param newVolume Define the new volume of the sound track
  34531. */
  34532. setVolume(newVolume: number): void;
  34533. /**
  34534. * Switch the panning model to HRTF:
  34535. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34537. */
  34538. switchPanningModelToHRTF(): void;
  34539. /**
  34540. * Switch the panning model to Equal Power:
  34541. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34543. */
  34544. switchPanningModelToEqualPower(): void;
  34545. /**
  34546. * Connect the sound track to an audio analyser allowing some amazing
  34547. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34549. * @param analyser The analyser to connect to the engine
  34550. */
  34551. connectToAnalyser(analyser: Analyser): void;
  34552. }
  34553. }
  34554. declare module BABYLON {
  34555. interface AbstractScene {
  34556. /**
  34557. * The list of sounds used in the scene.
  34558. */
  34559. sounds: Nullable<Array<Sound>>;
  34560. }
  34561. interface Scene {
  34562. /**
  34563. * @hidden
  34564. * Backing field
  34565. */ private _mainSoundTrack: SoundTrack;
  34566. /**
  34567. * The main sound track played by the scene.
  34568. * It cotains your primary collection of sounds.
  34569. */
  34570. mainSoundTrack: SoundTrack;
  34571. /**
  34572. * The list of sound tracks added to the scene
  34573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34574. */
  34575. soundTracks: Nullable<Array<SoundTrack>>;
  34576. /**
  34577. * Gets a sound using a given name
  34578. * @param name defines the name to search for
  34579. * @return the found sound or null if not found at all.
  34580. */
  34581. getSoundByName(name: string): Nullable<Sound>;
  34582. /**
  34583. * Gets or sets if audio support is enabled
  34584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34585. */
  34586. audioEnabled: boolean;
  34587. /**
  34588. * Gets or sets if audio will be output to headphones
  34589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34590. */
  34591. headphone: boolean;
  34592. /**
  34593. * Gets or sets custom audio listener position provider
  34594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34595. */
  34596. audioListenerPositionProvider: Nullable<() => Vector3>;
  34597. }
  34598. /**
  34599. * Defines the sound scene component responsible to manage any sounds
  34600. * in a given scene.
  34601. */
  34602. export class AudioSceneComponent implements ISceneSerializableComponent {
  34603. /**
  34604. * The component name helpfull to identify the component in the list of scene components.
  34605. */
  34606. readonly name: string;
  34607. /**
  34608. * The scene the component belongs to.
  34609. */
  34610. scene: Scene;
  34611. private _audioEnabled;
  34612. /**
  34613. * Gets whether audio is enabled or not.
  34614. * Please use related enable/disable method to switch state.
  34615. */
  34616. readonly audioEnabled: boolean;
  34617. private _headphone;
  34618. /**
  34619. * Gets whether audio is outputing to headphone or not.
  34620. * Please use the according Switch methods to change output.
  34621. */
  34622. readonly headphone: boolean;
  34623. private _audioListenerPositionProvider;
  34624. /**
  34625. * Gets the current audio listener position provider
  34626. */
  34627. /**
  34628. * Sets a custom listener position for all sounds in the scene
  34629. * By default, this is the position of the first active camera
  34630. */
  34631. audioListenerPositionProvider: Nullable<() => Vector3>;
  34632. /**
  34633. * Creates a new instance of the component for the given scene
  34634. * @param scene Defines the scene to register the component in
  34635. */
  34636. constructor(scene: Scene);
  34637. /**
  34638. * Registers the component in a given scene
  34639. */
  34640. register(): void;
  34641. /**
  34642. * Rebuilds the elements related to this component in case of
  34643. * context lost for instance.
  34644. */
  34645. rebuild(): void;
  34646. /**
  34647. * Serializes the component data to the specified json object
  34648. * @param serializationObject The object to serialize to
  34649. */
  34650. serialize(serializationObject: any): void;
  34651. /**
  34652. * Adds all the elements from the container to the scene
  34653. * @param container the container holding the elements
  34654. */
  34655. addFromContainer(container: AbstractScene): void;
  34656. /**
  34657. * Removes all the elements in the container from the scene
  34658. * @param container contains the elements to remove
  34659. * @param dispose if the removed element should be disposed (default: false)
  34660. */
  34661. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34662. /**
  34663. * Disposes the component and the associated ressources.
  34664. */
  34665. dispose(): void;
  34666. /**
  34667. * Disables audio in the associated scene.
  34668. */
  34669. disableAudio(): void;
  34670. /**
  34671. * Enables audio in the associated scene.
  34672. */
  34673. enableAudio(): void;
  34674. /**
  34675. * Switch audio to headphone output.
  34676. */
  34677. switchAudioModeForHeadphones(): void;
  34678. /**
  34679. * Switch audio to normal speakers.
  34680. */
  34681. switchAudioModeForNormalSpeakers(): void;
  34682. private _afterRender;
  34683. }
  34684. }
  34685. declare module BABYLON {
  34686. /**
  34687. * Wraps one or more Sound objects and selects one with random weight for playback.
  34688. */
  34689. export class WeightedSound {
  34690. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34691. loop: boolean;
  34692. private _coneInnerAngle;
  34693. private _coneOuterAngle;
  34694. private _volume;
  34695. /** A Sound is currently playing. */
  34696. isPlaying: boolean;
  34697. /** A Sound is currently paused. */
  34698. isPaused: boolean;
  34699. private _sounds;
  34700. private _weights;
  34701. private _currentIndex?;
  34702. /**
  34703. * Creates a new WeightedSound from the list of sounds given.
  34704. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34705. * @param sounds Array of Sounds that will be selected from.
  34706. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34707. */
  34708. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34709. /**
  34710. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34711. */
  34712. /**
  34713. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34714. */
  34715. directionalConeInnerAngle: number;
  34716. /**
  34717. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34718. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34719. */
  34720. /**
  34721. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34722. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34723. */
  34724. directionalConeOuterAngle: number;
  34725. /**
  34726. * Playback volume.
  34727. */
  34728. /**
  34729. * Playback volume.
  34730. */
  34731. volume: number;
  34732. private _onended;
  34733. /**
  34734. * Suspend playback
  34735. */
  34736. pause(): void;
  34737. /**
  34738. * Stop playback
  34739. */
  34740. stop(): void;
  34741. /**
  34742. * Start playback.
  34743. * @param startOffset Position the clip head at a specific time in seconds.
  34744. */
  34745. play(startOffset?: number): void;
  34746. }
  34747. }
  34748. declare module BABYLON {
  34749. /**
  34750. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34752. */
  34753. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34754. /**
  34755. * Gets the name of the behavior.
  34756. */
  34757. readonly name: string;
  34758. /**
  34759. * The easing function used by animations
  34760. */
  34761. static EasingFunction: BackEase;
  34762. /**
  34763. * The easing mode used by animations
  34764. */
  34765. static EasingMode: number;
  34766. /**
  34767. * The duration of the animation, in milliseconds
  34768. */
  34769. transitionDuration: number;
  34770. /**
  34771. * Length of the distance animated by the transition when lower radius is reached
  34772. */
  34773. lowerRadiusTransitionRange: number;
  34774. /**
  34775. * Length of the distance animated by the transition when upper radius is reached
  34776. */
  34777. upperRadiusTransitionRange: number;
  34778. private _autoTransitionRange;
  34779. /**
  34780. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34781. */
  34782. /**
  34783. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34784. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34785. */
  34786. autoTransitionRange: boolean;
  34787. private _attachedCamera;
  34788. private _onAfterCheckInputsObserver;
  34789. private _onMeshTargetChangedObserver;
  34790. /**
  34791. * Initializes the behavior.
  34792. */
  34793. init(): void;
  34794. /**
  34795. * Attaches the behavior to its arc rotate camera.
  34796. * @param camera Defines the camera to attach the behavior to
  34797. */
  34798. attach(camera: ArcRotateCamera): void;
  34799. /**
  34800. * Detaches the behavior from its current arc rotate camera.
  34801. */
  34802. detach(): void;
  34803. private _radiusIsAnimating;
  34804. private _radiusBounceTransition;
  34805. private _animatables;
  34806. private _cachedWheelPrecision;
  34807. /**
  34808. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34809. * @param radiusLimit The limit to check against.
  34810. * @return Bool to indicate if at limit.
  34811. */
  34812. private _isRadiusAtLimit;
  34813. /**
  34814. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34815. * @param radiusDelta The delta by which to animate to. Can be negative.
  34816. */
  34817. private _applyBoundRadiusAnimation;
  34818. /**
  34819. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34820. */
  34821. protected _clearAnimationLocks(): void;
  34822. /**
  34823. * Stops and removes all animations that have been applied to the camera
  34824. */
  34825. stopAllAnimations(): void;
  34826. }
  34827. }
  34828. declare module BABYLON {
  34829. /**
  34830. * 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.
  34831. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34832. */
  34833. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34834. /**
  34835. * Gets the name of the behavior.
  34836. */
  34837. readonly name: string;
  34838. private _mode;
  34839. private _radiusScale;
  34840. private _positionScale;
  34841. private _defaultElevation;
  34842. private _elevationReturnTime;
  34843. private _elevationReturnWaitTime;
  34844. private _zoomStopsAnimation;
  34845. private _framingTime;
  34846. /**
  34847. * The easing function used by animations
  34848. */
  34849. static EasingFunction: ExponentialEase;
  34850. /**
  34851. * The easing mode used by animations
  34852. */
  34853. static EasingMode: number;
  34854. /**
  34855. * Sets the current mode used by the behavior
  34856. */
  34857. /**
  34858. * Gets current mode used by the behavior.
  34859. */
  34860. mode: number;
  34861. /**
  34862. * Sets the scale applied to the radius (1 by default)
  34863. */
  34864. /**
  34865. * Gets the scale applied to the radius
  34866. */
  34867. radiusScale: number;
  34868. /**
  34869. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34870. */
  34871. /**
  34872. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34873. */
  34874. positionScale: number;
  34875. /**
  34876. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34877. * behaviour is triggered, in radians.
  34878. */
  34879. /**
  34880. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34881. * behaviour is triggered, in radians.
  34882. */
  34883. defaultElevation: number;
  34884. /**
  34885. * Sets the time (in milliseconds) taken to return to the default beta position.
  34886. * Negative value indicates camera should not return to default.
  34887. */
  34888. /**
  34889. * Gets the time (in milliseconds) taken to return to the default beta position.
  34890. * Negative value indicates camera should not return to default.
  34891. */
  34892. elevationReturnTime: number;
  34893. /**
  34894. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34895. */
  34896. /**
  34897. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34898. */
  34899. elevationReturnWaitTime: number;
  34900. /**
  34901. * Sets the flag that indicates if user zooming should stop animation.
  34902. */
  34903. /**
  34904. * Gets the flag that indicates if user zooming should stop animation.
  34905. */
  34906. zoomStopsAnimation: boolean;
  34907. /**
  34908. * Sets the transition time when framing the mesh, in milliseconds
  34909. */
  34910. /**
  34911. * Gets the transition time when framing the mesh, in milliseconds
  34912. */
  34913. framingTime: number;
  34914. /**
  34915. * Define if the behavior should automatically change the configured
  34916. * camera limits and sensibilities.
  34917. */
  34918. autoCorrectCameraLimitsAndSensibility: boolean;
  34919. private _onPrePointerObservableObserver;
  34920. private _onAfterCheckInputsObserver;
  34921. private _onMeshTargetChangedObserver;
  34922. private _attachedCamera;
  34923. private _isPointerDown;
  34924. private _lastInteractionTime;
  34925. /**
  34926. * Initializes the behavior.
  34927. */
  34928. init(): void;
  34929. /**
  34930. * Attaches the behavior to its arc rotate camera.
  34931. * @param camera Defines the camera to attach the behavior to
  34932. */
  34933. attach(camera: ArcRotateCamera): void;
  34934. /**
  34935. * Detaches the behavior from its current arc rotate camera.
  34936. */
  34937. detach(): void;
  34938. private _animatables;
  34939. private _betaIsAnimating;
  34940. private _betaTransition;
  34941. private _radiusTransition;
  34942. private _vectorTransition;
  34943. /**
  34944. * Targets the given mesh and updates zoom level accordingly.
  34945. * @param mesh The mesh to target.
  34946. * @param radius Optional. If a cached radius position already exists, overrides default.
  34947. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34948. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34949. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34950. */
  34951. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34952. /**
  34953. * Targets the given mesh with its children and updates zoom level accordingly.
  34954. * @param mesh The mesh to target.
  34955. * @param radius Optional. If a cached radius position already exists, overrides default.
  34956. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34957. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34958. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34959. */
  34960. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34961. /**
  34962. * Targets the given meshes with their children and updates zoom level accordingly.
  34963. * @param meshes The mesh to target.
  34964. * @param radius Optional. If a cached radius position already exists, overrides default.
  34965. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34966. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34967. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34968. */
  34969. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34970. /**
  34971. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34972. * @param minimumWorld Determines the smaller position of the bounding box extend
  34973. * @param maximumWorld Determines the bigger position of the bounding box extend
  34974. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34975. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34976. */
  34977. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34978. /**
  34979. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34980. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34981. * frustum width.
  34982. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34983. * to fully enclose the mesh in the viewing frustum.
  34984. */
  34985. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34986. /**
  34987. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34988. * is automatically returned to its default position (expected to be above ground plane).
  34989. */
  34990. private _maintainCameraAboveGround;
  34991. /**
  34992. * Returns the frustum slope based on the canvas ratio and camera FOV
  34993. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34994. */
  34995. private _getFrustumSlope;
  34996. /**
  34997. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34998. */
  34999. private _clearAnimationLocks;
  35000. /**
  35001. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35002. */
  35003. private _applyUserInteraction;
  35004. /**
  35005. * Stops and removes all animations that have been applied to the camera
  35006. */
  35007. stopAllAnimations(): void;
  35008. /**
  35009. * Gets a value indicating if the user is moving the camera
  35010. */
  35011. readonly isUserIsMoving: boolean;
  35012. /**
  35013. * The camera can move all the way towards the mesh.
  35014. */
  35015. static IgnoreBoundsSizeMode: number;
  35016. /**
  35017. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35018. */
  35019. static FitFrustumSidesMode: number;
  35020. }
  35021. }
  35022. declare module BABYLON {
  35023. /**
  35024. * Base class for Camera Pointer Inputs.
  35025. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35026. * for example usage.
  35027. */
  35028. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35029. /**
  35030. * Defines the camera the input is attached to.
  35031. */
  35032. abstract camera: Camera;
  35033. /**
  35034. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35035. */
  35036. protected _altKey: boolean;
  35037. protected _ctrlKey: boolean;
  35038. protected _metaKey: boolean;
  35039. protected _shiftKey: boolean;
  35040. /**
  35041. * Which mouse buttons were pressed at time of last mouse event.
  35042. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35043. */
  35044. protected _buttonsPressed: number;
  35045. /**
  35046. * Defines the buttons associated with the input to handle camera move.
  35047. */
  35048. buttons: number[];
  35049. /**
  35050. * Attach the input controls to a specific dom element to get the input from.
  35051. * @param element Defines the element the controls should be listened from
  35052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35053. */
  35054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35055. /**
  35056. * Detach the current controls from the specified dom element.
  35057. * @param element Defines the element to stop listening the inputs from
  35058. */
  35059. detachControl(element: Nullable<HTMLElement>): void;
  35060. /**
  35061. * Gets the class name of the current input.
  35062. * @returns the class name
  35063. */
  35064. getClassName(): string;
  35065. /**
  35066. * Get the friendly name associated with the input class.
  35067. * @returns the input friendly name
  35068. */
  35069. getSimpleName(): string;
  35070. /**
  35071. * Called on pointer POINTERDOUBLETAP event.
  35072. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35073. */
  35074. protected onDoubleTap(type: string): void;
  35075. /**
  35076. * Called on pointer POINTERMOVE event if only a single touch is active.
  35077. * Override this method to provide functionality.
  35078. */
  35079. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35080. /**
  35081. * Called on pointer POINTERMOVE event if multiple touches are active.
  35082. * Override this method to provide functionality.
  35083. */
  35084. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35085. /**
  35086. * Called on JS contextmenu event.
  35087. * Override this method to provide functionality.
  35088. */
  35089. protected onContextMenu(evt: PointerEvent): void;
  35090. /**
  35091. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35092. * press.
  35093. * Override this method to provide functionality.
  35094. */
  35095. protected onButtonDown(evt: PointerEvent): void;
  35096. /**
  35097. * Called each time a new POINTERUP event occurs. Ie, for each button
  35098. * release.
  35099. * Override this method to provide functionality.
  35100. */
  35101. protected onButtonUp(evt: PointerEvent): void;
  35102. /**
  35103. * Called when window becomes inactive.
  35104. * Override this method to provide functionality.
  35105. */
  35106. protected onLostFocus(): void;
  35107. private _pointerInput;
  35108. private _observer;
  35109. private _onLostFocus;
  35110. private pointA;
  35111. private pointB;
  35112. }
  35113. }
  35114. declare module BABYLON {
  35115. /**
  35116. * Manage the pointers inputs to control an arc rotate camera.
  35117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35118. */
  35119. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35120. /**
  35121. * Defines the camera the input is attached to.
  35122. */
  35123. camera: ArcRotateCamera;
  35124. /**
  35125. * Gets the class name of the current input.
  35126. * @returns the class name
  35127. */
  35128. getClassName(): string;
  35129. /**
  35130. * Defines the buttons associated with the input to handle camera move.
  35131. */
  35132. buttons: number[];
  35133. /**
  35134. * Defines the pointer angular sensibility along the X axis or how fast is
  35135. * the camera rotating.
  35136. */
  35137. angularSensibilityX: number;
  35138. /**
  35139. * Defines the pointer angular sensibility along the Y axis or how fast is
  35140. * the camera rotating.
  35141. */
  35142. angularSensibilityY: number;
  35143. /**
  35144. * Defines the pointer pinch precision or how fast is the camera zooming.
  35145. */
  35146. pinchPrecision: number;
  35147. /**
  35148. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35149. * from 0.
  35150. * It defines the percentage of current camera.radius to use as delta when
  35151. * pinch zoom is used.
  35152. */
  35153. pinchDeltaPercentage: number;
  35154. /**
  35155. * Defines the pointer panning sensibility or how fast is the camera moving.
  35156. */
  35157. panningSensibility: number;
  35158. /**
  35159. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35160. */
  35161. multiTouchPanning: boolean;
  35162. /**
  35163. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35164. * zoom (pinch) through multitouch.
  35165. */
  35166. multiTouchPanAndZoom: boolean;
  35167. /**
  35168. * Revers pinch action direction.
  35169. */
  35170. pinchInwards: boolean;
  35171. private _isPanClick;
  35172. private _twoFingerActivityCount;
  35173. private _isPinching;
  35174. /**
  35175. * Called on pointer POINTERMOVE event if only a single touch is active.
  35176. */
  35177. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35178. /**
  35179. * Called on pointer POINTERDOUBLETAP event.
  35180. */
  35181. protected onDoubleTap(type: string): void;
  35182. /**
  35183. * Called on pointer POINTERMOVE event if multiple touches are active.
  35184. */
  35185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35186. /**
  35187. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35188. * press.
  35189. */
  35190. protected onButtonDown(evt: PointerEvent): void;
  35191. /**
  35192. * Called each time a new POINTERUP event occurs. Ie, for each button
  35193. * release.
  35194. */
  35195. protected onButtonUp(evt: PointerEvent): void;
  35196. /**
  35197. * Called when window becomes inactive.
  35198. */
  35199. protected onLostFocus(): void;
  35200. }
  35201. }
  35202. declare module BABYLON {
  35203. /**
  35204. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35206. */
  35207. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35208. /**
  35209. * Defines the camera the input is attached to.
  35210. */
  35211. camera: ArcRotateCamera;
  35212. /**
  35213. * Defines the list of key codes associated with the up action (increase alpha)
  35214. */
  35215. keysUp: number[];
  35216. /**
  35217. * Defines the list of key codes associated with the down action (decrease alpha)
  35218. */
  35219. keysDown: number[];
  35220. /**
  35221. * Defines the list of key codes associated with the left action (increase beta)
  35222. */
  35223. keysLeft: number[];
  35224. /**
  35225. * Defines the list of key codes associated with the right action (decrease beta)
  35226. */
  35227. keysRight: number[];
  35228. /**
  35229. * Defines the list of key codes associated with the reset action.
  35230. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35231. */
  35232. keysReset: number[];
  35233. /**
  35234. * Defines the panning sensibility of the inputs.
  35235. * (How fast is the camera paning)
  35236. */
  35237. panningSensibility: number;
  35238. /**
  35239. * Defines the zooming sensibility of the inputs.
  35240. * (How fast is the camera zooming)
  35241. */
  35242. zoomingSensibility: number;
  35243. /**
  35244. * Defines wether maintaining the alt key down switch the movement mode from
  35245. * orientation to zoom.
  35246. */
  35247. useAltToZoom: boolean;
  35248. /**
  35249. * Rotation speed of the camera
  35250. */
  35251. angularSpeed: number;
  35252. private _keys;
  35253. private _ctrlPressed;
  35254. private _altPressed;
  35255. private _onCanvasBlurObserver;
  35256. private _onKeyboardObserver;
  35257. private _engine;
  35258. private _scene;
  35259. /**
  35260. * Attach the input controls to a specific dom element to get the input from.
  35261. * @param element Defines the element the controls should be listened from
  35262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35263. */
  35264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35265. /**
  35266. * Detach the current controls from the specified dom element.
  35267. * @param element Defines the element to stop listening the inputs from
  35268. */
  35269. detachControl(element: Nullable<HTMLElement>): void;
  35270. /**
  35271. * Update the current camera state depending on the inputs that have been used this frame.
  35272. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35273. */
  35274. checkInputs(): void;
  35275. /**
  35276. * Gets the class name of the current intput.
  35277. * @returns the class name
  35278. */
  35279. getClassName(): string;
  35280. /**
  35281. * Get the friendly name associated with the input class.
  35282. * @returns the input friendly name
  35283. */
  35284. getSimpleName(): string;
  35285. }
  35286. }
  35287. declare module BABYLON {
  35288. /**
  35289. * Manage the mouse wheel inputs to control an arc rotate camera.
  35290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35291. */
  35292. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35293. /**
  35294. * Defines the camera the input is attached to.
  35295. */
  35296. camera: ArcRotateCamera;
  35297. /**
  35298. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35299. */
  35300. wheelPrecision: number;
  35301. /**
  35302. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35303. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35304. */
  35305. wheelDeltaPercentage: number;
  35306. private _wheel;
  35307. private _observer;
  35308. private computeDeltaFromMouseWheelLegacyEvent;
  35309. /**
  35310. * Attach the input controls to a specific dom element to get the input from.
  35311. * @param element Defines the element the controls should be listened from
  35312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35313. */
  35314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35315. /**
  35316. * Detach the current controls from the specified dom element.
  35317. * @param element Defines the element to stop listening the inputs from
  35318. */
  35319. detachControl(element: Nullable<HTMLElement>): void;
  35320. /**
  35321. * Gets the class name of the current intput.
  35322. * @returns the class name
  35323. */
  35324. getClassName(): string;
  35325. /**
  35326. * Get the friendly name associated with the input class.
  35327. * @returns the input friendly name
  35328. */
  35329. getSimpleName(): string;
  35330. }
  35331. }
  35332. declare module BABYLON {
  35333. /**
  35334. * Default Inputs manager for the ArcRotateCamera.
  35335. * It groups all the default supported inputs for ease of use.
  35336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35337. */
  35338. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35339. /**
  35340. * Instantiates a new ArcRotateCameraInputsManager.
  35341. * @param camera Defines the camera the inputs belong to
  35342. */
  35343. constructor(camera: ArcRotateCamera);
  35344. /**
  35345. * Add mouse wheel input support to the input manager.
  35346. * @returns the current input manager
  35347. */
  35348. addMouseWheel(): ArcRotateCameraInputsManager;
  35349. /**
  35350. * Add pointers input support to the input manager.
  35351. * @returns the current input manager
  35352. */
  35353. addPointers(): ArcRotateCameraInputsManager;
  35354. /**
  35355. * Add keyboard input support to the input manager.
  35356. * @returns the current input manager
  35357. */
  35358. addKeyboard(): ArcRotateCameraInputsManager;
  35359. }
  35360. }
  35361. declare module BABYLON {
  35362. /**
  35363. * This represents an orbital type of camera.
  35364. *
  35365. * 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.
  35366. * 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.
  35367. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35368. */
  35369. export class ArcRotateCamera extends TargetCamera {
  35370. /**
  35371. * Defines the rotation angle of the camera along the longitudinal axis.
  35372. */
  35373. alpha: number;
  35374. /**
  35375. * Defines the rotation angle of the camera along the latitudinal axis.
  35376. */
  35377. beta: number;
  35378. /**
  35379. * Defines the radius of the camera from it s target point.
  35380. */
  35381. radius: number;
  35382. protected _target: Vector3;
  35383. protected _targetHost: Nullable<AbstractMesh>;
  35384. /**
  35385. * Defines the target point of the camera.
  35386. * The camera looks towards it form the radius distance.
  35387. */
  35388. target: Vector3;
  35389. /**
  35390. * Define the current local position of the camera in the scene
  35391. */
  35392. position: Vector3;
  35393. protected _upVector: Vector3;
  35394. protected _upToYMatrix: Matrix;
  35395. protected _YToUpMatrix: Matrix;
  35396. /**
  35397. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35398. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35399. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35400. */
  35401. upVector: Vector3;
  35402. /**
  35403. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35404. */
  35405. setMatUp(): void;
  35406. /**
  35407. * Current inertia value on the longitudinal axis.
  35408. * The bigger this number the longer it will take for the camera to stop.
  35409. */
  35410. inertialAlphaOffset: number;
  35411. /**
  35412. * Current inertia value on the latitudinal axis.
  35413. * The bigger this number the longer it will take for the camera to stop.
  35414. */
  35415. inertialBetaOffset: number;
  35416. /**
  35417. * Current inertia value on the radius axis.
  35418. * The bigger this number the longer it will take for the camera to stop.
  35419. */
  35420. inertialRadiusOffset: number;
  35421. /**
  35422. * Minimum allowed angle on the longitudinal axis.
  35423. * This can help limiting how the Camera is able to move in the scene.
  35424. */
  35425. lowerAlphaLimit: Nullable<number>;
  35426. /**
  35427. * Maximum allowed angle on the longitudinal axis.
  35428. * This can help limiting how the Camera is able to move in the scene.
  35429. */
  35430. upperAlphaLimit: Nullable<number>;
  35431. /**
  35432. * Minimum allowed angle on the latitudinal axis.
  35433. * This can help limiting how the Camera is able to move in the scene.
  35434. */
  35435. lowerBetaLimit: number;
  35436. /**
  35437. * Maximum allowed angle on the latitudinal axis.
  35438. * This can help limiting how the Camera is able to move in the scene.
  35439. */
  35440. upperBetaLimit: number;
  35441. /**
  35442. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35443. * This can help limiting how the Camera is able to move in the scene.
  35444. */
  35445. lowerRadiusLimit: Nullable<number>;
  35446. /**
  35447. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35448. * This can help limiting how the Camera is able to move in the scene.
  35449. */
  35450. upperRadiusLimit: Nullable<number>;
  35451. /**
  35452. * Defines the current inertia value used during panning of the camera along the X axis.
  35453. */
  35454. inertialPanningX: number;
  35455. /**
  35456. * Defines the current inertia value used during panning of the camera along the Y axis.
  35457. */
  35458. inertialPanningY: number;
  35459. /**
  35460. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35461. * Basically if your fingers moves away from more than this distance you will be considered
  35462. * in pinch mode.
  35463. */
  35464. pinchToPanMaxDistance: number;
  35465. /**
  35466. * Defines the maximum distance the camera can pan.
  35467. * This could help keeping the cammera always in your scene.
  35468. */
  35469. panningDistanceLimit: Nullable<number>;
  35470. /**
  35471. * Defines the target of the camera before paning.
  35472. */
  35473. panningOriginTarget: Vector3;
  35474. /**
  35475. * Defines the value of the inertia used during panning.
  35476. * 0 would mean stop inertia and one would mean no decelleration at all.
  35477. */
  35478. panningInertia: number;
  35479. /**
  35480. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35481. */
  35482. angularSensibilityX: number;
  35483. /**
  35484. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35485. */
  35486. angularSensibilityY: number;
  35487. /**
  35488. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35489. */
  35490. pinchPrecision: number;
  35491. /**
  35492. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35493. * It will be used instead of pinchDeltaPrecision if different from 0.
  35494. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35495. */
  35496. pinchDeltaPercentage: number;
  35497. /**
  35498. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35499. */
  35500. panningSensibility: number;
  35501. /**
  35502. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35503. */
  35504. keysUp: number[];
  35505. /**
  35506. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35507. */
  35508. keysDown: number[];
  35509. /**
  35510. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35511. */
  35512. keysLeft: number[];
  35513. /**
  35514. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35515. */
  35516. keysRight: number[];
  35517. /**
  35518. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35519. */
  35520. wheelPrecision: number;
  35521. /**
  35522. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35523. * It will be used instead of pinchDeltaPrecision if different from 0.
  35524. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35525. */
  35526. wheelDeltaPercentage: number;
  35527. /**
  35528. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35529. */
  35530. zoomOnFactor: number;
  35531. /**
  35532. * Defines a screen offset for the camera position.
  35533. */
  35534. targetScreenOffset: Vector2;
  35535. /**
  35536. * Allows the camera to be completely reversed.
  35537. * If false the camera can not arrive upside down.
  35538. */
  35539. allowUpsideDown: boolean;
  35540. /**
  35541. * Define if double tap/click is used to restore the previously saved state of the camera.
  35542. */
  35543. useInputToRestoreState: boolean;
  35544. /** @hidden */ private _viewMatrix: Matrix;
  35545. /** @hidden */ private _useCtrlForPanning: boolean;
  35546. /** @hidden */ private _panningMouseButton: number;
  35547. /**
  35548. * Defines the input associated to the camera.
  35549. */
  35550. inputs: ArcRotateCameraInputsManager;
  35551. /** @hidden */ private _reset: () => void;
  35552. /**
  35553. * Defines the allowed panning axis.
  35554. */
  35555. panningAxis: Vector3;
  35556. protected _localDirection: Vector3;
  35557. protected _transformedDirection: Vector3;
  35558. private _bouncingBehavior;
  35559. /**
  35560. * Gets the bouncing behavior of the camera if it has been enabled.
  35561. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35562. */
  35563. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35564. /**
  35565. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35566. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35567. */
  35568. useBouncingBehavior: boolean;
  35569. private _framingBehavior;
  35570. /**
  35571. * Gets the framing behavior of the camera if it has been enabled.
  35572. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35573. */
  35574. readonly framingBehavior: Nullable<FramingBehavior>;
  35575. /**
  35576. * Defines if the framing behavior of the camera is enabled on the camera.
  35577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35578. */
  35579. useFramingBehavior: boolean;
  35580. private _autoRotationBehavior;
  35581. /**
  35582. * Gets the auto rotation behavior of the camera if it has been enabled.
  35583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35584. */
  35585. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35586. /**
  35587. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35589. */
  35590. useAutoRotationBehavior: boolean;
  35591. /**
  35592. * Observable triggered when the mesh target has been changed on the camera.
  35593. */
  35594. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35595. /**
  35596. * Event raised when the camera is colliding with a mesh.
  35597. */
  35598. onCollide: (collidedMesh: AbstractMesh) => void;
  35599. /**
  35600. * Defines whether the camera should check collision with the objects oh the scene.
  35601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35602. */
  35603. checkCollisions: boolean;
  35604. /**
  35605. * Defines the collision radius of the camera.
  35606. * This simulates a sphere around the camera.
  35607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35608. */
  35609. collisionRadius: Vector3;
  35610. protected _collider: Collider;
  35611. protected _previousPosition: Vector3;
  35612. protected _collisionVelocity: Vector3;
  35613. protected _newPosition: Vector3;
  35614. protected _previousAlpha: number;
  35615. protected _previousBeta: number;
  35616. protected _previousRadius: number;
  35617. protected _collisionTriggered: boolean;
  35618. protected _targetBoundingCenter: Nullable<Vector3>;
  35619. private _computationVector;
  35620. /**
  35621. * Instantiates a new ArcRotateCamera in a given scene
  35622. * @param name Defines the name of the camera
  35623. * @param alpha Defines the camera rotation along the logitudinal axis
  35624. * @param beta Defines the camera rotation along the latitudinal axis
  35625. * @param radius Defines the camera distance from its target
  35626. * @param target Defines the camera target
  35627. * @param scene Defines the scene the camera belongs to
  35628. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35629. */
  35630. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35631. /** @hidden */ private _initCache(): void;
  35632. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35633. protected _getTargetPosition(): Vector3;
  35634. private _storedAlpha;
  35635. private _storedBeta;
  35636. private _storedRadius;
  35637. private _storedTarget;
  35638. private _storedTargetScreenOffset;
  35639. /**
  35640. * Stores the current state of the camera (alpha, beta, radius and target)
  35641. * @returns the camera itself
  35642. */
  35643. storeState(): Camera;
  35644. /**
  35645. * @hidden
  35646. * Restored camera state. You must call storeState() first
  35647. */ private _restoreStateValues(): boolean;
  35648. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35649. /**
  35650. * Attached controls to the current camera.
  35651. * @param element Defines the element the controls should be listened from
  35652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35653. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35654. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35655. */
  35656. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35657. /**
  35658. * Detach the current controls from the camera.
  35659. * The camera will stop reacting to inputs.
  35660. * @param element Defines the element to stop listening the inputs from
  35661. */
  35662. detachControl(element: HTMLElement): void;
  35663. /** @hidden */ private _checkInputs(): void;
  35664. protected _checkLimits(): void;
  35665. /**
  35666. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35667. */
  35668. rebuildAnglesAndRadius(): void;
  35669. /**
  35670. * Use a position to define the current camera related information like aplha, beta and radius
  35671. * @param position Defines the position to set the camera at
  35672. */
  35673. setPosition(position: Vector3): void;
  35674. /**
  35675. * Defines the target the camera should look at.
  35676. * This will automatically adapt alpha beta and radius to fit within the new target.
  35677. * @param target Defines the new target as a Vector or a mesh
  35678. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35679. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35680. */
  35681. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35682. /** @hidden */ private _getViewMatrix(): Matrix;
  35683. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35684. /**
  35685. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35686. * @param meshes Defines the mesh to zoom on
  35687. * @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)
  35688. */
  35689. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35690. /**
  35691. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35692. * The target will be changed but the radius
  35693. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35694. * @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)
  35695. */
  35696. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35697. min: Vector3;
  35698. max: Vector3;
  35699. distance: number;
  35700. }, doNotUpdateMaxZ?: boolean): void;
  35701. /**
  35702. * @override
  35703. * Override Camera.createRigCamera
  35704. */
  35705. createRigCamera(name: string, cameraIndex: number): Camera;
  35706. /**
  35707. * @hidden
  35708. * @override
  35709. * Override Camera._updateRigCameras
  35710. */ private _updateRigCameras(): void;
  35711. /**
  35712. * Destroy the camera and release the current resources hold by it.
  35713. */
  35714. dispose(): void;
  35715. /**
  35716. * Gets the current object class name.
  35717. * @return the class name
  35718. */
  35719. getClassName(): string;
  35720. }
  35721. }
  35722. declare module BABYLON {
  35723. /**
  35724. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35726. */
  35727. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35728. /**
  35729. * Gets the name of the behavior.
  35730. */
  35731. readonly name: string;
  35732. private _zoomStopsAnimation;
  35733. private _idleRotationSpeed;
  35734. private _idleRotationWaitTime;
  35735. private _idleRotationSpinupTime;
  35736. /**
  35737. * Sets the flag that indicates if user zooming should stop animation.
  35738. */
  35739. /**
  35740. * Gets the flag that indicates if user zooming should stop animation.
  35741. */
  35742. zoomStopsAnimation: boolean;
  35743. /**
  35744. * Sets the default speed at which the camera rotates around the model.
  35745. */
  35746. /**
  35747. * Gets the default speed at which the camera rotates around the model.
  35748. */
  35749. idleRotationSpeed: number;
  35750. /**
  35751. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35752. */
  35753. /**
  35754. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35755. */
  35756. idleRotationWaitTime: number;
  35757. /**
  35758. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35759. */
  35760. /**
  35761. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35762. */
  35763. idleRotationSpinupTime: number;
  35764. /**
  35765. * Gets a value indicating if the camera is currently rotating because of this behavior
  35766. */
  35767. readonly rotationInProgress: boolean;
  35768. private _onPrePointerObservableObserver;
  35769. private _onAfterCheckInputsObserver;
  35770. private _attachedCamera;
  35771. private _isPointerDown;
  35772. private _lastFrameTime;
  35773. private _lastInteractionTime;
  35774. private _cameraRotationSpeed;
  35775. /**
  35776. * Initializes the behavior.
  35777. */
  35778. init(): void;
  35779. /**
  35780. * Attaches the behavior to its arc rotate camera.
  35781. * @param camera Defines the camera to attach the behavior to
  35782. */
  35783. attach(camera: ArcRotateCamera): void;
  35784. /**
  35785. * Detaches the behavior from its current arc rotate camera.
  35786. */
  35787. detach(): void;
  35788. /**
  35789. * Returns true if user is scrolling.
  35790. * @return true if user is scrolling.
  35791. */
  35792. private _userIsZooming;
  35793. private _lastFrameRadius;
  35794. private _shouldAnimationStopForInteraction;
  35795. /**
  35796. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35797. */
  35798. private _applyUserInteraction;
  35799. private _userIsMoving;
  35800. }
  35801. }
  35802. declare module BABYLON {
  35803. /**
  35804. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35805. */
  35806. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35807. private ui;
  35808. /**
  35809. * The name of the behavior
  35810. */
  35811. name: string;
  35812. /**
  35813. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35814. */
  35815. distanceAwayFromFace: number;
  35816. /**
  35817. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35818. */
  35819. distanceAwayFromBottomOfFace: number;
  35820. private _faceVectors;
  35821. private _target;
  35822. private _scene;
  35823. private _onRenderObserver;
  35824. private _tmpMatrix;
  35825. private _tmpVector;
  35826. /**
  35827. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35828. * @param ui The transform node that should be attched to the mesh
  35829. */
  35830. constructor(ui: TransformNode);
  35831. /**
  35832. * Initializes the behavior
  35833. */
  35834. init(): void;
  35835. private _closestFace;
  35836. private _zeroVector;
  35837. private _lookAtTmpMatrix;
  35838. private _lookAtToRef;
  35839. /**
  35840. * Attaches the AttachToBoxBehavior to the passed in mesh
  35841. * @param target The mesh that the specified node will be attached to
  35842. */
  35843. attach(target: Mesh): void;
  35844. /**
  35845. * Detaches the behavior from the mesh
  35846. */
  35847. detach(): void;
  35848. }
  35849. }
  35850. declare module BABYLON {
  35851. /**
  35852. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35853. */
  35854. export class FadeInOutBehavior implements Behavior<Mesh> {
  35855. /**
  35856. * Time in milliseconds to delay before fading in (Default: 0)
  35857. */
  35858. delay: number;
  35859. /**
  35860. * Time in milliseconds for the mesh to fade in (Default: 300)
  35861. */
  35862. fadeInTime: number;
  35863. private _millisecondsPerFrame;
  35864. private _hovered;
  35865. private _hoverValue;
  35866. private _ownerNode;
  35867. /**
  35868. * Instatiates the FadeInOutBehavior
  35869. */
  35870. constructor();
  35871. /**
  35872. * The name of the behavior
  35873. */
  35874. readonly name: string;
  35875. /**
  35876. * Initializes the behavior
  35877. */
  35878. init(): void;
  35879. /**
  35880. * Attaches the fade behavior on the passed in mesh
  35881. * @param ownerNode The mesh that will be faded in/out once attached
  35882. */
  35883. attach(ownerNode: Mesh): void;
  35884. /**
  35885. * Detaches the behavior from the mesh
  35886. */
  35887. detach(): void;
  35888. /**
  35889. * Triggers the mesh to begin fading in or out
  35890. * @param value if the object should fade in or out (true to fade in)
  35891. */
  35892. fadeIn(value: boolean): void;
  35893. private _update;
  35894. private _setAllVisibility;
  35895. }
  35896. }
  35897. declare module BABYLON {
  35898. /**
  35899. * Class containing a set of static utilities functions for managing Pivots
  35900. * @hidden
  35901. */
  35902. export class PivotTools {
  35903. private static _PivotCached;
  35904. private static _OldPivotPoint;
  35905. private static _PivotTranslation;
  35906. private static _PivotTmpVector;
  35907. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35908. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35909. }
  35910. }
  35911. declare module BABYLON {
  35912. /**
  35913. * Class containing static functions to help procedurally build meshes
  35914. */
  35915. export class PlaneBuilder {
  35916. /**
  35917. * Creates a plane mesh
  35918. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35919. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35920. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35922. * * 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
  35923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35924. * @param name defines the name of the mesh
  35925. * @param options defines the options used to create the mesh
  35926. * @param scene defines the hosting scene
  35927. * @returns the plane mesh
  35928. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35929. */
  35930. static CreatePlane(name: string, options: {
  35931. size?: number;
  35932. width?: number;
  35933. height?: number;
  35934. sideOrientation?: number;
  35935. frontUVs?: Vector4;
  35936. backUVs?: Vector4;
  35937. updatable?: boolean;
  35938. sourcePlane?: Plane;
  35939. }, scene?: Nullable<Scene>): Mesh;
  35940. }
  35941. }
  35942. declare module BABYLON {
  35943. /**
  35944. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35945. */
  35946. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35947. private static _AnyMouseID;
  35948. /**
  35949. * Abstract mesh the behavior is set on
  35950. */
  35951. attachedNode: AbstractMesh;
  35952. private _dragPlane;
  35953. private _scene;
  35954. private _pointerObserver;
  35955. private _beforeRenderObserver;
  35956. private static _planeScene;
  35957. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35958. /**
  35959. * 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)
  35960. */
  35961. maxDragAngle: number;
  35962. /**
  35963. * @hidden
  35964. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35965. /**
  35966. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35967. */
  35968. currentDraggingPointerID: number;
  35969. /**
  35970. * The last position where the pointer hit the drag plane in world space
  35971. */
  35972. lastDragPosition: Vector3;
  35973. /**
  35974. * If the behavior is currently in a dragging state
  35975. */
  35976. dragging: boolean;
  35977. /**
  35978. * 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)
  35979. */
  35980. dragDeltaRatio: number;
  35981. /**
  35982. * If the drag plane orientation should be updated during the dragging (Default: true)
  35983. */
  35984. updateDragPlane: boolean;
  35985. private _debugMode;
  35986. private _moving;
  35987. /**
  35988. * Fires each time the attached mesh is dragged with the pointer
  35989. * * delta between last drag position and current drag position in world space
  35990. * * dragDistance along the drag axis
  35991. * * dragPlaneNormal normal of the current drag plane used during the drag
  35992. * * dragPlanePoint in world space where the drag intersects the drag plane
  35993. */
  35994. onDragObservable: Observable<{
  35995. delta: Vector3;
  35996. dragPlanePoint: Vector3;
  35997. dragPlaneNormal: Vector3;
  35998. dragDistance: number;
  35999. pointerId: number;
  36000. }>;
  36001. /**
  36002. * Fires each time a drag begins (eg. mouse down on mesh)
  36003. */
  36004. onDragStartObservable: Observable<{
  36005. dragPlanePoint: Vector3;
  36006. pointerId: number;
  36007. }>;
  36008. /**
  36009. * Fires each time a drag ends (eg. mouse release after drag)
  36010. */
  36011. onDragEndObservable: Observable<{
  36012. dragPlanePoint: Vector3;
  36013. pointerId: number;
  36014. }>;
  36015. /**
  36016. * If the attached mesh should be moved when dragged
  36017. */
  36018. moveAttached: boolean;
  36019. /**
  36020. * If the drag behavior will react to drag events (Default: true)
  36021. */
  36022. enabled: boolean;
  36023. /**
  36024. * If pointer events should start and release the drag (Default: true)
  36025. */
  36026. startAndReleaseDragOnPointerEvents: boolean;
  36027. /**
  36028. * If camera controls should be detached during the drag
  36029. */
  36030. detachCameraControls: boolean;
  36031. /**
  36032. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36033. */
  36034. useObjectOrienationForDragging: boolean;
  36035. private _options;
  36036. /**
  36037. * Creates a pointer drag behavior that can be attached to a mesh
  36038. * @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)
  36039. */
  36040. constructor(options?: {
  36041. dragAxis?: Vector3;
  36042. dragPlaneNormal?: Vector3;
  36043. });
  36044. /**
  36045. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36046. */
  36047. validateDrag: (targetPosition: Vector3) => boolean;
  36048. /**
  36049. * The name of the behavior
  36050. */
  36051. readonly name: string;
  36052. /**
  36053. * Initializes the behavior
  36054. */
  36055. init(): void;
  36056. private _tmpVector;
  36057. private _alternatePickedPoint;
  36058. private _worldDragAxis;
  36059. private _targetPosition;
  36060. private _attachedElement;
  36061. /**
  36062. * Attaches the drag behavior the passed in mesh
  36063. * @param ownerNode The mesh that will be dragged around once attached
  36064. * @param predicate Predicate to use for pick filtering
  36065. */
  36066. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36067. /**
  36068. * Force relase the drag action by code.
  36069. */
  36070. releaseDrag(): void;
  36071. private _startDragRay;
  36072. private _lastPointerRay;
  36073. /**
  36074. * Simulates the start of a pointer drag event on the behavior
  36075. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36076. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36077. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36078. */
  36079. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36080. private _startDrag;
  36081. private _dragDelta;
  36082. private _moveDrag;
  36083. private _pickWithRayOnDragPlane;
  36084. private _pointA;
  36085. private _pointB;
  36086. private _pointC;
  36087. private _lineA;
  36088. private _lineB;
  36089. private _localAxis;
  36090. private _lookAt;
  36091. private _updateDragPlanePosition;
  36092. /**
  36093. * Detaches the behavior from the mesh
  36094. */
  36095. detach(): void;
  36096. }
  36097. }
  36098. declare module BABYLON {
  36099. /**
  36100. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36101. */
  36102. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36103. private _dragBehaviorA;
  36104. private _dragBehaviorB;
  36105. private _startDistance;
  36106. private _initialScale;
  36107. private _targetScale;
  36108. private _ownerNode;
  36109. private _sceneRenderObserver;
  36110. /**
  36111. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36112. */
  36113. constructor();
  36114. /**
  36115. * The name of the behavior
  36116. */
  36117. readonly name: string;
  36118. /**
  36119. * Initializes the behavior
  36120. */
  36121. init(): void;
  36122. private _getCurrentDistance;
  36123. /**
  36124. * Attaches the scale behavior the passed in mesh
  36125. * @param ownerNode The mesh that will be scaled around once attached
  36126. */
  36127. attach(ownerNode: Mesh): void;
  36128. /**
  36129. * Detaches the behavior from the mesh
  36130. */
  36131. detach(): void;
  36132. }
  36133. }
  36134. declare module BABYLON {
  36135. /**
  36136. * 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
  36137. */
  36138. export class SixDofDragBehavior implements Behavior<Mesh> {
  36139. private static _virtualScene;
  36140. private _ownerNode;
  36141. private _sceneRenderObserver;
  36142. private _scene;
  36143. private _targetPosition;
  36144. private _virtualOriginMesh;
  36145. private _virtualDragMesh;
  36146. private _pointerObserver;
  36147. private _moving;
  36148. private _startingOrientation;
  36149. /**
  36150. * 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)
  36151. */
  36152. private zDragFactor;
  36153. /**
  36154. * If the object should rotate to face the drag origin
  36155. */
  36156. rotateDraggedObject: boolean;
  36157. /**
  36158. * If the behavior is currently in a dragging state
  36159. */
  36160. dragging: boolean;
  36161. /**
  36162. * 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)
  36163. */
  36164. dragDeltaRatio: number;
  36165. /**
  36166. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36167. */
  36168. currentDraggingPointerID: number;
  36169. /**
  36170. * If camera controls should be detached during the drag
  36171. */
  36172. detachCameraControls: boolean;
  36173. /**
  36174. * Fires each time a drag starts
  36175. */
  36176. onDragStartObservable: Observable<{}>;
  36177. /**
  36178. * Fires each time a drag ends (eg. mouse release after drag)
  36179. */
  36180. onDragEndObservable: Observable<{}>;
  36181. /**
  36182. * 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
  36183. */
  36184. constructor();
  36185. /**
  36186. * The name of the behavior
  36187. */
  36188. readonly name: string;
  36189. /**
  36190. * Initializes the behavior
  36191. */
  36192. init(): void;
  36193. /**
  36194. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36195. */
  36196. private readonly _pointerCamera;
  36197. /**
  36198. * Attaches the scale behavior the passed in mesh
  36199. * @param ownerNode The mesh that will be scaled around once attached
  36200. */
  36201. attach(ownerNode: Mesh): void;
  36202. /**
  36203. * Detaches the behavior from the mesh
  36204. */
  36205. detach(): void;
  36206. }
  36207. }
  36208. declare module BABYLON {
  36209. /**
  36210. * Class used to apply inverse kinematics to bones
  36211. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36212. */
  36213. export class BoneIKController {
  36214. private static _tmpVecs;
  36215. private static _tmpQuat;
  36216. private static _tmpMats;
  36217. /**
  36218. * Gets or sets the target mesh
  36219. */
  36220. targetMesh: AbstractMesh;
  36221. /** Gets or sets the mesh used as pole */
  36222. poleTargetMesh: AbstractMesh;
  36223. /**
  36224. * Gets or sets the bone used as pole
  36225. */
  36226. poleTargetBone: Nullable<Bone>;
  36227. /**
  36228. * Gets or sets the target position
  36229. */
  36230. targetPosition: Vector3;
  36231. /**
  36232. * Gets or sets the pole target position
  36233. */
  36234. poleTargetPosition: Vector3;
  36235. /**
  36236. * Gets or sets the pole target local offset
  36237. */
  36238. poleTargetLocalOffset: Vector3;
  36239. /**
  36240. * Gets or sets the pole angle
  36241. */
  36242. poleAngle: number;
  36243. /**
  36244. * Gets or sets the mesh associated with the controller
  36245. */
  36246. mesh: AbstractMesh;
  36247. /**
  36248. * 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)
  36249. */
  36250. slerpAmount: number;
  36251. private _bone1Quat;
  36252. private _bone1Mat;
  36253. private _bone2Ang;
  36254. private _bone1;
  36255. private _bone2;
  36256. private _bone1Length;
  36257. private _bone2Length;
  36258. private _maxAngle;
  36259. private _maxReach;
  36260. private _rightHandedSystem;
  36261. private _bendAxis;
  36262. private _slerping;
  36263. private _adjustRoll;
  36264. /**
  36265. * Gets or sets maximum allowed angle
  36266. */
  36267. maxAngle: number;
  36268. /**
  36269. * Creates a new BoneIKController
  36270. * @param mesh defines the mesh to control
  36271. * @param bone defines the bone to control
  36272. * @param options defines options to set up the controller
  36273. */
  36274. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36275. targetMesh?: AbstractMesh;
  36276. poleTargetMesh?: AbstractMesh;
  36277. poleTargetBone?: Bone;
  36278. poleTargetLocalOffset?: Vector3;
  36279. poleAngle?: number;
  36280. bendAxis?: Vector3;
  36281. maxAngle?: number;
  36282. slerpAmount?: number;
  36283. });
  36284. private _setMaxAngle;
  36285. /**
  36286. * Force the controller to update the bones
  36287. */
  36288. update(): void;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. /**
  36293. * Class used to make a bone look toward a point in space
  36294. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36295. */
  36296. export class BoneLookController {
  36297. private static _tmpVecs;
  36298. private static _tmpQuat;
  36299. private static _tmpMats;
  36300. /**
  36301. * The target Vector3 that the bone will look at
  36302. */
  36303. target: Vector3;
  36304. /**
  36305. * The mesh that the bone is attached to
  36306. */
  36307. mesh: AbstractMesh;
  36308. /**
  36309. * The bone that will be looking to the target
  36310. */
  36311. bone: Bone;
  36312. /**
  36313. * The up axis of the coordinate system that is used when the bone is rotated
  36314. */
  36315. upAxis: Vector3;
  36316. /**
  36317. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36318. */
  36319. upAxisSpace: Space;
  36320. /**
  36321. * Used to make an adjustment to the yaw of the bone
  36322. */
  36323. adjustYaw: number;
  36324. /**
  36325. * Used to make an adjustment to the pitch of the bone
  36326. */
  36327. adjustPitch: number;
  36328. /**
  36329. * Used to make an adjustment to the roll of the bone
  36330. */
  36331. adjustRoll: number;
  36332. /**
  36333. * 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)
  36334. */
  36335. slerpAmount: number;
  36336. private _minYaw;
  36337. private _maxYaw;
  36338. private _minPitch;
  36339. private _maxPitch;
  36340. private _minYawSin;
  36341. private _minYawCos;
  36342. private _maxYawSin;
  36343. private _maxYawCos;
  36344. private _midYawConstraint;
  36345. private _minPitchTan;
  36346. private _maxPitchTan;
  36347. private _boneQuat;
  36348. private _slerping;
  36349. private _transformYawPitch;
  36350. private _transformYawPitchInv;
  36351. private _firstFrameSkipped;
  36352. private _yawRange;
  36353. private _fowardAxis;
  36354. /**
  36355. * Gets or sets the minimum yaw angle that the bone can look to
  36356. */
  36357. minYaw: number;
  36358. /**
  36359. * Gets or sets the maximum yaw angle that the bone can look to
  36360. */
  36361. maxYaw: number;
  36362. /**
  36363. * Gets or sets the minimum pitch angle that the bone can look to
  36364. */
  36365. minPitch: number;
  36366. /**
  36367. * Gets or sets the maximum pitch angle that the bone can look to
  36368. */
  36369. maxPitch: number;
  36370. /**
  36371. * Create a BoneLookController
  36372. * @param mesh the mesh that the bone belongs to
  36373. * @param bone the bone that will be looking to the target
  36374. * @param target the target Vector3 to look at
  36375. * @param options optional settings:
  36376. * * maxYaw: the maximum angle the bone will yaw to
  36377. * * minYaw: the minimum angle the bone will yaw to
  36378. * * maxPitch: the maximum angle the bone will pitch to
  36379. * * minPitch: the minimum angle the bone will yaw to
  36380. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36381. * * upAxis: the up axis of the coordinate system
  36382. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36383. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36384. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36385. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36386. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36387. * * adjustRoll: used to make an adjustment to the roll of the bone
  36388. **/
  36389. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36390. maxYaw?: number;
  36391. minYaw?: number;
  36392. maxPitch?: number;
  36393. minPitch?: number;
  36394. slerpAmount?: number;
  36395. upAxis?: Vector3;
  36396. upAxisSpace?: Space;
  36397. yawAxis?: Vector3;
  36398. pitchAxis?: Vector3;
  36399. adjustYaw?: number;
  36400. adjustPitch?: number;
  36401. adjustRoll?: number;
  36402. });
  36403. /**
  36404. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36405. */
  36406. update(): void;
  36407. private _getAngleDiff;
  36408. private _getAngleBetween;
  36409. private _isAngleBetween;
  36410. }
  36411. }
  36412. declare module BABYLON {
  36413. /**
  36414. * Manage the gamepad inputs to control an arc rotate camera.
  36415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36416. */
  36417. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36418. /**
  36419. * Defines the camera the input is attached to.
  36420. */
  36421. camera: ArcRotateCamera;
  36422. /**
  36423. * Defines the gamepad the input is gathering event from.
  36424. */
  36425. gamepad: Nullable<Gamepad>;
  36426. /**
  36427. * Defines the gamepad rotation sensiblity.
  36428. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36429. */
  36430. gamepadRotationSensibility: number;
  36431. /**
  36432. * Defines the gamepad move sensiblity.
  36433. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36434. */
  36435. gamepadMoveSensibility: number;
  36436. private _onGamepadConnectedObserver;
  36437. private _onGamepadDisconnectedObserver;
  36438. /**
  36439. * Attach the input controls to a specific dom element to get the input from.
  36440. * @param element Defines the element the controls should be listened from
  36441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36442. */
  36443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36444. /**
  36445. * Detach the current controls from the specified dom element.
  36446. * @param element Defines the element to stop listening the inputs from
  36447. */
  36448. detachControl(element: Nullable<HTMLElement>): void;
  36449. /**
  36450. * Update the current camera state depending on the inputs that have been used this frame.
  36451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36452. */
  36453. checkInputs(): void;
  36454. /**
  36455. * Gets the class name of the current intput.
  36456. * @returns the class name
  36457. */
  36458. getClassName(): string;
  36459. /**
  36460. * Get the friendly name associated with the input class.
  36461. * @returns the input friendly name
  36462. */
  36463. getSimpleName(): string;
  36464. }
  36465. }
  36466. declare module BABYLON {
  36467. interface ArcRotateCameraInputsManager {
  36468. /**
  36469. * Add orientation input support to the input manager.
  36470. * @returns the current input manager
  36471. */
  36472. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36473. }
  36474. /**
  36475. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36477. */
  36478. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36479. /**
  36480. * Defines the camera the input is attached to.
  36481. */
  36482. camera: ArcRotateCamera;
  36483. /**
  36484. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36485. */
  36486. alphaCorrection: number;
  36487. /**
  36488. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36489. */
  36490. gammaCorrection: number;
  36491. private _alpha;
  36492. private _gamma;
  36493. private _dirty;
  36494. private _deviceOrientationHandler;
  36495. /**
  36496. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36497. */
  36498. constructor();
  36499. /**
  36500. * Attach the input controls to a specific dom element to get the input from.
  36501. * @param element Defines the element the controls should be listened from
  36502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36503. */
  36504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36505. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36506. /**
  36507. * Update the current camera state depending on the inputs that have been used this frame.
  36508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36509. */
  36510. checkInputs(): void;
  36511. /**
  36512. * Detach the current controls from the specified dom element.
  36513. * @param element Defines the element to stop listening the inputs from
  36514. */
  36515. detachControl(element: Nullable<HTMLElement>): void;
  36516. /**
  36517. * Gets the class name of the current intput.
  36518. * @returns the class name
  36519. */
  36520. getClassName(): string;
  36521. /**
  36522. * Get the friendly name associated with the input class.
  36523. * @returns the input friendly name
  36524. */
  36525. getSimpleName(): string;
  36526. }
  36527. }
  36528. declare module BABYLON {
  36529. /**
  36530. * Listen to mouse events to control the camera.
  36531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36532. */
  36533. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36534. /**
  36535. * Defines the camera the input is attached to.
  36536. */
  36537. camera: FlyCamera;
  36538. /**
  36539. * Defines if touch is enabled. (Default is true.)
  36540. */
  36541. touchEnabled: boolean;
  36542. /**
  36543. * Defines the buttons associated with the input to handle camera rotation.
  36544. */
  36545. buttons: number[];
  36546. /**
  36547. * Assign buttons for Yaw control.
  36548. */
  36549. buttonsYaw: number[];
  36550. /**
  36551. * Assign buttons for Pitch control.
  36552. */
  36553. buttonsPitch: number[];
  36554. /**
  36555. * Assign buttons for Roll control.
  36556. */
  36557. buttonsRoll: number[];
  36558. /**
  36559. * Detect if any button is being pressed while mouse is moved.
  36560. * -1 = Mouse locked.
  36561. * 0 = Left button.
  36562. * 1 = Middle Button.
  36563. * 2 = Right Button.
  36564. */
  36565. activeButton: number;
  36566. /**
  36567. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36568. * Higher values reduce its sensitivity.
  36569. */
  36570. angularSensibility: number;
  36571. private _mousemoveCallback;
  36572. private _observer;
  36573. private _rollObserver;
  36574. private previousPosition;
  36575. private noPreventDefault;
  36576. private element;
  36577. /**
  36578. * Listen to mouse events to control the camera.
  36579. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36581. */
  36582. constructor(touchEnabled?: boolean);
  36583. /**
  36584. * Attach the mouse control to the HTML DOM element.
  36585. * @param element Defines the element that listens to the input events.
  36586. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36587. */
  36588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36589. /**
  36590. * Detach the current controls from the specified dom element.
  36591. * @param element Defines the element to stop listening the inputs from
  36592. */
  36593. detachControl(element: Nullable<HTMLElement>): void;
  36594. /**
  36595. * Gets the class name of the current input.
  36596. * @returns the class name.
  36597. */
  36598. getClassName(): string;
  36599. /**
  36600. * Get the friendly name associated with the input class.
  36601. * @returns the input's friendly name.
  36602. */
  36603. getSimpleName(): string;
  36604. private _pointerInput;
  36605. private _onMouseMove;
  36606. /**
  36607. * Rotate camera by mouse offset.
  36608. */
  36609. private rotateCamera;
  36610. }
  36611. }
  36612. declare module BABYLON {
  36613. /**
  36614. * Default Inputs manager for the FlyCamera.
  36615. * It groups all the default supported inputs for ease of use.
  36616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36617. */
  36618. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36619. /**
  36620. * Instantiates a new FlyCameraInputsManager.
  36621. * @param camera Defines the camera the inputs belong to.
  36622. */
  36623. constructor(camera: FlyCamera);
  36624. /**
  36625. * Add keyboard input support to the input manager.
  36626. * @returns the new FlyCameraKeyboardMoveInput().
  36627. */
  36628. addKeyboard(): FlyCameraInputsManager;
  36629. /**
  36630. * Add mouse input support to the input manager.
  36631. * @param touchEnabled Enable touch screen support.
  36632. * @returns the new FlyCameraMouseInput().
  36633. */
  36634. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36635. }
  36636. }
  36637. declare module BABYLON {
  36638. /**
  36639. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36640. * such as in a 3D Space Shooter or a Flight Simulator.
  36641. */
  36642. export class FlyCamera extends TargetCamera {
  36643. /**
  36644. * Define the collision ellipsoid of the camera.
  36645. * This is helpful for simulating a camera body, like a player's body.
  36646. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36647. */
  36648. ellipsoid: Vector3;
  36649. /**
  36650. * Define an offset for the position of the ellipsoid around the camera.
  36651. * This can be helpful if the camera is attached away from the player's body center,
  36652. * such as at its head.
  36653. */
  36654. ellipsoidOffset: Vector3;
  36655. /**
  36656. * Enable or disable collisions of the camera with the rest of the scene objects.
  36657. */
  36658. checkCollisions: boolean;
  36659. /**
  36660. * Enable or disable gravity on the camera.
  36661. */
  36662. applyGravity: boolean;
  36663. /**
  36664. * Define the current direction the camera is moving to.
  36665. */
  36666. cameraDirection: Vector3;
  36667. /**
  36668. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36669. * This overrides and empties cameraRotation.
  36670. */
  36671. rotationQuaternion: Quaternion;
  36672. /**
  36673. * Track Roll to maintain the wanted Rolling when looking around.
  36674. */ private _trackRoll: number;
  36675. /**
  36676. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36677. */
  36678. rollCorrect: number;
  36679. /**
  36680. * Mimic a banked turn, Rolling the camera when Yawing.
  36681. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36682. */
  36683. bankedTurn: boolean;
  36684. /**
  36685. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36686. */
  36687. bankedTurnLimit: number;
  36688. /**
  36689. * Value of 0 disables the banked Roll.
  36690. * Value of 1 is equal to the Yaw angle in radians.
  36691. */
  36692. bankedTurnMultiplier: number;
  36693. /**
  36694. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36695. */
  36696. inputs: FlyCameraInputsManager;
  36697. /**
  36698. * Gets the input sensibility for mouse input.
  36699. * Higher values reduce sensitivity.
  36700. */
  36701. /**
  36702. * Sets the input sensibility for a mouse input.
  36703. * Higher values reduce sensitivity.
  36704. */
  36705. angularSensibility: number;
  36706. /**
  36707. * Get the keys for camera movement forward.
  36708. */
  36709. /**
  36710. * Set the keys for camera movement forward.
  36711. */
  36712. keysForward: number[];
  36713. /**
  36714. * Get the keys for camera movement backward.
  36715. */
  36716. keysBackward: number[];
  36717. /**
  36718. * Get the keys for camera movement up.
  36719. */
  36720. /**
  36721. * Set the keys for camera movement up.
  36722. */
  36723. keysUp: number[];
  36724. /**
  36725. * Get the keys for camera movement down.
  36726. */
  36727. /**
  36728. * Set the keys for camera movement down.
  36729. */
  36730. keysDown: number[];
  36731. /**
  36732. * Get the keys for camera movement left.
  36733. */
  36734. /**
  36735. * Set the keys for camera movement left.
  36736. */
  36737. keysLeft: number[];
  36738. /**
  36739. * Set the keys for camera movement right.
  36740. */
  36741. /**
  36742. * Set the keys for camera movement right.
  36743. */
  36744. keysRight: number[];
  36745. /**
  36746. * Event raised when the camera collides with a mesh in the scene.
  36747. */
  36748. onCollide: (collidedMesh: AbstractMesh) => void;
  36749. private _collider;
  36750. private _needMoveForGravity;
  36751. private _oldPosition;
  36752. private _diffPosition;
  36753. private _newPosition;
  36754. /** @hidden */ private _localDirection: Vector3;
  36755. /** @hidden */ private _transformedDirection: Vector3;
  36756. /**
  36757. * Instantiates a FlyCamera.
  36758. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36759. * such as in a 3D Space Shooter or a Flight Simulator.
  36760. * @param name Define the name of the camera in the scene.
  36761. * @param position Define the starting position of the camera in the scene.
  36762. * @param scene Define the scene the camera belongs to.
  36763. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36764. */
  36765. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36766. /**
  36767. * Attach a control to the HTML DOM element.
  36768. * @param element Defines the element that listens to the input events.
  36769. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36770. */
  36771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36772. /**
  36773. * Detach a control from the HTML DOM element.
  36774. * The camera will stop reacting to that input.
  36775. * @param element Defines the element that listens to the input events.
  36776. */
  36777. detachControl(element: HTMLElement): void;
  36778. private _collisionMask;
  36779. /**
  36780. * Get the mask that the camera ignores in collision events.
  36781. */
  36782. /**
  36783. * Set the mask that the camera ignores in collision events.
  36784. */
  36785. collisionMask: number;
  36786. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36787. /** @hidden */
  36788. private _onCollisionPositionChange;
  36789. /** @hidden */ private _checkInputs(): void;
  36790. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36791. /** @hidden */ private _updatePosition(): void;
  36792. /**
  36793. * Restore the Roll to its target value at the rate specified.
  36794. * @param rate - Higher means slower restoring.
  36795. * @hidden
  36796. */
  36797. restoreRoll(rate: number): void;
  36798. /**
  36799. * Destroy the camera and release the current resources held by it.
  36800. */
  36801. dispose(): void;
  36802. /**
  36803. * Get the current object class name.
  36804. * @returns the class name.
  36805. */
  36806. getClassName(): string;
  36807. }
  36808. }
  36809. declare module BABYLON {
  36810. /**
  36811. * Listen to keyboard events to control the camera.
  36812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36813. */
  36814. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36815. /**
  36816. * Defines the camera the input is attached to.
  36817. */
  36818. camera: FlyCamera;
  36819. /**
  36820. * The list of keyboard keys used to control the forward move of the camera.
  36821. */
  36822. keysForward: number[];
  36823. /**
  36824. * The list of keyboard keys used to control the backward move of the camera.
  36825. */
  36826. keysBackward: number[];
  36827. /**
  36828. * The list of keyboard keys used to control the forward move of the camera.
  36829. */
  36830. keysUp: number[];
  36831. /**
  36832. * The list of keyboard keys used to control the backward move of the camera.
  36833. */
  36834. keysDown: number[];
  36835. /**
  36836. * The list of keyboard keys used to control the right strafe move of the camera.
  36837. */
  36838. keysRight: number[];
  36839. /**
  36840. * The list of keyboard keys used to control the left strafe move of the camera.
  36841. */
  36842. keysLeft: number[];
  36843. private _keys;
  36844. private _onCanvasBlurObserver;
  36845. private _onKeyboardObserver;
  36846. private _engine;
  36847. private _scene;
  36848. /**
  36849. * Attach the input controls to a specific dom element to get the input from.
  36850. * @param element Defines the element the controls should be listened from
  36851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36852. */
  36853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36854. /**
  36855. * Detach the current controls from the specified dom element.
  36856. * @param element Defines the element to stop listening the inputs from
  36857. */
  36858. detachControl(element: Nullable<HTMLElement>): void;
  36859. /**
  36860. * Gets the class name of the current intput.
  36861. * @returns the class name
  36862. */
  36863. getClassName(): string;
  36864. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36865. /**
  36866. * Get the friendly name associated with the input class.
  36867. * @returns the input friendly name
  36868. */
  36869. getSimpleName(): string;
  36870. /**
  36871. * Update the current camera state depending on the inputs that have been used this frame.
  36872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36873. */
  36874. checkInputs(): void;
  36875. }
  36876. }
  36877. declare module BABYLON {
  36878. /**
  36879. * Manage the mouse wheel inputs to control a follow camera.
  36880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36881. */
  36882. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36883. /**
  36884. * Defines the camera the input is attached to.
  36885. */
  36886. camera: FollowCamera;
  36887. /**
  36888. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36889. */
  36890. axisControlRadius: boolean;
  36891. /**
  36892. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36893. */
  36894. axisControlHeight: boolean;
  36895. /**
  36896. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36897. */
  36898. axisControlRotation: boolean;
  36899. /**
  36900. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36901. * relation to mouseWheel events.
  36902. */
  36903. wheelPrecision: number;
  36904. /**
  36905. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36906. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36907. */
  36908. wheelDeltaPercentage: number;
  36909. private _wheel;
  36910. private _observer;
  36911. /**
  36912. * Attach the input controls to a specific dom element to get the input from.
  36913. * @param element Defines the element the controls should be listened from
  36914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36915. */
  36916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36917. /**
  36918. * Detach the current controls from the specified dom element.
  36919. * @param element Defines the element to stop listening the inputs from
  36920. */
  36921. detachControl(element: Nullable<HTMLElement>): void;
  36922. /**
  36923. * Gets the class name of the current intput.
  36924. * @returns the class name
  36925. */
  36926. getClassName(): string;
  36927. /**
  36928. * Get the friendly name associated with the input class.
  36929. * @returns the input friendly name
  36930. */
  36931. getSimpleName(): string;
  36932. }
  36933. }
  36934. declare module BABYLON {
  36935. /**
  36936. * Manage the pointers inputs to control an follow camera.
  36937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36938. */
  36939. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36940. /**
  36941. * Defines the camera the input is attached to.
  36942. */
  36943. camera: FollowCamera;
  36944. /**
  36945. * Gets the class name of the current input.
  36946. * @returns the class name
  36947. */
  36948. getClassName(): string;
  36949. /**
  36950. * Defines the pointer angular sensibility along the X axis or how fast is
  36951. * the camera rotating.
  36952. * A negative number will reverse the axis direction.
  36953. */
  36954. angularSensibilityX: number;
  36955. /**
  36956. * Defines the pointer angular sensibility along the Y axis or how fast is
  36957. * the camera rotating.
  36958. * A negative number will reverse the axis direction.
  36959. */
  36960. angularSensibilityY: number;
  36961. /**
  36962. * Defines the pointer pinch precision or how fast is the camera zooming.
  36963. * A negative number will reverse the axis direction.
  36964. */
  36965. pinchPrecision: number;
  36966. /**
  36967. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36968. * from 0.
  36969. * It defines the percentage of current camera.radius to use as delta when
  36970. * pinch zoom is used.
  36971. */
  36972. pinchDeltaPercentage: number;
  36973. /**
  36974. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36975. */
  36976. axisXControlRadius: boolean;
  36977. /**
  36978. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36979. */
  36980. axisXControlHeight: boolean;
  36981. /**
  36982. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36983. */
  36984. axisXControlRotation: boolean;
  36985. /**
  36986. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36987. */
  36988. axisYControlRadius: boolean;
  36989. /**
  36990. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36991. */
  36992. axisYControlHeight: boolean;
  36993. /**
  36994. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36995. */
  36996. axisYControlRotation: boolean;
  36997. /**
  36998. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36999. */
  37000. axisPinchControlRadius: boolean;
  37001. /**
  37002. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37003. */
  37004. axisPinchControlHeight: boolean;
  37005. /**
  37006. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37007. */
  37008. axisPinchControlRotation: boolean;
  37009. /**
  37010. * Log error messages if basic misconfiguration has occurred.
  37011. */
  37012. warningEnable: boolean;
  37013. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37014. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37015. private _warningCounter;
  37016. private _warning;
  37017. }
  37018. }
  37019. declare module BABYLON {
  37020. /**
  37021. * Default Inputs manager for the FollowCamera.
  37022. * It groups all the default supported inputs for ease of use.
  37023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37024. */
  37025. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37026. /**
  37027. * Instantiates a new FollowCameraInputsManager.
  37028. * @param camera Defines the camera the inputs belong to
  37029. */
  37030. constructor(camera: FollowCamera);
  37031. /**
  37032. * Add keyboard input support to the input manager.
  37033. * @returns the current input manager
  37034. */
  37035. addKeyboard(): FollowCameraInputsManager;
  37036. /**
  37037. * Add mouse wheel input support to the input manager.
  37038. * @returns the current input manager
  37039. */
  37040. addMouseWheel(): FollowCameraInputsManager;
  37041. /**
  37042. * Add pointers input support to the input manager.
  37043. * @returns the current input manager
  37044. */
  37045. addPointers(): FollowCameraInputsManager;
  37046. /**
  37047. * Add orientation input support to the input manager.
  37048. * @returns the current input manager
  37049. */
  37050. addVRDeviceOrientation(): FollowCameraInputsManager;
  37051. }
  37052. }
  37053. declare module BABYLON {
  37054. /**
  37055. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37056. * an arc rotate version arcFollowCamera are available.
  37057. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37058. */
  37059. export class FollowCamera extends TargetCamera {
  37060. /**
  37061. * Distance the follow camera should follow an object at
  37062. */
  37063. radius: number;
  37064. /**
  37065. * Minimum allowed distance of the camera to the axis of rotation
  37066. * (The camera can not get closer).
  37067. * This can help limiting how the Camera is able to move in the scene.
  37068. */
  37069. lowerRadiusLimit: Nullable<number>;
  37070. /**
  37071. * Maximum allowed distance of the camera to the axis of rotation
  37072. * (The camera can not get further).
  37073. * This can help limiting how the Camera is able to move in the scene.
  37074. */
  37075. upperRadiusLimit: Nullable<number>;
  37076. /**
  37077. * Define a rotation offset between the camera and the object it follows
  37078. */
  37079. rotationOffset: number;
  37080. /**
  37081. * Minimum allowed angle to camera position relative to target object.
  37082. * This can help limiting how the Camera is able to move in the scene.
  37083. */
  37084. lowerRotationOffsetLimit: Nullable<number>;
  37085. /**
  37086. * Maximum allowed angle to camera position relative to target object.
  37087. * This can help limiting how the Camera is able to move in the scene.
  37088. */
  37089. upperRotationOffsetLimit: Nullable<number>;
  37090. /**
  37091. * Define a height offset between the camera and the object it follows.
  37092. * It can help following an object from the top (like a car chaing a plane)
  37093. */
  37094. heightOffset: number;
  37095. /**
  37096. * Minimum allowed height of camera position relative to target object.
  37097. * This can help limiting how the Camera is able to move in the scene.
  37098. */
  37099. lowerHeightOffsetLimit: Nullable<number>;
  37100. /**
  37101. * Maximum allowed height of camera position relative to target object.
  37102. * This can help limiting how the Camera is able to move in the scene.
  37103. */
  37104. upperHeightOffsetLimit: Nullable<number>;
  37105. /**
  37106. * Define how fast the camera can accelerate to follow it s target.
  37107. */
  37108. cameraAcceleration: number;
  37109. /**
  37110. * Define the speed limit of the camera following an object.
  37111. */
  37112. maxCameraSpeed: number;
  37113. /**
  37114. * Define the target of the camera.
  37115. */
  37116. lockedTarget: Nullable<AbstractMesh>;
  37117. /**
  37118. * Defines the input associated with the camera.
  37119. */
  37120. inputs: FollowCameraInputsManager;
  37121. /**
  37122. * Instantiates the follow camera.
  37123. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37124. * @param name Define the name of the camera in the scene
  37125. * @param position Define the position of the camera
  37126. * @param scene Define the scene the camera belong to
  37127. * @param lockedTarget Define the target of the camera
  37128. */
  37129. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37130. private _follow;
  37131. /**
  37132. * Attached controls to the current camera.
  37133. * @param element Defines the element the controls should be listened from
  37134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37135. */
  37136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37137. /**
  37138. * Detach the current controls from the camera.
  37139. * The camera will stop reacting to inputs.
  37140. * @param element Defines the element to stop listening the inputs from
  37141. */
  37142. detachControl(element: HTMLElement): void;
  37143. /** @hidden */ private _checkInputs(): void;
  37144. private _checkLimits;
  37145. /**
  37146. * Gets the camera class name.
  37147. * @returns the class name
  37148. */
  37149. getClassName(): string;
  37150. }
  37151. /**
  37152. * Arc Rotate version of the follow camera.
  37153. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37154. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37155. */
  37156. export class ArcFollowCamera extends TargetCamera {
  37157. /** The longitudinal angle of the camera */
  37158. alpha: number;
  37159. /** The latitudinal angle of the camera */
  37160. beta: number;
  37161. /** The radius of the camera from its target */
  37162. radius: number;
  37163. /** Define the camera target (the messh it should follow) */
  37164. target: Nullable<AbstractMesh>;
  37165. private _cartesianCoordinates;
  37166. /**
  37167. * Instantiates a new ArcFollowCamera
  37168. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37169. * @param name Define the name of the camera
  37170. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37171. * @param beta Define the rotation angle of the camera around the elevation axis
  37172. * @param radius Define the radius of the camera from its target point
  37173. * @param target Define the target of the camera
  37174. * @param scene Define the scene the camera belongs to
  37175. */
  37176. constructor(name: string,
  37177. /** The longitudinal angle of the camera */
  37178. alpha: number,
  37179. /** The latitudinal angle of the camera */
  37180. beta: number,
  37181. /** The radius of the camera from its target */
  37182. radius: number,
  37183. /** Define the camera target (the messh it should follow) */
  37184. target: Nullable<AbstractMesh>, scene: Scene);
  37185. private _follow;
  37186. /** @hidden */ private _checkInputs(): void;
  37187. /**
  37188. * Returns the class name of the object.
  37189. * It is mostly used internally for serialization purposes.
  37190. */
  37191. getClassName(): string;
  37192. }
  37193. }
  37194. declare module BABYLON {
  37195. /**
  37196. * Manage the keyboard inputs to control the movement of a follow camera.
  37197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37198. */
  37199. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37200. /**
  37201. * Defines the camera the input is attached to.
  37202. */
  37203. camera: FollowCamera;
  37204. /**
  37205. * Defines the list of key codes associated with the up action (increase heightOffset)
  37206. */
  37207. keysHeightOffsetIncr: number[];
  37208. /**
  37209. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37210. */
  37211. keysHeightOffsetDecr: number[];
  37212. /**
  37213. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37214. */
  37215. keysHeightOffsetModifierAlt: boolean;
  37216. /**
  37217. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37218. */
  37219. keysHeightOffsetModifierCtrl: boolean;
  37220. /**
  37221. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37222. */
  37223. keysHeightOffsetModifierShift: boolean;
  37224. /**
  37225. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37226. */
  37227. keysRotationOffsetIncr: number[];
  37228. /**
  37229. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37230. */
  37231. keysRotationOffsetDecr: number[];
  37232. /**
  37233. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37234. */
  37235. keysRotationOffsetModifierAlt: boolean;
  37236. /**
  37237. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37238. */
  37239. keysRotationOffsetModifierCtrl: boolean;
  37240. /**
  37241. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37242. */
  37243. keysRotationOffsetModifierShift: boolean;
  37244. /**
  37245. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37246. */
  37247. keysRadiusIncr: number[];
  37248. /**
  37249. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37250. */
  37251. keysRadiusDecr: number[];
  37252. /**
  37253. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37254. */
  37255. keysRadiusModifierAlt: boolean;
  37256. /**
  37257. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37258. */
  37259. keysRadiusModifierCtrl: boolean;
  37260. /**
  37261. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37262. */
  37263. keysRadiusModifierShift: boolean;
  37264. /**
  37265. * Defines the rate of change of heightOffset.
  37266. */
  37267. heightSensibility: number;
  37268. /**
  37269. * Defines the rate of change of rotationOffset.
  37270. */
  37271. rotationSensibility: number;
  37272. /**
  37273. * Defines the rate of change of radius.
  37274. */
  37275. radiusSensibility: number;
  37276. private _keys;
  37277. private _ctrlPressed;
  37278. private _altPressed;
  37279. private _shiftPressed;
  37280. private _onCanvasBlurObserver;
  37281. private _onKeyboardObserver;
  37282. private _engine;
  37283. private _scene;
  37284. /**
  37285. * Attach the input controls to a specific dom element to get the input from.
  37286. * @param element Defines the element the controls should be listened from
  37287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37288. */
  37289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37290. /**
  37291. * Detach the current controls from the specified dom element.
  37292. * @param element Defines the element to stop listening the inputs from
  37293. */
  37294. detachControl(element: Nullable<HTMLElement>): void;
  37295. /**
  37296. * Update the current camera state depending on the inputs that have been used this frame.
  37297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37298. */
  37299. checkInputs(): void;
  37300. /**
  37301. * Gets the class name of the current input.
  37302. * @returns the class name
  37303. */
  37304. getClassName(): string;
  37305. /**
  37306. * Get the friendly name associated with the input class.
  37307. * @returns the input friendly name
  37308. */
  37309. getSimpleName(): string;
  37310. /**
  37311. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37312. * allow modification of the heightOffset value.
  37313. */
  37314. private _modifierHeightOffset;
  37315. /**
  37316. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37317. * allow modification of the rotationOffset value.
  37318. */
  37319. private _modifierRotationOffset;
  37320. /**
  37321. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37322. * allow modification of the radius value.
  37323. */
  37324. private _modifierRadius;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. interface FreeCameraInputsManager {
  37329. /**
  37330. * @hidden
  37331. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37332. /**
  37333. * Add orientation input support to the input manager.
  37334. * @returns the current input manager
  37335. */
  37336. addDeviceOrientation(): FreeCameraInputsManager;
  37337. }
  37338. /**
  37339. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37340. * Screen rotation is taken into account.
  37341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37342. */
  37343. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37344. private _camera;
  37345. private _screenOrientationAngle;
  37346. private _constantTranform;
  37347. private _screenQuaternion;
  37348. private _alpha;
  37349. private _beta;
  37350. private _gamma;
  37351. /**
  37352. * Can be used to detect if a device orientation sensor is availible on a device
  37353. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37354. * @returns a promise that will resolve on orientation change
  37355. */
  37356. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37357. /**
  37358. * @hidden
  37359. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37360. /**
  37361. * Instantiates a new input
  37362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37363. */
  37364. constructor();
  37365. /**
  37366. * Define the camera controlled by the input.
  37367. */
  37368. camera: FreeCamera;
  37369. /**
  37370. * Attach the input controls to a specific dom element to get the input from.
  37371. * @param element Defines the element the controls should be listened from
  37372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37373. */
  37374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37375. private _orientationChanged;
  37376. private _deviceOrientation;
  37377. /**
  37378. * Detach the current controls from the specified dom element.
  37379. * @param element Defines the element to stop listening the inputs from
  37380. */
  37381. detachControl(element: Nullable<HTMLElement>): void;
  37382. /**
  37383. * Update the current camera state depending on the inputs that have been used this frame.
  37384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37385. */
  37386. checkInputs(): void;
  37387. /**
  37388. * Gets the class name of the current intput.
  37389. * @returns the class name
  37390. */
  37391. getClassName(): string;
  37392. /**
  37393. * Get the friendly name associated with the input class.
  37394. * @returns the input friendly name
  37395. */
  37396. getSimpleName(): string;
  37397. }
  37398. }
  37399. declare module BABYLON {
  37400. /**
  37401. * Manage the gamepad inputs to control a free camera.
  37402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37403. */
  37404. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37405. /**
  37406. * Define the camera the input is attached to.
  37407. */
  37408. camera: FreeCamera;
  37409. /**
  37410. * Define the Gamepad controlling the input
  37411. */
  37412. gamepad: Nullable<Gamepad>;
  37413. /**
  37414. * Defines the gamepad rotation sensiblity.
  37415. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37416. */
  37417. gamepadAngularSensibility: number;
  37418. /**
  37419. * Defines the gamepad move sensiblity.
  37420. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37421. */
  37422. gamepadMoveSensibility: number;
  37423. private _onGamepadConnectedObserver;
  37424. private _onGamepadDisconnectedObserver;
  37425. private _cameraTransform;
  37426. private _deltaTransform;
  37427. private _vector3;
  37428. private _vector2;
  37429. /**
  37430. * Attach the input controls to a specific dom element to get the input from.
  37431. * @param element Defines the element the controls should be listened from
  37432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37433. */
  37434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37435. /**
  37436. * Detach the current controls from the specified dom element.
  37437. * @param element Defines the element to stop listening the inputs from
  37438. */
  37439. detachControl(element: Nullable<HTMLElement>): void;
  37440. /**
  37441. * Update the current camera state depending on the inputs that have been used this frame.
  37442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37443. */
  37444. checkInputs(): void;
  37445. /**
  37446. * Gets the class name of the current intput.
  37447. * @returns the class name
  37448. */
  37449. getClassName(): string;
  37450. /**
  37451. * Get the friendly name associated with the input class.
  37452. * @returns the input friendly name
  37453. */
  37454. getSimpleName(): string;
  37455. }
  37456. }
  37457. declare module BABYLON {
  37458. /**
  37459. * Defines the potential axis of a Joystick
  37460. */
  37461. export enum JoystickAxis {
  37462. /** X axis */
  37463. X = 0,
  37464. /** Y axis */
  37465. Y = 1,
  37466. /** Z axis */
  37467. Z = 2
  37468. }
  37469. /**
  37470. * Class used to define virtual joystick (used in touch mode)
  37471. */
  37472. export class VirtualJoystick {
  37473. /**
  37474. * Gets or sets a boolean indicating that left and right values must be inverted
  37475. */
  37476. reverseLeftRight: boolean;
  37477. /**
  37478. * Gets or sets a boolean indicating that up and down values must be inverted
  37479. */
  37480. reverseUpDown: boolean;
  37481. /**
  37482. * Gets the offset value for the position (ie. the change of the position value)
  37483. */
  37484. deltaPosition: Vector3;
  37485. /**
  37486. * Gets a boolean indicating if the virtual joystick was pressed
  37487. */
  37488. pressed: boolean;
  37489. /**
  37490. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37491. */
  37492. static Canvas: Nullable<HTMLCanvasElement>;
  37493. private static _globalJoystickIndex;
  37494. private static vjCanvasContext;
  37495. private static vjCanvasWidth;
  37496. private static vjCanvasHeight;
  37497. private static halfWidth;
  37498. private _action;
  37499. private _axisTargetedByLeftAndRight;
  37500. private _axisTargetedByUpAndDown;
  37501. private _joystickSensibility;
  37502. private _inversedSensibility;
  37503. private _joystickPointerID;
  37504. private _joystickColor;
  37505. private _joystickPointerPos;
  37506. private _joystickPreviousPointerPos;
  37507. private _joystickPointerStartPos;
  37508. private _deltaJoystickVector;
  37509. private _leftJoystick;
  37510. private _touches;
  37511. private _onPointerDownHandlerRef;
  37512. private _onPointerMoveHandlerRef;
  37513. private _onPointerUpHandlerRef;
  37514. private _onResize;
  37515. /**
  37516. * Creates a new virtual joystick
  37517. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37518. */
  37519. constructor(leftJoystick?: boolean);
  37520. /**
  37521. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37522. * @param newJoystickSensibility defines the new sensibility
  37523. */
  37524. setJoystickSensibility(newJoystickSensibility: number): void;
  37525. private _onPointerDown;
  37526. private _onPointerMove;
  37527. private _onPointerUp;
  37528. /**
  37529. * Change the color of the virtual joystick
  37530. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37531. */
  37532. setJoystickColor(newColor: string): void;
  37533. /**
  37534. * Defines a callback to call when the joystick is touched
  37535. * @param action defines the callback
  37536. */
  37537. setActionOnTouch(action: () => any): void;
  37538. /**
  37539. * Defines which axis you'd like to control for left & right
  37540. * @param axis defines the axis to use
  37541. */
  37542. setAxisForLeftRight(axis: JoystickAxis): void;
  37543. /**
  37544. * Defines which axis you'd like to control for up & down
  37545. * @param axis defines the axis to use
  37546. */
  37547. setAxisForUpDown(axis: JoystickAxis): void;
  37548. private _drawVirtualJoystick;
  37549. /**
  37550. * Release internal HTML canvas
  37551. */
  37552. releaseCanvas(): void;
  37553. }
  37554. }
  37555. declare module BABYLON {
  37556. interface FreeCameraInputsManager {
  37557. /**
  37558. * Add virtual joystick input support to the input manager.
  37559. * @returns the current input manager
  37560. */
  37561. addVirtualJoystick(): FreeCameraInputsManager;
  37562. }
  37563. /**
  37564. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37566. */
  37567. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37568. /**
  37569. * Defines the camera the input is attached to.
  37570. */
  37571. camera: FreeCamera;
  37572. private _leftjoystick;
  37573. private _rightjoystick;
  37574. /**
  37575. * Gets the left stick of the virtual joystick.
  37576. * @returns The virtual Joystick
  37577. */
  37578. getLeftJoystick(): VirtualJoystick;
  37579. /**
  37580. * Gets the right stick of the virtual joystick.
  37581. * @returns The virtual Joystick
  37582. */
  37583. getRightJoystick(): VirtualJoystick;
  37584. /**
  37585. * Update the current camera state depending on the inputs that have been used this frame.
  37586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37587. */
  37588. checkInputs(): void;
  37589. /**
  37590. * Attach the input controls to a specific dom element to get the input from.
  37591. * @param element Defines the element the controls should be listened from
  37592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37593. */
  37594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37595. /**
  37596. * Detach the current controls from the specified dom element.
  37597. * @param element Defines the element to stop listening the inputs from
  37598. */
  37599. detachControl(element: Nullable<HTMLElement>): void;
  37600. /**
  37601. * Gets the class name of the current intput.
  37602. * @returns the class name
  37603. */
  37604. getClassName(): string;
  37605. /**
  37606. * Get the friendly name associated with the input class.
  37607. * @returns the input friendly name
  37608. */
  37609. getSimpleName(): string;
  37610. }
  37611. }
  37612. declare module BABYLON {
  37613. /**
  37614. * This represents a FPS type of camera controlled by touch.
  37615. * This is like a universal camera minus the Gamepad controls.
  37616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37617. */
  37618. export class TouchCamera extends FreeCamera {
  37619. /**
  37620. * Defines the touch sensibility for rotation.
  37621. * The higher the faster.
  37622. */
  37623. touchAngularSensibility: number;
  37624. /**
  37625. * Defines the touch sensibility for move.
  37626. * The higher the faster.
  37627. */
  37628. touchMoveSensibility: number;
  37629. /**
  37630. * Instantiates a new touch camera.
  37631. * This represents a FPS type of camera controlled by touch.
  37632. * This is like a universal camera minus the Gamepad controls.
  37633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37634. * @param name Define the name of the camera in the scene
  37635. * @param position Define the start position of the camera in the scene
  37636. * @param scene Define the scene the camera belongs to
  37637. */
  37638. constructor(name: string, position: Vector3, scene: Scene);
  37639. /**
  37640. * Gets the current object class name.
  37641. * @return the class name
  37642. */
  37643. getClassName(): string;
  37644. /** @hidden */ private _setupInputs(): void;
  37645. }
  37646. }
  37647. declare module BABYLON {
  37648. /**
  37649. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37650. * being tilted forward or back and left or right.
  37651. */
  37652. export class DeviceOrientationCamera extends FreeCamera {
  37653. private _initialQuaternion;
  37654. private _quaternionCache;
  37655. private _tmpDragQuaternion;
  37656. private _disablePointerInputWhenUsingDeviceOrientation;
  37657. /**
  37658. * Creates a new device orientation camera
  37659. * @param name The name of the camera
  37660. * @param position The start position camera
  37661. * @param scene The scene the camera belongs to
  37662. */
  37663. constructor(name: string, position: Vector3, scene: Scene);
  37664. /**
  37665. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37666. */
  37667. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37668. private _dragFactor;
  37669. /**
  37670. * Enabled turning on the y axis when the orientation sensor is active
  37671. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37672. */
  37673. enableHorizontalDragging(dragFactor?: number): void;
  37674. /**
  37675. * Gets the current instance class name ("DeviceOrientationCamera").
  37676. * This helps avoiding instanceof at run time.
  37677. * @returns the class name
  37678. */
  37679. getClassName(): string;
  37680. /**
  37681. * @hidden
  37682. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37683. */ private _checkInputs(): void;
  37684. /**
  37685. * Reset the camera to its default orientation on the specified axis only.
  37686. * @param axis The axis to reset
  37687. */
  37688. resetToCurrentRotation(axis?: Axis): void;
  37689. }
  37690. }
  37691. declare module BABYLON {
  37692. /**
  37693. * Defines supported buttons for XBox360 compatible gamepads
  37694. */
  37695. export enum Xbox360Button {
  37696. /** A */
  37697. A = 0,
  37698. /** B */
  37699. B = 1,
  37700. /** X */
  37701. X = 2,
  37702. /** Y */
  37703. Y = 3,
  37704. /** Start */
  37705. Start = 4,
  37706. /** Back */
  37707. Back = 5,
  37708. /** Left button */
  37709. LB = 6,
  37710. /** Right button */
  37711. RB = 7,
  37712. /** Left stick */
  37713. LeftStick = 8,
  37714. /** Right stick */
  37715. RightStick = 9
  37716. }
  37717. /** Defines values for XBox360 DPad */
  37718. export enum Xbox360Dpad {
  37719. /** Up */
  37720. Up = 0,
  37721. /** Down */
  37722. Down = 1,
  37723. /** Left */
  37724. Left = 2,
  37725. /** Right */
  37726. Right = 3
  37727. }
  37728. /**
  37729. * Defines a XBox360 gamepad
  37730. */
  37731. export class Xbox360Pad extends Gamepad {
  37732. private _leftTrigger;
  37733. private _rightTrigger;
  37734. private _onlefttriggerchanged;
  37735. private _onrighttriggerchanged;
  37736. private _onbuttondown;
  37737. private _onbuttonup;
  37738. private _ondpaddown;
  37739. private _ondpadup;
  37740. /** Observable raised when a button is pressed */
  37741. onButtonDownObservable: Observable<Xbox360Button>;
  37742. /** Observable raised when a button is released */
  37743. onButtonUpObservable: Observable<Xbox360Button>;
  37744. /** Observable raised when a pad is pressed */
  37745. onPadDownObservable: Observable<Xbox360Dpad>;
  37746. /** Observable raised when a pad is released */
  37747. onPadUpObservable: Observable<Xbox360Dpad>;
  37748. private _buttonA;
  37749. private _buttonB;
  37750. private _buttonX;
  37751. private _buttonY;
  37752. private _buttonBack;
  37753. private _buttonStart;
  37754. private _buttonLB;
  37755. private _buttonRB;
  37756. private _buttonLeftStick;
  37757. private _buttonRightStick;
  37758. private _dPadUp;
  37759. private _dPadDown;
  37760. private _dPadLeft;
  37761. private _dPadRight;
  37762. private _isXboxOnePad;
  37763. /**
  37764. * Creates a new XBox360 gamepad object
  37765. * @param id defines the id of this gamepad
  37766. * @param index defines its index
  37767. * @param gamepad defines the internal HTML gamepad object
  37768. * @param xboxOne defines if it is a XBox One gamepad
  37769. */
  37770. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37771. /**
  37772. * Defines the callback to call when left trigger is pressed
  37773. * @param callback defines the callback to use
  37774. */
  37775. onlefttriggerchanged(callback: (value: number) => void): void;
  37776. /**
  37777. * Defines the callback to call when right trigger is pressed
  37778. * @param callback defines the callback to use
  37779. */
  37780. onrighttriggerchanged(callback: (value: number) => void): void;
  37781. /**
  37782. * Gets the left trigger value
  37783. */
  37784. /**
  37785. * Sets the left trigger value
  37786. */
  37787. leftTrigger: number;
  37788. /**
  37789. * Gets the right trigger value
  37790. */
  37791. /**
  37792. * Sets the right trigger value
  37793. */
  37794. rightTrigger: number;
  37795. /**
  37796. * Defines the callback to call when a button is pressed
  37797. * @param callback defines the callback to use
  37798. */
  37799. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37800. /**
  37801. * Defines the callback to call when a button is released
  37802. * @param callback defines the callback to use
  37803. */
  37804. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37805. /**
  37806. * Defines the callback to call when a pad is pressed
  37807. * @param callback defines the callback to use
  37808. */
  37809. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37810. /**
  37811. * Defines the callback to call when a pad is released
  37812. * @param callback defines the callback to use
  37813. */
  37814. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37815. private _setButtonValue;
  37816. private _setDPadValue;
  37817. /**
  37818. * Gets the value of the `A` button
  37819. */
  37820. /**
  37821. * Sets the value of the `A` button
  37822. */
  37823. buttonA: number;
  37824. /**
  37825. * Gets the value of the `B` button
  37826. */
  37827. /**
  37828. * Sets the value of the `B` button
  37829. */
  37830. buttonB: number;
  37831. /**
  37832. * Gets the value of the `X` button
  37833. */
  37834. /**
  37835. * Sets the value of the `X` button
  37836. */
  37837. buttonX: number;
  37838. /**
  37839. * Gets the value of the `Y` button
  37840. */
  37841. /**
  37842. * Sets the value of the `Y` button
  37843. */
  37844. buttonY: number;
  37845. /**
  37846. * Gets the value of the `Start` button
  37847. */
  37848. /**
  37849. * Sets the value of the `Start` button
  37850. */
  37851. buttonStart: number;
  37852. /**
  37853. * Gets the value of the `Back` button
  37854. */
  37855. /**
  37856. * Sets the value of the `Back` button
  37857. */
  37858. buttonBack: number;
  37859. /**
  37860. * Gets the value of the `Left` button
  37861. */
  37862. /**
  37863. * Sets the value of the `Left` button
  37864. */
  37865. buttonLB: number;
  37866. /**
  37867. * Gets the value of the `Right` button
  37868. */
  37869. /**
  37870. * Sets the value of the `Right` button
  37871. */
  37872. buttonRB: number;
  37873. /**
  37874. * Gets the value of the Left joystick
  37875. */
  37876. /**
  37877. * Sets the value of the Left joystick
  37878. */
  37879. buttonLeftStick: number;
  37880. /**
  37881. * Gets the value of the Right joystick
  37882. */
  37883. /**
  37884. * Sets the value of the Right joystick
  37885. */
  37886. buttonRightStick: number;
  37887. /**
  37888. * Gets the value of D-pad up
  37889. */
  37890. /**
  37891. * Sets the value of D-pad up
  37892. */
  37893. dPadUp: number;
  37894. /**
  37895. * Gets the value of D-pad down
  37896. */
  37897. /**
  37898. * Sets the value of D-pad down
  37899. */
  37900. dPadDown: number;
  37901. /**
  37902. * Gets the value of D-pad left
  37903. */
  37904. /**
  37905. * Sets the value of D-pad left
  37906. */
  37907. dPadLeft: number;
  37908. /**
  37909. * Gets the value of D-pad right
  37910. */
  37911. /**
  37912. * Sets the value of D-pad right
  37913. */
  37914. dPadRight: number;
  37915. /**
  37916. * Force the gamepad to synchronize with device values
  37917. */
  37918. update(): void;
  37919. /**
  37920. * Disposes the gamepad
  37921. */
  37922. dispose(): void;
  37923. }
  37924. }
  37925. declare module BABYLON {
  37926. /**
  37927. * Defines supported buttons for DualShock compatible gamepads
  37928. */
  37929. export enum DualShockButton {
  37930. /** Cross */
  37931. Cross = 0,
  37932. /** Circle */
  37933. Circle = 1,
  37934. /** Square */
  37935. Square = 2,
  37936. /** Triangle */
  37937. Triangle = 3,
  37938. /** Options */
  37939. Options = 4,
  37940. /** Share */
  37941. Share = 5,
  37942. /** L1 */
  37943. L1 = 6,
  37944. /** R1 */
  37945. R1 = 7,
  37946. /** Left stick */
  37947. LeftStick = 8,
  37948. /** Right stick */
  37949. RightStick = 9
  37950. }
  37951. /** Defines values for DualShock DPad */
  37952. export enum DualShockDpad {
  37953. /** Up */
  37954. Up = 0,
  37955. /** Down */
  37956. Down = 1,
  37957. /** Left */
  37958. Left = 2,
  37959. /** Right */
  37960. Right = 3
  37961. }
  37962. /**
  37963. * Defines a DualShock gamepad
  37964. */
  37965. export class DualShockPad extends Gamepad {
  37966. private _leftTrigger;
  37967. private _rightTrigger;
  37968. private _onlefttriggerchanged;
  37969. private _onrighttriggerchanged;
  37970. private _onbuttondown;
  37971. private _onbuttonup;
  37972. private _ondpaddown;
  37973. private _ondpadup;
  37974. /** Observable raised when a button is pressed */
  37975. onButtonDownObservable: Observable<DualShockButton>;
  37976. /** Observable raised when a button is released */
  37977. onButtonUpObservable: Observable<DualShockButton>;
  37978. /** Observable raised when a pad is pressed */
  37979. onPadDownObservable: Observable<DualShockDpad>;
  37980. /** Observable raised when a pad is released */
  37981. onPadUpObservable: Observable<DualShockDpad>;
  37982. private _buttonCross;
  37983. private _buttonCircle;
  37984. private _buttonSquare;
  37985. private _buttonTriangle;
  37986. private _buttonShare;
  37987. private _buttonOptions;
  37988. private _buttonL1;
  37989. private _buttonR1;
  37990. private _buttonLeftStick;
  37991. private _buttonRightStick;
  37992. private _dPadUp;
  37993. private _dPadDown;
  37994. private _dPadLeft;
  37995. private _dPadRight;
  37996. /**
  37997. * Creates a new DualShock gamepad object
  37998. * @param id defines the id of this gamepad
  37999. * @param index defines its index
  38000. * @param gamepad defines the internal HTML gamepad object
  38001. */
  38002. constructor(id: string, index: number, gamepad: any);
  38003. /**
  38004. * Defines the callback to call when left trigger is pressed
  38005. * @param callback defines the callback to use
  38006. */
  38007. onlefttriggerchanged(callback: (value: number) => void): void;
  38008. /**
  38009. * Defines the callback to call when right trigger is pressed
  38010. * @param callback defines the callback to use
  38011. */
  38012. onrighttriggerchanged(callback: (value: number) => void): void;
  38013. /**
  38014. * Gets the left trigger value
  38015. */
  38016. /**
  38017. * Sets the left trigger value
  38018. */
  38019. leftTrigger: number;
  38020. /**
  38021. * Gets the right trigger value
  38022. */
  38023. /**
  38024. * Sets the right trigger value
  38025. */
  38026. rightTrigger: number;
  38027. /**
  38028. * Defines the callback to call when a button is pressed
  38029. * @param callback defines the callback to use
  38030. */
  38031. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38032. /**
  38033. * Defines the callback to call when a button is released
  38034. * @param callback defines the callback to use
  38035. */
  38036. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38037. /**
  38038. * Defines the callback to call when a pad is pressed
  38039. * @param callback defines the callback to use
  38040. */
  38041. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38042. /**
  38043. * Defines the callback to call when a pad is released
  38044. * @param callback defines the callback to use
  38045. */
  38046. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38047. private _setButtonValue;
  38048. private _setDPadValue;
  38049. /**
  38050. * Gets the value of the `Cross` button
  38051. */
  38052. /**
  38053. * Sets the value of the `Cross` button
  38054. */
  38055. buttonCross: number;
  38056. /**
  38057. * Gets the value of the `Circle` button
  38058. */
  38059. /**
  38060. * Sets the value of the `Circle` button
  38061. */
  38062. buttonCircle: number;
  38063. /**
  38064. * Gets the value of the `Square` button
  38065. */
  38066. /**
  38067. * Sets the value of the `Square` button
  38068. */
  38069. buttonSquare: number;
  38070. /**
  38071. * Gets the value of the `Triangle` button
  38072. */
  38073. /**
  38074. * Sets the value of the `Triangle` button
  38075. */
  38076. buttonTriangle: number;
  38077. /**
  38078. * Gets the value of the `Options` button
  38079. */
  38080. /**
  38081. * Sets the value of the `Options` button
  38082. */
  38083. buttonOptions: number;
  38084. /**
  38085. * Gets the value of the `Share` button
  38086. */
  38087. /**
  38088. * Sets the value of the `Share` button
  38089. */
  38090. buttonShare: number;
  38091. /**
  38092. * Gets the value of the `L1` button
  38093. */
  38094. /**
  38095. * Sets the value of the `L1` button
  38096. */
  38097. buttonL1: number;
  38098. /**
  38099. * Gets the value of the `R1` button
  38100. */
  38101. /**
  38102. * Sets the value of the `R1` button
  38103. */
  38104. buttonR1: number;
  38105. /**
  38106. * Gets the value of the Left joystick
  38107. */
  38108. /**
  38109. * Sets the value of the Left joystick
  38110. */
  38111. buttonLeftStick: number;
  38112. /**
  38113. * Gets the value of the Right joystick
  38114. */
  38115. /**
  38116. * Sets the value of the Right joystick
  38117. */
  38118. buttonRightStick: number;
  38119. /**
  38120. * Gets the value of D-pad up
  38121. */
  38122. /**
  38123. * Sets the value of D-pad up
  38124. */
  38125. dPadUp: number;
  38126. /**
  38127. * Gets the value of D-pad down
  38128. */
  38129. /**
  38130. * Sets the value of D-pad down
  38131. */
  38132. dPadDown: number;
  38133. /**
  38134. * Gets the value of D-pad left
  38135. */
  38136. /**
  38137. * Sets the value of D-pad left
  38138. */
  38139. dPadLeft: number;
  38140. /**
  38141. * Gets the value of D-pad right
  38142. */
  38143. /**
  38144. * Sets the value of D-pad right
  38145. */
  38146. dPadRight: number;
  38147. /**
  38148. * Force the gamepad to synchronize with device values
  38149. */
  38150. update(): void;
  38151. /**
  38152. * Disposes the gamepad
  38153. */
  38154. dispose(): void;
  38155. }
  38156. }
  38157. declare module BABYLON {
  38158. /**
  38159. * Manager for handling gamepads
  38160. */
  38161. export class GamepadManager {
  38162. private _scene?;
  38163. private _babylonGamepads;
  38164. private _oneGamepadConnected;
  38165. /** @hidden */ private _isMonitoring: boolean;
  38166. private _gamepadEventSupported;
  38167. private _gamepadSupport;
  38168. /**
  38169. * observable to be triggered when the gamepad controller has been connected
  38170. */
  38171. onGamepadConnectedObservable: Observable<Gamepad>;
  38172. /**
  38173. * observable to be triggered when the gamepad controller has been disconnected
  38174. */
  38175. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38176. private _onGamepadConnectedEvent;
  38177. private _onGamepadDisconnectedEvent;
  38178. /**
  38179. * Initializes the gamepad manager
  38180. * @param _scene BabylonJS scene
  38181. */
  38182. constructor(_scene?: Scene | undefined);
  38183. /**
  38184. * The gamepads in the game pad manager
  38185. */
  38186. readonly gamepads: Gamepad[];
  38187. /**
  38188. * Get the gamepad controllers based on type
  38189. * @param type The type of gamepad controller
  38190. * @returns Nullable gamepad
  38191. */
  38192. getGamepadByType(type?: number): Nullable<Gamepad>;
  38193. /**
  38194. * Disposes the gamepad manager
  38195. */
  38196. dispose(): void;
  38197. private _addNewGamepad;
  38198. private _startMonitoringGamepads;
  38199. private _stopMonitoringGamepads;
  38200. /** @hidden */ private _checkGamepadsStatus(): void;
  38201. private _updateGamepadObjects;
  38202. }
  38203. }
  38204. declare module BABYLON {
  38205. interface Scene {
  38206. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38207. /**
  38208. * Gets the gamepad manager associated with the scene
  38209. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38210. */
  38211. gamepadManager: GamepadManager;
  38212. }
  38213. /**
  38214. * Interface representing a free camera inputs manager
  38215. */
  38216. interface FreeCameraInputsManager {
  38217. /**
  38218. * Adds gamepad input support to the FreeCameraInputsManager.
  38219. * @returns the FreeCameraInputsManager
  38220. */
  38221. addGamepad(): FreeCameraInputsManager;
  38222. }
  38223. /**
  38224. * Interface representing an arc rotate camera inputs manager
  38225. */
  38226. interface ArcRotateCameraInputsManager {
  38227. /**
  38228. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38229. * @returns the camera inputs manager
  38230. */
  38231. addGamepad(): ArcRotateCameraInputsManager;
  38232. }
  38233. /**
  38234. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38235. */
  38236. export class GamepadSystemSceneComponent implements ISceneComponent {
  38237. /**
  38238. * The component name helpfull to identify the component in the list of scene components.
  38239. */
  38240. readonly name: string;
  38241. /**
  38242. * The scene the component belongs to.
  38243. */
  38244. scene: Scene;
  38245. /**
  38246. * Creates a new instance of the component for the given scene
  38247. * @param scene Defines the scene to register the component in
  38248. */
  38249. constructor(scene: Scene);
  38250. /**
  38251. * Registers the component in a given scene
  38252. */
  38253. register(): void;
  38254. /**
  38255. * Rebuilds the elements related to this component in case of
  38256. * context lost for instance.
  38257. */
  38258. rebuild(): void;
  38259. /**
  38260. * Disposes the component and the associated ressources
  38261. */
  38262. dispose(): void;
  38263. private _beforeCameraUpdate;
  38264. }
  38265. }
  38266. declare module BABYLON {
  38267. /**
  38268. * 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,
  38269. * which still works and will still be found in many Playgrounds.
  38270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38271. */
  38272. export class UniversalCamera extends TouchCamera {
  38273. /**
  38274. * Defines the gamepad rotation sensiblity.
  38275. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38276. */
  38277. gamepadAngularSensibility: number;
  38278. /**
  38279. * Defines the gamepad move sensiblity.
  38280. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38281. */
  38282. gamepadMoveSensibility: number;
  38283. /**
  38284. * 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,
  38285. * which still works and will still be found in many Playgrounds.
  38286. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38287. * @param name Define the name of the camera in the scene
  38288. * @param position Define the start position of the camera in the scene
  38289. * @param scene Define the scene the camera belongs to
  38290. */
  38291. constructor(name: string, position: Vector3, scene: Scene);
  38292. /**
  38293. * Gets the current object class name.
  38294. * @return the class name
  38295. */
  38296. getClassName(): string;
  38297. }
  38298. }
  38299. declare module BABYLON {
  38300. /**
  38301. * This represents a FPS type of camera. This is only here for back compat purpose.
  38302. * Please use the UniversalCamera instead as both are identical.
  38303. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38304. */
  38305. export class GamepadCamera extends UniversalCamera {
  38306. /**
  38307. * Instantiates a new Gamepad Camera
  38308. * This represents a FPS type of camera. This is only here for back compat purpose.
  38309. * Please use the UniversalCamera instead as both are identical.
  38310. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38311. * @param name Define the name of the camera in the scene
  38312. * @param position Define the start position of the camera in the scene
  38313. * @param scene Define the scene the camera belongs to
  38314. */
  38315. constructor(name: string, position: Vector3, scene: Scene);
  38316. /**
  38317. * Gets the current object class name.
  38318. * @return the class name
  38319. */
  38320. getClassName(): string;
  38321. }
  38322. }
  38323. declare module BABYLON {
  38324. /** @hidden */
  38325. export var passPixelShader: {
  38326. name: string;
  38327. shader: string;
  38328. };
  38329. }
  38330. declare module BABYLON {
  38331. /** @hidden */
  38332. export var passCubePixelShader: {
  38333. name: string;
  38334. shader: string;
  38335. };
  38336. }
  38337. declare module BABYLON {
  38338. /**
  38339. * PassPostProcess which produces an output the same as it's input
  38340. */
  38341. export class PassPostProcess extends PostProcess {
  38342. /**
  38343. * Creates the PassPostProcess
  38344. * @param name The name of the effect.
  38345. * @param options The required width/height ratio to downsize to before computing the render pass.
  38346. * @param camera The camera to apply the render pass to.
  38347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38348. * @param engine The engine which the post process will be applied. (default: current engine)
  38349. * @param reusable If the post process can be reused on the same frame. (default: false)
  38350. * @param textureType The type of texture to be used when performing the post processing.
  38351. * @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)
  38352. */
  38353. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38354. }
  38355. /**
  38356. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38357. */
  38358. export class PassCubePostProcess extends PostProcess {
  38359. private _face;
  38360. /**
  38361. * Gets or sets the cube face to display.
  38362. * * 0 is +X
  38363. * * 1 is -X
  38364. * * 2 is +Y
  38365. * * 3 is -Y
  38366. * * 4 is +Z
  38367. * * 5 is -Z
  38368. */
  38369. face: number;
  38370. /**
  38371. * Creates the PassCubePostProcess
  38372. * @param name The name of the effect.
  38373. * @param options The required width/height ratio to downsize to before computing the render pass.
  38374. * @param camera The camera to apply the render pass to.
  38375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38376. * @param engine The engine which the post process will be applied. (default: current engine)
  38377. * @param reusable If the post process can be reused on the same frame. (default: false)
  38378. * @param textureType The type of texture to be used when performing the post processing.
  38379. * @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)
  38380. */
  38381. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38382. }
  38383. }
  38384. declare module BABYLON {
  38385. /** @hidden */
  38386. export var anaglyphPixelShader: {
  38387. name: string;
  38388. shader: string;
  38389. };
  38390. }
  38391. declare module BABYLON {
  38392. /**
  38393. * Postprocess used to generate anaglyphic rendering
  38394. */
  38395. export class AnaglyphPostProcess extends PostProcess {
  38396. private _passedProcess;
  38397. /**
  38398. * Creates a new AnaglyphPostProcess
  38399. * @param name defines postprocess name
  38400. * @param options defines creation options or target ratio scale
  38401. * @param rigCameras defines cameras using this postprocess
  38402. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38403. * @param engine defines hosting engine
  38404. * @param reusable defines if the postprocess will be reused multiple times per frame
  38405. */
  38406. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38407. }
  38408. }
  38409. declare module BABYLON {
  38410. /**
  38411. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38412. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38413. */
  38414. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38415. /**
  38416. * Creates a new AnaglyphArcRotateCamera
  38417. * @param name defines camera name
  38418. * @param alpha defines alpha angle (in radians)
  38419. * @param beta defines beta angle (in radians)
  38420. * @param radius defines radius
  38421. * @param target defines camera target
  38422. * @param interaxialDistance defines distance between each color axis
  38423. * @param scene defines the hosting scene
  38424. */
  38425. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38426. /**
  38427. * Gets camera class name
  38428. * @returns AnaglyphArcRotateCamera
  38429. */
  38430. getClassName(): string;
  38431. }
  38432. }
  38433. declare module BABYLON {
  38434. /**
  38435. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38436. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38437. */
  38438. export class AnaglyphFreeCamera extends FreeCamera {
  38439. /**
  38440. * Creates a new AnaglyphFreeCamera
  38441. * @param name defines camera name
  38442. * @param position defines initial position
  38443. * @param interaxialDistance defines distance between each color axis
  38444. * @param scene defines the hosting scene
  38445. */
  38446. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38447. /**
  38448. * Gets camera class name
  38449. * @returns AnaglyphFreeCamera
  38450. */
  38451. getClassName(): string;
  38452. }
  38453. }
  38454. declare module BABYLON {
  38455. /**
  38456. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38458. */
  38459. export class AnaglyphGamepadCamera extends GamepadCamera {
  38460. /**
  38461. * Creates a new AnaglyphGamepadCamera
  38462. * @param name defines camera name
  38463. * @param position defines initial position
  38464. * @param interaxialDistance defines distance between each color axis
  38465. * @param scene defines the hosting scene
  38466. */
  38467. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38468. /**
  38469. * Gets camera class name
  38470. * @returns AnaglyphGamepadCamera
  38471. */
  38472. getClassName(): string;
  38473. }
  38474. }
  38475. declare module BABYLON {
  38476. /**
  38477. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38478. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38479. */
  38480. export class AnaglyphUniversalCamera extends UniversalCamera {
  38481. /**
  38482. * Creates a new AnaglyphUniversalCamera
  38483. * @param name defines camera name
  38484. * @param position defines initial position
  38485. * @param interaxialDistance defines distance between each color axis
  38486. * @param scene defines the hosting scene
  38487. */
  38488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38489. /**
  38490. * Gets camera class name
  38491. * @returns AnaglyphUniversalCamera
  38492. */
  38493. getClassName(): string;
  38494. }
  38495. }
  38496. declare module BABYLON {
  38497. /** @hidden */
  38498. export var stereoscopicInterlacePixelShader: {
  38499. name: string;
  38500. shader: string;
  38501. };
  38502. }
  38503. declare module BABYLON {
  38504. /**
  38505. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38506. */
  38507. export class StereoscopicInterlacePostProcess extends PostProcess {
  38508. private _stepSize;
  38509. private _passedProcess;
  38510. /**
  38511. * Initializes a StereoscopicInterlacePostProcess
  38512. * @param name The name of the effect.
  38513. * @param rigCameras The rig cameras to be appled to the post process
  38514. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38516. * @param engine The engine which the post process will be applied. (default: current engine)
  38517. * @param reusable If the post process can be reused on the same frame. (default: false)
  38518. */
  38519. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38520. }
  38521. }
  38522. declare module BABYLON {
  38523. /**
  38524. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38525. * @see http://doc.babylonjs.com/features/cameras
  38526. */
  38527. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38528. /**
  38529. * Creates a new StereoscopicArcRotateCamera
  38530. * @param name defines camera name
  38531. * @param alpha defines alpha angle (in radians)
  38532. * @param beta defines beta angle (in radians)
  38533. * @param radius defines radius
  38534. * @param target defines camera target
  38535. * @param interaxialDistance defines distance between each color axis
  38536. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38537. * @param scene defines the hosting scene
  38538. */
  38539. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38540. /**
  38541. * Gets camera class name
  38542. * @returns StereoscopicArcRotateCamera
  38543. */
  38544. getClassName(): string;
  38545. }
  38546. }
  38547. declare module BABYLON {
  38548. /**
  38549. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38550. * @see http://doc.babylonjs.com/features/cameras
  38551. */
  38552. export class StereoscopicFreeCamera extends FreeCamera {
  38553. /**
  38554. * Creates a new StereoscopicFreeCamera
  38555. * @param name defines camera name
  38556. * @param position defines initial position
  38557. * @param interaxialDistance defines distance between each color axis
  38558. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38559. * @param scene defines the hosting scene
  38560. */
  38561. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38562. /**
  38563. * Gets camera class name
  38564. * @returns StereoscopicFreeCamera
  38565. */
  38566. getClassName(): string;
  38567. }
  38568. }
  38569. declare module BABYLON {
  38570. /**
  38571. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38572. * @see http://doc.babylonjs.com/features/cameras
  38573. */
  38574. export class StereoscopicGamepadCamera extends GamepadCamera {
  38575. /**
  38576. * Creates a new StereoscopicGamepadCamera
  38577. * @param name defines camera name
  38578. * @param position defines initial position
  38579. * @param interaxialDistance defines distance between each color axis
  38580. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38581. * @param scene defines the hosting scene
  38582. */
  38583. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38584. /**
  38585. * Gets camera class name
  38586. * @returns StereoscopicGamepadCamera
  38587. */
  38588. getClassName(): string;
  38589. }
  38590. }
  38591. declare module BABYLON {
  38592. /**
  38593. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38594. * @see http://doc.babylonjs.com/features/cameras
  38595. */
  38596. export class StereoscopicUniversalCamera extends UniversalCamera {
  38597. /**
  38598. * Creates a new StereoscopicUniversalCamera
  38599. * @param name defines camera name
  38600. * @param position defines initial position
  38601. * @param interaxialDistance defines distance between each color axis
  38602. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38603. * @param scene defines the hosting scene
  38604. */
  38605. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38606. /**
  38607. * Gets camera class name
  38608. * @returns StereoscopicUniversalCamera
  38609. */
  38610. getClassName(): string;
  38611. }
  38612. }
  38613. declare module BABYLON {
  38614. /**
  38615. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38616. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38617. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38618. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38619. */
  38620. export class VirtualJoysticksCamera extends FreeCamera {
  38621. /**
  38622. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38623. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38624. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38625. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38626. * @param name Define the name of the camera in the scene
  38627. * @param position Define the start position of the camera in the scene
  38628. * @param scene Define the scene the camera belongs to
  38629. */
  38630. constructor(name: string, position: Vector3, scene: Scene);
  38631. /**
  38632. * Gets the current object class name.
  38633. * @return the class name
  38634. */
  38635. getClassName(): string;
  38636. }
  38637. }
  38638. declare module BABYLON {
  38639. /**
  38640. * This represents all the required metrics to create a VR camera.
  38641. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38642. */
  38643. export class VRCameraMetrics {
  38644. /**
  38645. * Define the horizontal resolution off the screen.
  38646. */
  38647. hResolution: number;
  38648. /**
  38649. * Define the vertical resolution off the screen.
  38650. */
  38651. vResolution: number;
  38652. /**
  38653. * Define the horizontal screen size.
  38654. */
  38655. hScreenSize: number;
  38656. /**
  38657. * Define the vertical screen size.
  38658. */
  38659. vScreenSize: number;
  38660. /**
  38661. * Define the vertical screen center position.
  38662. */
  38663. vScreenCenter: number;
  38664. /**
  38665. * Define the distance of the eyes to the screen.
  38666. */
  38667. eyeToScreenDistance: number;
  38668. /**
  38669. * Define the distance between both lenses
  38670. */
  38671. lensSeparationDistance: number;
  38672. /**
  38673. * Define the distance between both viewer's eyes.
  38674. */
  38675. interpupillaryDistance: number;
  38676. /**
  38677. * Define the distortion factor of the VR postprocess.
  38678. * Please, touch with care.
  38679. */
  38680. distortionK: number[];
  38681. /**
  38682. * Define the chromatic aberration correction factors for the VR post process.
  38683. */
  38684. chromaAbCorrection: number[];
  38685. /**
  38686. * Define the scale factor of the post process.
  38687. * The smaller the better but the slower.
  38688. */
  38689. postProcessScaleFactor: number;
  38690. /**
  38691. * Define an offset for the lens center.
  38692. */
  38693. lensCenterOffset: number;
  38694. /**
  38695. * Define if the current vr camera should compensate the distortion of the lense or not.
  38696. */
  38697. compensateDistortion: boolean;
  38698. /**
  38699. * Defines if multiview should be enabled when rendering (Default: false)
  38700. */
  38701. multiviewEnabled: boolean;
  38702. /**
  38703. * Gets the rendering aspect ratio based on the provided resolutions.
  38704. */
  38705. readonly aspectRatio: number;
  38706. /**
  38707. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38708. */
  38709. readonly aspectRatioFov: number;
  38710. /**
  38711. * @hidden
  38712. */
  38713. readonly leftHMatrix: Matrix;
  38714. /**
  38715. * @hidden
  38716. */
  38717. readonly rightHMatrix: Matrix;
  38718. /**
  38719. * @hidden
  38720. */
  38721. readonly leftPreViewMatrix: Matrix;
  38722. /**
  38723. * @hidden
  38724. */
  38725. readonly rightPreViewMatrix: Matrix;
  38726. /**
  38727. * Get the default VRMetrics based on the most generic setup.
  38728. * @returns the default vr metrics
  38729. */
  38730. static GetDefault(): VRCameraMetrics;
  38731. }
  38732. }
  38733. declare module BABYLON {
  38734. /** @hidden */
  38735. export var vrDistortionCorrectionPixelShader: {
  38736. name: string;
  38737. shader: string;
  38738. };
  38739. }
  38740. declare module BABYLON {
  38741. /**
  38742. * VRDistortionCorrectionPostProcess used for mobile VR
  38743. */
  38744. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38745. private _isRightEye;
  38746. private _distortionFactors;
  38747. private _postProcessScaleFactor;
  38748. private _lensCenterOffset;
  38749. private _scaleIn;
  38750. private _scaleFactor;
  38751. private _lensCenter;
  38752. /**
  38753. * Initializes the VRDistortionCorrectionPostProcess
  38754. * @param name The name of the effect.
  38755. * @param camera The camera to apply the render pass to.
  38756. * @param isRightEye If this is for the right eye distortion
  38757. * @param vrMetrics All the required metrics for the VR camera
  38758. */
  38759. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38760. }
  38761. }
  38762. declare module BABYLON {
  38763. /**
  38764. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38765. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38766. */
  38767. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38768. /**
  38769. * Creates a new VRDeviceOrientationArcRotateCamera
  38770. * @param name defines camera name
  38771. * @param alpha defines the camera rotation along the logitudinal axis
  38772. * @param beta defines the camera rotation along the latitudinal axis
  38773. * @param radius defines the camera distance from its target
  38774. * @param target defines the camera target
  38775. * @param scene defines the scene the camera belongs to
  38776. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38777. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38778. */
  38779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38780. /**
  38781. * Gets camera class name
  38782. * @returns VRDeviceOrientationArcRotateCamera
  38783. */
  38784. getClassName(): string;
  38785. }
  38786. }
  38787. declare module BABYLON {
  38788. /**
  38789. * Camera used to simulate VR rendering (based on FreeCamera)
  38790. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38791. */
  38792. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38793. /**
  38794. * Creates a new VRDeviceOrientationFreeCamera
  38795. * @param name defines camera name
  38796. * @param position defines the start position of the camera
  38797. * @param scene defines the scene the camera belongs to
  38798. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38799. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38800. */
  38801. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38802. /**
  38803. * Gets camera class name
  38804. * @returns VRDeviceOrientationFreeCamera
  38805. */
  38806. getClassName(): string;
  38807. }
  38808. }
  38809. declare module BABYLON {
  38810. /**
  38811. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38812. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38813. */
  38814. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38815. /**
  38816. * Creates a new VRDeviceOrientationGamepadCamera
  38817. * @param name defines camera name
  38818. * @param position defines the start position of the camera
  38819. * @param scene defines the scene the camera belongs to
  38820. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38821. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38822. */
  38823. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38824. /**
  38825. * Gets camera class name
  38826. * @returns VRDeviceOrientationGamepadCamera
  38827. */
  38828. getClassName(): string;
  38829. }
  38830. }
  38831. declare module BABYLON {
  38832. /**
  38833. * Base class of materials working in push mode in babylon JS
  38834. * @hidden
  38835. */
  38836. export class PushMaterial extends Material {
  38837. protected _activeEffect: Effect;
  38838. protected _normalMatrix: Matrix;
  38839. /**
  38840. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38841. * This means that the material can keep using a previous shader while a new one is being compiled.
  38842. * This is mostly used when shader parallel compilation is supported (true by default)
  38843. */
  38844. allowShaderHotSwapping: boolean;
  38845. constructor(name: string, scene: Scene);
  38846. getEffect(): Effect;
  38847. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38848. /**
  38849. * Binds the given world matrix to the active effect
  38850. *
  38851. * @param world the matrix to bind
  38852. */
  38853. bindOnlyWorldMatrix(world: Matrix): void;
  38854. /**
  38855. * Binds the given normal matrix to the active effect
  38856. *
  38857. * @param normalMatrix the matrix to bind
  38858. */
  38859. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38860. bind(world: Matrix, mesh?: Mesh): void;
  38861. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38862. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38863. }
  38864. }
  38865. declare module BABYLON {
  38866. /**
  38867. * This groups all the flags used to control the materials channel.
  38868. */
  38869. export class MaterialFlags {
  38870. private static _DiffuseTextureEnabled;
  38871. /**
  38872. * Are diffuse textures enabled in the application.
  38873. */
  38874. static DiffuseTextureEnabled: boolean;
  38875. private static _AmbientTextureEnabled;
  38876. /**
  38877. * Are ambient textures enabled in the application.
  38878. */
  38879. static AmbientTextureEnabled: boolean;
  38880. private static _OpacityTextureEnabled;
  38881. /**
  38882. * Are opacity textures enabled in the application.
  38883. */
  38884. static OpacityTextureEnabled: boolean;
  38885. private static _ReflectionTextureEnabled;
  38886. /**
  38887. * Are reflection textures enabled in the application.
  38888. */
  38889. static ReflectionTextureEnabled: boolean;
  38890. private static _EmissiveTextureEnabled;
  38891. /**
  38892. * Are emissive textures enabled in the application.
  38893. */
  38894. static EmissiveTextureEnabled: boolean;
  38895. private static _SpecularTextureEnabled;
  38896. /**
  38897. * Are specular textures enabled in the application.
  38898. */
  38899. static SpecularTextureEnabled: boolean;
  38900. private static _BumpTextureEnabled;
  38901. /**
  38902. * Are bump textures enabled in the application.
  38903. */
  38904. static BumpTextureEnabled: boolean;
  38905. private static _LightmapTextureEnabled;
  38906. /**
  38907. * Are lightmap textures enabled in the application.
  38908. */
  38909. static LightmapTextureEnabled: boolean;
  38910. private static _RefractionTextureEnabled;
  38911. /**
  38912. * Are refraction textures enabled in the application.
  38913. */
  38914. static RefractionTextureEnabled: boolean;
  38915. private static _ColorGradingTextureEnabled;
  38916. /**
  38917. * Are color grading textures enabled in the application.
  38918. */
  38919. static ColorGradingTextureEnabled: boolean;
  38920. private static _FresnelEnabled;
  38921. /**
  38922. * Are fresnels enabled in the application.
  38923. */
  38924. static FresnelEnabled: boolean;
  38925. private static _ClearCoatTextureEnabled;
  38926. /**
  38927. * Are clear coat textures enabled in the application.
  38928. */
  38929. static ClearCoatTextureEnabled: boolean;
  38930. private static _ClearCoatBumpTextureEnabled;
  38931. /**
  38932. * Are clear coat bump textures enabled in the application.
  38933. */
  38934. static ClearCoatBumpTextureEnabled: boolean;
  38935. private static _ClearCoatTintTextureEnabled;
  38936. /**
  38937. * Are clear coat tint textures enabled in the application.
  38938. */
  38939. static ClearCoatTintTextureEnabled: boolean;
  38940. private static _SheenTextureEnabled;
  38941. /**
  38942. * Are sheen textures enabled in the application.
  38943. */
  38944. static SheenTextureEnabled: boolean;
  38945. private static _AnisotropicTextureEnabled;
  38946. /**
  38947. * Are anisotropic textures enabled in the application.
  38948. */
  38949. static AnisotropicTextureEnabled: boolean;
  38950. private static _ThicknessTextureEnabled;
  38951. /**
  38952. * Are thickness textures enabled in the application.
  38953. */
  38954. static ThicknessTextureEnabled: boolean;
  38955. }
  38956. }
  38957. declare module BABYLON {
  38958. /** @hidden */
  38959. export var defaultFragmentDeclaration: {
  38960. name: string;
  38961. shader: string;
  38962. };
  38963. }
  38964. declare module BABYLON {
  38965. /** @hidden */
  38966. export var defaultUboDeclaration: {
  38967. name: string;
  38968. shader: string;
  38969. };
  38970. }
  38971. declare module BABYLON {
  38972. /** @hidden */
  38973. export var lightFragmentDeclaration: {
  38974. name: string;
  38975. shader: string;
  38976. };
  38977. }
  38978. declare module BABYLON {
  38979. /** @hidden */
  38980. export var lightUboDeclaration: {
  38981. name: string;
  38982. shader: string;
  38983. };
  38984. }
  38985. declare module BABYLON {
  38986. /** @hidden */
  38987. export var lightsFragmentFunctions: {
  38988. name: string;
  38989. shader: string;
  38990. };
  38991. }
  38992. declare module BABYLON {
  38993. /** @hidden */
  38994. export var shadowsFragmentFunctions: {
  38995. name: string;
  38996. shader: string;
  38997. };
  38998. }
  38999. declare module BABYLON {
  39000. /** @hidden */
  39001. export var fresnelFunction: {
  39002. name: string;
  39003. shader: string;
  39004. };
  39005. }
  39006. declare module BABYLON {
  39007. /** @hidden */
  39008. export var reflectionFunction: {
  39009. name: string;
  39010. shader: string;
  39011. };
  39012. }
  39013. declare module BABYLON {
  39014. /** @hidden */
  39015. export var bumpFragmentFunctions: {
  39016. name: string;
  39017. shader: string;
  39018. };
  39019. }
  39020. declare module BABYLON {
  39021. /** @hidden */
  39022. export var logDepthDeclaration: {
  39023. name: string;
  39024. shader: string;
  39025. };
  39026. }
  39027. declare module BABYLON {
  39028. /** @hidden */
  39029. export var bumpFragment: {
  39030. name: string;
  39031. shader: string;
  39032. };
  39033. }
  39034. declare module BABYLON {
  39035. /** @hidden */
  39036. export var depthPrePass: {
  39037. name: string;
  39038. shader: string;
  39039. };
  39040. }
  39041. declare module BABYLON {
  39042. /** @hidden */
  39043. export var lightFragment: {
  39044. name: string;
  39045. shader: string;
  39046. };
  39047. }
  39048. declare module BABYLON {
  39049. /** @hidden */
  39050. export var logDepthFragment: {
  39051. name: string;
  39052. shader: string;
  39053. };
  39054. }
  39055. declare module BABYLON {
  39056. /** @hidden */
  39057. export var defaultPixelShader: {
  39058. name: string;
  39059. shader: string;
  39060. };
  39061. }
  39062. declare module BABYLON {
  39063. /** @hidden */
  39064. export var defaultVertexDeclaration: {
  39065. name: string;
  39066. shader: string;
  39067. };
  39068. }
  39069. declare module BABYLON {
  39070. /** @hidden */
  39071. export var bumpVertexDeclaration: {
  39072. name: string;
  39073. shader: string;
  39074. };
  39075. }
  39076. declare module BABYLON {
  39077. /** @hidden */
  39078. export var bumpVertex: {
  39079. name: string;
  39080. shader: string;
  39081. };
  39082. }
  39083. declare module BABYLON {
  39084. /** @hidden */
  39085. export var fogVertex: {
  39086. name: string;
  39087. shader: string;
  39088. };
  39089. }
  39090. declare module BABYLON {
  39091. /** @hidden */
  39092. export var shadowsVertex: {
  39093. name: string;
  39094. shader: string;
  39095. };
  39096. }
  39097. declare module BABYLON {
  39098. /** @hidden */
  39099. export var pointCloudVertex: {
  39100. name: string;
  39101. shader: string;
  39102. };
  39103. }
  39104. declare module BABYLON {
  39105. /** @hidden */
  39106. export var logDepthVertex: {
  39107. name: string;
  39108. shader: string;
  39109. };
  39110. }
  39111. declare module BABYLON {
  39112. /** @hidden */
  39113. export var defaultVertexShader: {
  39114. name: string;
  39115. shader: string;
  39116. };
  39117. }
  39118. declare module BABYLON {
  39119. /** @hidden */
  39120. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39121. MAINUV1: boolean;
  39122. MAINUV2: boolean;
  39123. DIFFUSE: boolean;
  39124. DIFFUSEDIRECTUV: number;
  39125. AMBIENT: boolean;
  39126. AMBIENTDIRECTUV: number;
  39127. OPACITY: boolean;
  39128. OPACITYDIRECTUV: number;
  39129. OPACITYRGB: boolean;
  39130. REFLECTION: boolean;
  39131. EMISSIVE: boolean;
  39132. EMISSIVEDIRECTUV: number;
  39133. SPECULAR: boolean;
  39134. SPECULARDIRECTUV: number;
  39135. BUMP: boolean;
  39136. BUMPDIRECTUV: number;
  39137. PARALLAX: boolean;
  39138. PARALLAXOCCLUSION: boolean;
  39139. SPECULAROVERALPHA: boolean;
  39140. CLIPPLANE: boolean;
  39141. CLIPPLANE2: boolean;
  39142. CLIPPLANE3: boolean;
  39143. CLIPPLANE4: boolean;
  39144. ALPHATEST: boolean;
  39145. DEPTHPREPASS: boolean;
  39146. ALPHAFROMDIFFUSE: boolean;
  39147. POINTSIZE: boolean;
  39148. FOG: boolean;
  39149. SPECULARTERM: boolean;
  39150. DIFFUSEFRESNEL: boolean;
  39151. OPACITYFRESNEL: boolean;
  39152. REFLECTIONFRESNEL: boolean;
  39153. REFRACTIONFRESNEL: boolean;
  39154. EMISSIVEFRESNEL: boolean;
  39155. FRESNEL: boolean;
  39156. NORMAL: boolean;
  39157. UV1: boolean;
  39158. UV2: boolean;
  39159. VERTEXCOLOR: boolean;
  39160. VERTEXALPHA: boolean;
  39161. NUM_BONE_INFLUENCERS: number;
  39162. BonesPerMesh: number;
  39163. BONETEXTURE: boolean;
  39164. INSTANCES: boolean;
  39165. GLOSSINESS: boolean;
  39166. ROUGHNESS: boolean;
  39167. EMISSIVEASILLUMINATION: boolean;
  39168. LINKEMISSIVEWITHDIFFUSE: boolean;
  39169. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39170. LIGHTMAP: boolean;
  39171. LIGHTMAPDIRECTUV: number;
  39172. OBJECTSPACE_NORMALMAP: boolean;
  39173. USELIGHTMAPASSHADOWMAP: boolean;
  39174. REFLECTIONMAP_3D: boolean;
  39175. REFLECTIONMAP_SPHERICAL: boolean;
  39176. REFLECTIONMAP_PLANAR: boolean;
  39177. REFLECTIONMAP_CUBIC: boolean;
  39178. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39179. REFLECTIONMAP_PROJECTION: boolean;
  39180. REFLECTIONMAP_SKYBOX: boolean;
  39181. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39182. REFLECTIONMAP_EXPLICIT: boolean;
  39183. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39184. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39185. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39186. INVERTCUBICMAP: boolean;
  39187. LOGARITHMICDEPTH: boolean;
  39188. REFRACTION: boolean;
  39189. REFRACTIONMAP_3D: boolean;
  39190. REFLECTIONOVERALPHA: boolean;
  39191. TWOSIDEDLIGHTING: boolean;
  39192. SHADOWFLOAT: boolean;
  39193. MORPHTARGETS: boolean;
  39194. MORPHTARGETS_NORMAL: boolean;
  39195. MORPHTARGETS_TANGENT: boolean;
  39196. MORPHTARGETS_UV: boolean;
  39197. NUM_MORPH_INFLUENCERS: number;
  39198. NONUNIFORMSCALING: boolean;
  39199. PREMULTIPLYALPHA: boolean;
  39200. IMAGEPROCESSING: boolean;
  39201. VIGNETTE: boolean;
  39202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39203. VIGNETTEBLENDMODEOPAQUE: boolean;
  39204. TONEMAPPING: boolean;
  39205. TONEMAPPING_ACES: boolean;
  39206. CONTRAST: boolean;
  39207. COLORCURVES: boolean;
  39208. COLORGRADING: boolean;
  39209. COLORGRADING3D: boolean;
  39210. SAMPLER3DGREENDEPTH: boolean;
  39211. SAMPLER3DBGRMAP: boolean;
  39212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39213. MULTIVIEW: boolean;
  39214. /**
  39215. * If the reflection texture on this material is in linear color space
  39216. * @hidden
  39217. */
  39218. IS_REFLECTION_LINEAR: boolean;
  39219. /**
  39220. * If the refraction texture on this material is in linear color space
  39221. * @hidden
  39222. */
  39223. IS_REFRACTION_LINEAR: boolean;
  39224. EXPOSURE: boolean;
  39225. constructor();
  39226. setReflectionMode(modeToEnable: string): void;
  39227. }
  39228. /**
  39229. * This is the default material used in Babylon. It is the best trade off between quality
  39230. * and performances.
  39231. * @see http://doc.babylonjs.com/babylon101/materials
  39232. */
  39233. export class StandardMaterial extends PushMaterial {
  39234. private _diffuseTexture;
  39235. /**
  39236. * The basic texture of the material as viewed under a light.
  39237. */
  39238. diffuseTexture: Nullable<BaseTexture>;
  39239. private _ambientTexture;
  39240. /**
  39241. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39242. */
  39243. ambientTexture: Nullable<BaseTexture>;
  39244. private _opacityTexture;
  39245. /**
  39246. * Define the transparency of the material from a texture.
  39247. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39248. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39249. */
  39250. opacityTexture: Nullable<BaseTexture>;
  39251. private _reflectionTexture;
  39252. /**
  39253. * Define the texture used to display the reflection.
  39254. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39255. */
  39256. reflectionTexture: Nullable<BaseTexture>;
  39257. private _emissiveTexture;
  39258. /**
  39259. * Define texture of the material as if self lit.
  39260. * This will be mixed in the final result even in the absence of light.
  39261. */
  39262. emissiveTexture: Nullable<BaseTexture>;
  39263. private _specularTexture;
  39264. /**
  39265. * Define how the color and intensity of the highlight given by the light in the material.
  39266. */
  39267. specularTexture: Nullable<BaseTexture>;
  39268. private _bumpTexture;
  39269. /**
  39270. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39271. * 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.
  39272. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39273. */
  39274. bumpTexture: Nullable<BaseTexture>;
  39275. private _lightmapTexture;
  39276. /**
  39277. * Complex lighting can be computationally expensive to compute at runtime.
  39278. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39279. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39280. */
  39281. lightmapTexture: Nullable<BaseTexture>;
  39282. private _refractionTexture;
  39283. /**
  39284. * Define the texture used to display the refraction.
  39285. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39286. */
  39287. refractionTexture: Nullable<BaseTexture>;
  39288. /**
  39289. * The color of the material lit by the environmental background lighting.
  39290. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39291. */
  39292. ambientColor: Color3;
  39293. /**
  39294. * The basic color of the material as viewed under a light.
  39295. */
  39296. diffuseColor: Color3;
  39297. /**
  39298. * Define how the color and intensity of the highlight given by the light in the material.
  39299. */
  39300. specularColor: Color3;
  39301. /**
  39302. * Define the color of the material as if self lit.
  39303. * This will be mixed in the final result even in the absence of light.
  39304. */
  39305. emissiveColor: Color3;
  39306. /**
  39307. * Defines how sharp are the highlights in the material.
  39308. * The bigger the value the sharper giving a more glossy feeling to the result.
  39309. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39310. */
  39311. specularPower: number;
  39312. private _useAlphaFromDiffuseTexture;
  39313. /**
  39314. * Does the transparency come from the diffuse texture alpha channel.
  39315. */
  39316. useAlphaFromDiffuseTexture: boolean;
  39317. private _useEmissiveAsIllumination;
  39318. /**
  39319. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39320. */
  39321. useEmissiveAsIllumination: boolean;
  39322. private _linkEmissiveWithDiffuse;
  39323. /**
  39324. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39325. * the emissive level when the final color is close to one.
  39326. */
  39327. linkEmissiveWithDiffuse: boolean;
  39328. private _useSpecularOverAlpha;
  39329. /**
  39330. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39331. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39332. */
  39333. useSpecularOverAlpha: boolean;
  39334. private _useReflectionOverAlpha;
  39335. /**
  39336. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39337. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39338. */
  39339. useReflectionOverAlpha: boolean;
  39340. private _disableLighting;
  39341. /**
  39342. * Does lights from the scene impacts this material.
  39343. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39344. */
  39345. disableLighting: boolean;
  39346. private _useObjectSpaceNormalMap;
  39347. /**
  39348. * Allows using an object space normal map (instead of tangent space).
  39349. */
  39350. useObjectSpaceNormalMap: boolean;
  39351. private _useParallax;
  39352. /**
  39353. * Is parallax enabled or not.
  39354. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39355. */
  39356. useParallax: boolean;
  39357. private _useParallaxOcclusion;
  39358. /**
  39359. * Is parallax occlusion enabled or not.
  39360. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39361. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39362. */
  39363. useParallaxOcclusion: boolean;
  39364. /**
  39365. * 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.
  39366. */
  39367. parallaxScaleBias: number;
  39368. private _roughness;
  39369. /**
  39370. * Helps to define how blurry the reflections should appears in the material.
  39371. */
  39372. roughness: number;
  39373. /**
  39374. * In case of refraction, define the value of the index of refraction.
  39375. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39376. */
  39377. indexOfRefraction: number;
  39378. /**
  39379. * Invert the refraction texture alongside the y axis.
  39380. * It can be useful with procedural textures or probe for instance.
  39381. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39382. */
  39383. invertRefractionY: boolean;
  39384. /**
  39385. * Defines the alpha limits in alpha test mode.
  39386. */
  39387. alphaCutOff: number;
  39388. private _useLightmapAsShadowmap;
  39389. /**
  39390. * In case of light mapping, define whether the map contains light or shadow informations.
  39391. */
  39392. useLightmapAsShadowmap: boolean;
  39393. private _diffuseFresnelParameters;
  39394. /**
  39395. * Define the diffuse fresnel parameters of the material.
  39396. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39397. */
  39398. diffuseFresnelParameters: FresnelParameters;
  39399. private _opacityFresnelParameters;
  39400. /**
  39401. * Define the opacity fresnel parameters of the material.
  39402. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39403. */
  39404. opacityFresnelParameters: FresnelParameters;
  39405. private _reflectionFresnelParameters;
  39406. /**
  39407. * Define the reflection fresnel parameters of the material.
  39408. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39409. */
  39410. reflectionFresnelParameters: FresnelParameters;
  39411. private _refractionFresnelParameters;
  39412. /**
  39413. * Define the refraction fresnel parameters of the material.
  39414. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39415. */
  39416. refractionFresnelParameters: FresnelParameters;
  39417. private _emissiveFresnelParameters;
  39418. /**
  39419. * Define the emissive fresnel parameters of the material.
  39420. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39421. */
  39422. emissiveFresnelParameters: FresnelParameters;
  39423. private _useReflectionFresnelFromSpecular;
  39424. /**
  39425. * If true automatically deducts the fresnels values from the material specularity.
  39426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39427. */
  39428. useReflectionFresnelFromSpecular: boolean;
  39429. private _useGlossinessFromSpecularMapAlpha;
  39430. /**
  39431. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39432. */
  39433. useGlossinessFromSpecularMapAlpha: boolean;
  39434. private _maxSimultaneousLights;
  39435. /**
  39436. * Defines the maximum number of lights that can be used in the material
  39437. */
  39438. maxSimultaneousLights: number;
  39439. private _invertNormalMapX;
  39440. /**
  39441. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39442. */
  39443. invertNormalMapX: boolean;
  39444. private _invertNormalMapY;
  39445. /**
  39446. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39447. */
  39448. invertNormalMapY: boolean;
  39449. private _twoSidedLighting;
  39450. /**
  39451. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39452. */
  39453. twoSidedLighting: boolean;
  39454. /**
  39455. * Default configuration related to image processing available in the standard Material.
  39456. */
  39457. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39458. /**
  39459. * Gets the image processing configuration used either in this material.
  39460. */
  39461. /**
  39462. * Sets the Default image processing configuration used either in the this material.
  39463. *
  39464. * If sets to null, the scene one is in use.
  39465. */
  39466. imageProcessingConfiguration: ImageProcessingConfiguration;
  39467. /**
  39468. * Keep track of the image processing observer to allow dispose and replace.
  39469. */
  39470. private _imageProcessingObserver;
  39471. /**
  39472. * Attaches a new image processing configuration to the Standard Material.
  39473. * @param configuration
  39474. */
  39475. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39476. /**
  39477. * Gets wether the color curves effect is enabled.
  39478. */
  39479. /**
  39480. * Sets wether the color curves effect is enabled.
  39481. */
  39482. cameraColorCurvesEnabled: boolean;
  39483. /**
  39484. * Gets wether the color grading effect is enabled.
  39485. */
  39486. /**
  39487. * Gets wether the color grading effect is enabled.
  39488. */
  39489. cameraColorGradingEnabled: boolean;
  39490. /**
  39491. * Gets wether tonemapping is enabled or not.
  39492. */
  39493. /**
  39494. * Sets wether tonemapping is enabled or not
  39495. */
  39496. cameraToneMappingEnabled: boolean;
  39497. /**
  39498. * The camera exposure used on this material.
  39499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39500. * This corresponds to a photographic exposure.
  39501. */
  39502. /**
  39503. * The camera exposure used on this material.
  39504. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39505. * This corresponds to a photographic exposure.
  39506. */
  39507. cameraExposure: number;
  39508. /**
  39509. * Gets The camera contrast used on this material.
  39510. */
  39511. /**
  39512. * Sets The camera contrast used on this material.
  39513. */
  39514. cameraContrast: number;
  39515. /**
  39516. * Gets the Color Grading 2D Lookup Texture.
  39517. */
  39518. /**
  39519. * Sets the Color Grading 2D Lookup Texture.
  39520. */
  39521. cameraColorGradingTexture: Nullable<BaseTexture>;
  39522. /**
  39523. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39524. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39525. * 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;
  39526. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39527. */
  39528. /**
  39529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39531. * 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;
  39532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39533. */
  39534. cameraColorCurves: Nullable<ColorCurves>;
  39535. /**
  39536. * Custom callback helping to override the default shader used in the material.
  39537. */
  39538. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39539. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39540. protected _worldViewProjectionMatrix: Matrix;
  39541. protected _globalAmbientColor: Color3;
  39542. protected _useLogarithmicDepth: boolean;
  39543. protected _rebuildInParallel: boolean;
  39544. /**
  39545. * Instantiates a new standard material.
  39546. * This is the default material used in Babylon. It is the best trade off between quality
  39547. * and performances.
  39548. * @see http://doc.babylonjs.com/babylon101/materials
  39549. * @param name Define the name of the material in the scene
  39550. * @param scene Define the scene the material belong to
  39551. */
  39552. constructor(name: string, scene: Scene);
  39553. /**
  39554. * Gets a boolean indicating that current material needs to register RTT
  39555. */
  39556. readonly hasRenderTargetTextures: boolean;
  39557. /**
  39558. * Gets the current class name of the material e.g. "StandardMaterial"
  39559. * Mainly use in serialization.
  39560. * @returns the class name
  39561. */
  39562. getClassName(): string;
  39563. /**
  39564. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39565. * You can try switching to logarithmic depth.
  39566. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39567. */
  39568. useLogarithmicDepth: boolean;
  39569. /**
  39570. * Specifies if the material will require alpha blending
  39571. * @returns a boolean specifying if alpha blending is needed
  39572. */
  39573. needAlphaBlending(): boolean;
  39574. /**
  39575. * Specifies if this material should be rendered in alpha test mode
  39576. * @returns a boolean specifying if an alpha test is needed.
  39577. */
  39578. needAlphaTesting(): boolean;
  39579. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39580. /**
  39581. * Get the texture used for alpha test purpose.
  39582. * @returns the diffuse texture in case of the standard material.
  39583. */
  39584. getAlphaTestTexture(): Nullable<BaseTexture>;
  39585. /**
  39586. * Get if the submesh is ready to be used and all its information available.
  39587. * Child classes can use it to update shaders
  39588. * @param mesh defines the mesh to check
  39589. * @param subMesh defines which submesh to check
  39590. * @param useInstances specifies that instances should be used
  39591. * @returns a boolean indicating that the submesh is ready or not
  39592. */
  39593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39594. /**
  39595. * Builds the material UBO layouts.
  39596. * Used internally during the effect preparation.
  39597. */
  39598. buildUniformLayout(): void;
  39599. /**
  39600. * Unbinds the material from the mesh
  39601. */
  39602. unbind(): void;
  39603. /**
  39604. * Binds the submesh to this material by preparing the effect and shader to draw
  39605. * @param world defines the world transformation matrix
  39606. * @param mesh defines the mesh containing the submesh
  39607. * @param subMesh defines the submesh to bind the material to
  39608. */
  39609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39610. /**
  39611. * Get the list of animatables in the material.
  39612. * @returns the list of animatables object used in the material
  39613. */
  39614. getAnimatables(): IAnimatable[];
  39615. /**
  39616. * Gets the active textures from the material
  39617. * @returns an array of textures
  39618. */
  39619. getActiveTextures(): BaseTexture[];
  39620. /**
  39621. * Specifies if the material uses a texture
  39622. * @param texture defines the texture to check against the material
  39623. * @returns a boolean specifying if the material uses the texture
  39624. */
  39625. hasTexture(texture: BaseTexture): boolean;
  39626. /**
  39627. * Disposes the material
  39628. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39629. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39630. */
  39631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39632. /**
  39633. * Makes a duplicate of the material, and gives it a new name
  39634. * @param name defines the new name for the duplicated material
  39635. * @returns the cloned material
  39636. */
  39637. clone(name: string): StandardMaterial;
  39638. /**
  39639. * Serializes this material in a JSON representation
  39640. * @returns the serialized material object
  39641. */
  39642. serialize(): any;
  39643. /**
  39644. * Creates a standard material from parsed material data
  39645. * @param source defines the JSON representation of the material
  39646. * @param scene defines the hosting scene
  39647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39648. * @returns a new standard material
  39649. */
  39650. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39651. /**
  39652. * Are diffuse textures enabled in the application.
  39653. */
  39654. static DiffuseTextureEnabled: boolean;
  39655. /**
  39656. * Are ambient textures enabled in the application.
  39657. */
  39658. static AmbientTextureEnabled: boolean;
  39659. /**
  39660. * Are opacity textures enabled in the application.
  39661. */
  39662. static OpacityTextureEnabled: boolean;
  39663. /**
  39664. * Are reflection textures enabled in the application.
  39665. */
  39666. static ReflectionTextureEnabled: boolean;
  39667. /**
  39668. * Are emissive textures enabled in the application.
  39669. */
  39670. static EmissiveTextureEnabled: boolean;
  39671. /**
  39672. * Are specular textures enabled in the application.
  39673. */
  39674. static SpecularTextureEnabled: boolean;
  39675. /**
  39676. * Are bump textures enabled in the application.
  39677. */
  39678. static BumpTextureEnabled: boolean;
  39679. /**
  39680. * Are lightmap textures enabled in the application.
  39681. */
  39682. static LightmapTextureEnabled: boolean;
  39683. /**
  39684. * Are refraction textures enabled in the application.
  39685. */
  39686. static RefractionTextureEnabled: boolean;
  39687. /**
  39688. * Are color grading textures enabled in the application.
  39689. */
  39690. static ColorGradingTextureEnabled: boolean;
  39691. /**
  39692. * Are fresnels enabled in the application.
  39693. */
  39694. static FresnelEnabled: boolean;
  39695. }
  39696. }
  39697. declare module BABYLON {
  39698. /**
  39699. * A class extending Texture allowing drawing on a texture
  39700. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39701. */
  39702. export class DynamicTexture extends Texture {
  39703. private _generateMipMaps;
  39704. private _canvas;
  39705. private _context;
  39706. private _engine;
  39707. /**
  39708. * Creates a DynamicTexture
  39709. * @param name defines the name of the texture
  39710. * @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
  39711. * @param scene defines the scene where you want the texture
  39712. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39713. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39714. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39715. */
  39716. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39717. /**
  39718. * Get the current class name of the texture useful for serialization or dynamic coding.
  39719. * @returns "DynamicTexture"
  39720. */
  39721. getClassName(): string;
  39722. /**
  39723. * Gets the current state of canRescale
  39724. */
  39725. readonly canRescale: boolean;
  39726. private _recreate;
  39727. /**
  39728. * Scales the texture
  39729. * @param ratio the scale factor to apply to both width and height
  39730. */
  39731. scale(ratio: number): void;
  39732. /**
  39733. * Resizes the texture
  39734. * @param width the new width
  39735. * @param height the new height
  39736. */
  39737. scaleTo(width: number, height: number): void;
  39738. /**
  39739. * Gets the context of the canvas used by the texture
  39740. * @returns the canvas context of the dynamic texture
  39741. */
  39742. getContext(): CanvasRenderingContext2D;
  39743. /**
  39744. * Clears the texture
  39745. */
  39746. clear(): void;
  39747. /**
  39748. * Updates the texture
  39749. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39750. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39751. */
  39752. update(invertY?: boolean, premulAlpha?: boolean): void;
  39753. /**
  39754. * Draws text onto the texture
  39755. * @param text defines the text to be drawn
  39756. * @param x defines the placement of the text from the left
  39757. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39758. * @param font defines the font to be used with font-style, font-size, font-name
  39759. * @param color defines the color used for the text
  39760. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39761. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39762. * @param update defines whether texture is immediately update (default is true)
  39763. */
  39764. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39765. /**
  39766. * Clones the texture
  39767. * @returns the clone of the texture.
  39768. */
  39769. clone(): DynamicTexture;
  39770. /**
  39771. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39772. * @returns a serialized dynamic texture object
  39773. */
  39774. serialize(): any;
  39775. /** @hidden */ private _rebuild(): void;
  39776. }
  39777. }
  39778. declare module BABYLON {
  39779. /** @hidden */
  39780. export var imageProcessingPixelShader: {
  39781. name: string;
  39782. shader: string;
  39783. };
  39784. }
  39785. declare module BABYLON {
  39786. /**
  39787. * ImageProcessingPostProcess
  39788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39789. */
  39790. export class ImageProcessingPostProcess extends PostProcess {
  39791. /**
  39792. * Default configuration related to image processing available in the PBR Material.
  39793. */
  39794. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39795. /**
  39796. * Gets the image processing configuration used either in this material.
  39797. */
  39798. /**
  39799. * Sets the Default image processing configuration used either in the this material.
  39800. *
  39801. * If sets to null, the scene one is in use.
  39802. */
  39803. imageProcessingConfiguration: ImageProcessingConfiguration;
  39804. /**
  39805. * Keep track of the image processing observer to allow dispose and replace.
  39806. */
  39807. private _imageProcessingObserver;
  39808. /**
  39809. * Attaches a new image processing configuration to the PBR Material.
  39810. * @param configuration
  39811. */
  39812. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39813. /**
  39814. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39815. */
  39816. /**
  39817. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39818. */
  39819. colorCurves: Nullable<ColorCurves>;
  39820. /**
  39821. * Gets wether the color curves effect is enabled.
  39822. */
  39823. /**
  39824. * Sets wether the color curves effect is enabled.
  39825. */
  39826. colorCurvesEnabled: boolean;
  39827. /**
  39828. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39829. */
  39830. /**
  39831. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39832. */
  39833. colorGradingTexture: Nullable<BaseTexture>;
  39834. /**
  39835. * Gets wether the color grading effect is enabled.
  39836. */
  39837. /**
  39838. * Gets wether the color grading effect is enabled.
  39839. */
  39840. colorGradingEnabled: boolean;
  39841. /**
  39842. * Gets exposure used in the effect.
  39843. */
  39844. /**
  39845. * Sets exposure used in the effect.
  39846. */
  39847. exposure: number;
  39848. /**
  39849. * Gets wether tonemapping is enabled or not.
  39850. */
  39851. /**
  39852. * Sets wether tonemapping is enabled or not
  39853. */
  39854. toneMappingEnabled: boolean;
  39855. /**
  39856. * Gets the type of tone mapping effect.
  39857. */
  39858. /**
  39859. * Sets the type of tone mapping effect.
  39860. */
  39861. toneMappingType: number;
  39862. /**
  39863. * Gets contrast used in the effect.
  39864. */
  39865. /**
  39866. * Sets contrast used in the effect.
  39867. */
  39868. contrast: number;
  39869. /**
  39870. * Gets Vignette stretch size.
  39871. */
  39872. /**
  39873. * Sets Vignette stretch size.
  39874. */
  39875. vignetteStretch: number;
  39876. /**
  39877. * Gets Vignette centre X Offset.
  39878. */
  39879. /**
  39880. * Sets Vignette centre X Offset.
  39881. */
  39882. vignetteCentreX: number;
  39883. /**
  39884. * Gets Vignette centre Y Offset.
  39885. */
  39886. /**
  39887. * Sets Vignette centre Y Offset.
  39888. */
  39889. vignetteCentreY: number;
  39890. /**
  39891. * Gets Vignette weight or intensity of the vignette effect.
  39892. */
  39893. /**
  39894. * Sets Vignette weight or intensity of the vignette effect.
  39895. */
  39896. vignetteWeight: number;
  39897. /**
  39898. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39899. * if vignetteEnabled is set to true.
  39900. */
  39901. /**
  39902. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39903. * if vignetteEnabled is set to true.
  39904. */
  39905. vignetteColor: Color4;
  39906. /**
  39907. * Gets Camera field of view used by the Vignette effect.
  39908. */
  39909. /**
  39910. * Sets Camera field of view used by the Vignette effect.
  39911. */
  39912. vignetteCameraFov: number;
  39913. /**
  39914. * Gets the vignette blend mode allowing different kind of effect.
  39915. */
  39916. /**
  39917. * Sets the vignette blend mode allowing different kind of effect.
  39918. */
  39919. vignetteBlendMode: number;
  39920. /**
  39921. * Gets wether the vignette effect is enabled.
  39922. */
  39923. /**
  39924. * Sets wether the vignette effect is enabled.
  39925. */
  39926. vignetteEnabled: boolean;
  39927. private _fromLinearSpace;
  39928. /**
  39929. * Gets wether the input of the processing is in Gamma or Linear Space.
  39930. */
  39931. /**
  39932. * Sets wether the input of the processing is in Gamma or Linear Space.
  39933. */
  39934. fromLinearSpace: boolean;
  39935. /**
  39936. * Defines cache preventing GC.
  39937. */
  39938. private _defines;
  39939. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39940. /**
  39941. * "ImageProcessingPostProcess"
  39942. * @returns "ImageProcessingPostProcess"
  39943. */
  39944. getClassName(): string;
  39945. protected _updateParameters(): void;
  39946. dispose(camera?: Camera): void;
  39947. }
  39948. }
  39949. declare module BABYLON {
  39950. /**
  39951. * Class containing static functions to help procedurally build meshes
  39952. */
  39953. export class GroundBuilder {
  39954. /**
  39955. * Creates a ground mesh
  39956. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39957. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39959. * @param name defines the name of the mesh
  39960. * @param options defines the options used to create the mesh
  39961. * @param scene defines the hosting scene
  39962. * @returns the ground mesh
  39963. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39964. */
  39965. static CreateGround(name: string, options: {
  39966. width?: number;
  39967. height?: number;
  39968. subdivisions?: number;
  39969. subdivisionsX?: number;
  39970. subdivisionsY?: number;
  39971. updatable?: boolean;
  39972. }, scene: any): Mesh;
  39973. /**
  39974. * Creates a tiled ground mesh
  39975. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39976. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39977. * * 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
  39978. * * 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
  39979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39980. * @param name defines the name of the mesh
  39981. * @param options defines the options used to create the mesh
  39982. * @param scene defines the hosting scene
  39983. * @returns the tiled ground mesh
  39984. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39985. */
  39986. static CreateTiledGround(name: string, options: {
  39987. xmin: number;
  39988. zmin: number;
  39989. xmax: number;
  39990. zmax: number;
  39991. subdivisions?: {
  39992. w: number;
  39993. h: number;
  39994. };
  39995. precision?: {
  39996. w: number;
  39997. h: number;
  39998. };
  39999. updatable?: boolean;
  40000. }, scene?: Nullable<Scene>): Mesh;
  40001. /**
  40002. * Creates a ground mesh from a height map
  40003. * * The parameter `url` sets the URL of the height map image resource.
  40004. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40005. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40006. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40007. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40008. * * 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.
  40009. * * 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).
  40010. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40012. * @param name defines the name of the mesh
  40013. * @param url defines the url to the height map
  40014. * @param options defines the options used to create the mesh
  40015. * @param scene defines the hosting scene
  40016. * @returns the ground mesh
  40017. * @see https://doc.babylonjs.com/babylon101/height_map
  40018. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40019. */
  40020. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40021. width?: number;
  40022. height?: number;
  40023. subdivisions?: number;
  40024. minHeight?: number;
  40025. maxHeight?: number;
  40026. colorFilter?: Color3;
  40027. alphaFilter?: number;
  40028. updatable?: boolean;
  40029. onReady?: (mesh: GroundMesh) => void;
  40030. }, scene?: Nullable<Scene>): GroundMesh;
  40031. }
  40032. }
  40033. declare module BABYLON {
  40034. /**
  40035. * Class containing static functions to help procedurally build meshes
  40036. */
  40037. export class TorusBuilder {
  40038. /**
  40039. * Creates a torus mesh
  40040. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40041. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40042. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40044. * * 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
  40045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40046. * @param name defines the name of the mesh
  40047. * @param options defines the options used to create the mesh
  40048. * @param scene defines the hosting scene
  40049. * @returns the torus mesh
  40050. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40051. */
  40052. static CreateTorus(name: string, options: {
  40053. diameter?: number;
  40054. thickness?: number;
  40055. tessellation?: number;
  40056. updatable?: boolean;
  40057. sideOrientation?: number;
  40058. frontUVs?: Vector4;
  40059. backUVs?: Vector4;
  40060. }, scene: any): Mesh;
  40061. }
  40062. }
  40063. declare module BABYLON {
  40064. /**
  40065. * Class containing static functions to help procedurally build meshes
  40066. */
  40067. export class CylinderBuilder {
  40068. /**
  40069. * Creates a cylinder or a cone mesh
  40070. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40071. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40072. * * 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.
  40073. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40074. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40075. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40076. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40077. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  40078. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40079. * * 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).
  40080. * * 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
  40081. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40082. * * 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
  40083. * * 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.
  40084. * * If `enclose` is false, a ring surface is one element.
  40085. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40086. * * 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
  40087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40088. * * 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
  40089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40090. * @param name defines the name of the mesh
  40091. * @param options defines the options used to create the mesh
  40092. * @param scene defines the hosting scene
  40093. * @returns the cylinder mesh
  40094. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40095. */
  40096. static CreateCylinder(name: string, options: {
  40097. height?: number;
  40098. diameterTop?: number;
  40099. diameterBottom?: number;
  40100. diameter?: number;
  40101. tessellation?: number;
  40102. subdivisions?: number;
  40103. arc?: number;
  40104. faceColors?: Color4[];
  40105. faceUV?: Vector4[];
  40106. updatable?: boolean;
  40107. hasRings?: boolean;
  40108. enclose?: boolean;
  40109. cap?: number;
  40110. sideOrientation?: number;
  40111. frontUVs?: Vector4;
  40112. backUVs?: Vector4;
  40113. }, scene: any): Mesh;
  40114. }
  40115. }
  40116. declare module BABYLON {
  40117. /**
  40118. * Options to modify the vr teleportation behavior.
  40119. */
  40120. export interface VRTeleportationOptions {
  40121. /**
  40122. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40123. */
  40124. floorMeshName?: string;
  40125. /**
  40126. * A list of meshes to be used as the teleportation floor. (default: empty)
  40127. */
  40128. floorMeshes?: Mesh[];
  40129. }
  40130. /**
  40131. * Options to modify the vr experience helper's behavior.
  40132. */
  40133. export interface VRExperienceHelperOptions extends WebVROptions {
  40134. /**
  40135. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40136. */
  40137. createDeviceOrientationCamera?: boolean;
  40138. /**
  40139. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40140. */
  40141. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40142. /**
  40143. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40144. */
  40145. laserToggle?: boolean;
  40146. /**
  40147. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40148. */
  40149. floorMeshes?: Mesh[];
  40150. /**
  40151. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40152. */
  40153. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40154. }
  40155. /**
  40156. * Event containing information after VR has been entered
  40157. */
  40158. export class OnAfterEnteringVRObservableEvent {
  40159. /**
  40160. * If entering vr was successful
  40161. */
  40162. success: boolean;
  40163. }
  40164. /**
  40165. * Helps to quickly add VR support to an existing scene.
  40166. * See http://doc.babylonjs.com/how_to/webvr_helper
  40167. */
  40168. export class VRExperienceHelper {
  40169. /** Options to modify the vr experience helper's behavior. */
  40170. webVROptions: VRExperienceHelperOptions;
  40171. private _scene;
  40172. private _position;
  40173. private _btnVR;
  40174. private _btnVRDisplayed;
  40175. private _webVRsupported;
  40176. private _webVRready;
  40177. private _webVRrequesting;
  40178. private _webVRpresenting;
  40179. private _hasEnteredVR;
  40180. private _fullscreenVRpresenting;
  40181. private _canvas;
  40182. private _webVRCamera;
  40183. private _vrDeviceOrientationCamera;
  40184. private _deviceOrientationCamera;
  40185. private _existingCamera;
  40186. private _onKeyDown;
  40187. private _onVrDisplayPresentChange;
  40188. private _onVRDisplayChanged;
  40189. private _onVRRequestPresentStart;
  40190. private _onVRRequestPresentComplete;
  40191. /**
  40192. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40193. */
  40194. enableGazeEvenWhenNoPointerLock: boolean;
  40195. /**
  40196. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40197. */
  40198. exitVROnDoubleTap: boolean;
  40199. /**
  40200. * Observable raised right before entering VR.
  40201. */
  40202. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40203. /**
  40204. * Observable raised when entering VR has completed.
  40205. */
  40206. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40207. /**
  40208. * Observable raised when exiting VR.
  40209. */
  40210. onExitingVRObservable: Observable<VRExperienceHelper>;
  40211. /**
  40212. * Observable raised when controller mesh is loaded.
  40213. */
  40214. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40215. /** Return this.onEnteringVRObservable
  40216. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40217. */
  40218. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40219. /** Return this.onExitingVRObservable
  40220. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40221. */
  40222. readonly onExitingVR: Observable<VRExperienceHelper>;
  40223. /** Return this.onControllerMeshLoadedObservable
  40224. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40225. */
  40226. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40227. private _rayLength;
  40228. private _useCustomVRButton;
  40229. private _teleportationRequested;
  40230. private _teleportActive;
  40231. private _floorMeshName;
  40232. private _floorMeshesCollection;
  40233. private _rotationAllowed;
  40234. private _teleportBackwardsVector;
  40235. private _teleportationTarget;
  40236. private _isDefaultTeleportationTarget;
  40237. private _postProcessMove;
  40238. private _teleportationFillColor;
  40239. private _teleportationBorderColor;
  40240. private _rotationAngle;
  40241. private _haloCenter;
  40242. private _cameraGazer;
  40243. private _padSensibilityUp;
  40244. private _padSensibilityDown;
  40245. private _leftController;
  40246. private _rightController;
  40247. /**
  40248. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40249. */
  40250. onNewMeshSelected: Observable<AbstractMesh>;
  40251. /**
  40252. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40253. * This observable will provide the mesh and the controller used to select the mesh
  40254. */
  40255. onMeshSelectedWithController: Observable<{
  40256. mesh: AbstractMesh;
  40257. controller: WebVRController;
  40258. }>;
  40259. /**
  40260. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40261. */
  40262. onNewMeshPicked: Observable<PickingInfo>;
  40263. private _circleEase;
  40264. /**
  40265. * Observable raised before camera teleportation
  40266. */
  40267. onBeforeCameraTeleport: Observable<Vector3>;
  40268. /**
  40269. * Observable raised after camera teleportation
  40270. */
  40271. onAfterCameraTeleport: Observable<Vector3>;
  40272. /**
  40273. * Observable raised when current selected mesh gets unselected
  40274. */
  40275. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40276. private _raySelectionPredicate;
  40277. /**
  40278. * To be optionaly changed by user to define custom ray selection
  40279. */
  40280. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40281. /**
  40282. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40283. */
  40284. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40285. /**
  40286. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40287. */
  40288. teleportationEnabled: boolean;
  40289. private _defaultHeight;
  40290. private _teleportationInitialized;
  40291. private _interactionsEnabled;
  40292. private _interactionsRequested;
  40293. private _displayGaze;
  40294. private _displayLaserPointer;
  40295. /**
  40296. * The mesh used to display where the user is going to teleport.
  40297. */
  40298. /**
  40299. * Sets the mesh to be used to display where the user is going to teleport.
  40300. */
  40301. teleportationTarget: Mesh;
  40302. /**
  40303. * 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
  40304. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40305. * See http://doc.babylonjs.com/resources/baking_transformations
  40306. */
  40307. gazeTrackerMesh: Mesh;
  40308. /**
  40309. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40310. */
  40311. updateGazeTrackerScale: boolean;
  40312. /**
  40313. * If the gaze trackers color should be updated when selecting meshes
  40314. */
  40315. updateGazeTrackerColor: boolean;
  40316. /**
  40317. * If the controller laser color should be updated when selecting meshes
  40318. */
  40319. updateControllerLaserColor: boolean;
  40320. /**
  40321. * The gaze tracking mesh corresponding to the left controller
  40322. */
  40323. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40324. /**
  40325. * The gaze tracking mesh corresponding to the right controller
  40326. */
  40327. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40328. /**
  40329. * If the ray of the gaze should be displayed.
  40330. */
  40331. /**
  40332. * Sets if the ray of the gaze should be displayed.
  40333. */
  40334. displayGaze: boolean;
  40335. /**
  40336. * If the ray of the LaserPointer should be displayed.
  40337. */
  40338. /**
  40339. * Sets if the ray of the LaserPointer should be displayed.
  40340. */
  40341. displayLaserPointer: boolean;
  40342. /**
  40343. * The deviceOrientationCamera used as the camera when not in VR.
  40344. */
  40345. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40346. /**
  40347. * Based on the current WebVR support, returns the current VR camera used.
  40348. */
  40349. readonly currentVRCamera: Nullable<Camera>;
  40350. /**
  40351. * The webVRCamera which is used when in VR.
  40352. */
  40353. readonly webVRCamera: WebVRFreeCamera;
  40354. /**
  40355. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40356. */
  40357. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40358. /**
  40359. * The html button that is used to trigger entering into VR.
  40360. */
  40361. readonly vrButton: Nullable<HTMLButtonElement>;
  40362. private readonly _teleportationRequestInitiated;
  40363. /**
  40364. * Defines wether or not Pointer lock should be requested when switching to
  40365. * full screen.
  40366. */
  40367. requestPointerLockOnFullScreen: boolean;
  40368. /**
  40369. * Instantiates a VRExperienceHelper.
  40370. * Helps to quickly add VR support to an existing scene.
  40371. * @param scene The scene the VRExperienceHelper belongs to.
  40372. * @param webVROptions Options to modify the vr experience helper's behavior.
  40373. */
  40374. constructor(scene: Scene,
  40375. /** Options to modify the vr experience helper's behavior. */
  40376. webVROptions?: VRExperienceHelperOptions);
  40377. private _onDefaultMeshLoaded;
  40378. private _onResize;
  40379. private _onFullscreenChange;
  40380. /**
  40381. * Gets a value indicating if we are currently in VR mode.
  40382. */
  40383. readonly isInVRMode: boolean;
  40384. private onVrDisplayPresentChange;
  40385. private onVRDisplayChanged;
  40386. private moveButtonToBottomRight;
  40387. private displayVRButton;
  40388. private updateButtonVisibility;
  40389. private _cachedAngularSensibility;
  40390. /**
  40391. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40392. * Otherwise, will use the fullscreen API.
  40393. */
  40394. enterVR(): void;
  40395. /**
  40396. * Attempt to exit VR, or fullscreen.
  40397. */
  40398. exitVR(): void;
  40399. /**
  40400. * The position of the vr experience helper.
  40401. */
  40402. /**
  40403. * Sets the position of the vr experience helper.
  40404. */
  40405. position: Vector3;
  40406. /**
  40407. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40408. */
  40409. enableInteractions(): void;
  40410. private readonly _noControllerIsActive;
  40411. private beforeRender;
  40412. private _isTeleportationFloor;
  40413. /**
  40414. * Adds a floor mesh to be used for teleportation.
  40415. * @param floorMesh the mesh to be used for teleportation.
  40416. */
  40417. addFloorMesh(floorMesh: Mesh): void;
  40418. /**
  40419. * Removes a floor mesh from being used for teleportation.
  40420. * @param floorMesh the mesh to be removed.
  40421. */
  40422. removeFloorMesh(floorMesh: Mesh): void;
  40423. /**
  40424. * Enables interactions and teleportation using the VR controllers and gaze.
  40425. * @param vrTeleportationOptions options to modify teleportation behavior.
  40426. */
  40427. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40428. private _onNewGamepadConnected;
  40429. private _tryEnableInteractionOnController;
  40430. private _onNewGamepadDisconnected;
  40431. private _enableInteractionOnController;
  40432. private _checkTeleportWithRay;
  40433. private _checkRotate;
  40434. private _checkTeleportBackwards;
  40435. private _enableTeleportationOnController;
  40436. private _createTeleportationCircles;
  40437. private _displayTeleportationTarget;
  40438. private _hideTeleportationTarget;
  40439. private _rotateCamera;
  40440. private _moveTeleportationSelectorTo;
  40441. private _workingVector;
  40442. private _workingQuaternion;
  40443. private _workingMatrix;
  40444. /**
  40445. * Teleports the users feet to the desired location
  40446. * @param location The location where the user's feet should be placed
  40447. */
  40448. teleportCamera(location: Vector3): void;
  40449. private _convertNormalToDirectionOfRay;
  40450. private _castRayAndSelectObject;
  40451. private _notifySelectedMeshUnselected;
  40452. /**
  40453. * Sets the color of the laser ray from the vr controllers.
  40454. * @param color new color for the ray.
  40455. */
  40456. changeLaserColor(color: Color3): void;
  40457. /**
  40458. * Sets the color of the ray from the vr headsets gaze.
  40459. * @param color new color for the ray.
  40460. */
  40461. changeGazeColor(color: Color3): void;
  40462. /**
  40463. * Exits VR and disposes of the vr experience helper
  40464. */
  40465. dispose(): void;
  40466. /**
  40467. * Gets the name of the VRExperienceHelper class
  40468. * @returns "VRExperienceHelper"
  40469. */
  40470. getClassName(): string;
  40471. }
  40472. }
  40473. declare module BABYLON {
  40474. /**
  40475. * Manages an XRSession to work with Babylon's engine
  40476. * @see https://doc.babylonjs.com/how_to/webxr
  40477. */
  40478. export class WebXRSessionManager implements IDisposable {
  40479. private scene;
  40480. /**
  40481. * Fires every time a new xrFrame arrives which can be used to update the camera
  40482. */
  40483. onXRFrameObservable: Observable<any>;
  40484. /**
  40485. * Fires when the xr session is ended either by the device or manually done
  40486. */
  40487. onXRSessionEnded: Observable<any>;
  40488. /**
  40489. * Underlying xr session
  40490. */
  40491. session: XRSession;
  40492. /**
  40493. * Type of reference space used when creating the session
  40494. */
  40495. referenceSpace: XRReferenceSpace;
  40496. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40497. /**
  40498. * Current XR frame
  40499. */
  40500. currentFrame: Nullable<XRFrame>;
  40501. private _xrNavigator;
  40502. private baseLayer;
  40503. /**
  40504. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40505. * @param scene The scene which the session should be created for
  40506. */
  40507. constructor(scene: Scene);
  40508. /**
  40509. * Initializes the manager
  40510. * After initialization enterXR can be called to start an XR session
  40511. * @returns Promise which resolves after it is initialized
  40512. */
  40513. initializeAsync(): Promise<void>;
  40514. /**
  40515. * Initializes an xr session
  40516. * @param xrSessionMode mode to initialize
  40517. * @returns a promise which will resolve once the session has been initialized
  40518. */
  40519. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40520. /**
  40521. * Sets the reference space on the xr session
  40522. * @param referenceSpace space to set
  40523. * @returns a promise that will resolve once the reference space has been set
  40524. */
  40525. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40526. /**
  40527. * Updates the render state of the session
  40528. * @param state state to set
  40529. * @returns a promise that resolves once the render state has been updated
  40530. */
  40531. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40532. /**
  40533. * Starts rendering to the xr layer
  40534. * @returns a promise that will resolve once rendering has started
  40535. */
  40536. startRenderingToXRAsync(): Promise<void>;
  40537. /**
  40538. * Stops the xrSession and restores the renderloop
  40539. * @returns Promise which resolves after it exits XR
  40540. */
  40541. exitXRAsync(): Promise<unknown>;
  40542. /**
  40543. * Checks if a session would be supported for the creation options specified
  40544. * @param sessionMode session mode to check if supported eg. immersive-vr
  40545. * @returns true if supported
  40546. */
  40547. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40548. /**
  40549. * @hidden
  40550. * Converts the render layer of xrSession to a render target
  40551. * @param session session to create render target for
  40552. * @param scene scene the new render target should be created for
  40553. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40554. /**
  40555. * Disposes of the session manager
  40556. */
  40557. dispose(): void;
  40558. }
  40559. }
  40560. declare module BABYLON {
  40561. /**
  40562. * WebXR Camera which holds the views for the xrSession
  40563. * @see https://doc.babylonjs.com/how_to/webxr
  40564. */
  40565. export class WebXRCamera extends FreeCamera {
  40566. private static _TmpMatrix;
  40567. /**
  40568. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40569. * @param name the name of the camera
  40570. * @param scene the scene to add the camera to
  40571. */
  40572. constructor(name: string, scene: Scene);
  40573. private _updateNumberOfRigCameras;
  40574. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40575. /**
  40576. * Updates the cameras position from the current pose information of the XR session
  40577. * @param xrSessionManager the session containing pose information
  40578. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40579. */
  40580. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40581. }
  40582. }
  40583. declare module BABYLON {
  40584. /**
  40585. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40586. */
  40587. export class WebXRManagedOutputCanvas implements IDisposable {
  40588. private helper;
  40589. private _canvas;
  40590. /**
  40591. * xrpresent context of the canvas which can be used to display/mirror xr content
  40592. */
  40593. canvasContext: WebGLRenderingContext;
  40594. /**
  40595. * xr layer for the canvas
  40596. */
  40597. xrLayer: Nullable<XRWebGLLayer>;
  40598. /**
  40599. * Initializes the xr layer for the session
  40600. * @param xrSession xr session
  40601. * @returns a promise that will resolve once the XR Layer has been created
  40602. */
  40603. initializeXRLayerAsync(xrSession: any): any;
  40604. /**
  40605. * Initializes the canvas to be added/removed upon entering/exiting xr
  40606. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40607. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40608. */
  40609. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40610. /**
  40611. * Disposes of the object
  40612. */
  40613. dispose(): void;
  40614. private _setManagedOutputCanvas;
  40615. private _addCanvas;
  40616. private _removeCanvas;
  40617. }
  40618. }
  40619. declare module BABYLON {
  40620. /**
  40621. * States of the webXR experience
  40622. */
  40623. export enum WebXRState {
  40624. /**
  40625. * Transitioning to being in XR mode
  40626. */
  40627. ENTERING_XR = 0,
  40628. /**
  40629. * Transitioning to non XR mode
  40630. */
  40631. EXITING_XR = 1,
  40632. /**
  40633. * In XR mode and presenting
  40634. */
  40635. IN_XR = 2,
  40636. /**
  40637. * Not entered XR mode
  40638. */
  40639. NOT_IN_XR = 3
  40640. }
  40641. /**
  40642. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40643. * @see https://doc.babylonjs.com/how_to/webxr
  40644. */
  40645. export class WebXRExperienceHelper implements IDisposable {
  40646. private scene;
  40647. /**
  40648. * 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
  40649. */
  40650. container: AbstractMesh;
  40651. /**
  40652. * Camera used to render xr content
  40653. */
  40654. camera: WebXRCamera;
  40655. /**
  40656. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40657. */
  40658. state: WebXRState;
  40659. private _setState;
  40660. private static _TmpVector;
  40661. /**
  40662. * Fires when the state of the experience helper has changed
  40663. */
  40664. onStateChangedObservable: Observable<WebXRState>;
  40665. /** Session manager used to keep track of xr session */
  40666. sessionManager: WebXRSessionManager;
  40667. private _nonVRCamera;
  40668. private _originalSceneAutoClear;
  40669. private _supported;
  40670. /**
  40671. * Creates the experience helper
  40672. * @param scene the scene to attach the experience helper to
  40673. * @returns a promise for the experience helper
  40674. */
  40675. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40676. /**
  40677. * Creates a WebXRExperienceHelper
  40678. * @param scene The scene the helper should be created in
  40679. */
  40680. private constructor();
  40681. /**
  40682. * Exits XR mode and returns the scene to its original state
  40683. * @returns promise that resolves after xr mode has exited
  40684. */
  40685. exitXRAsync(): Promise<unknown>;
  40686. /**
  40687. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40688. * @param sessionCreationOptions options for the XR session
  40689. * @param referenceSpaceType frame of reference of the XR session
  40690. * @param outputCanvas the output canvas that will be used to enter XR mode
  40691. * @returns promise that resolves after xr mode has entered
  40692. */
  40693. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40694. /**
  40695. * Updates the global position of the camera by moving the camera's container
  40696. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40697. * @param position The desired global position of the camera
  40698. */
  40699. setPositionOfCameraUsingContainer(position: Vector3): void;
  40700. /**
  40701. * Rotates the xr camera by rotating the camera's container around the camera's position
  40702. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40703. * @param rotation the desired quaternion rotation to apply to the camera
  40704. */
  40705. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40706. /**
  40707. * Disposes of the experience helper
  40708. */
  40709. dispose(): void;
  40710. }
  40711. }
  40712. declare module BABYLON {
  40713. /**
  40714. * Button which can be used to enter a different mode of XR
  40715. */
  40716. export class WebXREnterExitUIButton {
  40717. /** button element */
  40718. element: HTMLElement;
  40719. /** XR initialization options for the button */
  40720. sessionMode: XRSessionMode;
  40721. /** Reference space type */
  40722. referenceSpaceType: XRReferenceSpaceType;
  40723. /**
  40724. * Creates a WebXREnterExitUIButton
  40725. * @param element button element
  40726. * @param sessionMode XR initialization session mode
  40727. * @param referenceSpaceType the type of reference space to be used
  40728. */
  40729. constructor(
  40730. /** button element */
  40731. element: HTMLElement,
  40732. /** XR initialization options for the button */
  40733. sessionMode: XRSessionMode,
  40734. /** Reference space type */
  40735. referenceSpaceType: XRReferenceSpaceType);
  40736. /**
  40737. * Overwritable function which can be used to update the button's visuals when the state changes
  40738. * @param activeButton the current active button in the UI
  40739. */
  40740. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40741. }
  40742. /**
  40743. * Options to create the webXR UI
  40744. */
  40745. export class WebXREnterExitUIOptions {
  40746. /**
  40747. * Context to enter xr with
  40748. */
  40749. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40750. /**
  40751. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40752. */
  40753. customButtons?: Array<WebXREnterExitUIButton>;
  40754. }
  40755. /**
  40756. * UI to allow the user to enter/exit XR mode
  40757. */
  40758. export class WebXREnterExitUI implements IDisposable {
  40759. private scene;
  40760. private _overlay;
  40761. private _buttons;
  40762. private _activeButton;
  40763. /**
  40764. * Fired every time the active button is changed.
  40765. *
  40766. * When xr is entered via a button that launches xr that button will be the callback parameter
  40767. *
  40768. * When exiting xr the callback parameter will be null)
  40769. */
  40770. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40771. /**
  40772. * Creates UI to allow the user to enter/exit XR mode
  40773. * @param scene the scene to add the ui to
  40774. * @param helper the xr experience helper to enter/exit xr with
  40775. * @param options options to configure the UI
  40776. * @returns the created ui
  40777. */
  40778. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40779. private constructor();
  40780. private _updateButtons;
  40781. /**
  40782. * Disposes of the object
  40783. */
  40784. dispose(): void;
  40785. }
  40786. }
  40787. declare module BABYLON {
  40788. /**
  40789. * Represents an XR input
  40790. */
  40791. export class WebXRController {
  40792. private scene;
  40793. /** The underlying input source for the controller */
  40794. inputSource: XRInputSource;
  40795. private parentContainer;
  40796. /**
  40797. * 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
  40798. */
  40799. grip?: AbstractMesh;
  40800. /**
  40801. * Pointer which can be used to select objects or attach a visible laser to
  40802. */
  40803. pointer: AbstractMesh;
  40804. /**
  40805. * Event that fires when the controller is removed/disposed
  40806. */
  40807. onDisposeObservable: Observable<{}>;
  40808. private _tmpMatrix;
  40809. private _tmpQuaternion;
  40810. private _tmpVector;
  40811. /**
  40812. * Creates the controller
  40813. * @see https://doc.babylonjs.com/how_to/webxr
  40814. * @param scene the scene which the controller should be associated to
  40815. * @param inputSource the underlying input source for the controller
  40816. * @param parentContainer parent that the controller meshes should be children of
  40817. */
  40818. constructor(scene: Scene,
  40819. /** The underlying input source for the controller */
  40820. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40821. /**
  40822. * Updates the controller pose based on the given XRFrame
  40823. * @param xrFrame xr frame to update the pose with
  40824. * @param referenceSpace reference space to use
  40825. */
  40826. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40827. /**
  40828. * Gets a world space ray coming from the controller
  40829. * @param result the resulting ray
  40830. */
  40831. getWorldPointerRayToRef(result: Ray): void;
  40832. /**
  40833. * Disposes of the object
  40834. */
  40835. dispose(): void;
  40836. }
  40837. }
  40838. declare module BABYLON {
  40839. /**
  40840. * XR input used to track XR inputs such as controllers/rays
  40841. */
  40842. export class WebXRInput implements IDisposable {
  40843. /**
  40844. * Base experience the input listens to
  40845. */
  40846. baseExperience: WebXRExperienceHelper;
  40847. /**
  40848. * XR controllers being tracked
  40849. */
  40850. controllers: Array<WebXRController>;
  40851. private _frameObserver;
  40852. private _stateObserver;
  40853. /**
  40854. * Event when a controller has been connected/added
  40855. */
  40856. onControllerAddedObservable: Observable<WebXRController>;
  40857. /**
  40858. * Event when a controller has been removed/disconnected
  40859. */
  40860. onControllerRemovedObservable: Observable<WebXRController>;
  40861. /**
  40862. * Initializes the WebXRInput
  40863. * @param baseExperience experience helper which the input should be created for
  40864. */
  40865. constructor(
  40866. /**
  40867. * Base experience the input listens to
  40868. */
  40869. baseExperience: WebXRExperienceHelper);
  40870. private _onInputSourcesChange;
  40871. private _addAndRemoveControllers;
  40872. /**
  40873. * Disposes of the object
  40874. */
  40875. dispose(): void;
  40876. }
  40877. }
  40878. declare module BABYLON {
  40879. /**
  40880. * Enables teleportation
  40881. */
  40882. export class WebXRControllerTeleportation {
  40883. private _teleportationFillColor;
  40884. private _teleportationBorderColor;
  40885. private _tmpRay;
  40886. private _tmpVector;
  40887. /**
  40888. * Creates a WebXRControllerTeleportation
  40889. * @param input input manager to add teleportation to
  40890. * @param floorMeshes floormeshes which can be teleported to
  40891. */
  40892. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40893. }
  40894. }
  40895. declare module BABYLON {
  40896. /**
  40897. * Handles pointer input automatically for the pointer of XR controllers
  40898. */
  40899. export class WebXRControllerPointerSelection {
  40900. private static _idCounter;
  40901. private _tmpRay;
  40902. /**
  40903. * Creates a WebXRControllerPointerSelection
  40904. * @param input input manager to setup pointer selection
  40905. */
  40906. constructor(input: WebXRInput);
  40907. private _convertNormalToDirectionOfRay;
  40908. private _updatePointerDistance;
  40909. }
  40910. }
  40911. declare module BABYLON {
  40912. /**
  40913. * Class used to represent data loading progression
  40914. */
  40915. export class SceneLoaderProgressEvent {
  40916. /** defines if data length to load can be evaluated */
  40917. readonly lengthComputable: boolean;
  40918. /** defines the loaded data length */
  40919. readonly loaded: number;
  40920. /** defines the data length to load */
  40921. readonly total: number;
  40922. /**
  40923. * Create a new progress event
  40924. * @param lengthComputable defines if data length to load can be evaluated
  40925. * @param loaded defines the loaded data length
  40926. * @param total defines the data length to load
  40927. */
  40928. constructor(
  40929. /** defines if data length to load can be evaluated */
  40930. lengthComputable: boolean,
  40931. /** defines the loaded data length */
  40932. loaded: number,
  40933. /** defines the data length to load */
  40934. total: number);
  40935. /**
  40936. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40937. * @param event defines the source event
  40938. * @returns a new SceneLoaderProgressEvent
  40939. */
  40940. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40941. }
  40942. /**
  40943. * Interface used by SceneLoader plugins to define supported file extensions
  40944. */
  40945. export interface ISceneLoaderPluginExtensions {
  40946. /**
  40947. * Defines the list of supported extensions
  40948. */
  40949. [extension: string]: {
  40950. isBinary: boolean;
  40951. };
  40952. }
  40953. /**
  40954. * Interface used by SceneLoader plugin factory
  40955. */
  40956. export interface ISceneLoaderPluginFactory {
  40957. /**
  40958. * Defines the name of the factory
  40959. */
  40960. name: string;
  40961. /**
  40962. * Function called to create a new plugin
  40963. * @return the new plugin
  40964. */
  40965. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40966. /**
  40967. * Boolean indicating if the plugin can direct load specific data
  40968. */
  40969. canDirectLoad?: (data: string) => boolean;
  40970. }
  40971. /**
  40972. * Interface used to define a SceneLoader plugin
  40973. */
  40974. export interface ISceneLoaderPlugin {
  40975. /**
  40976. * The friendly name of this plugin.
  40977. */
  40978. name: string;
  40979. /**
  40980. * The file extensions supported by this plugin.
  40981. */
  40982. extensions: string | ISceneLoaderPluginExtensions;
  40983. /**
  40984. * Import meshes into a scene.
  40985. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40986. * @param scene The scene to import into
  40987. * @param data The data to import
  40988. * @param rootUrl The root url for scene and resources
  40989. * @param meshes The meshes array to import into
  40990. * @param particleSystems The particle systems array to import into
  40991. * @param skeletons The skeletons array to import into
  40992. * @param onError The callback when import fails
  40993. * @returns True if successful or false otherwise
  40994. */
  40995. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40996. /**
  40997. * Load into a scene.
  40998. * @param scene The scene to load into
  40999. * @param data The data to import
  41000. * @param rootUrl The root url for scene and resources
  41001. * @param onError The callback when import fails
  41002. * @returns true if successful or false otherwise
  41003. */
  41004. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41005. /**
  41006. * The callback that returns true if the data can be directly loaded.
  41007. */
  41008. canDirectLoad?: (data: string) => boolean;
  41009. /**
  41010. * The callback that allows custom handling of the root url based on the response url.
  41011. */
  41012. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41013. /**
  41014. * Load into an asset container.
  41015. * @param scene The scene to load into
  41016. * @param data The data to import
  41017. * @param rootUrl The root url for scene and resources
  41018. * @param onError The callback when import fails
  41019. * @returns The loaded asset container
  41020. */
  41021. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41022. }
  41023. /**
  41024. * Interface used to define an async SceneLoader plugin
  41025. */
  41026. export interface ISceneLoaderPluginAsync {
  41027. /**
  41028. * The friendly name of this plugin.
  41029. */
  41030. name: string;
  41031. /**
  41032. * The file extensions supported by this plugin.
  41033. */
  41034. extensions: string | ISceneLoaderPluginExtensions;
  41035. /**
  41036. * Import meshes into a scene.
  41037. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41038. * @param scene The scene to import into
  41039. * @param data The data to import
  41040. * @param rootUrl The root url for scene and resources
  41041. * @param onProgress The callback when the load progresses
  41042. * @param fileName Defines the name of the file to load
  41043. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41044. */
  41045. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41046. meshes: AbstractMesh[];
  41047. particleSystems: IParticleSystem[];
  41048. skeletons: Skeleton[];
  41049. animationGroups: AnimationGroup[];
  41050. }>;
  41051. /**
  41052. * Load into a scene.
  41053. * @param scene The scene to load into
  41054. * @param data The data to import
  41055. * @param rootUrl The root url for scene and resources
  41056. * @param onProgress The callback when the load progresses
  41057. * @param fileName Defines the name of the file to load
  41058. * @returns Nothing
  41059. */
  41060. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41061. /**
  41062. * The callback that returns true if the data can be directly loaded.
  41063. */
  41064. canDirectLoad?: (data: string) => boolean;
  41065. /**
  41066. * The callback that allows custom handling of the root url based on the response url.
  41067. */
  41068. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41069. /**
  41070. * Load into an asset container.
  41071. * @param scene The scene to load into
  41072. * @param data The data to import
  41073. * @param rootUrl The root url for scene and resources
  41074. * @param onProgress The callback when the load progresses
  41075. * @param fileName Defines the name of the file to load
  41076. * @returns The loaded asset container
  41077. */
  41078. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41079. }
  41080. /**
  41081. * Class used to load scene from various file formats using registered plugins
  41082. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41083. */
  41084. export class SceneLoader {
  41085. /**
  41086. * No logging while loading
  41087. */
  41088. static readonly NO_LOGGING: number;
  41089. /**
  41090. * Minimal logging while loading
  41091. */
  41092. static readonly MINIMAL_LOGGING: number;
  41093. /**
  41094. * Summary logging while loading
  41095. */
  41096. static readonly SUMMARY_LOGGING: number;
  41097. /**
  41098. * Detailled logging while loading
  41099. */
  41100. static readonly DETAILED_LOGGING: number;
  41101. /**
  41102. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41103. */
  41104. static ForceFullSceneLoadingForIncremental: boolean;
  41105. /**
  41106. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41107. */
  41108. static ShowLoadingScreen: boolean;
  41109. /**
  41110. * Defines the current logging level (while loading the scene)
  41111. * @ignorenaming
  41112. */
  41113. static loggingLevel: number;
  41114. /**
  41115. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41116. */
  41117. static CleanBoneMatrixWeights: boolean;
  41118. /**
  41119. * Event raised when a plugin is used to load a scene
  41120. */
  41121. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41122. private static _registeredPlugins;
  41123. private static _getDefaultPlugin;
  41124. private static _getPluginForExtension;
  41125. private static _getPluginForDirectLoad;
  41126. private static _getPluginForFilename;
  41127. private static _getDirectLoad;
  41128. private static _loadData;
  41129. private static _getFileInfo;
  41130. /**
  41131. * Gets a plugin that can load the given extension
  41132. * @param extension defines the extension to load
  41133. * @returns a plugin or null if none works
  41134. */
  41135. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41136. /**
  41137. * Gets a boolean indicating that the given extension can be loaded
  41138. * @param extension defines the extension to load
  41139. * @returns true if the extension is supported
  41140. */
  41141. static IsPluginForExtensionAvailable(extension: string): boolean;
  41142. /**
  41143. * Adds a new plugin to the list of registered plugins
  41144. * @param plugin defines the plugin to add
  41145. */
  41146. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41147. /**
  41148. * Import meshes into a scene
  41149. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41150. * @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)
  41151. * @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)
  41152. * @param scene the instance of BABYLON.Scene to append to
  41153. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41154. * @param onProgress a callback with a progress event for each file being loaded
  41155. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41156. * @param pluginExtension the extension used to determine the plugin
  41157. * @returns The loaded plugin
  41158. */
  41159. 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>;
  41160. /**
  41161. * Import meshes into a scene
  41162. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41163. * @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)
  41164. * @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)
  41165. * @param scene the instance of BABYLON.Scene to append to
  41166. * @param onProgress a callback with a progress event for each file being loaded
  41167. * @param pluginExtension the extension used to determine the plugin
  41168. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41169. */
  41170. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41171. meshes: AbstractMesh[];
  41172. particleSystems: IParticleSystem[];
  41173. skeletons: Skeleton[];
  41174. animationGroups: AnimationGroup[];
  41175. }>;
  41176. /**
  41177. * Load a scene
  41178. * @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)
  41179. * @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)
  41180. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41181. * @param onSuccess a callback with the scene when import succeeds
  41182. * @param onProgress a callback with a progress event for each file being loaded
  41183. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41184. * @param pluginExtension the extension used to determine the plugin
  41185. * @returns The loaded plugin
  41186. */
  41187. 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>;
  41188. /**
  41189. * Load a scene
  41190. * @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)
  41191. * @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)
  41192. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41193. * @param onProgress a callback with a progress event for each file being loaded
  41194. * @param pluginExtension the extension used to determine the plugin
  41195. * @returns The loaded scene
  41196. */
  41197. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41198. /**
  41199. * Append a scene
  41200. * @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)
  41201. * @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)
  41202. * @param scene is the instance of BABYLON.Scene to append to
  41203. * @param onSuccess a callback with the scene when import succeeds
  41204. * @param onProgress a callback with a progress event for each file being loaded
  41205. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41206. * @param pluginExtension the extension used to determine the plugin
  41207. * @returns The loaded plugin
  41208. */
  41209. 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>;
  41210. /**
  41211. * Append a scene
  41212. * @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)
  41213. * @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)
  41214. * @param scene is the instance of BABYLON.Scene to append to
  41215. * @param onProgress a callback with a progress event for each file being loaded
  41216. * @param pluginExtension the extension used to determine the plugin
  41217. * @returns The given scene
  41218. */
  41219. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41220. /**
  41221. * Load a scene into an asset container
  41222. * @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)
  41223. * @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)
  41224. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41225. * @param onSuccess a callback with the scene when import succeeds
  41226. * @param onProgress a callback with a progress event for each file being loaded
  41227. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41228. * @param pluginExtension the extension used to determine the plugin
  41229. * @returns The loaded plugin
  41230. */
  41231. 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>;
  41232. /**
  41233. * Load a scene into an asset container
  41234. * @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)
  41235. * @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)
  41236. * @param scene is the instance of Scene to append to
  41237. * @param onProgress a callback with a progress event for each file being loaded
  41238. * @param pluginExtension the extension used to determine the plugin
  41239. * @returns The loaded asset container
  41240. */
  41241. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41242. }
  41243. }
  41244. declare module BABYLON {
  41245. /**
  41246. * Generic Controller
  41247. */
  41248. export class GenericController extends WebVRController {
  41249. /**
  41250. * Base Url for the controller model.
  41251. */
  41252. static readonly MODEL_BASE_URL: string;
  41253. /**
  41254. * File name for the controller model.
  41255. */
  41256. static readonly MODEL_FILENAME: string;
  41257. /**
  41258. * Creates a new GenericController from a gamepad
  41259. * @param vrGamepad the gamepad that the controller should be created from
  41260. */
  41261. constructor(vrGamepad: any);
  41262. /**
  41263. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41264. * @param scene scene in which to add meshes
  41265. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41266. */
  41267. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41268. /**
  41269. * Called once for each button that changed state since the last frame
  41270. * @param buttonIdx Which button index changed
  41271. * @param state New state of the button
  41272. * @param changes Which properties on the state changed since last frame
  41273. */
  41274. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41275. }
  41276. }
  41277. declare module BABYLON {
  41278. /**
  41279. * Defines the WindowsMotionController object that the state of the windows motion controller
  41280. */
  41281. export class WindowsMotionController extends WebVRController {
  41282. /**
  41283. * The base url used to load the left and right controller models
  41284. */
  41285. static MODEL_BASE_URL: string;
  41286. /**
  41287. * The name of the left controller model file
  41288. */
  41289. static MODEL_LEFT_FILENAME: string;
  41290. /**
  41291. * The name of the right controller model file
  41292. */
  41293. static MODEL_RIGHT_FILENAME: string;
  41294. /**
  41295. * The controller name prefix for this controller type
  41296. */
  41297. static readonly GAMEPAD_ID_PREFIX: string;
  41298. /**
  41299. * The controller id pattern for this controller type
  41300. */
  41301. private static readonly GAMEPAD_ID_PATTERN;
  41302. private _loadedMeshInfo;
  41303. private readonly _mapping;
  41304. /**
  41305. * Fired when the trackpad on this controller is clicked
  41306. */
  41307. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41308. /**
  41309. * Fired when the trackpad on this controller is modified
  41310. */
  41311. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41312. /**
  41313. * The current x and y values of this controller's trackpad
  41314. */
  41315. trackpad: StickValues;
  41316. /**
  41317. * Creates a new WindowsMotionController from a gamepad
  41318. * @param vrGamepad the gamepad that the controller should be created from
  41319. */
  41320. constructor(vrGamepad: any);
  41321. /**
  41322. * Fired when the trigger on this controller is modified
  41323. */
  41324. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41325. /**
  41326. * Fired when the menu button on this controller is modified
  41327. */
  41328. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41329. /**
  41330. * Fired when the grip button on this controller is modified
  41331. */
  41332. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41333. /**
  41334. * Fired when the thumbstick button on this controller is modified
  41335. */
  41336. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41337. /**
  41338. * Fired when the touchpad button on this controller is modified
  41339. */
  41340. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41341. /**
  41342. * Fired when the touchpad values on this controller are modified
  41343. */
  41344. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41345. private _updateTrackpad;
  41346. /**
  41347. * Called once per frame by the engine.
  41348. */
  41349. update(): void;
  41350. /**
  41351. * Called once for each button that changed state since the last frame
  41352. * @param buttonIdx Which button index changed
  41353. * @param state New state of the button
  41354. * @param changes Which properties on the state changed since last frame
  41355. */
  41356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41357. /**
  41358. * Moves the buttons on the controller mesh based on their current state
  41359. * @param buttonName the name of the button to move
  41360. * @param buttonValue the value of the button which determines the buttons new position
  41361. */
  41362. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41363. /**
  41364. * Moves the axis on the controller mesh based on its current state
  41365. * @param axis the index of the axis
  41366. * @param axisValue the value of the axis which determines the meshes new position
  41367. * @hidden
  41368. */
  41369. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41370. /**
  41371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41372. * @param scene scene in which to add meshes
  41373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41374. */
  41375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41376. /**
  41377. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41378. * can be transformed by button presses and axes values, based on this._mapping.
  41379. *
  41380. * @param scene scene in which the meshes exist
  41381. * @param meshes list of meshes that make up the controller model to process
  41382. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41383. */
  41384. private processModel;
  41385. private createMeshInfo;
  41386. /**
  41387. * Gets the ray of the controller in the direction the controller is pointing
  41388. * @param length the length the resulting ray should be
  41389. * @returns a ray in the direction the controller is pointing
  41390. */
  41391. getForwardRay(length?: number): Ray;
  41392. /**
  41393. * Disposes of the controller
  41394. */
  41395. dispose(): void;
  41396. }
  41397. }
  41398. declare module BABYLON {
  41399. /**
  41400. * Oculus Touch Controller
  41401. */
  41402. export class OculusTouchController extends WebVRController {
  41403. /**
  41404. * Base Url for the controller model.
  41405. */
  41406. static MODEL_BASE_URL: string;
  41407. /**
  41408. * File name for the left controller model.
  41409. */
  41410. static MODEL_LEFT_FILENAME: string;
  41411. /**
  41412. * File name for the right controller model.
  41413. */
  41414. static MODEL_RIGHT_FILENAME: string;
  41415. /**
  41416. * Base Url for the Quest controller model.
  41417. */
  41418. static QUEST_MODEL_BASE_URL: string;
  41419. /**
  41420. * @hidden
  41421. * If the controllers are running on a device that needs the updated Quest controller models
  41422. */ private static _IsQuest: boolean;
  41423. /**
  41424. * Fired when the secondary trigger on this controller is modified
  41425. */
  41426. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41427. /**
  41428. * Fired when the thumb rest on this controller is modified
  41429. */
  41430. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41431. /**
  41432. * Creates a new OculusTouchController from a gamepad
  41433. * @param vrGamepad the gamepad that the controller should be created from
  41434. */
  41435. constructor(vrGamepad: any);
  41436. /**
  41437. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41438. * @param scene scene in which to add meshes
  41439. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41440. */
  41441. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41442. /**
  41443. * Fired when the A button on this controller is modified
  41444. */
  41445. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41446. /**
  41447. * Fired when the B button on this controller is modified
  41448. */
  41449. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41450. /**
  41451. * Fired when the X button on this controller is modified
  41452. */
  41453. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41454. /**
  41455. * Fired when the Y button on this controller is modified
  41456. */
  41457. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41458. /**
  41459. * Called once for each button that changed state since the last frame
  41460. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41461. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41462. * 2) secondary trigger (same)
  41463. * 3) A (right) X (left), touch, pressed = value
  41464. * 4) B / Y
  41465. * 5) thumb rest
  41466. * @param buttonIdx Which button index changed
  41467. * @param state New state of the button
  41468. * @param changes Which properties on the state changed since last frame
  41469. */
  41470. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41471. }
  41472. }
  41473. declare module BABYLON {
  41474. /**
  41475. * Vive Controller
  41476. */
  41477. export class ViveController extends WebVRController {
  41478. /**
  41479. * Base Url for the controller model.
  41480. */
  41481. static MODEL_BASE_URL: string;
  41482. /**
  41483. * File name for the controller model.
  41484. */
  41485. static MODEL_FILENAME: string;
  41486. /**
  41487. * Creates a new ViveController from a gamepad
  41488. * @param vrGamepad the gamepad that the controller should be created from
  41489. */
  41490. constructor(vrGamepad: any);
  41491. /**
  41492. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41493. * @param scene scene in which to add meshes
  41494. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41495. */
  41496. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41497. /**
  41498. * Fired when the left button on this controller is modified
  41499. */
  41500. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41501. /**
  41502. * Fired when the right button on this controller is modified
  41503. */
  41504. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41505. /**
  41506. * Fired when the menu button on this controller is modified
  41507. */
  41508. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41509. /**
  41510. * Called once for each button that changed state since the last frame
  41511. * Vive mapping:
  41512. * 0: touchpad
  41513. * 1: trigger
  41514. * 2: left AND right buttons
  41515. * 3: menu button
  41516. * @param buttonIdx Which button index changed
  41517. * @param state New state of the button
  41518. * @param changes Which properties on the state changed since last frame
  41519. */
  41520. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41521. }
  41522. }
  41523. declare module BABYLON {
  41524. /**
  41525. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41526. */
  41527. export class WebXRControllerModelLoader {
  41528. /**
  41529. * Creates the WebXRControllerModelLoader
  41530. * @param input xr input that creates the controllers
  41531. */
  41532. constructor(input: WebXRInput);
  41533. }
  41534. }
  41535. declare module BABYLON {
  41536. /**
  41537. * Contains an array of blocks representing the octree
  41538. */
  41539. export interface IOctreeContainer<T> {
  41540. /**
  41541. * Blocks within the octree
  41542. */
  41543. blocks: Array<OctreeBlock<T>>;
  41544. }
  41545. /**
  41546. * Class used to store a cell in an octree
  41547. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41548. */
  41549. export class OctreeBlock<T> {
  41550. /**
  41551. * Gets the content of the current block
  41552. */
  41553. entries: T[];
  41554. /**
  41555. * Gets the list of block children
  41556. */
  41557. blocks: Array<OctreeBlock<T>>;
  41558. private _depth;
  41559. private _maxDepth;
  41560. private _capacity;
  41561. private _minPoint;
  41562. private _maxPoint;
  41563. private _boundingVectors;
  41564. private _creationFunc;
  41565. /**
  41566. * Creates a new block
  41567. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41568. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41569. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41570. * @param depth defines the current depth of this block in the octree
  41571. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41572. * @param creationFunc defines a callback to call when an element is added to the block
  41573. */
  41574. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41575. /**
  41576. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41577. */
  41578. readonly capacity: number;
  41579. /**
  41580. * Gets the minimum vector (in world space) of the block's bounding box
  41581. */
  41582. readonly minPoint: Vector3;
  41583. /**
  41584. * Gets the maximum vector (in world space) of the block's bounding box
  41585. */
  41586. readonly maxPoint: Vector3;
  41587. /**
  41588. * Add a new element to this block
  41589. * @param entry defines the element to add
  41590. */
  41591. addEntry(entry: T): void;
  41592. /**
  41593. * Remove an element from this block
  41594. * @param entry defines the element to remove
  41595. */
  41596. removeEntry(entry: T): void;
  41597. /**
  41598. * Add an array of elements to this block
  41599. * @param entries defines the array of elements to add
  41600. */
  41601. addEntries(entries: T[]): void;
  41602. /**
  41603. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41604. * @param frustumPlanes defines the frustum planes to test
  41605. * @param selection defines the array to store current content if selection is positive
  41606. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41607. */
  41608. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41609. /**
  41610. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41611. * @param sphereCenter defines the bounding sphere center
  41612. * @param sphereRadius defines the bounding sphere radius
  41613. * @param selection defines the array to store current content if selection is positive
  41614. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41615. */
  41616. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41617. /**
  41618. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41619. * @param ray defines the ray to test with
  41620. * @param selection defines the array to store current content if selection is positive
  41621. */
  41622. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41623. /**
  41624. * Subdivide the content into child blocks (this block will then be empty)
  41625. */
  41626. createInnerBlocks(): void;
  41627. /**
  41628. * @hidden
  41629. */ 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;
  41630. }
  41631. }
  41632. declare module BABYLON {
  41633. /**
  41634. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41635. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41636. */
  41637. export class Octree<T> {
  41638. /** 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.) */
  41639. maxDepth: number;
  41640. /**
  41641. * Blocks within the octree containing objects
  41642. */
  41643. blocks: Array<OctreeBlock<T>>;
  41644. /**
  41645. * Content stored in the octree
  41646. */
  41647. dynamicContent: T[];
  41648. private _maxBlockCapacity;
  41649. private _selectionContent;
  41650. private _creationFunc;
  41651. /**
  41652. * Creates a octree
  41653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41654. * @param creationFunc function to be used to instatiate the octree
  41655. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41656. * @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.)
  41657. */
  41658. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41659. /** 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.) */
  41660. maxDepth?: number);
  41661. /**
  41662. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41663. * @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);
  41664. * @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);
  41665. * @param entries meshes to be added to the octree blocks
  41666. */
  41667. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41668. /**
  41669. * Adds a mesh to the octree
  41670. * @param entry Mesh to add to the octree
  41671. */
  41672. addMesh(entry: T): void;
  41673. /**
  41674. * Remove an element from the octree
  41675. * @param entry defines the element to remove
  41676. */
  41677. removeMesh(entry: T): void;
  41678. /**
  41679. * Selects an array of meshes within the frustum
  41680. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41681. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41682. * @returns array of meshes within the frustum
  41683. */
  41684. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41685. /**
  41686. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41687. * @param sphereCenter defines the bounding sphere center
  41688. * @param sphereRadius defines the bounding sphere radius
  41689. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41690. * @returns an array of objects that intersect the sphere
  41691. */
  41692. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41693. /**
  41694. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41695. * @param ray defines the ray to test with
  41696. * @returns array of intersected objects
  41697. */
  41698. intersectsRay(ray: Ray): SmartArray<T>;
  41699. /**
  41700. * Adds a mesh into the octree block if it intersects the block
  41701. */
  41702. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41703. /**
  41704. * Adds a submesh into the octree block if it intersects the block
  41705. */
  41706. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41707. }
  41708. }
  41709. declare module BABYLON {
  41710. interface Scene {
  41711. /**
  41712. * @hidden
  41713. * Backing Filed
  41714. */ private _selectionOctree: Octree<AbstractMesh>;
  41715. /**
  41716. * Gets the octree used to boost mesh selection (picking)
  41717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41718. */
  41719. selectionOctree: Octree<AbstractMesh>;
  41720. /**
  41721. * Creates or updates the octree used to boost selection (picking)
  41722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41723. * @param maxCapacity defines the maximum capacity per leaf
  41724. * @param maxDepth defines the maximum depth of the octree
  41725. * @returns an octree of AbstractMesh
  41726. */
  41727. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41728. }
  41729. interface AbstractMesh {
  41730. /**
  41731. * @hidden
  41732. * Backing Field
  41733. */ private _submeshesOctree: Octree<SubMesh>;
  41734. /**
  41735. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41736. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41737. * @param maxCapacity defines the maximum size of each block (64 by default)
  41738. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41739. * @returns the new octree
  41740. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41741. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41742. */
  41743. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41744. }
  41745. /**
  41746. * Defines the octree scene component responsible to manage any octrees
  41747. * in a given scene.
  41748. */
  41749. export class OctreeSceneComponent {
  41750. /**
  41751. * The component name help to identify the component in the list of scene components.
  41752. */
  41753. readonly name: string;
  41754. /**
  41755. * The scene the component belongs to.
  41756. */
  41757. scene: Scene;
  41758. /**
  41759. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41760. */
  41761. readonly checksIsEnabled: boolean;
  41762. /**
  41763. * Creates a new instance of the component for the given scene
  41764. * @param scene Defines the scene to register the component in
  41765. */
  41766. constructor(scene: Scene);
  41767. /**
  41768. * Registers the component in a given scene
  41769. */
  41770. register(): void;
  41771. /**
  41772. * Return the list of active meshes
  41773. * @returns the list of active meshes
  41774. */
  41775. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41776. /**
  41777. * Return the list of active sub meshes
  41778. * @param mesh The mesh to get the candidates sub meshes from
  41779. * @returns the list of active sub meshes
  41780. */
  41781. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41782. private _tempRay;
  41783. /**
  41784. * Return the list of sub meshes intersecting with a given local ray
  41785. * @param mesh defines the mesh to find the submesh for
  41786. * @param localRay defines the ray in local space
  41787. * @returns the list of intersecting sub meshes
  41788. */
  41789. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41790. /**
  41791. * Return the list of sub meshes colliding with a collider
  41792. * @param mesh defines the mesh to find the submesh for
  41793. * @param collider defines the collider to evaluate the collision against
  41794. * @returns the list of colliding sub meshes
  41795. */
  41796. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41797. /**
  41798. * Rebuilds the elements related to this component in case of
  41799. * context lost for instance.
  41800. */
  41801. rebuild(): void;
  41802. /**
  41803. * Disposes the component and the associated ressources.
  41804. */
  41805. dispose(): void;
  41806. }
  41807. }
  41808. declare module BABYLON {
  41809. /**
  41810. * Renders a layer on top of an existing scene
  41811. */
  41812. export class UtilityLayerRenderer implements IDisposable {
  41813. /** the original scene that will be rendered on top of */
  41814. originalScene: Scene;
  41815. private _pointerCaptures;
  41816. private _lastPointerEvents;
  41817. private static _DefaultUtilityLayer;
  41818. private static _DefaultKeepDepthUtilityLayer;
  41819. private _sharedGizmoLight;
  41820. private _renderCamera;
  41821. /**
  41822. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41823. * @returns the camera that is used when rendering the utility layer
  41824. */
  41825. getRenderCamera(): Nullable<Camera>;
  41826. /**
  41827. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41828. * @param cam the camera that should be used when rendering the utility layer
  41829. */
  41830. setRenderCamera(cam: Nullable<Camera>): void;
  41831. /**
  41832. * @hidden
  41833. * Light which used by gizmos to get light shading
  41834. */ private _getSharedGizmoLight(): HemisphericLight;
  41835. /**
  41836. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41837. */
  41838. pickUtilitySceneFirst: boolean;
  41839. /**
  41840. * 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)
  41841. */
  41842. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41843. /**
  41844. * 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)
  41845. */
  41846. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41847. /**
  41848. * The scene that is rendered on top of the original scene
  41849. */
  41850. utilityLayerScene: Scene;
  41851. /**
  41852. * If the utility layer should automatically be rendered on top of existing scene
  41853. */
  41854. shouldRender: boolean;
  41855. /**
  41856. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41857. */
  41858. onlyCheckPointerDownEvents: boolean;
  41859. /**
  41860. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41861. */
  41862. processAllEvents: boolean;
  41863. /**
  41864. * Observable raised when the pointer move from the utility layer scene to the main scene
  41865. */
  41866. onPointerOutObservable: Observable<number>;
  41867. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41868. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41869. private _afterRenderObserver;
  41870. private _sceneDisposeObserver;
  41871. private _originalPointerObserver;
  41872. /**
  41873. * Instantiates a UtilityLayerRenderer
  41874. * @param originalScene the original scene that will be rendered on top of
  41875. * @param handleEvents boolean indicating if the utility layer should handle events
  41876. */
  41877. constructor(
  41878. /** the original scene that will be rendered on top of */
  41879. originalScene: Scene, handleEvents?: boolean);
  41880. private _notifyObservers;
  41881. /**
  41882. * Renders the utility layers scene on top of the original scene
  41883. */
  41884. render(): void;
  41885. /**
  41886. * Disposes of the renderer
  41887. */
  41888. dispose(): void;
  41889. private _updateCamera;
  41890. }
  41891. }
  41892. declare module BABYLON {
  41893. /**
  41894. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41895. */
  41896. export class Gizmo implements IDisposable {
  41897. /** The utility layer the gizmo will be added to */
  41898. gizmoLayer: UtilityLayerRenderer;
  41899. /**
  41900. * The root mesh of the gizmo
  41901. */ private _rootMesh: Mesh;
  41902. private _attachedMesh;
  41903. /**
  41904. * Ratio for the scale of the gizmo (Default: 1)
  41905. */
  41906. scaleRatio: number;
  41907. /**
  41908. * If a custom mesh has been set (Default: false)
  41909. */
  41910. protected _customMeshSet: boolean;
  41911. /**
  41912. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41913. * * When set, interactions will be enabled
  41914. */
  41915. attachedMesh: Nullable<AbstractMesh>;
  41916. /**
  41917. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41918. * @param mesh The mesh to replace the default mesh of the gizmo
  41919. */
  41920. setCustomMesh(mesh: Mesh): void;
  41921. /**
  41922. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41923. */
  41924. updateGizmoRotationToMatchAttachedMesh: boolean;
  41925. /**
  41926. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41927. */
  41928. updateGizmoPositionToMatchAttachedMesh: boolean;
  41929. /**
  41930. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41931. */
  41932. updateScale: boolean;
  41933. protected _interactionsEnabled: boolean;
  41934. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41935. private _beforeRenderObserver;
  41936. private _tempVector;
  41937. /**
  41938. * Creates a gizmo
  41939. * @param gizmoLayer The utility layer the gizmo will be added to
  41940. */
  41941. constructor(
  41942. /** The utility layer the gizmo will be added to */
  41943. gizmoLayer?: UtilityLayerRenderer);
  41944. /**
  41945. * Updates the gizmo to match the attached mesh's position/rotation
  41946. */
  41947. protected _update(): void;
  41948. /**
  41949. * Disposes of the gizmo
  41950. */
  41951. dispose(): void;
  41952. }
  41953. }
  41954. declare module BABYLON {
  41955. /**
  41956. * Single plane drag gizmo
  41957. */
  41958. export class PlaneDragGizmo extends Gizmo {
  41959. /**
  41960. * Drag behavior responsible for the gizmos dragging interactions
  41961. */
  41962. dragBehavior: PointerDragBehavior;
  41963. private _pointerObserver;
  41964. /**
  41965. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41966. */
  41967. snapDistance: number;
  41968. /**
  41969. * Event that fires each time the gizmo snaps to a new location.
  41970. * * snapDistance is the the change in distance
  41971. */
  41972. onSnapObservable: Observable<{
  41973. snapDistance: number;
  41974. }>;
  41975. private _plane;
  41976. private _coloredMaterial;
  41977. private _hoverMaterial;
  41978. private _isEnabled;
  41979. private _parent;
  41980. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41981. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41982. /**
  41983. * Creates a PlaneDragGizmo
  41984. * @param gizmoLayer The utility layer the gizmo will be added to
  41985. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41986. * @param color The color of the gizmo
  41987. */
  41988. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41990. /**
  41991. * If the gizmo is enabled
  41992. */
  41993. isEnabled: boolean;
  41994. /**
  41995. * Disposes of the gizmo
  41996. */
  41997. dispose(): void;
  41998. }
  41999. }
  42000. declare module BABYLON {
  42001. /**
  42002. * Gizmo that enables dragging a mesh along 3 axis
  42003. */
  42004. export class PositionGizmo extends Gizmo {
  42005. /**
  42006. * Internal gizmo used for interactions on the x axis
  42007. */
  42008. xGizmo: AxisDragGizmo;
  42009. /**
  42010. * Internal gizmo used for interactions on the y axis
  42011. */
  42012. yGizmo: AxisDragGizmo;
  42013. /**
  42014. * Internal gizmo used for interactions on the z axis
  42015. */
  42016. zGizmo: AxisDragGizmo;
  42017. /**
  42018. * Internal gizmo used for interactions on the yz plane
  42019. */
  42020. xPlaneGizmo: PlaneDragGizmo;
  42021. /**
  42022. * Internal gizmo used for interactions on the xz plane
  42023. */
  42024. yPlaneGizmo: PlaneDragGizmo;
  42025. /**
  42026. * Internal gizmo used for interactions on the xy plane
  42027. */
  42028. zPlaneGizmo: PlaneDragGizmo;
  42029. /**
  42030. * private variables
  42031. */
  42032. private _meshAttached;
  42033. private _updateGizmoRotationToMatchAttachedMesh;
  42034. private _snapDistance;
  42035. private _scaleRatio;
  42036. /** Fires an event when any of it's sub gizmos are dragged */
  42037. onDragStartObservable: Observable<unknown>;
  42038. /** Fires an event when any of it's sub gizmos are released from dragging */
  42039. onDragEndObservable: Observable<unknown>;
  42040. /**
  42041. * If set to true, planar drag is enabled
  42042. */
  42043. private _planarGizmoEnabled;
  42044. attachedMesh: Nullable<AbstractMesh>;
  42045. /**
  42046. * Creates a PositionGizmo
  42047. * @param gizmoLayer The utility layer the gizmo will be added to
  42048. */
  42049. constructor(gizmoLayer?: UtilityLayerRenderer);
  42050. /**
  42051. * If the planar drag gizmo is enabled
  42052. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42053. */
  42054. planarGizmoEnabled: boolean;
  42055. updateGizmoRotationToMatchAttachedMesh: boolean;
  42056. /**
  42057. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42058. */
  42059. snapDistance: number;
  42060. /**
  42061. * Ratio for the scale of the gizmo (Default: 1)
  42062. */
  42063. scaleRatio: number;
  42064. /**
  42065. * Disposes of the gizmo
  42066. */
  42067. dispose(): void;
  42068. /**
  42069. * CustomMeshes are not supported by this gizmo
  42070. * @param mesh The mesh to replace the default mesh of the gizmo
  42071. */
  42072. setCustomMesh(mesh: Mesh): void;
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. /**
  42077. * Single axis drag gizmo
  42078. */
  42079. export class AxisDragGizmo extends Gizmo {
  42080. /**
  42081. * Drag behavior responsible for the gizmos dragging interactions
  42082. */
  42083. dragBehavior: PointerDragBehavior;
  42084. private _pointerObserver;
  42085. /**
  42086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42087. */
  42088. snapDistance: number;
  42089. /**
  42090. * Event that fires each time the gizmo snaps to a new location.
  42091. * * snapDistance is the the change in distance
  42092. */
  42093. onSnapObservable: Observable<{
  42094. snapDistance: number;
  42095. }>;
  42096. private _isEnabled;
  42097. private _parent;
  42098. private _arrow;
  42099. private _coloredMaterial;
  42100. private _hoverMaterial;
  42101. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42102. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42103. /**
  42104. * Creates an AxisDragGizmo
  42105. * @param gizmoLayer The utility layer the gizmo will be added to
  42106. * @param dragAxis The axis which the gizmo will be able to drag on
  42107. * @param color The color of the gizmo
  42108. */
  42109. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42110. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42111. /**
  42112. * If the gizmo is enabled
  42113. */
  42114. isEnabled: boolean;
  42115. /**
  42116. * Disposes of the gizmo
  42117. */
  42118. dispose(): void;
  42119. }
  42120. }
  42121. declare module BABYLON.Debug {
  42122. /**
  42123. * The Axes viewer will show 3 axes in a specific point in space
  42124. */
  42125. export class AxesViewer {
  42126. private _xAxis;
  42127. private _yAxis;
  42128. private _zAxis;
  42129. private _scaleLinesFactor;
  42130. private _instanced;
  42131. /**
  42132. * Gets the hosting scene
  42133. */
  42134. scene: Scene;
  42135. /**
  42136. * Gets or sets a number used to scale line length
  42137. */
  42138. scaleLines: number;
  42139. /** Gets the node hierarchy used to render x-axis */
  42140. readonly xAxis: TransformNode;
  42141. /** Gets the node hierarchy used to render y-axis */
  42142. readonly yAxis: TransformNode;
  42143. /** Gets the node hierarchy used to render z-axis */
  42144. readonly zAxis: TransformNode;
  42145. /**
  42146. * Creates a new AxesViewer
  42147. * @param scene defines the hosting scene
  42148. * @param scaleLines defines a number used to scale line length (1 by default)
  42149. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42150. * @param xAxis defines the node hierarchy used to render the x-axis
  42151. * @param yAxis defines the node hierarchy used to render the y-axis
  42152. * @param zAxis defines the node hierarchy used to render the z-axis
  42153. */
  42154. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42155. /**
  42156. * Force the viewer to update
  42157. * @param position defines the position of the viewer
  42158. * @param xaxis defines the x axis of the viewer
  42159. * @param yaxis defines the y axis of the viewer
  42160. * @param zaxis defines the z axis of the viewer
  42161. */
  42162. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42163. /**
  42164. * Creates an instance of this axes viewer.
  42165. * @returns a new axes viewer with instanced meshes
  42166. */
  42167. createInstance(): AxesViewer;
  42168. /** Releases resources */
  42169. dispose(): void;
  42170. private static _SetRenderingGroupId;
  42171. }
  42172. }
  42173. declare module BABYLON.Debug {
  42174. /**
  42175. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42176. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42177. */
  42178. export class BoneAxesViewer extends AxesViewer {
  42179. /**
  42180. * Gets or sets the target mesh where to display the axes viewer
  42181. */
  42182. mesh: Nullable<Mesh>;
  42183. /**
  42184. * Gets or sets the target bone where to display the axes viewer
  42185. */
  42186. bone: Nullable<Bone>;
  42187. /** Gets current position */
  42188. pos: Vector3;
  42189. /** Gets direction of X axis */
  42190. xaxis: Vector3;
  42191. /** Gets direction of Y axis */
  42192. yaxis: Vector3;
  42193. /** Gets direction of Z axis */
  42194. zaxis: Vector3;
  42195. /**
  42196. * Creates a new BoneAxesViewer
  42197. * @param scene defines the hosting scene
  42198. * @param bone defines the target bone
  42199. * @param mesh defines the target mesh
  42200. * @param scaleLines defines a scaling factor for line length (1 by default)
  42201. */
  42202. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42203. /**
  42204. * Force the viewer to update
  42205. */
  42206. update(): void;
  42207. /** Releases resources */
  42208. dispose(): void;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Interface used to define scene explorer extensibility option
  42214. */
  42215. export interface IExplorerExtensibilityOption {
  42216. /**
  42217. * Define the option label
  42218. */
  42219. label: string;
  42220. /**
  42221. * Defines the action to execute on click
  42222. */
  42223. action: (entity: any) => void;
  42224. }
  42225. /**
  42226. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42227. */
  42228. export interface IExplorerExtensibilityGroup {
  42229. /**
  42230. * Defines a predicate to test if a given type mut be extended
  42231. */
  42232. predicate: (entity: any) => boolean;
  42233. /**
  42234. * Gets the list of options added to a type
  42235. */
  42236. entries: IExplorerExtensibilityOption[];
  42237. }
  42238. /**
  42239. * Interface used to define the options to use to create the Inspector
  42240. */
  42241. export interface IInspectorOptions {
  42242. /**
  42243. * Display in overlay mode (default: false)
  42244. */
  42245. overlay?: boolean;
  42246. /**
  42247. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42248. */
  42249. globalRoot?: HTMLElement;
  42250. /**
  42251. * Display the Scene explorer
  42252. */
  42253. showExplorer?: boolean;
  42254. /**
  42255. * Display the property inspector
  42256. */
  42257. showInspector?: boolean;
  42258. /**
  42259. * Display in embed mode (both panes on the right)
  42260. */
  42261. embedMode?: boolean;
  42262. /**
  42263. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42264. */
  42265. handleResize?: boolean;
  42266. /**
  42267. * Allow the panes to popup (default: true)
  42268. */
  42269. enablePopup?: boolean;
  42270. /**
  42271. * Allow the panes to be closed by users (default: true)
  42272. */
  42273. enableClose?: boolean;
  42274. /**
  42275. * Optional list of extensibility entries
  42276. */
  42277. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42278. /**
  42279. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42280. */
  42281. inspectorURL?: string;
  42282. }
  42283. interface Scene {
  42284. /**
  42285. * @hidden
  42286. * Backing field
  42287. */ private _debugLayer: DebugLayer;
  42288. /**
  42289. * Gets the debug layer (aka Inspector) associated with the scene
  42290. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42291. */
  42292. debugLayer: DebugLayer;
  42293. }
  42294. /**
  42295. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42296. * what is happening in your scene
  42297. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42298. */
  42299. export class DebugLayer {
  42300. /**
  42301. * Define the url to get the inspector script from.
  42302. * By default it uses the babylonjs CDN.
  42303. * @ignoreNaming
  42304. */
  42305. static InspectorURL: string;
  42306. private _scene;
  42307. private BJSINSPECTOR;
  42308. private _onPropertyChangedObservable?;
  42309. /**
  42310. * Observable triggered when a property is changed through the inspector.
  42311. */
  42312. readonly onPropertyChangedObservable: any;
  42313. /**
  42314. * Instantiates a new debug layer.
  42315. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42316. * what is happening in your scene
  42317. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42318. * @param scene Defines the scene to inspect
  42319. */
  42320. constructor(scene: Scene);
  42321. /** Creates the inspector window. */
  42322. private _createInspector;
  42323. /**
  42324. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42325. * @param entity defines the entity to select
  42326. * @param lineContainerTitle defines the specific block to highlight
  42327. */
  42328. select(entity: any, lineContainerTitle?: string): void;
  42329. /** Get the inspector from bundle or global */
  42330. private _getGlobalInspector;
  42331. /**
  42332. * Get if the inspector is visible or not.
  42333. * @returns true if visible otherwise, false
  42334. */
  42335. isVisible(): boolean;
  42336. /**
  42337. * Hide the inspector and close its window.
  42338. */
  42339. hide(): void;
  42340. /**
  42341. * Launch the debugLayer.
  42342. * @param config Define the configuration of the inspector
  42343. * @return a promise fulfilled when the debug layer is visible
  42344. */
  42345. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42346. }
  42347. }
  42348. declare module BABYLON {
  42349. /**
  42350. * Class containing static functions to help procedurally build meshes
  42351. */
  42352. export class BoxBuilder {
  42353. /**
  42354. * Creates a box mesh
  42355. * * The parameter `size` sets the size (float) of each box side (default 1)
  42356. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42357. * * 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)
  42358. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42360. * * 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
  42361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42362. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42363. * @param name defines the name of the mesh
  42364. * @param options defines the options used to create the mesh
  42365. * @param scene defines the hosting scene
  42366. * @returns the box mesh
  42367. */
  42368. static CreateBox(name: string, options: {
  42369. size?: number;
  42370. width?: number;
  42371. height?: number;
  42372. depth?: number;
  42373. faceUV?: Vector4[];
  42374. faceColors?: Color4[];
  42375. sideOrientation?: number;
  42376. frontUVs?: Vector4;
  42377. backUVs?: Vector4;
  42378. wrap?: boolean;
  42379. topBaseAt?: number;
  42380. bottomBaseAt?: number;
  42381. updatable?: boolean;
  42382. }, scene?: Nullable<Scene>): Mesh;
  42383. }
  42384. }
  42385. declare module BABYLON {
  42386. /**
  42387. * Class containing static functions to help procedurally build meshes
  42388. */
  42389. export class SphereBuilder {
  42390. /**
  42391. * Creates a sphere mesh
  42392. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42393. * * 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`)
  42394. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42395. * * 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
  42396. * * 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)
  42397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42398. * * 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
  42399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42400. * @param name defines the name of the mesh
  42401. * @param options defines the options used to create the mesh
  42402. * @param scene defines the hosting scene
  42403. * @returns the sphere mesh
  42404. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42405. */
  42406. static CreateSphere(name: string, options: {
  42407. segments?: number;
  42408. diameter?: number;
  42409. diameterX?: number;
  42410. diameterY?: number;
  42411. diameterZ?: number;
  42412. arc?: number;
  42413. slice?: number;
  42414. sideOrientation?: number;
  42415. frontUVs?: Vector4;
  42416. backUVs?: Vector4;
  42417. updatable?: boolean;
  42418. }, scene?: Nullable<Scene>): Mesh;
  42419. }
  42420. }
  42421. declare module BABYLON.Debug {
  42422. /**
  42423. * Used to show the physics impostor around the specific mesh
  42424. */
  42425. export class PhysicsViewer {
  42426. /** @hidden */
  42427. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42428. /** @hidden */
  42429. protected _meshes: Array<Nullable<AbstractMesh>>;
  42430. /** @hidden */
  42431. protected _scene: Nullable<Scene>;
  42432. /** @hidden */
  42433. protected _numMeshes: number;
  42434. /** @hidden */
  42435. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42436. private _renderFunction;
  42437. private _utilityLayer;
  42438. private _debugBoxMesh;
  42439. private _debugSphereMesh;
  42440. private _debugCylinderMesh;
  42441. private _debugMaterial;
  42442. private _debugMeshMeshes;
  42443. /**
  42444. * Creates a new PhysicsViewer
  42445. * @param scene defines the hosting scene
  42446. */
  42447. constructor(scene: Scene);
  42448. /** @hidden */
  42449. protected _updateDebugMeshes(): void;
  42450. /**
  42451. * Renders a specified physic impostor
  42452. * @param impostor defines the impostor to render
  42453. * @param targetMesh defines the mesh represented by the impostor
  42454. * @returns the new debug mesh used to render the impostor
  42455. */
  42456. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42457. /**
  42458. * Hides a specified physic impostor
  42459. * @param impostor defines the impostor to hide
  42460. */
  42461. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42462. private _getDebugMaterial;
  42463. private _getDebugBoxMesh;
  42464. private _getDebugSphereMesh;
  42465. private _getDebugCylinderMesh;
  42466. private _getDebugMeshMesh;
  42467. private _getDebugMesh;
  42468. /** Releases all resources */
  42469. dispose(): void;
  42470. }
  42471. }
  42472. declare module BABYLON {
  42473. /**
  42474. * Class containing static functions to help procedurally build meshes
  42475. */
  42476. export class LinesBuilder {
  42477. /**
  42478. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42479. * * 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
  42480. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42481. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42482. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42483. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42484. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42485. * * 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
  42486. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42489. * @param name defines the name of the new line system
  42490. * @param options defines the options used to create the line system
  42491. * @param scene defines the hosting scene
  42492. * @returns a new line system mesh
  42493. */
  42494. static CreateLineSystem(name: string, options: {
  42495. lines: Vector3[][];
  42496. updatable?: boolean;
  42497. instance?: Nullable<LinesMesh>;
  42498. colors?: Nullable<Color4[][]>;
  42499. useVertexAlpha?: boolean;
  42500. }, scene: Nullable<Scene>): LinesMesh;
  42501. /**
  42502. * Creates a line mesh
  42503. * 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
  42504. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42505. * * The parameter `points` is an array successive Vector3
  42506. * * 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
  42507. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42508. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42509. * * When updating an instance, remember that only point positions can change, not the number of points
  42510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42512. * @param name defines the name of the new line system
  42513. * @param options defines the options used to create the line system
  42514. * @param scene defines the hosting scene
  42515. * @returns a new line mesh
  42516. */
  42517. static CreateLines(name: string, options: {
  42518. points: Vector3[];
  42519. updatable?: boolean;
  42520. instance?: Nullable<LinesMesh>;
  42521. colors?: Color4[];
  42522. useVertexAlpha?: boolean;
  42523. }, scene?: Nullable<Scene>): LinesMesh;
  42524. /**
  42525. * Creates a dashed line mesh
  42526. * * 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
  42527. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42528. * * The parameter `points` is an array successive Vector3
  42529. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42530. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42531. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42532. * * 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
  42533. * * When updating an instance, remember that only point positions can change, not the number of points
  42534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42535. * @param name defines the name of the mesh
  42536. * @param options defines the options used to create the mesh
  42537. * @param scene defines the hosting scene
  42538. * @returns the dashed line mesh
  42539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42540. */
  42541. static CreateDashedLines(name: string, options: {
  42542. points: Vector3[];
  42543. dashSize?: number;
  42544. gapSize?: number;
  42545. dashNb?: number;
  42546. updatable?: boolean;
  42547. instance?: LinesMesh;
  42548. }, scene?: Nullable<Scene>): LinesMesh;
  42549. }
  42550. }
  42551. declare module BABYLON {
  42552. /**
  42553. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42554. * in order to better appreciate the issue one might have.
  42555. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42556. */
  42557. export class RayHelper {
  42558. /**
  42559. * Defines the ray we are currently tryin to visualize.
  42560. */
  42561. ray: Nullable<Ray>;
  42562. private _renderPoints;
  42563. private _renderLine;
  42564. private _renderFunction;
  42565. private _scene;
  42566. private _updateToMeshFunction;
  42567. private _attachedToMesh;
  42568. private _meshSpaceDirection;
  42569. private _meshSpaceOrigin;
  42570. /**
  42571. * Helper function to create a colored helper in a scene in one line.
  42572. * @param ray Defines the ray we are currently tryin to visualize
  42573. * @param scene Defines the scene the ray is used in
  42574. * @param color Defines the color we want to see the ray in
  42575. * @returns The newly created ray helper.
  42576. */
  42577. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42578. /**
  42579. * Instantiate a new ray helper.
  42580. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42581. * in order to better appreciate the issue one might have.
  42582. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42583. * @param ray Defines the ray we are currently tryin to visualize
  42584. */
  42585. constructor(ray: Ray);
  42586. /**
  42587. * Shows the ray we are willing to debug.
  42588. * @param scene Defines the scene the ray needs to be rendered in
  42589. * @param color Defines the color the ray needs to be rendered in
  42590. */
  42591. show(scene: Scene, color?: Color3): void;
  42592. /**
  42593. * Hides the ray we are debugging.
  42594. */
  42595. hide(): void;
  42596. private _render;
  42597. /**
  42598. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42599. * @param mesh Defines the mesh we want the helper attached to
  42600. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42601. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42602. * @param length Defines the length of the ray
  42603. */
  42604. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42605. /**
  42606. * Detach the ray helper from the mesh it has previously been attached to.
  42607. */
  42608. detachFromMesh(): void;
  42609. private _updateToMesh;
  42610. /**
  42611. * Dispose the helper and release its associated resources.
  42612. */
  42613. dispose(): void;
  42614. }
  42615. }
  42616. declare module BABYLON.Debug {
  42617. /**
  42618. * Class used to render a debug view of a given skeleton
  42619. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42620. */
  42621. export class SkeletonViewer {
  42622. /** defines the skeleton to render */
  42623. skeleton: Skeleton;
  42624. /** defines the mesh attached to the skeleton */
  42625. mesh: AbstractMesh;
  42626. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42627. autoUpdateBonesMatrices: boolean;
  42628. /** defines the rendering group id to use with the viewer */
  42629. renderingGroupId: number;
  42630. /** Gets or sets the color used to render the skeleton */
  42631. color: Color3;
  42632. private _scene;
  42633. private _debugLines;
  42634. private _debugMesh;
  42635. private _isEnabled;
  42636. private _renderFunction;
  42637. private _utilityLayer;
  42638. /**
  42639. * Returns the mesh used to render the bones
  42640. */
  42641. readonly debugMesh: Nullable<LinesMesh>;
  42642. /**
  42643. * Creates a new SkeletonViewer
  42644. * @param skeleton defines the skeleton to render
  42645. * @param mesh defines the mesh attached to the skeleton
  42646. * @param scene defines the hosting scene
  42647. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42648. * @param renderingGroupId defines the rendering group id to use with the viewer
  42649. */
  42650. constructor(
  42651. /** defines the skeleton to render */
  42652. skeleton: Skeleton,
  42653. /** defines the mesh attached to the skeleton */
  42654. mesh: AbstractMesh, scene: Scene,
  42655. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42656. autoUpdateBonesMatrices?: boolean,
  42657. /** defines the rendering group id to use with the viewer */
  42658. renderingGroupId?: number);
  42659. /** Gets or sets a boolean indicating if the viewer is enabled */
  42660. isEnabled: boolean;
  42661. private _getBonePosition;
  42662. private _getLinesForBonesWithLength;
  42663. private _getLinesForBonesNoLength;
  42664. /** Update the viewer to sync with current skeleton state */
  42665. update(): void;
  42666. /** Release associated resources */
  42667. dispose(): void;
  42668. }
  42669. }
  42670. declare module BABYLON {
  42671. /**
  42672. * Options to create the null engine
  42673. */
  42674. export class NullEngineOptions {
  42675. /**
  42676. * Render width (Default: 512)
  42677. */
  42678. renderWidth: number;
  42679. /**
  42680. * Render height (Default: 256)
  42681. */
  42682. renderHeight: number;
  42683. /**
  42684. * Texture size (Default: 512)
  42685. */
  42686. textureSize: number;
  42687. /**
  42688. * If delta time between frames should be constant
  42689. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42690. */
  42691. deterministicLockstep: boolean;
  42692. /**
  42693. * Maximum about of steps between frames (Default: 4)
  42694. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42695. */
  42696. lockstepMaxSteps: number;
  42697. }
  42698. /**
  42699. * The null engine class provides support for headless version of babylon.js.
  42700. * This can be used in server side scenario or for testing purposes
  42701. */
  42702. export class NullEngine extends Engine {
  42703. private _options;
  42704. /**
  42705. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42706. */
  42707. isDeterministicLockStep(): boolean;
  42708. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42709. getLockstepMaxSteps(): number;
  42710. /**
  42711. * Sets hardware scaling, used to save performance if needed
  42712. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42713. */
  42714. getHardwareScalingLevel(): number;
  42715. constructor(options?: NullEngineOptions);
  42716. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42717. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42718. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42719. getRenderWidth(useScreen?: boolean): number;
  42720. getRenderHeight(useScreen?: boolean): number;
  42721. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42722. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42723. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42724. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42725. bindSamplers(effect: Effect): void;
  42726. enableEffect(effect: Effect): void;
  42727. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42728. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42729. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42730. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42731. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42732. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42733. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42734. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42735. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42736. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42737. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42738. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42739. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42740. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42741. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42742. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42743. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42744. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42745. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42746. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42747. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42748. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42749. bindBuffers(vertexBuffers: {
  42750. [key: string]: VertexBuffer;
  42751. }, indexBuffer: DataBuffer, effect: Effect): void;
  42752. wipeCaches(bruteForce?: boolean): void;
  42753. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42754. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42755. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42756. /** @hidden */ private _createTexture(): WebGLTexture;
  42757. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  42758. 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;
  42759. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42760. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42761. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42762. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42763. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42764. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42765. areAllEffectsReady(): boolean;
  42766. /**
  42767. * @hidden
  42768. * Get the current error code of the webGL context
  42769. * @returns the error code
  42770. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42771. */
  42772. getError(): number;
  42773. /** @hidden */ private _getUnpackAlignement(): number;
  42774. /** @hidden */ private _unpackFlipY(value: boolean): void;
  42775. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42776. /**
  42777. * Updates a dynamic vertex buffer.
  42778. * @param vertexBuffer the vertex buffer to update
  42779. * @param data the data used to update the vertex buffer
  42780. * @param byteOffset the byte offset of the data (optional)
  42781. * @param byteLength the byte length of the data (optional)
  42782. */
  42783. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42784. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  42785. protected _deleteBuffer(buffer: WebGLBuffer): void;
  42786. releaseEffects(): void;
  42787. displayLoadingUI(): void;
  42788. hideLoadingUI(): void;
  42789. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42790. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42791. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42792. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42793. }
  42794. }
  42795. declare module BABYLON {
  42796. /** @hidden */
  42797. export class _OcclusionDataStorage {
  42798. /** @hidden */
  42799. occlusionInternalRetryCounter: number;
  42800. /** @hidden */
  42801. isOcclusionQueryInProgress: boolean;
  42802. /** @hidden */
  42803. isOccluded: boolean;
  42804. /** @hidden */
  42805. occlusionRetryCount: number;
  42806. /** @hidden */
  42807. occlusionType: number;
  42808. /** @hidden */
  42809. occlusionQueryAlgorithmType: number;
  42810. }
  42811. interface Engine {
  42812. /**
  42813. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42814. * @return the new query
  42815. */
  42816. createQuery(): WebGLQuery;
  42817. /**
  42818. * Delete and release a webGL query
  42819. * @param query defines the query to delete
  42820. * @return the current engine
  42821. */
  42822. deleteQuery(query: WebGLQuery): Engine;
  42823. /**
  42824. * Check if a given query has resolved and got its value
  42825. * @param query defines the query to check
  42826. * @returns true if the query got its value
  42827. */
  42828. isQueryResultAvailable(query: WebGLQuery): boolean;
  42829. /**
  42830. * Gets the value of a given query
  42831. * @param query defines the query to check
  42832. * @returns the value of the query
  42833. */
  42834. getQueryResult(query: WebGLQuery): number;
  42835. /**
  42836. * Initiates an occlusion query
  42837. * @param algorithmType defines the algorithm to use
  42838. * @param query defines the query to use
  42839. * @returns the current engine
  42840. * @see http://doc.babylonjs.com/features/occlusionquery
  42841. */
  42842. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42843. /**
  42844. * Ends an occlusion query
  42845. * @see http://doc.babylonjs.com/features/occlusionquery
  42846. * @param algorithmType defines the algorithm to use
  42847. * @returns the current engine
  42848. */
  42849. endOcclusionQuery(algorithmType: number): Engine;
  42850. /**
  42851. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42852. * Please note that only one query can be issued at a time
  42853. * @returns a time token used to track the time span
  42854. */
  42855. startTimeQuery(): Nullable<_TimeToken>;
  42856. /**
  42857. * Ends a time query
  42858. * @param token defines the token used to measure the time span
  42859. * @returns the time spent (in ns)
  42860. */
  42861. endTimeQuery(token: _TimeToken): int;
  42862. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  42863. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  42864. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  42865. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  42866. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  42867. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  42868. }
  42869. interface AbstractMesh {
  42870. /**
  42871. * Backing filed
  42872. * @hidden
  42873. */ private __occlusionDataStorage: _OcclusionDataStorage;
  42874. /**
  42875. * Access property
  42876. * @hidden
  42877. */ private _occlusionDataStorage: _OcclusionDataStorage;
  42878. /**
  42879. * 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.
  42880. * The default value is -1 which means don't break the query and wait till the result
  42881. * @see http://doc.babylonjs.com/features/occlusionquery
  42882. */
  42883. occlusionRetryCount: number;
  42884. /**
  42885. * 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:
  42886. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42887. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42888. * * 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.
  42889. * @see http://doc.babylonjs.com/features/occlusionquery
  42890. */
  42891. occlusionType: number;
  42892. /**
  42893. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42894. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42895. * * 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.
  42896. * @see http://doc.babylonjs.com/features/occlusionquery
  42897. */
  42898. occlusionQueryAlgorithmType: number;
  42899. /**
  42900. * 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
  42901. * @see http://doc.babylonjs.com/features/occlusionquery
  42902. */
  42903. isOccluded: boolean;
  42904. /**
  42905. * Flag to check the progress status of the query
  42906. * @see http://doc.babylonjs.com/features/occlusionquery
  42907. */
  42908. isOcclusionQueryInProgress: boolean;
  42909. }
  42910. }
  42911. declare module BABYLON {
  42912. /** @hidden */
  42913. export var _forceTransformFeedbackToBundle: boolean;
  42914. interface Engine {
  42915. /**
  42916. * Creates a webGL transform feedback object
  42917. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42918. * @returns the webGL transform feedback object
  42919. */
  42920. createTransformFeedback(): WebGLTransformFeedback;
  42921. /**
  42922. * Delete a webGL transform feedback object
  42923. * @param value defines the webGL transform feedback object to delete
  42924. */
  42925. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42926. /**
  42927. * Bind a webGL transform feedback object to the webgl context
  42928. * @param value defines the webGL transform feedback object to bind
  42929. */
  42930. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42931. /**
  42932. * Begins a transform feedback operation
  42933. * @param usePoints defines if points or triangles must be used
  42934. */
  42935. beginTransformFeedback(usePoints: boolean): void;
  42936. /**
  42937. * Ends a transform feedback operation
  42938. */
  42939. endTransformFeedback(): void;
  42940. /**
  42941. * Specify the varyings to use with transform feedback
  42942. * @param program defines the associated webGL program
  42943. * @param value defines the list of strings representing the varying names
  42944. */
  42945. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42946. /**
  42947. * Bind a webGL buffer for a transform feedback operation
  42948. * @param value defines the webGL buffer to bind
  42949. */
  42950. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42951. }
  42952. }
  42953. declare module BABYLON {
  42954. /**
  42955. * Creation options of the multi render target texture.
  42956. */
  42957. export interface IMultiRenderTargetOptions {
  42958. /**
  42959. * Define if the texture needs to create mip maps after render.
  42960. */
  42961. generateMipMaps?: boolean;
  42962. /**
  42963. * Define the types of all the draw buffers we want to create
  42964. */
  42965. types?: number[];
  42966. /**
  42967. * Define the sampling modes of all the draw buffers we want to create
  42968. */
  42969. samplingModes?: number[];
  42970. /**
  42971. * Define if a depth buffer is required
  42972. */
  42973. generateDepthBuffer?: boolean;
  42974. /**
  42975. * Define if a stencil buffer is required
  42976. */
  42977. generateStencilBuffer?: boolean;
  42978. /**
  42979. * Define if a depth texture is required instead of a depth buffer
  42980. */
  42981. generateDepthTexture?: boolean;
  42982. /**
  42983. * Define the number of desired draw buffers
  42984. */
  42985. textureCount?: number;
  42986. /**
  42987. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42988. */
  42989. doNotChangeAspectRatio?: boolean;
  42990. /**
  42991. * Define the default type of the buffers we are creating
  42992. */
  42993. defaultType?: number;
  42994. }
  42995. /**
  42996. * A multi render target, like a render target provides the ability to render to a texture.
  42997. * Unlike the render target, it can render to several draw buffers in one draw.
  42998. * This is specially interesting in deferred rendering or for any effects requiring more than
  42999. * just one color from a single pass.
  43000. */
  43001. export class MultiRenderTarget extends RenderTargetTexture {
  43002. private _internalTextures;
  43003. private _textures;
  43004. private _multiRenderTargetOptions;
  43005. /**
  43006. * Get if draw buffers are currently supported by the used hardware and browser.
  43007. */
  43008. readonly isSupported: boolean;
  43009. /**
  43010. * Get the list of textures generated by the multi render target.
  43011. */
  43012. readonly textures: Texture[];
  43013. /**
  43014. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43015. */
  43016. readonly depthTexture: Texture;
  43017. /**
  43018. * Set the wrapping mode on U of all the textures we are rendering to.
  43019. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43020. */
  43021. wrapU: number;
  43022. /**
  43023. * Set the wrapping mode on V of all the textures we are rendering to.
  43024. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43025. */
  43026. wrapV: number;
  43027. /**
  43028. * Instantiate a new multi render target texture.
  43029. * A multi render target, like a render target provides the ability to render to a texture.
  43030. * Unlike the render target, it can render to several draw buffers in one draw.
  43031. * This is specially interesting in deferred rendering or for any effects requiring more than
  43032. * just one color from a single pass.
  43033. * @param name Define the name of the texture
  43034. * @param size Define the size of the buffers to render to
  43035. * @param count Define the number of target we are rendering into
  43036. * @param scene Define the scene the texture belongs to
  43037. * @param options Define the options used to create the multi render target
  43038. */
  43039. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43040. /** @hidden */ private _rebuild(): void;
  43041. private _createInternalTextures;
  43042. private _createTextures;
  43043. /**
  43044. * Define the number of samples used if MSAA is enabled.
  43045. */
  43046. samples: number;
  43047. /**
  43048. * Resize all the textures in the multi render target.
  43049. * Be carrefull as it will recreate all the data in the new texture.
  43050. * @param size Define the new size
  43051. */
  43052. resize(size: any): void;
  43053. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43054. /**
  43055. * Dispose the render targets and their associated resources
  43056. */
  43057. dispose(): void;
  43058. /**
  43059. * Release all the underlying texture used as draw buffers.
  43060. */
  43061. releaseInternalTextures(): void;
  43062. }
  43063. }
  43064. declare module BABYLON {
  43065. interface Engine {
  43066. /**
  43067. * Unbind a list of render target textures from the webGL context
  43068. * This is used only when drawBuffer extension or webGL2 are active
  43069. * @param textures defines the render target textures to unbind
  43070. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43071. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43072. */
  43073. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43074. /**
  43075. * Create a multi render target texture
  43076. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43077. * @param size defines the size of the texture
  43078. * @param options defines the creation options
  43079. * @returns the cube texture as an InternalTexture
  43080. */
  43081. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43082. /**
  43083. * Update the sample count for a given multiple render target texture
  43084. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43085. * @param textures defines the textures to update
  43086. * @param samples defines the sample count to set
  43087. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43088. */
  43089. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43090. }
  43091. }
  43092. declare module BABYLON {
  43093. /** @hidden */
  43094. export var rgbdEncodePixelShader: {
  43095. name: string;
  43096. shader: string;
  43097. };
  43098. }
  43099. declare module BABYLON {
  43100. /** @hidden */
  43101. export var rgbdDecodePixelShader: {
  43102. name: string;
  43103. shader: string;
  43104. };
  43105. }
  43106. declare module BABYLON {
  43107. /**
  43108. * Raw texture data and descriptor sufficient for WebGL texture upload
  43109. */
  43110. export interface EnvironmentTextureInfo {
  43111. /**
  43112. * Version of the environment map
  43113. */
  43114. version: number;
  43115. /**
  43116. * Width of image
  43117. */
  43118. width: number;
  43119. /**
  43120. * Irradiance information stored in the file.
  43121. */
  43122. irradiance: any;
  43123. /**
  43124. * Specular information stored in the file.
  43125. */
  43126. specular: any;
  43127. }
  43128. /**
  43129. * Defines One Image in the file. It requires only the position in the file
  43130. * as well as the length.
  43131. */
  43132. interface BufferImageData {
  43133. /**
  43134. * Length of the image data.
  43135. */
  43136. length: number;
  43137. /**
  43138. * Position of the data from the null terminator delimiting the end of the JSON.
  43139. */
  43140. position: number;
  43141. }
  43142. /**
  43143. * Defines the specular data enclosed in the file.
  43144. * This corresponds to the version 1 of the data.
  43145. */
  43146. export interface EnvironmentTextureSpecularInfoV1 {
  43147. /**
  43148. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43149. */
  43150. specularDataPosition?: number;
  43151. /**
  43152. * This contains all the images data needed to reconstruct the cubemap.
  43153. */
  43154. mipmaps: Array<BufferImageData>;
  43155. /**
  43156. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43157. */
  43158. lodGenerationScale: number;
  43159. }
  43160. /**
  43161. * Sets of helpers addressing the serialization and deserialization of environment texture
  43162. * stored in a BabylonJS env file.
  43163. * Those files are usually stored as .env files.
  43164. */
  43165. export class EnvironmentTextureTools {
  43166. /**
  43167. * Magic number identifying the env file.
  43168. */
  43169. private static _MagicBytes;
  43170. /**
  43171. * Gets the environment info from an env file.
  43172. * @param data The array buffer containing the .env bytes.
  43173. * @returns the environment file info (the json header) if successfully parsed.
  43174. */
  43175. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43176. /**
  43177. * Creates an environment texture from a loaded cube texture.
  43178. * @param texture defines the cube texture to convert in env file
  43179. * @return a promise containing the environment data if succesfull.
  43180. */
  43181. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43182. /**
  43183. * Creates a JSON representation of the spherical data.
  43184. * @param texture defines the texture containing the polynomials
  43185. * @return the JSON representation of the spherical info
  43186. */
  43187. private static _CreateEnvTextureIrradiance;
  43188. /**
  43189. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43190. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43191. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43192. * @return the views described by info providing access to the underlying buffer
  43193. */
  43194. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43195. /**
  43196. * Uploads the texture info contained in the env file to the GPU.
  43197. * @param texture defines the internal texture to upload to
  43198. * @param arrayBuffer defines the buffer cotaining the data to load
  43199. * @param info defines the texture info retrieved through the GetEnvInfo method
  43200. * @returns a promise
  43201. */
  43202. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43203. /**
  43204. * Uploads the levels of image data to the GPU.
  43205. * @param texture defines the internal texture to upload to
  43206. * @param imageData defines the array buffer views of image data [mipmap][face]
  43207. * @returns a promise
  43208. */
  43209. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43210. /**
  43211. * Uploads spherical polynomials information to the texture.
  43212. * @param texture defines the texture we are trying to upload the information to
  43213. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43214. */
  43215. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43216. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43217. }
  43218. }
  43219. declare module BABYLON {
  43220. /**
  43221. * Contains position and normal vectors for a vertex
  43222. */
  43223. export class PositionNormalVertex {
  43224. /** the position of the vertex (defaut: 0,0,0) */
  43225. position: Vector3;
  43226. /** the normal of the vertex (defaut: 0,1,0) */
  43227. normal: Vector3;
  43228. /**
  43229. * Creates a PositionNormalVertex
  43230. * @param position the position of the vertex (defaut: 0,0,0)
  43231. * @param normal the normal of the vertex (defaut: 0,1,0)
  43232. */
  43233. constructor(
  43234. /** the position of the vertex (defaut: 0,0,0) */
  43235. position?: Vector3,
  43236. /** the normal of the vertex (defaut: 0,1,0) */
  43237. normal?: Vector3);
  43238. /**
  43239. * Clones the PositionNormalVertex
  43240. * @returns the cloned PositionNormalVertex
  43241. */
  43242. clone(): PositionNormalVertex;
  43243. }
  43244. /**
  43245. * Contains position, normal and uv vectors for a vertex
  43246. */
  43247. export class PositionNormalTextureVertex {
  43248. /** the position of the vertex (defaut: 0,0,0) */
  43249. position: Vector3;
  43250. /** the normal of the vertex (defaut: 0,1,0) */
  43251. normal: Vector3;
  43252. /** the uv of the vertex (default: 0,0) */
  43253. uv: Vector2;
  43254. /**
  43255. * Creates a PositionNormalTextureVertex
  43256. * @param position the position of the vertex (defaut: 0,0,0)
  43257. * @param normal the normal of the vertex (defaut: 0,1,0)
  43258. * @param uv the uv of the vertex (default: 0,0)
  43259. */
  43260. constructor(
  43261. /** the position of the vertex (defaut: 0,0,0) */
  43262. position?: Vector3,
  43263. /** the normal of the vertex (defaut: 0,1,0) */
  43264. normal?: Vector3,
  43265. /** the uv of the vertex (default: 0,0) */
  43266. uv?: Vector2);
  43267. /**
  43268. * Clones the PositionNormalTextureVertex
  43269. * @returns the cloned PositionNormalTextureVertex
  43270. */
  43271. clone(): PositionNormalTextureVertex;
  43272. }
  43273. }
  43274. declare module BABYLON {
  43275. /** @hidden */
  43276. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43277. private _genericAttributeLocation;
  43278. private _varyingLocationCount;
  43279. private _varyingLocationMap;
  43280. private _replacements;
  43281. private _textureCount;
  43282. private _uniforms;
  43283. lineProcessor(line: string): string;
  43284. attributeProcessor(attribute: string): string;
  43285. varyingProcessor(varying: string, isFragment: boolean): string;
  43286. uniformProcessor(uniform: string): string;
  43287. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43288. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43289. }
  43290. }
  43291. declare module BABYLON {
  43292. /**
  43293. * Container for accessors for natively-stored mesh data buffers.
  43294. */
  43295. class NativeDataBuffer extends DataBuffer {
  43296. /**
  43297. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43298. */
  43299. nativeIndexBuffer?: any;
  43300. /**
  43301. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  43302. */
  43303. nativeVertexBuffer?: any;
  43304. }
  43305. /** @hidden */
  43306. export class NativeEngine extends Engine {
  43307. private readonly _native;
  43308. getHardwareScalingLevel(): number;
  43309. constructor();
  43310. /**
  43311. * Can be used to override the current requestAnimationFrame requester.
  43312. * @hidden
  43313. */
  43314. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  43315. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43316. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  43317. createVertexBuffer(data: DataArray): NativeDataBuffer;
  43318. recordVertexArrayObject(vertexBuffers: {
  43319. [key: string]: VertexBuffer;
  43320. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  43321. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43322. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43323. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43324. /**
  43325. * Draw a list of indexed primitives
  43326. * @param fillMode defines the primitive to use
  43327. * @param indexStart defines the starting index
  43328. * @param indexCount defines the number of index to draw
  43329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43330. */
  43331. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43332. /**
  43333. * Draw a list of unindexed primitives
  43334. * @param fillMode defines the primitive to use
  43335. * @param verticesStart defines the index of first vertex to draw
  43336. * @param verticesCount defines the count of vertices to draw
  43337. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43338. */
  43339. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43340. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  43341. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  43342. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  43343. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43344. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43345. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43346. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  43347. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  43348. bindSamplers(effect: Effect): void;
  43349. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43350. getRenderWidth(useScreen?: boolean): number;
  43351. getRenderHeight(useScreen?: boolean): number;
  43352. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43353. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43354. /**
  43355. * Set the z offset to apply to current rendering
  43356. * @param value defines the offset to apply
  43357. */
  43358. setZOffset(value: number): void;
  43359. /**
  43360. * Gets the current value of the zOffset
  43361. * @returns the current zOffset state
  43362. */
  43363. getZOffset(): number;
  43364. /**
  43365. * Enable or disable depth buffering
  43366. * @param enable defines the state to set
  43367. */
  43368. setDepthBuffer(enable: boolean): void;
  43369. /**
  43370. * Gets a boolean indicating if depth writing is enabled
  43371. * @returns the current depth writing state
  43372. */
  43373. getDepthWrite(): boolean;
  43374. /**
  43375. * Enable or disable depth writing
  43376. * @param enable defines the state to set
  43377. */
  43378. setDepthWrite(enable: boolean): void;
  43379. /**
  43380. * Enable or disable color writing
  43381. * @param enable defines the state to set
  43382. */
  43383. setColorWrite(enable: boolean): void;
  43384. /**
  43385. * Gets a boolean indicating if color writing is enabled
  43386. * @returns the current color writing state
  43387. */
  43388. getColorWrite(): boolean;
  43389. /**
  43390. * Sets alpha constants used by some alpha blending modes
  43391. * @param r defines the red component
  43392. * @param g defines the green component
  43393. * @param b defines the blue component
  43394. * @param a defines the alpha component
  43395. */
  43396. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  43397. /**
  43398. * Sets the current alpha mode
  43399. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  43400. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43402. */
  43403. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43404. /**
  43405. * Gets the current alpha mode
  43406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43407. * @returns the current alpha mode
  43408. */
  43409. getAlphaMode(): number;
  43410. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43411. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43412. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43413. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43414. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43415. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43416. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43417. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43418. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43419. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43420. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43421. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43422. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43423. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43424. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43425. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43426. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43427. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43428. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43429. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43430. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43431. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43432. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  43433. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  43434. /**
  43435. * Usually called from BABYLON.Texture.ts.
  43436. * Passed information to create a WebGLTexture
  43437. * @param urlArg defines a value which contains one of the following:
  43438. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43439. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43440. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43442. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  43443. * @param scene needed for loading to the correct scene
  43444. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43445. * @param onLoad optional callback to be called upon successful completion
  43446. * @param onError optional callback to be called upon failure
  43447. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  43448. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43449. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43450. * @param forcedExtension defines the extension to use to pick the right loader
  43451. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43452. */
  43453. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  43454. /**
  43455. * Creates a cube texture
  43456. * @param rootUrl defines the url where the files to load is located
  43457. * @param scene defines the current scene
  43458. * @param files defines the list of files to load (1 per face)
  43459. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  43460. * @param onLoad defines an optional callback raised when the texture is loaded
  43461. * @param onError defines an optional callback raised if there is an issue to load the texture
  43462. * @param format defines the format of the data
  43463. * @param forcedExtension defines the extension to use to pick the right loader
  43464. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  43465. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  43466. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  43467. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  43468. * @returns the cube texture as an InternalTexture
  43469. */
  43470. 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>): InternalTexture;
  43471. private _getSamplingFilter;
  43472. private static _GetNativeTextureFormat;
  43473. createRenderTargetTexture(size: number | {
  43474. width: number;
  43475. height: number;
  43476. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43477. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43478. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43479. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43480. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  43481. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  43482. /**
  43483. * Updates a dynamic vertex buffer.
  43484. * @param vertexBuffer the vertex buffer to update
  43485. * @param data the data used to update the vertex buffer
  43486. * @param byteOffset the byte offset of the data (optional)
  43487. * @param byteLength the byte length of the data (optional)
  43488. */
  43489. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  43490. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  43491. private _updateAnisotropicLevel;
  43492. private _getAddressMode;
  43493. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43494. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  43495. releaseEffects(): void;
  43496. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43497. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43498. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43499. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43500. }
  43501. }
  43502. declare module BABYLON {
  43503. /**
  43504. * Gather the list of clipboard event types as constants.
  43505. */
  43506. export class ClipboardEventTypes {
  43507. /**
  43508. * The clipboard event is fired when a copy command is active (pressed).
  43509. */
  43510. static readonly COPY: number;
  43511. /**
  43512. * The clipboard event is fired when a cut command is active (pressed).
  43513. */
  43514. static readonly CUT: number;
  43515. /**
  43516. * The clipboard event is fired when a paste command is active (pressed).
  43517. */
  43518. static readonly PASTE: number;
  43519. }
  43520. /**
  43521. * This class is used to store clipboard related info for the onClipboardObservable event.
  43522. */
  43523. export class ClipboardInfo {
  43524. /**
  43525. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43526. */
  43527. type: number;
  43528. /**
  43529. * Defines the related dom event
  43530. */
  43531. event: ClipboardEvent;
  43532. /**
  43533. *Creates an instance of ClipboardInfo.
  43534. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43535. * @param event Defines the related dom event
  43536. */
  43537. constructor(
  43538. /**
  43539. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43540. */
  43541. type: number,
  43542. /**
  43543. * Defines the related dom event
  43544. */
  43545. event: ClipboardEvent);
  43546. /**
  43547. * Get the clipboard event's type from the keycode.
  43548. * @param keyCode Defines the keyCode for the current keyboard event.
  43549. * @return {number}
  43550. */
  43551. static GetTypeFromCharacter(keyCode: number): number;
  43552. }
  43553. }
  43554. declare module BABYLON {
  43555. /**
  43556. * Google Daydream controller
  43557. */
  43558. export class DaydreamController extends WebVRController {
  43559. /**
  43560. * Base Url for the controller model.
  43561. */
  43562. static MODEL_BASE_URL: string;
  43563. /**
  43564. * File name for the controller model.
  43565. */
  43566. static MODEL_FILENAME: string;
  43567. /**
  43568. * Gamepad Id prefix used to identify Daydream Controller.
  43569. */
  43570. static readonly GAMEPAD_ID_PREFIX: string;
  43571. /**
  43572. * Creates a new DaydreamController from a gamepad
  43573. * @param vrGamepad the gamepad that the controller should be created from
  43574. */
  43575. constructor(vrGamepad: any);
  43576. /**
  43577. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43578. * @param scene scene in which to add meshes
  43579. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43580. */
  43581. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43582. /**
  43583. * Called once for each button that changed state since the last frame
  43584. * @param buttonIdx Which button index changed
  43585. * @param state New state of the button
  43586. * @param changes Which properties on the state changed since last frame
  43587. */
  43588. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43589. }
  43590. }
  43591. declare module BABYLON {
  43592. /**
  43593. * Gear VR Controller
  43594. */
  43595. export class GearVRController extends WebVRController {
  43596. /**
  43597. * Base Url for the controller model.
  43598. */
  43599. static MODEL_BASE_URL: string;
  43600. /**
  43601. * File name for the controller model.
  43602. */
  43603. static MODEL_FILENAME: string;
  43604. /**
  43605. * Gamepad Id prefix used to identify this controller.
  43606. */
  43607. static readonly GAMEPAD_ID_PREFIX: string;
  43608. private readonly _buttonIndexToObservableNameMap;
  43609. /**
  43610. * Creates a new GearVRController from a gamepad
  43611. * @param vrGamepad the gamepad that the controller should be created from
  43612. */
  43613. constructor(vrGamepad: any);
  43614. /**
  43615. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43616. * @param scene scene in which to add meshes
  43617. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43618. */
  43619. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43620. /**
  43621. * Called once for each button that changed state since the last frame
  43622. * @param buttonIdx Which button index changed
  43623. * @param state New state of the button
  43624. * @param changes Which properties on the state changed since last frame
  43625. */
  43626. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43627. }
  43628. }
  43629. declare module BABYLON {
  43630. /**
  43631. * Class containing static functions to help procedurally build meshes
  43632. */
  43633. export class PolyhedronBuilder {
  43634. /**
  43635. * Creates a polyhedron mesh
  43636. * * 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
  43637. * * The parameter `size` (positive float, default 1) sets the polygon size
  43638. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43639. * * 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`
  43640. * * 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
  43641. * * 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)`)
  43642. * * 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
  43643. * * 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
  43644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43645. * * 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
  43646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43647. * @param name defines the name of the mesh
  43648. * @param options defines the options used to create the mesh
  43649. * @param scene defines the hosting scene
  43650. * @returns the polyhedron mesh
  43651. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43652. */
  43653. static CreatePolyhedron(name: string, options: {
  43654. type?: number;
  43655. size?: number;
  43656. sizeX?: number;
  43657. sizeY?: number;
  43658. sizeZ?: number;
  43659. custom?: any;
  43660. faceUV?: Vector4[];
  43661. faceColors?: Color4[];
  43662. flat?: boolean;
  43663. updatable?: boolean;
  43664. sideOrientation?: number;
  43665. frontUVs?: Vector4;
  43666. backUVs?: Vector4;
  43667. }, scene?: Nullable<Scene>): Mesh;
  43668. }
  43669. }
  43670. declare module BABYLON {
  43671. /**
  43672. * Gizmo that enables scaling a mesh along 3 axis
  43673. */
  43674. export class ScaleGizmo extends Gizmo {
  43675. /**
  43676. * Internal gizmo used for interactions on the x axis
  43677. */
  43678. xGizmo: AxisScaleGizmo;
  43679. /**
  43680. * Internal gizmo used for interactions on the y axis
  43681. */
  43682. yGizmo: AxisScaleGizmo;
  43683. /**
  43684. * Internal gizmo used for interactions on the z axis
  43685. */
  43686. zGizmo: AxisScaleGizmo;
  43687. /**
  43688. * Internal gizmo used to scale all axis equally
  43689. */
  43690. uniformScaleGizmo: AxisScaleGizmo;
  43691. private _meshAttached;
  43692. private _updateGizmoRotationToMatchAttachedMesh;
  43693. private _snapDistance;
  43694. private _scaleRatio;
  43695. private _uniformScalingMesh;
  43696. private _octahedron;
  43697. /** Fires an event when any of it's sub gizmos are dragged */
  43698. onDragStartObservable: Observable<unknown>;
  43699. /** Fires an event when any of it's sub gizmos are released from dragging */
  43700. onDragEndObservable: Observable<unknown>;
  43701. attachedMesh: Nullable<AbstractMesh>;
  43702. /**
  43703. * Creates a ScaleGizmo
  43704. * @param gizmoLayer The utility layer the gizmo will be added to
  43705. */
  43706. constructor(gizmoLayer?: UtilityLayerRenderer);
  43707. updateGizmoRotationToMatchAttachedMesh: boolean;
  43708. /**
  43709. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43710. */
  43711. snapDistance: number;
  43712. /**
  43713. * Ratio for the scale of the gizmo (Default: 1)
  43714. */
  43715. scaleRatio: number;
  43716. /**
  43717. * Disposes of the gizmo
  43718. */
  43719. dispose(): void;
  43720. }
  43721. }
  43722. declare module BABYLON {
  43723. /**
  43724. * Single axis scale gizmo
  43725. */
  43726. export class AxisScaleGizmo extends Gizmo {
  43727. /**
  43728. * Drag behavior responsible for the gizmos dragging interactions
  43729. */
  43730. dragBehavior: PointerDragBehavior;
  43731. private _pointerObserver;
  43732. /**
  43733. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43734. */
  43735. snapDistance: number;
  43736. /**
  43737. * Event that fires each time the gizmo snaps to a new location.
  43738. * * snapDistance is the the change in distance
  43739. */
  43740. onSnapObservable: Observable<{
  43741. snapDistance: number;
  43742. }>;
  43743. /**
  43744. * If the scaling operation should be done on all axis (default: false)
  43745. */
  43746. uniformScaling: boolean;
  43747. private _isEnabled;
  43748. private _parent;
  43749. private _arrow;
  43750. private _coloredMaterial;
  43751. private _hoverMaterial;
  43752. /**
  43753. * Creates an AxisScaleGizmo
  43754. * @param gizmoLayer The utility layer the gizmo will be added to
  43755. * @param dragAxis The axis which the gizmo will be able to scale on
  43756. * @param color The color of the gizmo
  43757. */
  43758. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43759. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43760. /**
  43761. * If the gizmo is enabled
  43762. */
  43763. isEnabled: boolean;
  43764. /**
  43765. * Disposes of the gizmo
  43766. */
  43767. dispose(): void;
  43768. /**
  43769. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43770. * @param mesh The mesh to replace the default mesh of the gizmo
  43771. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43772. */
  43773. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43774. }
  43775. }
  43776. declare module BABYLON {
  43777. /**
  43778. * Bounding box gizmo
  43779. */
  43780. export class BoundingBoxGizmo extends Gizmo {
  43781. private _lineBoundingBox;
  43782. private _rotateSpheresParent;
  43783. private _scaleBoxesParent;
  43784. private _boundingDimensions;
  43785. private _renderObserver;
  43786. private _pointerObserver;
  43787. private _scaleDragSpeed;
  43788. private _tmpQuaternion;
  43789. private _tmpVector;
  43790. private _tmpRotationMatrix;
  43791. /**
  43792. * 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)
  43793. */
  43794. ignoreChildren: boolean;
  43795. /**
  43796. * 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)
  43797. */
  43798. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43799. /**
  43800. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43801. */
  43802. rotationSphereSize: number;
  43803. /**
  43804. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43805. */
  43806. scaleBoxSize: number;
  43807. /**
  43808. * 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)
  43809. */
  43810. fixedDragMeshScreenSize: boolean;
  43811. /**
  43812. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43813. */
  43814. fixedDragMeshScreenSizeDistanceFactor: number;
  43815. /**
  43816. * Fired when a rotation sphere or scale box is dragged
  43817. */
  43818. onDragStartObservable: Observable<{}>;
  43819. /**
  43820. * Fired when a scale box is dragged
  43821. */
  43822. onScaleBoxDragObservable: Observable<{}>;
  43823. /**
  43824. * Fired when a scale box drag is ended
  43825. */
  43826. onScaleBoxDragEndObservable: Observable<{}>;
  43827. /**
  43828. * Fired when a rotation sphere is dragged
  43829. */
  43830. onRotationSphereDragObservable: Observable<{}>;
  43831. /**
  43832. * Fired when a rotation sphere drag is ended
  43833. */
  43834. onRotationSphereDragEndObservable: Observable<{}>;
  43835. /**
  43836. * 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)
  43837. */
  43838. scalePivot: Nullable<Vector3>;
  43839. /**
  43840. * Mesh used as a pivot to rotate the attached mesh
  43841. */
  43842. private _anchorMesh;
  43843. private _existingMeshScale;
  43844. private _dragMesh;
  43845. private pointerDragBehavior;
  43846. private coloredMaterial;
  43847. private hoverColoredMaterial;
  43848. /**
  43849. * Sets the color of the bounding box gizmo
  43850. * @param color the color to set
  43851. */
  43852. setColor(color: Color3): void;
  43853. /**
  43854. * Creates an BoundingBoxGizmo
  43855. * @param gizmoLayer The utility layer the gizmo will be added to
  43856. * @param color The color of the gizmo
  43857. */
  43858. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43859. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43860. private _selectNode;
  43861. /**
  43862. * Updates the bounding box information for the Gizmo
  43863. */
  43864. updateBoundingBox(): void;
  43865. private _updateRotationSpheres;
  43866. private _updateScaleBoxes;
  43867. /**
  43868. * Enables rotation on the specified axis and disables rotation on the others
  43869. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43870. */
  43871. setEnabledRotationAxis(axis: string): void;
  43872. /**
  43873. * Enables/disables scaling
  43874. * @param enable if scaling should be enabled
  43875. */
  43876. setEnabledScaling(enable: boolean): void;
  43877. private _updateDummy;
  43878. /**
  43879. * Enables a pointer drag behavior on the bounding box of the gizmo
  43880. */
  43881. enableDragBehavior(): void;
  43882. /**
  43883. * Disposes of the gizmo
  43884. */
  43885. dispose(): void;
  43886. /**
  43887. * 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)
  43888. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43889. * @returns the bounding box mesh with the passed in mesh as a child
  43890. */
  43891. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43892. /**
  43893. * CustomMeshes are not supported by this gizmo
  43894. * @param mesh The mesh to replace the default mesh of the gizmo
  43895. */
  43896. setCustomMesh(mesh: Mesh): void;
  43897. }
  43898. }
  43899. declare module BABYLON {
  43900. /**
  43901. * Single plane rotation gizmo
  43902. */
  43903. export class PlaneRotationGizmo extends Gizmo {
  43904. /**
  43905. * Drag behavior responsible for the gizmos dragging interactions
  43906. */
  43907. dragBehavior: PointerDragBehavior;
  43908. private _pointerObserver;
  43909. /**
  43910. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43911. */
  43912. snapDistance: number;
  43913. /**
  43914. * Event that fires each time the gizmo snaps to a new location.
  43915. * * snapDistance is the the change in distance
  43916. */
  43917. onSnapObservable: Observable<{
  43918. snapDistance: number;
  43919. }>;
  43920. private _isEnabled;
  43921. private _parent;
  43922. /**
  43923. * Creates a PlaneRotationGizmo
  43924. * @param gizmoLayer The utility layer the gizmo will be added to
  43925. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43926. * @param color The color of the gizmo
  43927. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43928. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43929. */
  43930. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  43931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43932. /**
  43933. * If the gizmo is enabled
  43934. */
  43935. isEnabled: boolean;
  43936. /**
  43937. * Disposes of the gizmo
  43938. */
  43939. dispose(): void;
  43940. }
  43941. }
  43942. declare module BABYLON {
  43943. /**
  43944. * Gizmo that enables rotating a mesh along 3 axis
  43945. */
  43946. export class RotationGizmo extends Gizmo {
  43947. /**
  43948. * Internal gizmo used for interactions on the x axis
  43949. */
  43950. xGizmo: PlaneRotationGizmo;
  43951. /**
  43952. * Internal gizmo used for interactions on the y axis
  43953. */
  43954. yGizmo: PlaneRotationGizmo;
  43955. /**
  43956. * Internal gizmo used for interactions on the z axis
  43957. */
  43958. zGizmo: PlaneRotationGizmo;
  43959. /** Fires an event when any of it's sub gizmos are dragged */
  43960. onDragStartObservable: Observable<unknown>;
  43961. /** Fires an event when any of it's sub gizmos are released from dragging */
  43962. onDragEndObservable: Observable<unknown>;
  43963. private _meshAttached;
  43964. attachedMesh: Nullable<AbstractMesh>;
  43965. /**
  43966. * Creates a RotationGizmo
  43967. * @param gizmoLayer The utility layer the gizmo will be added to
  43968. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43969. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43970. */
  43971. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  43972. updateGizmoRotationToMatchAttachedMesh: boolean;
  43973. /**
  43974. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43975. */
  43976. snapDistance: number;
  43977. /**
  43978. * Ratio for the scale of the gizmo (Default: 1)
  43979. */
  43980. scaleRatio: number;
  43981. /**
  43982. * Disposes of the gizmo
  43983. */
  43984. dispose(): void;
  43985. /**
  43986. * CustomMeshes are not supported by this gizmo
  43987. * @param mesh The mesh to replace the default mesh of the gizmo
  43988. */
  43989. setCustomMesh(mesh: Mesh): void;
  43990. }
  43991. }
  43992. declare module BABYLON {
  43993. /**
  43994. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43995. */
  43996. export class GizmoManager implements IDisposable {
  43997. private scene;
  43998. /**
  43999. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44000. */
  44001. gizmos: {
  44002. positionGizmo: Nullable<PositionGizmo>;
  44003. rotationGizmo: Nullable<RotationGizmo>;
  44004. scaleGizmo: Nullable<ScaleGizmo>;
  44005. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44006. };
  44007. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44008. clearGizmoOnEmptyPointerEvent: boolean;
  44009. /** Fires an event when the manager is attached to a mesh */
  44010. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44011. private _gizmosEnabled;
  44012. private _pointerObserver;
  44013. private _attachedMesh;
  44014. private _boundingBoxColor;
  44015. private _defaultUtilityLayer;
  44016. private _defaultKeepDepthUtilityLayer;
  44017. /**
  44018. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44019. */
  44020. boundingBoxDragBehavior: SixDofDragBehavior;
  44021. /**
  44022. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44023. */
  44024. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44025. /**
  44026. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44027. */
  44028. usePointerToAttachGizmos: boolean;
  44029. /**
  44030. * Utility layer that the bounding box gizmo belongs to
  44031. */
  44032. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44033. /**
  44034. * Utility layer that all gizmos besides bounding box belong to
  44035. */
  44036. readonly utilityLayer: UtilityLayerRenderer;
  44037. /**
  44038. * Instatiates a gizmo manager
  44039. * @param scene the scene to overlay the gizmos on top of
  44040. */
  44041. constructor(scene: Scene);
  44042. /**
  44043. * Attaches a set of gizmos to the specified mesh
  44044. * @param mesh The mesh the gizmo's should be attached to
  44045. */
  44046. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44047. /**
  44048. * If the position gizmo is enabled
  44049. */
  44050. positionGizmoEnabled: boolean;
  44051. /**
  44052. * If the rotation gizmo is enabled
  44053. */
  44054. rotationGizmoEnabled: boolean;
  44055. /**
  44056. * If the scale gizmo is enabled
  44057. */
  44058. scaleGizmoEnabled: boolean;
  44059. /**
  44060. * If the boundingBox gizmo is enabled
  44061. */
  44062. boundingBoxGizmoEnabled: boolean;
  44063. /**
  44064. * Disposes of the gizmo manager
  44065. */
  44066. dispose(): void;
  44067. }
  44068. }
  44069. declare module BABYLON {
  44070. /**
  44071. * A directional light is defined by a direction (what a surprise!).
  44072. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44073. * 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.
  44074. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44075. */
  44076. export class DirectionalLight extends ShadowLight {
  44077. private _shadowFrustumSize;
  44078. /**
  44079. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44080. */
  44081. /**
  44082. * Specifies a fix frustum size for the shadow generation.
  44083. */
  44084. shadowFrustumSize: number;
  44085. private _shadowOrthoScale;
  44086. /**
  44087. * Gets the shadow projection scale against the optimal computed one.
  44088. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44089. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44090. */
  44091. /**
  44092. * Sets the shadow projection scale against the optimal computed one.
  44093. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44094. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44095. */
  44096. shadowOrthoScale: number;
  44097. /**
  44098. * Automatically compute the projection matrix to best fit (including all the casters)
  44099. * on each frame.
  44100. */
  44101. autoUpdateExtends: boolean;
  44102. private _orthoLeft;
  44103. private _orthoRight;
  44104. private _orthoTop;
  44105. private _orthoBottom;
  44106. /**
  44107. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44108. * The directional light is emitted from everywhere in the given direction.
  44109. * It can cast shadows.
  44110. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44111. * @param name The friendly name of the light
  44112. * @param direction The direction of the light
  44113. * @param scene The scene the light belongs to
  44114. */
  44115. constructor(name: string, direction: Vector3, scene: Scene);
  44116. /**
  44117. * Returns the string "DirectionalLight".
  44118. * @return The class name
  44119. */
  44120. getClassName(): string;
  44121. /**
  44122. * Returns the integer 1.
  44123. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44124. */
  44125. getTypeID(): number;
  44126. /**
  44127. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44128. * Returns the DirectionalLight Shadow projection matrix.
  44129. */
  44130. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44131. /**
  44132. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44133. * Returns the DirectionalLight Shadow projection matrix.
  44134. */
  44135. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44136. /**
  44137. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44138. * Returns the DirectionalLight Shadow projection matrix.
  44139. */
  44140. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44141. protected _buildUniformLayout(): void;
  44142. /**
  44143. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44144. * @param effect The effect to update
  44145. * @param lightIndex The index of the light in the effect to update
  44146. * @returns The directional light
  44147. */
  44148. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44149. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44150. /**
  44151. * Gets the minZ used for shadow according to both the scene and the light.
  44152. *
  44153. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44154. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44155. * @param activeCamera The camera we are returning the min for
  44156. * @returns the depth min z
  44157. */
  44158. getDepthMinZ(activeCamera: Camera): number;
  44159. /**
  44160. * Gets the maxZ used for shadow according to both the scene and the light.
  44161. *
  44162. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44163. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44164. * @param activeCamera The camera we are returning the max for
  44165. * @returns the depth max z
  44166. */
  44167. getDepthMaxZ(activeCamera: Camera): number;
  44168. /**
  44169. * Prepares the list of defines specific to the light type.
  44170. * @param defines the list of defines
  44171. * @param lightIndex defines the index of the light for the effect
  44172. */
  44173. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44174. }
  44175. }
  44176. declare module BABYLON {
  44177. /**
  44178. * Class containing static functions to help procedurally build meshes
  44179. */
  44180. export class HemisphereBuilder {
  44181. /**
  44182. * Creates a hemisphere mesh
  44183. * @param name defines the name of the mesh
  44184. * @param options defines the options used to create the mesh
  44185. * @param scene defines the hosting scene
  44186. * @returns the hemisphere mesh
  44187. */
  44188. static CreateHemisphere(name: string, options: {
  44189. segments?: number;
  44190. diameter?: number;
  44191. sideOrientation?: number;
  44192. }, scene: any): Mesh;
  44193. }
  44194. }
  44195. declare module BABYLON {
  44196. /**
  44197. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44198. * These values define a cone of light starting from the position, emitting toward the direction.
  44199. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44200. * and the exponent defines the speed of the decay of the light with distance (reach).
  44201. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44202. */
  44203. export class SpotLight extends ShadowLight {
  44204. private _angle;
  44205. private _innerAngle;
  44206. private _cosHalfAngle;
  44207. private _lightAngleScale;
  44208. private _lightAngleOffset;
  44209. /**
  44210. * Gets the cone angle of the spot light in Radians.
  44211. */
  44212. /**
  44213. * Sets the cone angle of the spot light in Radians.
  44214. */
  44215. angle: number;
  44216. /**
  44217. * Only used in gltf falloff mode, this defines the angle where
  44218. * the directional falloff will start before cutting at angle which could be seen
  44219. * as outer angle.
  44220. */
  44221. /**
  44222. * Only used in gltf falloff mode, this defines the angle where
  44223. * the directional falloff will start before cutting at angle which could be seen
  44224. * as outer angle.
  44225. */
  44226. innerAngle: number;
  44227. private _shadowAngleScale;
  44228. /**
  44229. * Allows scaling the angle of the light for shadow generation only.
  44230. */
  44231. /**
  44232. * Allows scaling the angle of the light for shadow generation only.
  44233. */
  44234. shadowAngleScale: number;
  44235. /**
  44236. * The light decay speed with the distance from the emission spot.
  44237. */
  44238. exponent: number;
  44239. private _projectionTextureMatrix;
  44240. /**
  44241. * Allows reading the projecton texture
  44242. */
  44243. readonly projectionTextureMatrix: Matrix;
  44244. protected _projectionTextureLightNear: number;
  44245. /**
  44246. * Gets the near clip of the Spotlight for texture projection.
  44247. */
  44248. /**
  44249. * Sets the near clip of the Spotlight for texture projection.
  44250. */
  44251. projectionTextureLightNear: number;
  44252. protected _projectionTextureLightFar: number;
  44253. /**
  44254. * Gets the far clip of the Spotlight for texture projection.
  44255. */
  44256. /**
  44257. * Sets the far clip of the Spotlight for texture projection.
  44258. */
  44259. projectionTextureLightFar: number;
  44260. protected _projectionTextureUpDirection: Vector3;
  44261. /**
  44262. * Gets the Up vector of the Spotlight for texture projection.
  44263. */
  44264. /**
  44265. * Sets the Up vector of the Spotlight for texture projection.
  44266. */
  44267. projectionTextureUpDirection: Vector3;
  44268. private _projectionTexture;
  44269. /**
  44270. * Gets the projection texture of the light.
  44271. */
  44272. /**
  44273. * Sets the projection texture of the light.
  44274. */
  44275. projectionTexture: Nullable<BaseTexture>;
  44276. private _projectionTextureViewLightDirty;
  44277. private _projectionTextureProjectionLightDirty;
  44278. private _projectionTextureDirty;
  44279. private _projectionTextureViewTargetVector;
  44280. private _projectionTextureViewLightMatrix;
  44281. private _projectionTextureProjectionLightMatrix;
  44282. private _projectionTextureScalingMatrix;
  44283. /**
  44284. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44285. * It can cast shadows.
  44286. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44287. * @param name The light friendly name
  44288. * @param position The position of the spot light in the scene
  44289. * @param direction The direction of the light in the scene
  44290. * @param angle The cone angle of the light in Radians
  44291. * @param exponent The light decay speed with the distance from the emission spot
  44292. * @param scene The scene the lights belongs to
  44293. */
  44294. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44295. /**
  44296. * Returns the string "SpotLight".
  44297. * @returns the class name
  44298. */
  44299. getClassName(): string;
  44300. /**
  44301. * Returns the integer 2.
  44302. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44303. */
  44304. getTypeID(): number;
  44305. /**
  44306. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44307. */
  44308. protected _setDirection(value: Vector3): void;
  44309. /**
  44310. * Overrides the position setter to recompute the projection texture view light Matrix.
  44311. */
  44312. protected _setPosition(value: Vector3): void;
  44313. /**
  44314. * 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.
  44315. * Returns the SpotLight.
  44316. */
  44317. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44318. protected _computeProjectionTextureViewLightMatrix(): void;
  44319. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44320. /**
  44321. * Main function for light texture projection matrix computing.
  44322. */
  44323. protected _computeProjectionTextureMatrix(): void;
  44324. protected _buildUniformLayout(): void;
  44325. private _computeAngleValues;
  44326. /**
  44327. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44328. * @param effect The effect to update
  44329. * @param lightIndex The index of the light in the effect to update
  44330. * @returns The spot light
  44331. */
  44332. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44333. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44334. /**
  44335. * Disposes the light and the associated resources.
  44336. */
  44337. dispose(): void;
  44338. /**
  44339. * Prepares the list of defines specific to the light type.
  44340. * @param defines the list of defines
  44341. * @param lightIndex defines the index of the light for the effect
  44342. */
  44343. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44344. }
  44345. }
  44346. declare module BABYLON {
  44347. /**
  44348. * Gizmo that enables viewing a light
  44349. */
  44350. export class LightGizmo extends Gizmo {
  44351. private _lightMesh;
  44352. private _material;
  44353. private cachedPosition;
  44354. private cachedForward;
  44355. /**
  44356. * Creates a LightGizmo
  44357. * @param gizmoLayer The utility layer the gizmo will be added to
  44358. */
  44359. constructor(gizmoLayer?: UtilityLayerRenderer);
  44360. private _light;
  44361. /**
  44362. * The light that the gizmo is attached to
  44363. */
  44364. light: Nullable<Light>;
  44365. /**
  44366. * Gets the material used to render the light gizmo
  44367. */
  44368. readonly material: StandardMaterial;
  44369. /**
  44370. * @hidden
  44371. * Updates the gizmo to match the attached mesh's position/rotation
  44372. */
  44373. protected _update(): void;
  44374. private static _Scale;
  44375. /**
  44376. * Creates the lines for a light mesh
  44377. */
  44378. private static _createLightLines;
  44379. /**
  44380. * Disposes of the light gizmo
  44381. */
  44382. dispose(): void;
  44383. private static _CreateHemisphericLightMesh;
  44384. private static _CreatePointLightMesh;
  44385. private static _CreateSpotLightMesh;
  44386. private static _CreateDirectionalLightMesh;
  44387. }
  44388. }
  44389. declare module BABYLON {
  44390. /** @hidden */
  44391. export var backgroundFragmentDeclaration: {
  44392. name: string;
  44393. shader: string;
  44394. };
  44395. }
  44396. declare module BABYLON {
  44397. /** @hidden */
  44398. export var backgroundUboDeclaration: {
  44399. name: string;
  44400. shader: string;
  44401. };
  44402. }
  44403. declare module BABYLON {
  44404. /** @hidden */
  44405. export var backgroundPixelShader: {
  44406. name: string;
  44407. shader: string;
  44408. };
  44409. }
  44410. declare module BABYLON {
  44411. /** @hidden */
  44412. export var backgroundVertexDeclaration: {
  44413. name: string;
  44414. shader: string;
  44415. };
  44416. }
  44417. declare module BABYLON {
  44418. /** @hidden */
  44419. export var backgroundVertexShader: {
  44420. name: string;
  44421. shader: string;
  44422. };
  44423. }
  44424. declare module BABYLON {
  44425. /**
  44426. * Background material used to create an efficient environement around your scene.
  44427. */
  44428. export class BackgroundMaterial extends PushMaterial {
  44429. /**
  44430. * Standard reflectance value at parallel view angle.
  44431. */
  44432. static StandardReflectance0: number;
  44433. /**
  44434. * Standard reflectance value at grazing angle.
  44435. */
  44436. static StandardReflectance90: number;
  44437. protected _primaryColor: Color3;
  44438. /**
  44439. * Key light Color (multiply against the environement texture)
  44440. */
  44441. primaryColor: Color3;
  44442. protected __perceptualColor: Nullable<Color3>;
  44443. /**
  44444. * Experimental Internal Use Only.
  44445. *
  44446. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44447. * This acts as a helper to set the primary color to a more "human friendly" value.
  44448. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44449. * output color as close as possible from the chosen value.
  44450. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44451. * part of lighting setup.)
  44452. */ private _perceptualColor: Nullable<Color3>;
  44453. protected _primaryColorShadowLevel: float;
  44454. /**
  44455. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44456. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44457. */
  44458. primaryColorShadowLevel: float;
  44459. protected _primaryColorHighlightLevel: float;
  44460. /**
  44461. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44462. * The primary color is used at the level chosen to define what the white area would look.
  44463. */
  44464. primaryColorHighlightLevel: float;
  44465. protected _reflectionTexture: Nullable<BaseTexture>;
  44466. /**
  44467. * Reflection Texture used in the material.
  44468. * Should be author in a specific way for the best result (refer to the documentation).
  44469. */
  44470. reflectionTexture: Nullable<BaseTexture>;
  44471. protected _reflectionBlur: float;
  44472. /**
  44473. * Reflection Texture level of blur.
  44474. *
  44475. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44476. * texture twice.
  44477. */
  44478. reflectionBlur: float;
  44479. protected _diffuseTexture: Nullable<BaseTexture>;
  44480. /**
  44481. * Diffuse Texture used in the material.
  44482. * Should be author in a specific way for the best result (refer to the documentation).
  44483. */
  44484. diffuseTexture: Nullable<BaseTexture>;
  44485. protected _shadowLights: Nullable<IShadowLight[]>;
  44486. /**
  44487. * Specify the list of lights casting shadow on the material.
  44488. * All scene shadow lights will be included if null.
  44489. */
  44490. shadowLights: Nullable<IShadowLight[]>;
  44491. protected _shadowLevel: float;
  44492. /**
  44493. * Helps adjusting the shadow to a softer level if required.
  44494. * 0 means black shadows and 1 means no shadows.
  44495. */
  44496. shadowLevel: float;
  44497. protected _sceneCenter: Vector3;
  44498. /**
  44499. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44500. * It is usually zero but might be interesting to modify according to your setup.
  44501. */
  44502. sceneCenter: Vector3;
  44503. protected _opacityFresnel: boolean;
  44504. /**
  44505. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44506. * This helps ensuring a nice transition when the camera goes under the ground.
  44507. */
  44508. opacityFresnel: boolean;
  44509. protected _reflectionFresnel: boolean;
  44510. /**
  44511. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44512. * This helps adding a mirror texture on the ground.
  44513. */
  44514. reflectionFresnel: boolean;
  44515. protected _reflectionFalloffDistance: number;
  44516. /**
  44517. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44518. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44519. */
  44520. reflectionFalloffDistance: number;
  44521. protected _reflectionAmount: number;
  44522. /**
  44523. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44524. */
  44525. reflectionAmount: number;
  44526. protected _reflectionReflectance0: number;
  44527. /**
  44528. * This specifies the weight of the reflection at grazing angle.
  44529. */
  44530. reflectionReflectance0: number;
  44531. protected _reflectionReflectance90: number;
  44532. /**
  44533. * This specifies the weight of the reflection at a perpendicular point of view.
  44534. */
  44535. reflectionReflectance90: number;
  44536. /**
  44537. * Sets the reflection reflectance fresnel values according to the default standard
  44538. * empirically know to work well :-)
  44539. */
  44540. reflectionStandardFresnelWeight: number;
  44541. protected _useRGBColor: boolean;
  44542. /**
  44543. * Helps to directly use the maps channels instead of their level.
  44544. */
  44545. useRGBColor: boolean;
  44546. protected _enableNoise: boolean;
  44547. /**
  44548. * This helps reducing the banding effect that could occur on the background.
  44549. */
  44550. enableNoise: boolean;
  44551. /**
  44552. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44553. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44554. * Recommended to be keep at 1.0 except for special cases.
  44555. */
  44556. fovMultiplier: number;
  44557. private _fovMultiplier;
  44558. /**
  44559. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44560. */
  44561. useEquirectangularFOV: boolean;
  44562. private _maxSimultaneousLights;
  44563. /**
  44564. * Number of Simultaneous lights allowed on the material.
  44565. */
  44566. maxSimultaneousLights: int;
  44567. /**
  44568. * Default configuration related to image processing available in the Background Material.
  44569. */
  44570. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44571. /**
  44572. * Keep track of the image processing observer to allow dispose and replace.
  44573. */
  44574. private _imageProcessingObserver;
  44575. /**
  44576. * Attaches a new image processing configuration to the PBR Material.
  44577. * @param configuration (if null the scene configuration will be use)
  44578. */
  44579. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44580. /**
  44581. * Gets the image processing configuration used either in this material.
  44582. */
  44583. /**
  44584. * Sets the Default image processing configuration used either in the this material.
  44585. *
  44586. * If sets to null, the scene one is in use.
  44587. */
  44588. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44589. /**
  44590. * Gets wether the color curves effect is enabled.
  44591. */
  44592. /**
  44593. * Sets wether the color curves effect is enabled.
  44594. */
  44595. cameraColorCurvesEnabled: boolean;
  44596. /**
  44597. * Gets wether the color grading effect is enabled.
  44598. */
  44599. /**
  44600. * Gets wether the color grading effect is enabled.
  44601. */
  44602. cameraColorGradingEnabled: boolean;
  44603. /**
  44604. * Gets wether tonemapping is enabled or not.
  44605. */
  44606. /**
  44607. * Sets wether tonemapping is enabled or not
  44608. */
  44609. cameraToneMappingEnabled: boolean;
  44610. /**
  44611. * The camera exposure used on this material.
  44612. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44613. * This corresponds to a photographic exposure.
  44614. */
  44615. /**
  44616. * The camera exposure used on this material.
  44617. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44618. * This corresponds to a photographic exposure.
  44619. */
  44620. cameraExposure: float;
  44621. /**
  44622. * Gets The camera contrast used on this material.
  44623. */
  44624. /**
  44625. * Sets The camera contrast used on this material.
  44626. */
  44627. cameraContrast: float;
  44628. /**
  44629. * Gets the Color Grading 2D Lookup Texture.
  44630. */
  44631. /**
  44632. * Sets the Color Grading 2D Lookup Texture.
  44633. */
  44634. cameraColorGradingTexture: Nullable<BaseTexture>;
  44635. /**
  44636. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44637. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44638. * 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;
  44639. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44640. */
  44641. /**
  44642. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44643. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44644. * 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;
  44645. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44646. */
  44647. cameraColorCurves: Nullable<ColorCurves>;
  44648. /**
  44649. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44650. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44651. */
  44652. switchToBGR: boolean;
  44653. private _renderTargets;
  44654. private _reflectionControls;
  44655. private _white;
  44656. private _primaryShadowColor;
  44657. private _primaryHighlightColor;
  44658. /**
  44659. * Instantiates a Background Material in the given scene
  44660. * @param name The friendly name of the material
  44661. * @param scene The scene to add the material to
  44662. */
  44663. constructor(name: string, scene: Scene);
  44664. /**
  44665. * Gets a boolean indicating that current material needs to register RTT
  44666. */
  44667. readonly hasRenderTargetTextures: boolean;
  44668. /**
  44669. * The entire material has been created in order to prevent overdraw.
  44670. * @returns false
  44671. */
  44672. needAlphaTesting(): boolean;
  44673. /**
  44674. * The entire material has been created in order to prevent overdraw.
  44675. * @returns true if blending is enable
  44676. */
  44677. needAlphaBlending(): boolean;
  44678. /**
  44679. * Checks wether the material is ready to be rendered for a given mesh.
  44680. * @param mesh The mesh to render
  44681. * @param subMesh The submesh to check against
  44682. * @param useInstances Specify wether or not the material is used with instances
  44683. * @returns true if all the dependencies are ready (Textures, Effects...)
  44684. */
  44685. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44686. /**
  44687. * Compute the primary color according to the chosen perceptual color.
  44688. */
  44689. private _computePrimaryColorFromPerceptualColor;
  44690. /**
  44691. * Compute the highlights and shadow colors according to their chosen levels.
  44692. */
  44693. private _computePrimaryColors;
  44694. /**
  44695. * Build the uniform buffer used in the material.
  44696. */
  44697. buildUniformLayout(): void;
  44698. /**
  44699. * Unbind the material.
  44700. */
  44701. unbind(): void;
  44702. /**
  44703. * Bind only the world matrix to the material.
  44704. * @param world The world matrix to bind.
  44705. */
  44706. bindOnlyWorldMatrix(world: Matrix): void;
  44707. /**
  44708. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44709. * @param world The world matrix to bind.
  44710. * @param subMesh The submesh to bind for.
  44711. */
  44712. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44713. /**
  44714. * Checks to see if a texture is used in the material.
  44715. * @param texture - Base texture to use.
  44716. * @returns - Boolean specifying if a texture is used in the material.
  44717. */
  44718. hasTexture(texture: BaseTexture): boolean;
  44719. /**
  44720. * Dispose the material.
  44721. * @param forceDisposeEffect Force disposal of the associated effect.
  44722. * @param forceDisposeTextures Force disposal of the associated textures.
  44723. */
  44724. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44725. /**
  44726. * Clones the material.
  44727. * @param name The cloned name.
  44728. * @returns The cloned material.
  44729. */
  44730. clone(name: string): BackgroundMaterial;
  44731. /**
  44732. * Serializes the current material to its JSON representation.
  44733. * @returns The JSON representation.
  44734. */
  44735. serialize(): any;
  44736. /**
  44737. * Gets the class name of the material
  44738. * @returns "BackgroundMaterial"
  44739. */
  44740. getClassName(): string;
  44741. /**
  44742. * Parse a JSON input to create back a background material.
  44743. * @param source The JSON data to parse
  44744. * @param scene The scene to create the parsed material in
  44745. * @param rootUrl The root url of the assets the material depends upon
  44746. * @returns the instantiated BackgroundMaterial.
  44747. */
  44748. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44749. }
  44750. }
  44751. declare module BABYLON {
  44752. /**
  44753. * Represents the different options available during the creation of
  44754. * a Environment helper.
  44755. *
  44756. * This can control the default ground, skybox and image processing setup of your scene.
  44757. */
  44758. export interface IEnvironmentHelperOptions {
  44759. /**
  44760. * Specifies wether or not to create a ground.
  44761. * True by default.
  44762. */
  44763. createGround: boolean;
  44764. /**
  44765. * Specifies the ground size.
  44766. * 15 by default.
  44767. */
  44768. groundSize: number;
  44769. /**
  44770. * The texture used on the ground for the main color.
  44771. * Comes from the BabylonJS CDN by default.
  44772. *
  44773. * Remarks: Can be either a texture or a url.
  44774. */
  44775. groundTexture: string | BaseTexture;
  44776. /**
  44777. * The color mixed in the ground texture by default.
  44778. * BabylonJS clearColor by default.
  44779. */
  44780. groundColor: Color3;
  44781. /**
  44782. * Specifies the ground opacity.
  44783. * 1 by default.
  44784. */
  44785. groundOpacity: number;
  44786. /**
  44787. * Enables the ground to receive shadows.
  44788. * True by default.
  44789. */
  44790. enableGroundShadow: boolean;
  44791. /**
  44792. * Helps preventing the shadow to be fully black on the ground.
  44793. * 0.5 by default.
  44794. */
  44795. groundShadowLevel: number;
  44796. /**
  44797. * Creates a mirror texture attach to the ground.
  44798. * false by default.
  44799. */
  44800. enableGroundMirror: boolean;
  44801. /**
  44802. * Specifies the ground mirror size ratio.
  44803. * 0.3 by default as the default kernel is 64.
  44804. */
  44805. groundMirrorSizeRatio: number;
  44806. /**
  44807. * Specifies the ground mirror blur kernel size.
  44808. * 64 by default.
  44809. */
  44810. groundMirrorBlurKernel: number;
  44811. /**
  44812. * Specifies the ground mirror visibility amount.
  44813. * 1 by default
  44814. */
  44815. groundMirrorAmount: number;
  44816. /**
  44817. * Specifies the ground mirror reflectance weight.
  44818. * This uses the standard weight of the background material to setup the fresnel effect
  44819. * of the mirror.
  44820. * 1 by default.
  44821. */
  44822. groundMirrorFresnelWeight: number;
  44823. /**
  44824. * Specifies the ground mirror Falloff distance.
  44825. * This can helps reducing the size of the reflection.
  44826. * 0 by Default.
  44827. */
  44828. groundMirrorFallOffDistance: number;
  44829. /**
  44830. * Specifies the ground mirror texture type.
  44831. * Unsigned Int by Default.
  44832. */
  44833. groundMirrorTextureType: number;
  44834. /**
  44835. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44836. * the shown objects.
  44837. */
  44838. groundYBias: number;
  44839. /**
  44840. * Specifies wether or not to create a skybox.
  44841. * True by default.
  44842. */
  44843. createSkybox: boolean;
  44844. /**
  44845. * Specifies the skybox size.
  44846. * 20 by default.
  44847. */
  44848. skyboxSize: number;
  44849. /**
  44850. * The texture used on the skybox for the main color.
  44851. * Comes from the BabylonJS CDN by default.
  44852. *
  44853. * Remarks: Can be either a texture or a url.
  44854. */
  44855. skyboxTexture: string | BaseTexture;
  44856. /**
  44857. * The color mixed in the skybox texture by default.
  44858. * BabylonJS clearColor by default.
  44859. */
  44860. skyboxColor: Color3;
  44861. /**
  44862. * The background rotation around the Y axis of the scene.
  44863. * This helps aligning the key lights of your scene with the background.
  44864. * 0 by default.
  44865. */
  44866. backgroundYRotation: number;
  44867. /**
  44868. * Compute automatically the size of the elements to best fit with the scene.
  44869. */
  44870. sizeAuto: boolean;
  44871. /**
  44872. * Default position of the rootMesh if autoSize is not true.
  44873. */
  44874. rootPosition: Vector3;
  44875. /**
  44876. * Sets up the image processing in the scene.
  44877. * true by default.
  44878. */
  44879. setupImageProcessing: boolean;
  44880. /**
  44881. * The texture used as your environment texture in the scene.
  44882. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44883. *
  44884. * Remarks: Can be either a texture or a url.
  44885. */
  44886. environmentTexture: string | BaseTexture;
  44887. /**
  44888. * The value of the exposure to apply to the scene.
  44889. * 0.6 by default if setupImageProcessing is true.
  44890. */
  44891. cameraExposure: number;
  44892. /**
  44893. * The value of the contrast to apply to the scene.
  44894. * 1.6 by default if setupImageProcessing is true.
  44895. */
  44896. cameraContrast: number;
  44897. /**
  44898. * Specifies wether or not tonemapping should be enabled in the scene.
  44899. * true by default if setupImageProcessing is true.
  44900. */
  44901. toneMappingEnabled: boolean;
  44902. }
  44903. /**
  44904. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44905. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44906. * It also helps with the default setup of your imageProcessing configuration.
  44907. */
  44908. export class EnvironmentHelper {
  44909. /**
  44910. * Default ground texture URL.
  44911. */
  44912. private static _groundTextureCDNUrl;
  44913. /**
  44914. * Default skybox texture URL.
  44915. */
  44916. private static _skyboxTextureCDNUrl;
  44917. /**
  44918. * Default environment texture URL.
  44919. */
  44920. private static _environmentTextureCDNUrl;
  44921. /**
  44922. * Creates the default options for the helper.
  44923. */
  44924. private static _getDefaultOptions;
  44925. private _rootMesh;
  44926. /**
  44927. * Gets the root mesh created by the helper.
  44928. */
  44929. readonly rootMesh: Mesh;
  44930. private _skybox;
  44931. /**
  44932. * Gets the skybox created by the helper.
  44933. */
  44934. readonly skybox: Nullable<Mesh>;
  44935. private _skyboxTexture;
  44936. /**
  44937. * Gets the skybox texture created by the helper.
  44938. */
  44939. readonly skyboxTexture: Nullable<BaseTexture>;
  44940. private _skyboxMaterial;
  44941. /**
  44942. * Gets the skybox material created by the helper.
  44943. */
  44944. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44945. private _ground;
  44946. /**
  44947. * Gets the ground mesh created by the helper.
  44948. */
  44949. readonly ground: Nullable<Mesh>;
  44950. private _groundTexture;
  44951. /**
  44952. * Gets the ground texture created by the helper.
  44953. */
  44954. readonly groundTexture: Nullable<BaseTexture>;
  44955. private _groundMirror;
  44956. /**
  44957. * Gets the ground mirror created by the helper.
  44958. */
  44959. readonly groundMirror: Nullable<MirrorTexture>;
  44960. /**
  44961. * Gets the ground mirror render list to helps pushing the meshes
  44962. * you wish in the ground reflection.
  44963. */
  44964. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44965. private _groundMaterial;
  44966. /**
  44967. * Gets the ground material created by the helper.
  44968. */
  44969. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44970. /**
  44971. * Stores the creation options.
  44972. */
  44973. private readonly _scene;
  44974. private _options;
  44975. /**
  44976. * This observable will be notified with any error during the creation of the environment,
  44977. * mainly texture creation errors.
  44978. */
  44979. onErrorObservable: Observable<{
  44980. message?: string;
  44981. exception?: any;
  44982. }>;
  44983. /**
  44984. * constructor
  44985. * @param options Defines the options we want to customize the helper
  44986. * @param scene The scene to add the material to
  44987. */
  44988. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44989. /**
  44990. * Updates the background according to the new options
  44991. * @param options
  44992. */
  44993. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44994. /**
  44995. * Sets the primary color of all the available elements.
  44996. * @param color the main color to affect to the ground and the background
  44997. */
  44998. setMainColor(color: Color3): void;
  44999. /**
  45000. * Setup the image processing according to the specified options.
  45001. */
  45002. private _setupImageProcessing;
  45003. /**
  45004. * Setup the environment texture according to the specified options.
  45005. */
  45006. private _setupEnvironmentTexture;
  45007. /**
  45008. * Setup the background according to the specified options.
  45009. */
  45010. private _setupBackground;
  45011. /**
  45012. * Get the scene sizes according to the setup.
  45013. */
  45014. private _getSceneSize;
  45015. /**
  45016. * Setup the ground according to the specified options.
  45017. */
  45018. private _setupGround;
  45019. /**
  45020. * Setup the ground material according to the specified options.
  45021. */
  45022. private _setupGroundMaterial;
  45023. /**
  45024. * Setup the ground diffuse texture according to the specified options.
  45025. */
  45026. private _setupGroundDiffuseTexture;
  45027. /**
  45028. * Setup the ground mirror texture according to the specified options.
  45029. */
  45030. private _setupGroundMirrorTexture;
  45031. /**
  45032. * Setup the ground to receive the mirror texture.
  45033. */
  45034. private _setupMirrorInGroundMaterial;
  45035. /**
  45036. * Setup the skybox according to the specified options.
  45037. */
  45038. private _setupSkybox;
  45039. /**
  45040. * Setup the skybox material according to the specified options.
  45041. */
  45042. private _setupSkyboxMaterial;
  45043. /**
  45044. * Setup the skybox reflection texture according to the specified options.
  45045. */
  45046. private _setupSkyboxReflectionTexture;
  45047. private _errorHandler;
  45048. /**
  45049. * Dispose all the elements created by the Helper.
  45050. */
  45051. dispose(): void;
  45052. }
  45053. }
  45054. declare module BABYLON {
  45055. /**
  45056. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45057. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45058. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45059. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45060. */
  45061. export class PhotoDome extends TransformNode {
  45062. /**
  45063. * Define the image as a Monoscopic panoramic 360 image.
  45064. */
  45065. static readonly MODE_MONOSCOPIC: number;
  45066. /**
  45067. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45068. */
  45069. static readonly MODE_TOPBOTTOM: number;
  45070. /**
  45071. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45072. */
  45073. static readonly MODE_SIDEBYSIDE: number;
  45074. private _useDirectMapping;
  45075. /**
  45076. * The texture being displayed on the sphere
  45077. */
  45078. protected _photoTexture: Texture;
  45079. /**
  45080. * Gets or sets the texture being displayed on the sphere
  45081. */
  45082. photoTexture: Texture;
  45083. /**
  45084. * Observable raised when an error occured while loading the 360 image
  45085. */
  45086. onLoadErrorObservable: Observable<string>;
  45087. /**
  45088. * The skybox material
  45089. */
  45090. protected _material: BackgroundMaterial;
  45091. /**
  45092. * The surface used for the skybox
  45093. */
  45094. protected _mesh: Mesh;
  45095. /**
  45096. * Gets the mesh used for the skybox.
  45097. */
  45098. readonly mesh: Mesh;
  45099. /**
  45100. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45101. * Also see the options.resolution property.
  45102. */
  45103. fovMultiplier: number;
  45104. private _imageMode;
  45105. /**
  45106. * Gets or set the current video mode for the video. It can be:
  45107. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45108. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45109. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45110. */
  45111. imageMode: number;
  45112. /**
  45113. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45114. * @param name Element's name, child elements will append suffixes for their own names.
  45115. * @param urlsOfPhoto defines the url of the photo to display
  45116. * @param options defines an object containing optional or exposed sub element properties
  45117. * @param onError defines a callback called when an error occured while loading the texture
  45118. */
  45119. constructor(name: string, urlOfPhoto: string, options: {
  45120. resolution?: number;
  45121. size?: number;
  45122. useDirectMapping?: boolean;
  45123. faceForward?: boolean;
  45124. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45125. private _onBeforeCameraRenderObserver;
  45126. private _changeImageMode;
  45127. /**
  45128. * Releases resources associated with this node.
  45129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45131. */
  45132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45133. }
  45134. }
  45135. declare module BABYLON {
  45136. /**
  45137. * Class used to host RGBD texture specific utilities
  45138. */
  45139. export class RGBDTextureTools {
  45140. /**
  45141. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45142. * @param texture the texture to expand.
  45143. */
  45144. static ExpandRGBDTexture(texture: Texture): void;
  45145. }
  45146. }
  45147. declare module BABYLON {
  45148. /**
  45149. * Class used to host texture specific utilities
  45150. */
  45151. export class BRDFTextureTools {
  45152. /**
  45153. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45154. * @param scene defines the hosting scene
  45155. * @returns the environment BRDF texture
  45156. */
  45157. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45158. private static _environmentBRDFBase64Texture;
  45159. }
  45160. }
  45161. declare module BABYLON {
  45162. /**
  45163. * @hidden
  45164. */
  45165. export interface IMaterialClearCoatDefines {
  45166. CLEARCOAT: boolean;
  45167. CLEARCOAT_DEFAULTIOR: boolean;
  45168. CLEARCOAT_TEXTURE: boolean;
  45169. CLEARCOAT_TEXTUREDIRECTUV: number;
  45170. CLEARCOAT_BUMP: boolean;
  45171. CLEARCOAT_BUMPDIRECTUV: number;
  45172. CLEARCOAT_TINT: boolean;
  45173. CLEARCOAT_TINT_TEXTURE: boolean;
  45174. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45175. /** @hidden */ private _areTexturesDirty: boolean;
  45176. }
  45177. /**
  45178. * Define the code related to the clear coat parameters of the pbr material.
  45179. */
  45180. export class PBRClearCoatConfiguration {
  45181. /**
  45182. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45183. * The default fits with a polyurethane material.
  45184. */
  45185. private static readonly _DefaultIndexOfRefraction;
  45186. private _isEnabled;
  45187. /**
  45188. * Defines if the clear coat is enabled in the material.
  45189. */
  45190. isEnabled: boolean;
  45191. /**
  45192. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45193. */
  45194. intensity: number;
  45195. /**
  45196. * Defines the clear coat layer roughness.
  45197. */
  45198. roughness: number;
  45199. private _indexOfRefraction;
  45200. /**
  45201. * Defines the index of refraction of the clear coat.
  45202. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45203. * The default fits with a polyurethane material.
  45204. * Changing the default value is more performance intensive.
  45205. */
  45206. indexOfRefraction: number;
  45207. private _texture;
  45208. /**
  45209. * Stores the clear coat values in a texture.
  45210. */
  45211. texture: Nullable<BaseTexture>;
  45212. private _bumpTexture;
  45213. /**
  45214. * Define the clear coat specific bump texture.
  45215. */
  45216. bumpTexture: Nullable<BaseTexture>;
  45217. private _isTintEnabled;
  45218. /**
  45219. * Defines if the clear coat tint is enabled in the material.
  45220. */
  45221. isTintEnabled: boolean;
  45222. /**
  45223. * Defines the clear coat tint of the material.
  45224. * This is only use if tint is enabled
  45225. */
  45226. tintColor: Color3;
  45227. /**
  45228. * Defines the distance at which the tint color should be found in the
  45229. * clear coat media.
  45230. * This is only use if tint is enabled
  45231. */
  45232. tintColorAtDistance: number;
  45233. /**
  45234. * Defines the clear coat layer thickness.
  45235. * This is only use if tint is enabled
  45236. */
  45237. tintThickness: number;
  45238. private _tintTexture;
  45239. /**
  45240. * Stores the clear tint values in a texture.
  45241. * rgb is tint
  45242. * a is a thickness factor
  45243. */
  45244. tintTexture: Nullable<BaseTexture>;
  45245. /** @hidden */
  45246. private _internalMarkAllSubMeshesAsTexturesDirty;
  45247. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45248. /**
  45249. * Instantiate a new istance of clear coat configuration.
  45250. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45251. */
  45252. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45253. /**
  45254. * Gets wehter the submesh is ready to be used or not.
  45255. * @param defines the list of "defines" to update.
  45256. * @param scene defines the scene the material belongs to.
  45257. * @param engine defines the engine the material belongs to.
  45258. * @param disableBumpMap defines wether the material disables bump or not.
  45259. * @returns - boolean indicating that the submesh is ready or not.
  45260. */
  45261. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45262. /**
  45263. * Checks to see if a texture is used in the material.
  45264. * @param defines the list of "defines" to update.
  45265. * @param scene defines the scene to the material belongs to.
  45266. */
  45267. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45268. /**
  45269. * Binds the material data.
  45270. * @param uniformBuffer defines the Uniform buffer to fill in.
  45271. * @param scene defines the scene the material belongs to.
  45272. * @param engine defines the engine the material belongs to.
  45273. * @param disableBumpMap defines wether the material disables bump or not.
  45274. * @param isFrozen defines wether the material is frozen or not.
  45275. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45276. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45277. */
  45278. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45279. /**
  45280. * Checks to see if a texture is used in the material.
  45281. * @param texture - Base texture to use.
  45282. * @returns - Boolean specifying if a texture is used in the material.
  45283. */
  45284. hasTexture(texture: BaseTexture): boolean;
  45285. /**
  45286. * Returns an array of the actively used textures.
  45287. * @param activeTextures Array of BaseTextures
  45288. */
  45289. getActiveTextures(activeTextures: BaseTexture[]): void;
  45290. /**
  45291. * Returns the animatable textures.
  45292. * @param animatables Array of animatable textures.
  45293. */
  45294. getAnimatables(animatables: IAnimatable[]): void;
  45295. /**
  45296. * Disposes the resources of the material.
  45297. * @param forceDisposeTextures - Forces the disposal of all textures.
  45298. */
  45299. dispose(forceDisposeTextures?: boolean): void;
  45300. /**
  45301. * Get the current class name of the texture useful for serialization or dynamic coding.
  45302. * @returns "PBRClearCoatConfiguration"
  45303. */
  45304. getClassName(): string;
  45305. /**
  45306. * Add fallbacks to the effect fallbacks list.
  45307. * @param defines defines the Base texture to use.
  45308. * @param fallbacks defines the current fallback list.
  45309. * @param currentRank defines the current fallback rank.
  45310. * @returns the new fallback rank.
  45311. */
  45312. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45313. /**
  45314. * Add the required uniforms to the current list.
  45315. * @param uniforms defines the current uniform list.
  45316. */
  45317. static AddUniforms(uniforms: string[]): void;
  45318. /**
  45319. * Add the required samplers to the current list.
  45320. * @param samplers defines the current sampler list.
  45321. */
  45322. static AddSamplers(samplers: string[]): void;
  45323. /**
  45324. * Add the required uniforms to the current buffer.
  45325. * @param uniformBuffer defines the current uniform buffer.
  45326. */
  45327. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45328. /**
  45329. * Makes a duplicate of the current configuration into another one.
  45330. * @param clearCoatConfiguration define the config where to copy the info
  45331. */
  45332. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45333. /**
  45334. * Serializes this clear coat configuration.
  45335. * @returns - An object with the serialized config.
  45336. */
  45337. serialize(): any;
  45338. /**
  45339. * Parses a anisotropy Configuration from a serialized object.
  45340. * @param source - Serialized object.
  45341. * @param scene Defines the scene we are parsing for
  45342. * @param rootUrl Defines the rootUrl to load from
  45343. */
  45344. parse(source: any, scene: Scene, rootUrl: string): void;
  45345. }
  45346. }
  45347. declare module BABYLON {
  45348. /**
  45349. * @hidden
  45350. */
  45351. export interface IMaterialAnisotropicDefines {
  45352. ANISOTROPIC: boolean;
  45353. ANISOTROPIC_TEXTURE: boolean;
  45354. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45355. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  45356. }
  45357. /**
  45358. * Define the code related to the anisotropic parameters of the pbr material.
  45359. */
  45360. export class PBRAnisotropicConfiguration {
  45361. private _isEnabled;
  45362. /**
  45363. * Defines if the anisotropy is enabled in the material.
  45364. */
  45365. isEnabled: boolean;
  45366. /**
  45367. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45368. */
  45369. intensity: number;
  45370. /**
  45371. * Defines if the effect is along the tangents, bitangents or in between.
  45372. * By default, the effect is "strectching" the highlights along the tangents.
  45373. */
  45374. direction: Vector2;
  45375. private _texture;
  45376. /**
  45377. * Stores the anisotropy values in a texture.
  45378. * rg is direction (like normal from -1 to 1)
  45379. * b is a intensity
  45380. */
  45381. texture: Nullable<BaseTexture>;
  45382. /** @hidden */
  45383. private _internalMarkAllSubMeshesAsTexturesDirty;
  45384. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45385. /**
  45386. * Instantiate a new istance of anisotropy configuration.
  45387. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45388. */
  45389. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45390. /**
  45391. * Specifies that the submesh is ready to be used.
  45392. * @param defines the list of "defines" to update.
  45393. * @param scene defines the scene the material belongs to.
  45394. * @returns - boolean indicating that the submesh is ready or not.
  45395. */
  45396. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45397. /**
  45398. * Checks to see if a texture is used in the material.
  45399. * @param defines the list of "defines" to update.
  45400. * @param mesh the mesh we are preparing the defines for.
  45401. * @param scene defines the scene the material belongs to.
  45402. */
  45403. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45404. /**
  45405. * Binds the material data.
  45406. * @param uniformBuffer defines the Uniform buffer to fill in.
  45407. * @param scene defines the scene the material belongs to.
  45408. * @param isFrozen defines wether the material is frozen or not.
  45409. */
  45410. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45411. /**
  45412. * Checks to see if a texture is used in the material.
  45413. * @param texture - Base texture to use.
  45414. * @returns - Boolean specifying if a texture is used in the material.
  45415. */
  45416. hasTexture(texture: BaseTexture): boolean;
  45417. /**
  45418. * Returns an array of the actively used textures.
  45419. * @param activeTextures Array of BaseTextures
  45420. */
  45421. getActiveTextures(activeTextures: BaseTexture[]): void;
  45422. /**
  45423. * Returns the animatable textures.
  45424. * @param animatables Array of animatable textures.
  45425. */
  45426. getAnimatables(animatables: IAnimatable[]): void;
  45427. /**
  45428. * Disposes the resources of the material.
  45429. * @param forceDisposeTextures - Forces the disposal of all textures.
  45430. */
  45431. dispose(forceDisposeTextures?: boolean): void;
  45432. /**
  45433. * Get the current class name of the texture useful for serialization or dynamic coding.
  45434. * @returns "PBRAnisotropicConfiguration"
  45435. */
  45436. getClassName(): string;
  45437. /**
  45438. * Add fallbacks to the effect fallbacks list.
  45439. * @param defines defines the Base texture to use.
  45440. * @param fallbacks defines the current fallback list.
  45441. * @param currentRank defines the current fallback rank.
  45442. * @returns the new fallback rank.
  45443. */
  45444. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45445. /**
  45446. * Add the required uniforms to the current list.
  45447. * @param uniforms defines the current uniform list.
  45448. */
  45449. static AddUniforms(uniforms: string[]): void;
  45450. /**
  45451. * Add the required uniforms to the current buffer.
  45452. * @param uniformBuffer defines the current uniform buffer.
  45453. */
  45454. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45455. /**
  45456. * Add the required samplers to the current list.
  45457. * @param samplers defines the current sampler list.
  45458. */
  45459. static AddSamplers(samplers: string[]): void;
  45460. /**
  45461. * Makes a duplicate of the current configuration into another one.
  45462. * @param anisotropicConfiguration define the config where to copy the info
  45463. */
  45464. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45465. /**
  45466. * Serializes this anisotropy configuration.
  45467. * @returns - An object with the serialized config.
  45468. */
  45469. serialize(): any;
  45470. /**
  45471. * Parses a anisotropy Configuration from a serialized object.
  45472. * @param source - Serialized object.
  45473. * @param scene Defines the scene we are parsing for
  45474. * @param rootUrl Defines the rootUrl to load from
  45475. */
  45476. parse(source: any, scene: Scene, rootUrl: string): void;
  45477. }
  45478. }
  45479. declare module BABYLON {
  45480. /**
  45481. * @hidden
  45482. */
  45483. export interface IMaterialBRDFDefines {
  45484. BRDF_V_HEIGHT_CORRELATED: boolean;
  45485. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45486. SPHERICAL_HARMONICS: boolean;
  45487. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  45488. /** @hidden */ private _areMiscDirty: boolean;
  45489. }
  45490. /**
  45491. * Define the code related to the BRDF parameters of the pbr material.
  45492. */
  45493. export class PBRBRDFConfiguration {
  45494. /**
  45495. * Default value used for the energy conservation.
  45496. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45497. */
  45498. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45499. /**
  45500. * Default value used for the Smith Visibility Height Correlated mode.
  45501. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45502. */
  45503. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45504. /**
  45505. * Default value used for the IBL diffuse part.
  45506. * This can help switching back to the polynomials mode globally which is a tiny bit
  45507. * less GPU intensive at the drawback of a lower quality.
  45508. */
  45509. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45510. /**
  45511. * Default value used for activating energy conservation for the specular workflow.
  45512. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  45513. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  45514. */
  45515. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  45516. private _useEnergyConservation;
  45517. /**
  45518. * Defines if the material uses energy conservation.
  45519. */
  45520. useEnergyConservation: boolean;
  45521. private _useSmithVisibilityHeightCorrelated;
  45522. /**
  45523. * LEGACY Mode set to false
  45524. * Defines if the material uses height smith correlated visibility term.
  45525. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45526. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45527. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45528. * Not relying on height correlated will also disable energy conservation.
  45529. */
  45530. useSmithVisibilityHeightCorrelated: boolean;
  45531. private _useSphericalHarmonics;
  45532. /**
  45533. * LEGACY Mode set to false
  45534. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45535. * diffuse part of the IBL.
  45536. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45537. * to the ground truth.
  45538. */
  45539. useSphericalHarmonics: boolean;
  45540. private _useSpecularGlossinessInputEnergyConservation;
  45541. /**
  45542. * Defines if the material uses energy conservation, when the specular workflow is active.
  45543. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  45544. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  45545. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  45546. */
  45547. useSpecularGlossinessInputEnergyConservation: boolean;
  45548. /** @hidden */
  45549. private _internalMarkAllSubMeshesAsMiscDirty;
  45550. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  45551. /**
  45552. * Instantiate a new istance of clear coat configuration.
  45553. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45554. */
  45555. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45556. /**
  45557. * Checks to see if a texture is used in the material.
  45558. * @param defines the list of "defines" to update.
  45559. */
  45560. prepareDefines(defines: IMaterialBRDFDefines): void;
  45561. /**
  45562. * Get the current class name of the texture useful for serialization or dynamic coding.
  45563. * @returns "PBRClearCoatConfiguration"
  45564. */
  45565. getClassName(): string;
  45566. /**
  45567. * Makes a duplicate of the current configuration into another one.
  45568. * @param brdfConfiguration define the config where to copy the info
  45569. */
  45570. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45571. /**
  45572. * Serializes this BRDF configuration.
  45573. * @returns - An object with the serialized config.
  45574. */
  45575. serialize(): any;
  45576. /**
  45577. * Parses a anisotropy Configuration from a serialized object.
  45578. * @param source - Serialized object.
  45579. * @param scene Defines the scene we are parsing for
  45580. * @param rootUrl Defines the rootUrl to load from
  45581. */
  45582. parse(source: any, scene: Scene, rootUrl: string): void;
  45583. }
  45584. }
  45585. declare module BABYLON {
  45586. /**
  45587. * @hidden
  45588. */
  45589. export interface IMaterialSheenDefines {
  45590. SHEEN: boolean;
  45591. SHEEN_TEXTURE: boolean;
  45592. SHEEN_TEXTUREDIRECTUV: number;
  45593. SHEEN_LINKWITHALBEDO: boolean;
  45594. /** @hidden */ private _areTexturesDirty: boolean;
  45595. }
  45596. /**
  45597. * Define the code related to the Sheen parameters of the pbr material.
  45598. */
  45599. export class PBRSheenConfiguration {
  45600. private _isEnabled;
  45601. /**
  45602. * Defines if the material uses sheen.
  45603. */
  45604. isEnabled: boolean;
  45605. private _linkSheenWithAlbedo;
  45606. /**
  45607. * Defines if the sheen is linked to the sheen color.
  45608. */
  45609. linkSheenWithAlbedo: boolean;
  45610. /**
  45611. * Defines the sheen intensity.
  45612. */
  45613. intensity: number;
  45614. /**
  45615. * Defines the sheen color.
  45616. */
  45617. color: Color3;
  45618. private _texture;
  45619. /**
  45620. * Stores the sheen tint values in a texture.
  45621. * rgb is tint
  45622. * a is a intensity
  45623. */
  45624. texture: Nullable<BaseTexture>;
  45625. /** @hidden */
  45626. private _internalMarkAllSubMeshesAsTexturesDirty;
  45627. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45628. /**
  45629. * Instantiate a new istance of clear coat configuration.
  45630. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45631. */
  45632. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45633. /**
  45634. * Specifies that the submesh is ready to be used.
  45635. * @param defines the list of "defines" to update.
  45636. * @param scene defines the scene the material belongs to.
  45637. * @returns - boolean indicating that the submesh is ready or not.
  45638. */
  45639. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45640. /**
  45641. * Checks to see if a texture is used in the material.
  45642. * @param defines the list of "defines" to update.
  45643. * @param scene defines the scene the material belongs to.
  45644. */
  45645. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45646. /**
  45647. * Binds the material data.
  45648. * @param uniformBuffer defines the Uniform buffer to fill in.
  45649. * @param scene defines the scene the material belongs to.
  45650. * @param isFrozen defines wether the material is frozen or not.
  45651. */
  45652. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45653. /**
  45654. * Checks to see if a texture is used in the material.
  45655. * @param texture - Base texture to use.
  45656. * @returns - Boolean specifying if a texture is used in the material.
  45657. */
  45658. hasTexture(texture: BaseTexture): boolean;
  45659. /**
  45660. * Returns an array of the actively used textures.
  45661. * @param activeTextures Array of BaseTextures
  45662. */
  45663. getActiveTextures(activeTextures: BaseTexture[]): void;
  45664. /**
  45665. * Returns the animatable textures.
  45666. * @param animatables Array of animatable textures.
  45667. */
  45668. getAnimatables(animatables: IAnimatable[]): void;
  45669. /**
  45670. * Disposes the resources of the material.
  45671. * @param forceDisposeTextures - Forces the disposal of all textures.
  45672. */
  45673. dispose(forceDisposeTextures?: boolean): void;
  45674. /**
  45675. * Get the current class name of the texture useful for serialization or dynamic coding.
  45676. * @returns "PBRSheenConfiguration"
  45677. */
  45678. getClassName(): string;
  45679. /**
  45680. * Add fallbacks to the effect fallbacks list.
  45681. * @param defines defines the Base texture to use.
  45682. * @param fallbacks defines the current fallback list.
  45683. * @param currentRank defines the current fallback rank.
  45684. * @returns the new fallback rank.
  45685. */
  45686. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45687. /**
  45688. * Add the required uniforms to the current list.
  45689. * @param uniforms defines the current uniform list.
  45690. */
  45691. static AddUniforms(uniforms: string[]): void;
  45692. /**
  45693. * Add the required uniforms to the current buffer.
  45694. * @param uniformBuffer defines the current uniform buffer.
  45695. */
  45696. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45697. /**
  45698. * Add the required samplers to the current list.
  45699. * @param samplers defines the current sampler list.
  45700. */
  45701. static AddSamplers(samplers: string[]): void;
  45702. /**
  45703. * Makes a duplicate of the current configuration into another one.
  45704. * @param sheenConfiguration define the config where to copy the info
  45705. */
  45706. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45707. /**
  45708. * Serializes this BRDF configuration.
  45709. * @returns - An object with the serialized config.
  45710. */
  45711. serialize(): any;
  45712. /**
  45713. * Parses a anisotropy Configuration from a serialized object.
  45714. * @param source - Serialized object.
  45715. * @param scene Defines the scene we are parsing for
  45716. * @param rootUrl Defines the rootUrl to load from
  45717. */
  45718. parse(source: any, scene: Scene, rootUrl: string): void;
  45719. }
  45720. }
  45721. declare module BABYLON {
  45722. /**
  45723. * @hidden
  45724. */
  45725. export interface IMaterialSubSurfaceDefines {
  45726. SUBSURFACE: boolean;
  45727. SS_REFRACTION: boolean;
  45728. SS_TRANSLUCENCY: boolean;
  45729. SS_SCATERRING: boolean;
  45730. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45731. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45732. SS_REFRACTIONMAP_3D: boolean;
  45733. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45734. SS_LODINREFRACTIONALPHA: boolean;
  45735. SS_GAMMAREFRACTION: boolean;
  45736. SS_RGBDREFRACTION: boolean;
  45737. SS_LINEARSPECULARREFRACTION: boolean;
  45738. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45739. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45740. /** @hidden */ private _areTexturesDirty: boolean;
  45741. }
  45742. /**
  45743. * Define the code related to the sub surface parameters of the pbr material.
  45744. */
  45745. export class PBRSubSurfaceConfiguration {
  45746. private _isRefractionEnabled;
  45747. /**
  45748. * Defines if the refraction is enabled in the material.
  45749. */
  45750. isRefractionEnabled: boolean;
  45751. private _isTranslucencyEnabled;
  45752. /**
  45753. * Defines if the translucency is enabled in the material.
  45754. */
  45755. isTranslucencyEnabled: boolean;
  45756. private _isScatteringEnabled;
  45757. /**
  45758. * Defines the refraction intensity of the material.
  45759. * The refraction when enabled replaces the Diffuse part of the material.
  45760. * The intensity helps transitionning between diffuse and refraction.
  45761. */
  45762. refractionIntensity: number;
  45763. /**
  45764. * Defines the translucency intensity of the material.
  45765. * When translucency has been enabled, this defines how much of the "translucency"
  45766. * is addded to the diffuse part of the material.
  45767. */
  45768. translucencyIntensity: number;
  45769. /**
  45770. * Defines the scattering intensity of the material.
  45771. * When scattering has been enabled, this defines how much of the "scattered light"
  45772. * is addded to the diffuse part of the material.
  45773. */
  45774. scatteringIntensity: number;
  45775. private _thicknessTexture;
  45776. /**
  45777. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45778. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45779. * 0 would mean minimumThickness
  45780. * 1 would mean maximumThickness
  45781. * The other channels might be use as a mask to vary the different effects intensity.
  45782. */
  45783. thicknessTexture: Nullable<BaseTexture>;
  45784. private _refractionTexture;
  45785. /**
  45786. * Defines the texture to use for refraction.
  45787. */
  45788. refractionTexture: Nullable<BaseTexture>;
  45789. private _indexOfRefraction;
  45790. /**
  45791. * Defines the index of refraction used in the material.
  45792. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45793. */
  45794. indexOfRefraction: number;
  45795. private _invertRefractionY;
  45796. /**
  45797. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45798. */
  45799. invertRefractionY: boolean;
  45800. private _linkRefractionWithTransparency;
  45801. /**
  45802. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45803. * Materials half opaque for instance using refraction could benefit from this control.
  45804. */
  45805. linkRefractionWithTransparency: boolean;
  45806. /**
  45807. * Defines the minimum thickness stored in the thickness map.
  45808. * If no thickness map is defined, this value will be used to simulate thickness.
  45809. */
  45810. minimumThickness: number;
  45811. /**
  45812. * Defines the maximum thickness stored in the thickness map.
  45813. */
  45814. maximumThickness: number;
  45815. /**
  45816. * Defines the volume tint of the material.
  45817. * This is used for both translucency and scattering.
  45818. */
  45819. tintColor: Color3;
  45820. /**
  45821. * Defines the distance at which the tint color should be found in the media.
  45822. * This is used for refraction only.
  45823. */
  45824. tintColorAtDistance: number;
  45825. /**
  45826. * Defines how far each channel transmit through the media.
  45827. * It is defined as a color to simplify it selection.
  45828. */
  45829. diffusionDistance: Color3;
  45830. private _useMaskFromThicknessTexture;
  45831. /**
  45832. * Stores the intensity of the different subsurface effects in the thickness texture.
  45833. * * the green channel is the translucency intensity.
  45834. * * the blue channel is the scattering intensity.
  45835. * * the alpha channel is the refraction intensity.
  45836. */
  45837. useMaskFromThicknessTexture: boolean;
  45838. /** @hidden */
  45839. private _internalMarkAllSubMeshesAsTexturesDirty;
  45840. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45841. /**
  45842. * Instantiate a new istance of sub surface configuration.
  45843. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45844. */
  45845. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45846. /**
  45847. * Gets wehter the submesh is ready to be used or not.
  45848. * @param defines the list of "defines" to update.
  45849. * @param scene defines the scene the material belongs to.
  45850. * @returns - boolean indicating that the submesh is ready or not.
  45851. */
  45852. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45853. /**
  45854. * Checks to see if a texture is used in the material.
  45855. * @param defines the list of "defines" to update.
  45856. * @param scene defines the scene to the material belongs to.
  45857. */
  45858. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45859. /**
  45860. * Binds the material data.
  45861. * @param uniformBuffer defines the Uniform buffer to fill in.
  45862. * @param scene defines the scene the material belongs to.
  45863. * @param engine defines the engine the material belongs to.
  45864. * @param isFrozen defines wether the material is frozen or not.
  45865. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45866. */
  45867. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45868. /**
  45869. * Unbinds the material from the mesh.
  45870. * @param activeEffect defines the effect that should be unbound from.
  45871. * @returns true if unbound, otherwise false
  45872. */
  45873. unbind(activeEffect: Effect): boolean;
  45874. /**
  45875. * Returns the texture used for refraction or null if none is used.
  45876. * @param scene defines the scene the material belongs to.
  45877. * @returns - Refraction texture if present. If no refraction texture and refraction
  45878. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45879. */
  45880. private _getRefractionTexture;
  45881. /**
  45882. * Returns true if alpha blending should be disabled.
  45883. */
  45884. readonly disableAlphaBlending: boolean;
  45885. /**
  45886. * Fills the list of render target textures.
  45887. * @param renderTargets the list of render targets to update
  45888. */
  45889. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45890. /**
  45891. * Checks to see if a texture is used in the material.
  45892. * @param texture - Base texture to use.
  45893. * @returns - Boolean specifying if a texture is used in the material.
  45894. */
  45895. hasTexture(texture: BaseTexture): boolean;
  45896. /**
  45897. * Gets a boolean indicating that current material needs to register RTT
  45898. * @returns true if this uses a render target otherwise false.
  45899. */
  45900. hasRenderTargetTextures(): boolean;
  45901. /**
  45902. * Returns an array of the actively used textures.
  45903. * @param activeTextures Array of BaseTextures
  45904. */
  45905. getActiveTextures(activeTextures: BaseTexture[]): void;
  45906. /**
  45907. * Returns the animatable textures.
  45908. * @param animatables Array of animatable textures.
  45909. */
  45910. getAnimatables(animatables: IAnimatable[]): void;
  45911. /**
  45912. * Disposes the resources of the material.
  45913. * @param forceDisposeTextures - Forces the disposal of all textures.
  45914. */
  45915. dispose(forceDisposeTextures?: boolean): void;
  45916. /**
  45917. * Get the current class name of the texture useful for serialization or dynamic coding.
  45918. * @returns "PBRSubSurfaceConfiguration"
  45919. */
  45920. getClassName(): string;
  45921. /**
  45922. * Add fallbacks to the effect fallbacks list.
  45923. * @param defines defines the Base texture to use.
  45924. * @param fallbacks defines the current fallback list.
  45925. * @param currentRank defines the current fallback rank.
  45926. * @returns the new fallback rank.
  45927. */
  45928. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45929. /**
  45930. * Add the required uniforms to the current list.
  45931. * @param uniforms defines the current uniform list.
  45932. */
  45933. static AddUniforms(uniforms: string[]): void;
  45934. /**
  45935. * Add the required samplers to the current list.
  45936. * @param samplers defines the current sampler list.
  45937. */
  45938. static AddSamplers(samplers: string[]): void;
  45939. /**
  45940. * Add the required uniforms to the current buffer.
  45941. * @param uniformBuffer defines the current uniform buffer.
  45942. */
  45943. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45944. /**
  45945. * Makes a duplicate of the current configuration into another one.
  45946. * @param configuration define the config where to copy the info
  45947. */
  45948. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45949. /**
  45950. * Serializes this Sub Surface configuration.
  45951. * @returns - An object with the serialized config.
  45952. */
  45953. serialize(): any;
  45954. /**
  45955. * Parses a anisotropy Configuration from a serialized object.
  45956. * @param source - Serialized object.
  45957. * @param scene Defines the scene we are parsing for
  45958. * @param rootUrl Defines the rootUrl to load from
  45959. */
  45960. parse(source: any, scene: Scene, rootUrl: string): void;
  45961. }
  45962. }
  45963. declare module BABYLON {
  45964. /** @hidden */
  45965. export var pbrFragmentDeclaration: {
  45966. name: string;
  45967. shader: string;
  45968. };
  45969. }
  45970. declare module BABYLON {
  45971. /** @hidden */
  45972. export var pbrUboDeclaration: {
  45973. name: string;
  45974. shader: string;
  45975. };
  45976. }
  45977. declare module BABYLON {
  45978. /** @hidden */
  45979. export var pbrFragmentExtraDeclaration: {
  45980. name: string;
  45981. shader: string;
  45982. };
  45983. }
  45984. declare module BABYLON {
  45985. /** @hidden */
  45986. export var pbrFragmentSamplersDeclaration: {
  45987. name: string;
  45988. shader: string;
  45989. };
  45990. }
  45991. declare module BABYLON {
  45992. /** @hidden */
  45993. export var pbrHelperFunctions: {
  45994. name: string;
  45995. shader: string;
  45996. };
  45997. }
  45998. declare module BABYLON {
  45999. /** @hidden */
  46000. export var harmonicsFunctions: {
  46001. name: string;
  46002. shader: string;
  46003. };
  46004. }
  46005. declare module BABYLON {
  46006. /** @hidden */
  46007. export var pbrDirectLightingSetupFunctions: {
  46008. name: string;
  46009. shader: string;
  46010. };
  46011. }
  46012. declare module BABYLON {
  46013. /** @hidden */
  46014. export var pbrDirectLightingFalloffFunctions: {
  46015. name: string;
  46016. shader: string;
  46017. };
  46018. }
  46019. declare module BABYLON {
  46020. /** @hidden */
  46021. export var pbrBRDFFunctions: {
  46022. name: string;
  46023. shader: string;
  46024. };
  46025. }
  46026. declare module BABYLON {
  46027. /** @hidden */
  46028. export var pbrDirectLightingFunctions: {
  46029. name: string;
  46030. shader: string;
  46031. };
  46032. }
  46033. declare module BABYLON {
  46034. /** @hidden */
  46035. export var pbrIBLFunctions: {
  46036. name: string;
  46037. shader: string;
  46038. };
  46039. }
  46040. declare module BABYLON {
  46041. /** @hidden */
  46042. export var pbrDebug: {
  46043. name: string;
  46044. shader: string;
  46045. };
  46046. }
  46047. declare module BABYLON {
  46048. /** @hidden */
  46049. export var pbrPixelShader: {
  46050. name: string;
  46051. shader: string;
  46052. };
  46053. }
  46054. declare module BABYLON {
  46055. /** @hidden */
  46056. export var pbrVertexDeclaration: {
  46057. name: string;
  46058. shader: string;
  46059. };
  46060. }
  46061. declare module BABYLON {
  46062. /** @hidden */
  46063. export var pbrVertexShader: {
  46064. name: string;
  46065. shader: string;
  46066. };
  46067. }
  46068. declare module BABYLON {
  46069. /**
  46070. * Manages the defines for the PBR Material.
  46071. * @hidden
  46072. */
  46073. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46074. PBR: boolean;
  46075. MAINUV1: boolean;
  46076. MAINUV2: boolean;
  46077. UV1: boolean;
  46078. UV2: boolean;
  46079. ALBEDO: boolean;
  46080. ALBEDODIRECTUV: number;
  46081. VERTEXCOLOR: boolean;
  46082. AMBIENT: boolean;
  46083. AMBIENTDIRECTUV: number;
  46084. AMBIENTINGRAYSCALE: boolean;
  46085. OPACITY: boolean;
  46086. VERTEXALPHA: boolean;
  46087. OPACITYDIRECTUV: number;
  46088. OPACITYRGB: boolean;
  46089. ALPHATEST: boolean;
  46090. DEPTHPREPASS: boolean;
  46091. ALPHABLEND: boolean;
  46092. ALPHAFROMALBEDO: boolean;
  46093. ALPHATESTVALUE: string;
  46094. SPECULAROVERALPHA: boolean;
  46095. RADIANCEOVERALPHA: boolean;
  46096. ALPHAFRESNEL: boolean;
  46097. LINEARALPHAFRESNEL: boolean;
  46098. PREMULTIPLYALPHA: boolean;
  46099. EMISSIVE: boolean;
  46100. EMISSIVEDIRECTUV: number;
  46101. REFLECTIVITY: boolean;
  46102. REFLECTIVITYDIRECTUV: number;
  46103. SPECULARTERM: boolean;
  46104. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46105. MICROSURFACEAUTOMATIC: boolean;
  46106. LODBASEDMICROSFURACE: boolean;
  46107. MICROSURFACEMAP: boolean;
  46108. MICROSURFACEMAPDIRECTUV: number;
  46109. METALLICWORKFLOW: boolean;
  46110. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46111. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46112. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46113. AOSTOREINMETALMAPRED: boolean;
  46114. ENVIRONMENTBRDF: boolean;
  46115. ENVIRONMENTBRDF_RGBD: boolean;
  46116. NORMAL: boolean;
  46117. TANGENT: boolean;
  46118. BUMP: boolean;
  46119. BUMPDIRECTUV: number;
  46120. OBJECTSPACE_NORMALMAP: boolean;
  46121. PARALLAX: boolean;
  46122. PARALLAXOCCLUSION: boolean;
  46123. NORMALXYSCALE: boolean;
  46124. LIGHTMAP: boolean;
  46125. LIGHTMAPDIRECTUV: number;
  46126. USELIGHTMAPASSHADOWMAP: boolean;
  46127. GAMMALIGHTMAP: boolean;
  46128. RGBDLIGHTMAP: boolean;
  46129. REFLECTION: boolean;
  46130. REFLECTIONMAP_3D: boolean;
  46131. REFLECTIONMAP_SPHERICAL: boolean;
  46132. REFLECTIONMAP_PLANAR: boolean;
  46133. REFLECTIONMAP_CUBIC: boolean;
  46134. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46135. REFLECTIONMAP_PROJECTION: boolean;
  46136. REFLECTIONMAP_SKYBOX: boolean;
  46137. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46138. REFLECTIONMAP_EXPLICIT: boolean;
  46139. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46140. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46141. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46142. INVERTCUBICMAP: boolean;
  46143. USESPHERICALFROMREFLECTIONMAP: boolean;
  46144. USEIRRADIANCEMAP: boolean;
  46145. SPHERICAL_HARMONICS: boolean;
  46146. USESPHERICALINVERTEX: boolean;
  46147. REFLECTIONMAP_OPPOSITEZ: boolean;
  46148. LODINREFLECTIONALPHA: boolean;
  46149. GAMMAREFLECTION: boolean;
  46150. RGBDREFLECTION: boolean;
  46151. LINEARSPECULARREFLECTION: boolean;
  46152. RADIANCEOCCLUSION: boolean;
  46153. HORIZONOCCLUSION: boolean;
  46154. INSTANCES: boolean;
  46155. NUM_BONE_INFLUENCERS: number;
  46156. BonesPerMesh: number;
  46157. BONETEXTURE: boolean;
  46158. NONUNIFORMSCALING: boolean;
  46159. MORPHTARGETS: boolean;
  46160. MORPHTARGETS_NORMAL: boolean;
  46161. MORPHTARGETS_TANGENT: boolean;
  46162. MORPHTARGETS_UV: boolean;
  46163. NUM_MORPH_INFLUENCERS: number;
  46164. IMAGEPROCESSING: boolean;
  46165. VIGNETTE: boolean;
  46166. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46167. VIGNETTEBLENDMODEOPAQUE: boolean;
  46168. TONEMAPPING: boolean;
  46169. TONEMAPPING_ACES: boolean;
  46170. CONTRAST: boolean;
  46171. COLORCURVES: boolean;
  46172. COLORGRADING: boolean;
  46173. COLORGRADING3D: boolean;
  46174. SAMPLER3DGREENDEPTH: boolean;
  46175. SAMPLER3DBGRMAP: boolean;
  46176. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46177. EXPOSURE: boolean;
  46178. MULTIVIEW: boolean;
  46179. USEPHYSICALLIGHTFALLOFF: boolean;
  46180. USEGLTFLIGHTFALLOFF: boolean;
  46181. TWOSIDEDLIGHTING: boolean;
  46182. SHADOWFLOAT: boolean;
  46183. CLIPPLANE: boolean;
  46184. CLIPPLANE2: boolean;
  46185. CLIPPLANE3: boolean;
  46186. CLIPPLANE4: boolean;
  46187. POINTSIZE: boolean;
  46188. FOG: boolean;
  46189. LOGARITHMICDEPTH: boolean;
  46190. FORCENORMALFORWARD: boolean;
  46191. SPECULARAA: boolean;
  46192. CLEARCOAT: boolean;
  46193. CLEARCOAT_DEFAULTIOR: boolean;
  46194. CLEARCOAT_TEXTURE: boolean;
  46195. CLEARCOAT_TEXTUREDIRECTUV: number;
  46196. CLEARCOAT_BUMP: boolean;
  46197. CLEARCOAT_BUMPDIRECTUV: number;
  46198. CLEARCOAT_TINT: boolean;
  46199. CLEARCOAT_TINT_TEXTURE: boolean;
  46200. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46201. ANISOTROPIC: boolean;
  46202. ANISOTROPIC_TEXTURE: boolean;
  46203. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46204. BRDF_V_HEIGHT_CORRELATED: boolean;
  46205. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46206. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46207. SHEEN: boolean;
  46208. SHEEN_TEXTURE: boolean;
  46209. SHEEN_TEXTUREDIRECTUV: number;
  46210. SHEEN_LINKWITHALBEDO: boolean;
  46211. SUBSURFACE: boolean;
  46212. SS_REFRACTION: boolean;
  46213. SS_TRANSLUCENCY: boolean;
  46214. SS_SCATERRING: boolean;
  46215. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46216. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46217. SS_REFRACTIONMAP_3D: boolean;
  46218. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46219. SS_LODINREFRACTIONALPHA: boolean;
  46220. SS_GAMMAREFRACTION: boolean;
  46221. SS_RGBDREFRACTION: boolean;
  46222. SS_LINEARSPECULARREFRACTION: boolean;
  46223. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46224. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46225. UNLIT: boolean;
  46226. DEBUGMODE: number;
  46227. /**
  46228. * Initializes the PBR Material defines.
  46229. */
  46230. constructor();
  46231. /**
  46232. * Resets the PBR Material defines.
  46233. */
  46234. reset(): void;
  46235. }
  46236. /**
  46237. * The Physically based material base class of BJS.
  46238. *
  46239. * This offers the main features of a standard PBR material.
  46240. * For more information, please refer to the documentation :
  46241. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46242. */
  46243. export abstract class PBRBaseMaterial extends PushMaterial {
  46244. /**
  46245. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46246. */
  46247. static readonly PBRMATERIAL_OPAQUE: number;
  46248. /**
  46249. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46250. */
  46251. static readonly PBRMATERIAL_ALPHATEST: number;
  46252. /**
  46253. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46254. */
  46255. static readonly PBRMATERIAL_ALPHABLEND: number;
  46256. /**
  46257. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46258. * They are also discarded below the alpha cutoff threshold to improve performances.
  46259. */
  46260. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46261. /**
  46262. * Defines the default value of how much AO map is occluding the analytical lights
  46263. * (point spot...).
  46264. */
  46265. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46266. /**
  46267. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46268. */
  46269. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46270. /**
  46271. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46272. * to enhance interoperability with other engines.
  46273. */
  46274. static readonly LIGHTFALLOFF_GLTF: number;
  46275. /**
  46276. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46277. * to enhance interoperability with other materials.
  46278. */
  46279. static readonly LIGHTFALLOFF_STANDARD: number;
  46280. /**
  46281. * Intensity of the direct lights e.g. the four lights available in your scene.
  46282. * This impacts both the direct diffuse and specular highlights.
  46283. */
  46284. protected _directIntensity: number;
  46285. /**
  46286. * Intensity of the emissive part of the material.
  46287. * This helps controlling the emissive effect without modifying the emissive color.
  46288. */
  46289. protected _emissiveIntensity: number;
  46290. /**
  46291. * Intensity of the environment e.g. how much the environment will light the object
  46292. * either through harmonics for rough material or through the refelction for shiny ones.
  46293. */
  46294. protected _environmentIntensity: number;
  46295. /**
  46296. * This is a special control allowing the reduction of the specular highlights coming from the
  46297. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46298. */
  46299. protected _specularIntensity: number;
  46300. /**
  46301. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46302. */
  46303. private _lightingInfos;
  46304. /**
  46305. * Debug Control allowing disabling the bump map on this material.
  46306. */
  46307. protected _disableBumpMap: boolean;
  46308. /**
  46309. * AKA Diffuse Texture in standard nomenclature.
  46310. */
  46311. protected _albedoTexture: Nullable<BaseTexture>;
  46312. /**
  46313. * AKA Occlusion Texture in other nomenclature.
  46314. */
  46315. protected _ambientTexture: Nullable<BaseTexture>;
  46316. /**
  46317. * AKA Occlusion Texture Intensity in other nomenclature.
  46318. */
  46319. protected _ambientTextureStrength: number;
  46320. /**
  46321. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46322. * 1 means it completely occludes it
  46323. * 0 mean it has no impact
  46324. */
  46325. protected _ambientTextureImpactOnAnalyticalLights: number;
  46326. /**
  46327. * Stores the alpha values in a texture.
  46328. */
  46329. protected _opacityTexture: Nullable<BaseTexture>;
  46330. /**
  46331. * Stores the reflection values in a texture.
  46332. */
  46333. protected _reflectionTexture: Nullable<BaseTexture>;
  46334. /**
  46335. * Stores the emissive values in a texture.
  46336. */
  46337. protected _emissiveTexture: Nullable<BaseTexture>;
  46338. /**
  46339. * AKA Specular texture in other nomenclature.
  46340. */
  46341. protected _reflectivityTexture: Nullable<BaseTexture>;
  46342. /**
  46343. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46344. */
  46345. protected _metallicTexture: Nullable<BaseTexture>;
  46346. /**
  46347. * Specifies the metallic scalar of the metallic/roughness workflow.
  46348. * Can also be used to scale the metalness values of the metallic texture.
  46349. */
  46350. protected _metallic: Nullable<number>;
  46351. /**
  46352. * Specifies the roughness scalar of the metallic/roughness workflow.
  46353. * Can also be used to scale the roughness values of the metallic texture.
  46354. */
  46355. protected _roughness: Nullable<number>;
  46356. /**
  46357. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46358. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46359. */
  46360. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46361. /**
  46362. * Stores surface normal data used to displace a mesh in a texture.
  46363. */
  46364. protected _bumpTexture: Nullable<BaseTexture>;
  46365. /**
  46366. * Stores the pre-calculated light information of a mesh in a texture.
  46367. */
  46368. protected _lightmapTexture: Nullable<BaseTexture>;
  46369. /**
  46370. * The color of a material in ambient lighting.
  46371. */
  46372. protected _ambientColor: Color3;
  46373. /**
  46374. * AKA Diffuse Color in other nomenclature.
  46375. */
  46376. protected _albedoColor: Color3;
  46377. /**
  46378. * AKA Specular Color in other nomenclature.
  46379. */
  46380. protected _reflectivityColor: Color3;
  46381. /**
  46382. * The color applied when light is reflected from a material.
  46383. */
  46384. protected _reflectionColor: Color3;
  46385. /**
  46386. * The color applied when light is emitted from a material.
  46387. */
  46388. protected _emissiveColor: Color3;
  46389. /**
  46390. * AKA Glossiness in other nomenclature.
  46391. */
  46392. protected _microSurface: number;
  46393. /**
  46394. * Specifies that the material will use the light map as a show map.
  46395. */
  46396. protected _useLightmapAsShadowmap: boolean;
  46397. /**
  46398. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46399. * makes the reflect vector face the model (under horizon).
  46400. */
  46401. protected _useHorizonOcclusion: boolean;
  46402. /**
  46403. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46404. * too much the area relying on ambient texture to define their ambient occlusion.
  46405. */
  46406. protected _useRadianceOcclusion: boolean;
  46407. /**
  46408. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46409. */
  46410. protected _useAlphaFromAlbedoTexture: boolean;
  46411. /**
  46412. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46413. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46414. */
  46415. protected _useSpecularOverAlpha: boolean;
  46416. /**
  46417. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46418. */
  46419. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46420. /**
  46421. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46422. */
  46423. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46424. /**
  46425. * Specifies if the metallic texture contains the roughness information in its green channel.
  46426. */
  46427. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46428. /**
  46429. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46430. */
  46431. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46432. /**
  46433. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46434. */
  46435. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46436. /**
  46437. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46438. */
  46439. protected _useAmbientInGrayScale: boolean;
  46440. /**
  46441. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46442. * The material will try to infer what glossiness each pixel should be.
  46443. */
  46444. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46445. /**
  46446. * Defines the falloff type used in this material.
  46447. * It by default is Physical.
  46448. */
  46449. protected _lightFalloff: number;
  46450. /**
  46451. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46452. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46453. */
  46454. protected _useRadianceOverAlpha: boolean;
  46455. /**
  46456. * Allows using an object space normal map (instead of tangent space).
  46457. */
  46458. protected _useObjectSpaceNormalMap: boolean;
  46459. /**
  46460. * Allows using the bump map in parallax mode.
  46461. */
  46462. protected _useParallax: boolean;
  46463. /**
  46464. * Allows using the bump map in parallax occlusion mode.
  46465. */
  46466. protected _useParallaxOcclusion: boolean;
  46467. /**
  46468. * Controls the scale bias of the parallax mode.
  46469. */
  46470. protected _parallaxScaleBias: number;
  46471. /**
  46472. * If sets to true, disables all the lights affecting the material.
  46473. */
  46474. protected _disableLighting: boolean;
  46475. /**
  46476. * Number of Simultaneous lights allowed on the material.
  46477. */
  46478. protected _maxSimultaneousLights: number;
  46479. /**
  46480. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46481. */
  46482. protected _invertNormalMapX: boolean;
  46483. /**
  46484. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46485. */
  46486. protected _invertNormalMapY: boolean;
  46487. /**
  46488. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46489. */
  46490. protected _twoSidedLighting: boolean;
  46491. /**
  46492. * Defines the alpha limits in alpha test mode.
  46493. */
  46494. protected _alphaCutOff: number;
  46495. /**
  46496. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46497. */
  46498. protected _forceAlphaTest: boolean;
  46499. /**
  46500. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46501. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46502. */
  46503. protected _useAlphaFresnel: boolean;
  46504. /**
  46505. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46506. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46507. */
  46508. protected _useLinearAlphaFresnel: boolean;
  46509. /**
  46510. * The transparency mode of the material.
  46511. */
  46512. protected _transparencyMode: Nullable<number>;
  46513. /**
  46514. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46515. * from cos thetav and roughness:
  46516. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46517. */
  46518. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46519. /**
  46520. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46521. */
  46522. protected _forceIrradianceInFragment: boolean;
  46523. /**
  46524. * Force normal to face away from face.
  46525. */
  46526. protected _forceNormalForward: boolean;
  46527. /**
  46528. * Enables specular anti aliasing in the PBR shader.
  46529. * It will both interacts on the Geometry for analytical and IBL lighting.
  46530. * It also prefilter the roughness map based on the bump values.
  46531. */
  46532. protected _enableSpecularAntiAliasing: boolean;
  46533. /**
  46534. * Default configuration related to image processing available in the PBR Material.
  46535. */
  46536. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46537. /**
  46538. * Keep track of the image processing observer to allow dispose and replace.
  46539. */
  46540. private _imageProcessingObserver;
  46541. /**
  46542. * Attaches a new image processing configuration to the PBR Material.
  46543. * @param configuration
  46544. */
  46545. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46546. /**
  46547. * Stores the available render targets.
  46548. */
  46549. private _renderTargets;
  46550. /**
  46551. * Sets the global ambient color for the material used in lighting calculations.
  46552. */
  46553. private _globalAmbientColor;
  46554. /**
  46555. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46556. */
  46557. private _useLogarithmicDepth;
  46558. /**
  46559. * If set to true, no lighting calculations will be applied.
  46560. */
  46561. private _unlit;
  46562. private _debugMode;
  46563. /**
  46564. * @hidden
  46565. * This is reserved for the inspector.
  46566. * Defines the material debug mode.
  46567. * It helps seeing only some components of the material while troubleshooting.
  46568. */
  46569. debugMode: number;
  46570. /**
  46571. * @hidden
  46572. * This is reserved for the inspector.
  46573. * Specify from where on screen the debug mode should start.
  46574. * The value goes from -1 (full screen) to 1 (not visible)
  46575. * It helps with side by side comparison against the final render
  46576. * This defaults to -1
  46577. */
  46578. private debugLimit;
  46579. /**
  46580. * @hidden
  46581. * This is reserved for the inspector.
  46582. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46583. * You can use the factor to better multiply the final value.
  46584. */
  46585. private debugFactor;
  46586. /**
  46587. * Defines the clear coat layer parameters for the material.
  46588. */
  46589. readonly clearCoat: PBRClearCoatConfiguration;
  46590. /**
  46591. * Defines the anisotropic parameters for the material.
  46592. */
  46593. readonly anisotropy: PBRAnisotropicConfiguration;
  46594. /**
  46595. * Defines the BRDF parameters for the material.
  46596. */
  46597. readonly brdf: PBRBRDFConfiguration;
  46598. /**
  46599. * Defines the Sheen parameters for the material.
  46600. */
  46601. readonly sheen: PBRSheenConfiguration;
  46602. /**
  46603. * Defines the SubSurface parameters for the material.
  46604. */
  46605. readonly subSurface: PBRSubSurfaceConfiguration;
  46606. /**
  46607. * Custom callback helping to override the default shader used in the material.
  46608. */
  46609. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46610. protected _rebuildInParallel: boolean;
  46611. /**
  46612. * Instantiates a new PBRMaterial instance.
  46613. *
  46614. * @param name The material name
  46615. * @param scene The scene the material will be use in.
  46616. */
  46617. constructor(name: string, scene: Scene);
  46618. /**
  46619. * Gets a boolean indicating that current material needs to register RTT
  46620. */
  46621. readonly hasRenderTargetTextures: boolean;
  46622. /**
  46623. * Gets the name of the material class.
  46624. */
  46625. getClassName(): string;
  46626. /**
  46627. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46628. */
  46629. /**
  46630. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46631. */
  46632. useLogarithmicDepth: boolean;
  46633. /**
  46634. * Gets the current transparency mode.
  46635. */
  46636. /**
  46637. * Sets the transparency mode of the material.
  46638. *
  46639. * | Value | Type | Description |
  46640. * | ----- | ----------------------------------- | ----------- |
  46641. * | 0 | OPAQUE | |
  46642. * | 1 | ALPHATEST | |
  46643. * | 2 | ALPHABLEND | |
  46644. * | 3 | ALPHATESTANDBLEND | |
  46645. *
  46646. */
  46647. transparencyMode: Nullable<number>;
  46648. /**
  46649. * Returns true if alpha blending should be disabled.
  46650. */
  46651. private readonly _disableAlphaBlending;
  46652. /**
  46653. * Specifies whether or not this material should be rendered in alpha blend mode.
  46654. */
  46655. needAlphaBlending(): boolean;
  46656. /**
  46657. * Specifies if the mesh will require alpha blending.
  46658. * @param mesh - BJS mesh.
  46659. */
  46660. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46661. /**
  46662. * Specifies whether or not this material should be rendered in alpha test mode.
  46663. */
  46664. needAlphaTesting(): boolean;
  46665. /**
  46666. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46667. */
  46668. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46669. /**
  46670. * Gets the texture used for the alpha test.
  46671. */
  46672. getAlphaTestTexture(): Nullable<BaseTexture>;
  46673. /**
  46674. * Specifies that the submesh is ready to be used.
  46675. * @param mesh - BJS mesh.
  46676. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46677. * @param useInstances - Specifies that instances should be used.
  46678. * @returns - boolean indicating that the submesh is ready or not.
  46679. */
  46680. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46681. /**
  46682. * Specifies if the material uses metallic roughness workflow.
  46683. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46684. */
  46685. isMetallicWorkflow(): boolean;
  46686. private _prepareEffect;
  46687. private _prepareDefines;
  46688. /**
  46689. * Force shader compilation
  46690. */
  46691. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46692. clipPlane: boolean;
  46693. }>): void;
  46694. /**
  46695. * Initializes the uniform buffer layout for the shader.
  46696. */
  46697. buildUniformLayout(): void;
  46698. /**
  46699. * Unbinds the material from the mesh
  46700. */
  46701. unbind(): void;
  46702. /**
  46703. * Binds the submesh data.
  46704. * @param world - The world matrix.
  46705. * @param mesh - The BJS mesh.
  46706. * @param subMesh - A submesh of the BJS mesh.
  46707. */
  46708. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46709. /**
  46710. * Returns the animatable textures.
  46711. * @returns - Array of animatable textures.
  46712. */
  46713. getAnimatables(): IAnimatable[];
  46714. /**
  46715. * Returns the texture used for reflections.
  46716. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46717. */
  46718. private _getReflectionTexture;
  46719. /**
  46720. * Returns an array of the actively used textures.
  46721. * @returns - Array of BaseTextures
  46722. */
  46723. getActiveTextures(): BaseTexture[];
  46724. /**
  46725. * Checks to see if a texture is used in the material.
  46726. * @param texture - Base texture to use.
  46727. * @returns - Boolean specifying if a texture is used in the material.
  46728. */
  46729. hasTexture(texture: BaseTexture): boolean;
  46730. /**
  46731. * Disposes the resources of the material.
  46732. * @param forceDisposeEffect - Forces the disposal of effects.
  46733. * @param forceDisposeTextures - Forces the disposal of all textures.
  46734. */
  46735. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46736. }
  46737. }
  46738. declare module BABYLON {
  46739. /**
  46740. * The Physically based material of BJS.
  46741. *
  46742. * This offers the main features of a standard PBR material.
  46743. * For more information, please refer to the documentation :
  46744. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46745. */
  46746. export class PBRMaterial extends PBRBaseMaterial {
  46747. /**
  46748. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46749. */
  46750. static readonly PBRMATERIAL_OPAQUE: number;
  46751. /**
  46752. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46753. */
  46754. static readonly PBRMATERIAL_ALPHATEST: number;
  46755. /**
  46756. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46757. */
  46758. static readonly PBRMATERIAL_ALPHABLEND: number;
  46759. /**
  46760. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46761. * They are also discarded below the alpha cutoff threshold to improve performances.
  46762. */
  46763. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46764. /**
  46765. * Defines the default value of how much AO map is occluding the analytical lights
  46766. * (point spot...).
  46767. */
  46768. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46769. /**
  46770. * Intensity of the direct lights e.g. the four lights available in your scene.
  46771. * This impacts both the direct diffuse and specular highlights.
  46772. */
  46773. directIntensity: number;
  46774. /**
  46775. * Intensity of the emissive part of the material.
  46776. * This helps controlling the emissive effect without modifying the emissive color.
  46777. */
  46778. emissiveIntensity: number;
  46779. /**
  46780. * Intensity of the environment e.g. how much the environment will light the object
  46781. * either through harmonics for rough material or through the refelction for shiny ones.
  46782. */
  46783. environmentIntensity: number;
  46784. /**
  46785. * This is a special control allowing the reduction of the specular highlights coming from the
  46786. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46787. */
  46788. specularIntensity: number;
  46789. /**
  46790. * Debug Control allowing disabling the bump map on this material.
  46791. */
  46792. disableBumpMap: boolean;
  46793. /**
  46794. * AKA Diffuse Texture in standard nomenclature.
  46795. */
  46796. albedoTexture: BaseTexture;
  46797. /**
  46798. * AKA Occlusion Texture in other nomenclature.
  46799. */
  46800. ambientTexture: BaseTexture;
  46801. /**
  46802. * AKA Occlusion Texture Intensity in other nomenclature.
  46803. */
  46804. ambientTextureStrength: number;
  46805. /**
  46806. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46807. * 1 means it completely occludes it
  46808. * 0 mean it has no impact
  46809. */
  46810. ambientTextureImpactOnAnalyticalLights: number;
  46811. /**
  46812. * Stores the alpha values in a texture.
  46813. */
  46814. opacityTexture: BaseTexture;
  46815. /**
  46816. * Stores the reflection values in a texture.
  46817. */
  46818. reflectionTexture: Nullable<BaseTexture>;
  46819. /**
  46820. * Stores the emissive values in a texture.
  46821. */
  46822. emissiveTexture: BaseTexture;
  46823. /**
  46824. * AKA Specular texture in other nomenclature.
  46825. */
  46826. reflectivityTexture: BaseTexture;
  46827. /**
  46828. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46829. */
  46830. metallicTexture: BaseTexture;
  46831. /**
  46832. * Specifies the metallic scalar of the metallic/roughness workflow.
  46833. * Can also be used to scale the metalness values of the metallic texture.
  46834. */
  46835. metallic: Nullable<number>;
  46836. /**
  46837. * Specifies the roughness scalar of the metallic/roughness workflow.
  46838. * Can also be used to scale the roughness values of the metallic texture.
  46839. */
  46840. roughness: Nullable<number>;
  46841. /**
  46842. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46843. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46844. */
  46845. microSurfaceTexture: BaseTexture;
  46846. /**
  46847. * Stores surface normal data used to displace a mesh in a texture.
  46848. */
  46849. bumpTexture: BaseTexture;
  46850. /**
  46851. * Stores the pre-calculated light information of a mesh in a texture.
  46852. */
  46853. lightmapTexture: BaseTexture;
  46854. /**
  46855. * Stores the refracted light information in a texture.
  46856. */
  46857. refractionTexture: Nullable<BaseTexture>;
  46858. /**
  46859. * The color of a material in ambient lighting.
  46860. */
  46861. ambientColor: Color3;
  46862. /**
  46863. * AKA Diffuse Color in other nomenclature.
  46864. */
  46865. albedoColor: Color3;
  46866. /**
  46867. * AKA Specular Color in other nomenclature.
  46868. */
  46869. reflectivityColor: Color3;
  46870. /**
  46871. * The color reflected from the material.
  46872. */
  46873. reflectionColor: Color3;
  46874. /**
  46875. * The color emitted from the material.
  46876. */
  46877. emissiveColor: Color3;
  46878. /**
  46879. * AKA Glossiness in other nomenclature.
  46880. */
  46881. microSurface: number;
  46882. /**
  46883. * source material index of refraction (IOR)' / 'destination material IOR.
  46884. */
  46885. indexOfRefraction: number;
  46886. /**
  46887. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46888. */
  46889. invertRefractionY: boolean;
  46890. /**
  46891. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46892. * Materials half opaque for instance using refraction could benefit from this control.
  46893. */
  46894. linkRefractionWithTransparency: boolean;
  46895. /**
  46896. * If true, the light map contains occlusion information instead of lighting info.
  46897. */
  46898. useLightmapAsShadowmap: boolean;
  46899. /**
  46900. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46901. */
  46902. useAlphaFromAlbedoTexture: boolean;
  46903. /**
  46904. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46905. */
  46906. forceAlphaTest: boolean;
  46907. /**
  46908. * Defines the alpha limits in alpha test mode.
  46909. */
  46910. alphaCutOff: number;
  46911. /**
  46912. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46913. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46914. */
  46915. useSpecularOverAlpha: boolean;
  46916. /**
  46917. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46918. */
  46919. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46920. /**
  46921. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46922. */
  46923. useRoughnessFromMetallicTextureAlpha: boolean;
  46924. /**
  46925. * Specifies if the metallic texture contains the roughness information in its green channel.
  46926. */
  46927. useRoughnessFromMetallicTextureGreen: boolean;
  46928. /**
  46929. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46930. */
  46931. useMetallnessFromMetallicTextureBlue: boolean;
  46932. /**
  46933. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46934. */
  46935. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46936. /**
  46937. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46938. */
  46939. useAmbientInGrayScale: boolean;
  46940. /**
  46941. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46942. * The material will try to infer what glossiness each pixel should be.
  46943. */
  46944. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46945. /**
  46946. * BJS is using an harcoded light falloff based on a manually sets up range.
  46947. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46948. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46949. */
  46950. /**
  46951. * BJS is using an harcoded light falloff based on a manually sets up range.
  46952. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46953. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46954. */
  46955. usePhysicalLightFalloff: boolean;
  46956. /**
  46957. * In order to support the falloff compatibility with gltf, a special mode has been added
  46958. * to reproduce the gltf light falloff.
  46959. */
  46960. /**
  46961. * In order to support the falloff compatibility with gltf, a special mode has been added
  46962. * to reproduce the gltf light falloff.
  46963. */
  46964. useGLTFLightFalloff: boolean;
  46965. /**
  46966. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46967. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46968. */
  46969. useRadianceOverAlpha: boolean;
  46970. /**
  46971. * Allows using an object space normal map (instead of tangent space).
  46972. */
  46973. useObjectSpaceNormalMap: boolean;
  46974. /**
  46975. * Allows using the bump map in parallax mode.
  46976. */
  46977. useParallax: boolean;
  46978. /**
  46979. * Allows using the bump map in parallax occlusion mode.
  46980. */
  46981. useParallaxOcclusion: boolean;
  46982. /**
  46983. * Controls the scale bias of the parallax mode.
  46984. */
  46985. parallaxScaleBias: number;
  46986. /**
  46987. * If sets to true, disables all the lights affecting the material.
  46988. */
  46989. disableLighting: boolean;
  46990. /**
  46991. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46992. */
  46993. forceIrradianceInFragment: boolean;
  46994. /**
  46995. * Number of Simultaneous lights allowed on the material.
  46996. */
  46997. maxSimultaneousLights: number;
  46998. /**
  46999. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47000. */
  47001. invertNormalMapX: boolean;
  47002. /**
  47003. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47004. */
  47005. invertNormalMapY: boolean;
  47006. /**
  47007. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47008. */
  47009. twoSidedLighting: boolean;
  47010. /**
  47011. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47012. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47013. */
  47014. useAlphaFresnel: boolean;
  47015. /**
  47016. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47017. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47018. */
  47019. useLinearAlphaFresnel: boolean;
  47020. /**
  47021. * Let user defines the brdf lookup texture used for IBL.
  47022. * A default 8bit version is embedded but you could point at :
  47023. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47024. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47025. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47026. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47027. */
  47028. environmentBRDFTexture: Nullable<BaseTexture>;
  47029. /**
  47030. * Force normal to face away from face.
  47031. */
  47032. forceNormalForward: boolean;
  47033. /**
  47034. * Enables specular anti aliasing in the PBR shader.
  47035. * It will both interacts on the Geometry for analytical and IBL lighting.
  47036. * It also prefilter the roughness map based on the bump values.
  47037. */
  47038. enableSpecularAntiAliasing: boolean;
  47039. /**
  47040. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47041. * makes the reflect vector face the model (under horizon).
  47042. */
  47043. useHorizonOcclusion: boolean;
  47044. /**
  47045. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47046. * too much the area relying on ambient texture to define their ambient occlusion.
  47047. */
  47048. useRadianceOcclusion: boolean;
  47049. /**
  47050. * If set to true, no lighting calculations will be applied.
  47051. */
  47052. unlit: boolean;
  47053. /**
  47054. * Gets the image processing configuration used either in this material.
  47055. */
  47056. /**
  47057. * Sets the Default image processing configuration used either in the this material.
  47058. *
  47059. * If sets to null, the scene one is in use.
  47060. */
  47061. imageProcessingConfiguration: ImageProcessingConfiguration;
  47062. /**
  47063. * Gets wether the color curves effect is enabled.
  47064. */
  47065. /**
  47066. * Sets wether the color curves effect is enabled.
  47067. */
  47068. cameraColorCurvesEnabled: boolean;
  47069. /**
  47070. * Gets wether the color grading effect is enabled.
  47071. */
  47072. /**
  47073. * Gets wether the color grading effect is enabled.
  47074. */
  47075. cameraColorGradingEnabled: boolean;
  47076. /**
  47077. * Gets wether tonemapping is enabled or not.
  47078. */
  47079. /**
  47080. * Sets wether tonemapping is enabled or not
  47081. */
  47082. cameraToneMappingEnabled: boolean;
  47083. /**
  47084. * The camera exposure used on this material.
  47085. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47086. * This corresponds to a photographic exposure.
  47087. */
  47088. /**
  47089. * The camera exposure used on this material.
  47090. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47091. * This corresponds to a photographic exposure.
  47092. */
  47093. cameraExposure: number;
  47094. /**
  47095. * Gets The camera contrast used on this material.
  47096. */
  47097. /**
  47098. * Sets The camera contrast used on this material.
  47099. */
  47100. cameraContrast: number;
  47101. /**
  47102. * Gets the Color Grading 2D Lookup Texture.
  47103. */
  47104. /**
  47105. * Sets the Color Grading 2D Lookup Texture.
  47106. */
  47107. cameraColorGradingTexture: Nullable<BaseTexture>;
  47108. /**
  47109. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47110. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47111. * 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;
  47112. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47113. */
  47114. /**
  47115. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47116. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47117. * 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;
  47118. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47119. */
  47120. cameraColorCurves: Nullable<ColorCurves>;
  47121. /**
  47122. * Instantiates a new PBRMaterial instance.
  47123. *
  47124. * @param name The material name
  47125. * @param scene The scene the material will be use in.
  47126. */
  47127. constructor(name: string, scene: Scene);
  47128. /**
  47129. * Returns the name of this material class.
  47130. */
  47131. getClassName(): string;
  47132. /**
  47133. * Makes a duplicate of the current material.
  47134. * @param name - name to use for the new material.
  47135. */
  47136. clone(name: string): PBRMaterial;
  47137. /**
  47138. * Serializes this PBR Material.
  47139. * @returns - An object with the serialized material.
  47140. */
  47141. serialize(): any;
  47142. /**
  47143. * Parses a PBR Material from a serialized object.
  47144. * @param source - Serialized object.
  47145. * @param scene - BJS scene instance.
  47146. * @param rootUrl - url for the scene object
  47147. * @returns - PBRMaterial
  47148. */
  47149. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47150. }
  47151. }
  47152. declare module BABYLON {
  47153. /**
  47154. * Direct draw surface info
  47155. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47156. */
  47157. export interface DDSInfo {
  47158. /**
  47159. * Width of the texture
  47160. */
  47161. width: number;
  47162. /**
  47163. * Width of the texture
  47164. */
  47165. height: number;
  47166. /**
  47167. * Number of Mipmaps for the texture
  47168. * @see https://en.wikipedia.org/wiki/Mipmap
  47169. */
  47170. mipmapCount: number;
  47171. /**
  47172. * If the textures format is a known fourCC format
  47173. * @see https://www.fourcc.org/
  47174. */
  47175. isFourCC: boolean;
  47176. /**
  47177. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47178. */
  47179. isRGB: boolean;
  47180. /**
  47181. * If the texture is a lumincance format
  47182. */
  47183. isLuminance: boolean;
  47184. /**
  47185. * If this is a cube texture
  47186. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47187. */
  47188. isCube: boolean;
  47189. /**
  47190. * If the texture is a compressed format eg. FOURCC_DXT1
  47191. */
  47192. isCompressed: boolean;
  47193. /**
  47194. * The dxgiFormat of the texture
  47195. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47196. */
  47197. dxgiFormat: number;
  47198. /**
  47199. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47200. */
  47201. textureType: number;
  47202. /**
  47203. * Sphericle polynomial created for the dds texture
  47204. */
  47205. sphericalPolynomial?: SphericalPolynomial;
  47206. }
  47207. /**
  47208. * Class used to provide DDS decompression tools
  47209. */
  47210. export class DDSTools {
  47211. /**
  47212. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47213. */
  47214. static StoreLODInAlphaChannel: boolean;
  47215. /**
  47216. * Gets DDS information from an array buffer
  47217. * @param arrayBuffer defines the array buffer to read data from
  47218. * @returns the DDS information
  47219. */
  47220. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47221. private static _FloatView;
  47222. private static _Int32View;
  47223. private static _ToHalfFloat;
  47224. private static _FromHalfFloat;
  47225. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47226. private static _GetHalfFloatRGBAArrayBuffer;
  47227. private static _GetFloatRGBAArrayBuffer;
  47228. private static _GetFloatAsUIntRGBAArrayBuffer;
  47229. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47230. private static _GetRGBAArrayBuffer;
  47231. private static _ExtractLongWordOrder;
  47232. private static _GetRGBArrayBuffer;
  47233. private static _GetLuminanceArrayBuffer;
  47234. /**
  47235. * Uploads DDS Levels to a Babylon Texture
  47236. * @hidden
  47237. */
  47238. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47239. }
  47240. interface Engine {
  47241. /**
  47242. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47243. * @param rootUrl defines the url where the file to load is located
  47244. * @param scene defines the current scene
  47245. * @param lodScale defines scale to apply to the mip map selection
  47246. * @param lodOffset defines offset to apply to the mip map selection
  47247. * @param onLoad defines an optional callback raised when the texture is loaded
  47248. * @param onError defines an optional callback raised if there is an issue to load the texture
  47249. * @param format defines the format of the data
  47250. * @param forcedExtension defines the extension to use to pick the right loader
  47251. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47252. * @returns the cube texture as an InternalTexture
  47253. */
  47254. 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;
  47255. }
  47256. }
  47257. declare module BABYLON {
  47258. /**
  47259. * Implementation of the DDS Texture Loader.
  47260. * @hidden
  47261. */
  47262. export class _DDSTextureLoader implements IInternalTextureLoader {
  47263. /**
  47264. * Defines wether the loader supports cascade loading the different faces.
  47265. */
  47266. readonly supportCascades: boolean;
  47267. /**
  47268. * This returns if the loader support the current file information.
  47269. * @param extension defines the file extension of the file being loaded
  47270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47271. * @param fallback defines the fallback internal texture if any
  47272. * @param isBase64 defines whether the texture is encoded as a base64
  47273. * @param isBuffer defines whether the texture data are stored as a buffer
  47274. * @returns true if the loader can load the specified file
  47275. */
  47276. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47277. /**
  47278. * Transform the url before loading if required.
  47279. * @param rootUrl the url of the texture
  47280. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47281. * @returns the transformed texture
  47282. */
  47283. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47284. /**
  47285. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47286. * @param rootUrl the url of the texture
  47287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47288. * @returns the fallback texture
  47289. */
  47290. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47291. /**
  47292. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47293. * @param data contains the texture data
  47294. * @param texture defines the BabylonJS internal texture
  47295. * @param createPolynomials will be true if polynomials have been requested
  47296. * @param onLoad defines the callback to trigger once the texture is ready
  47297. * @param onError defines the callback to trigger in case of error
  47298. */
  47299. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47300. /**
  47301. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47302. * @param data contains the texture data
  47303. * @param texture defines the BabylonJS internal texture
  47304. * @param callback defines the method to call once ready to upload
  47305. */
  47306. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47307. }
  47308. }
  47309. declare module BABYLON {
  47310. /**
  47311. * Implementation of the ENV Texture Loader.
  47312. * @hidden
  47313. */
  47314. export class _ENVTextureLoader implements IInternalTextureLoader {
  47315. /**
  47316. * Defines wether the loader supports cascade loading the different faces.
  47317. */
  47318. readonly supportCascades: boolean;
  47319. /**
  47320. * This returns if the loader support the current file information.
  47321. * @param extension defines the file extension of the file being loaded
  47322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47323. * @param fallback defines the fallback internal texture if any
  47324. * @param isBase64 defines whether the texture is encoded as a base64
  47325. * @param isBuffer defines whether the texture data are stored as a buffer
  47326. * @returns true if the loader can load the specified file
  47327. */
  47328. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47329. /**
  47330. * Transform the url before loading if required.
  47331. * @param rootUrl the url of the texture
  47332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47333. * @returns the transformed texture
  47334. */
  47335. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47336. /**
  47337. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47338. * @param rootUrl the url of the texture
  47339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47340. * @returns the fallback texture
  47341. */
  47342. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47343. /**
  47344. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47345. * @param data contains the texture data
  47346. * @param texture defines the BabylonJS internal texture
  47347. * @param createPolynomials will be true if polynomials have been requested
  47348. * @param onLoad defines the callback to trigger once the texture is ready
  47349. * @param onError defines the callback to trigger in case of error
  47350. */
  47351. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47352. /**
  47353. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47354. * @param data contains the texture data
  47355. * @param texture defines the BabylonJS internal texture
  47356. * @param callback defines the method to call once ready to upload
  47357. */
  47358. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47359. }
  47360. }
  47361. declare module BABYLON {
  47362. /**
  47363. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47364. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47365. */
  47366. export class KhronosTextureContainer {
  47367. /** contents of the KTX container file */
  47368. arrayBuffer: any;
  47369. private static HEADER_LEN;
  47370. private static COMPRESSED_2D;
  47371. private static COMPRESSED_3D;
  47372. private static TEX_2D;
  47373. private static TEX_3D;
  47374. /**
  47375. * Gets the openGL type
  47376. */
  47377. glType: number;
  47378. /**
  47379. * Gets the openGL type size
  47380. */
  47381. glTypeSize: number;
  47382. /**
  47383. * Gets the openGL format
  47384. */
  47385. glFormat: number;
  47386. /**
  47387. * Gets the openGL internal format
  47388. */
  47389. glInternalFormat: number;
  47390. /**
  47391. * Gets the base internal format
  47392. */
  47393. glBaseInternalFormat: number;
  47394. /**
  47395. * Gets image width in pixel
  47396. */
  47397. pixelWidth: number;
  47398. /**
  47399. * Gets image height in pixel
  47400. */
  47401. pixelHeight: number;
  47402. /**
  47403. * Gets image depth in pixels
  47404. */
  47405. pixelDepth: number;
  47406. /**
  47407. * Gets the number of array elements
  47408. */
  47409. numberOfArrayElements: number;
  47410. /**
  47411. * Gets the number of faces
  47412. */
  47413. numberOfFaces: number;
  47414. /**
  47415. * Gets the number of mipmap levels
  47416. */
  47417. numberOfMipmapLevels: number;
  47418. /**
  47419. * Gets the bytes of key value data
  47420. */
  47421. bytesOfKeyValueData: number;
  47422. /**
  47423. * Gets the load type
  47424. */
  47425. loadType: number;
  47426. /**
  47427. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47428. */
  47429. isInvalid: boolean;
  47430. /**
  47431. * Creates a new KhronosTextureContainer
  47432. * @param arrayBuffer contents of the KTX container file
  47433. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47434. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47435. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47436. */
  47437. constructor(
  47438. /** contents of the KTX container file */
  47439. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47440. /**
  47441. * Uploads KTX content to a Babylon Texture.
  47442. * It is assumed that the texture has already been created & is currently bound
  47443. * @hidden
  47444. */
  47445. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47446. private _upload2DCompressedLevels;
  47447. }
  47448. }
  47449. declare module BABYLON {
  47450. /**
  47451. * Implementation of the KTX Texture Loader.
  47452. * @hidden
  47453. */
  47454. export class _KTXTextureLoader implements IInternalTextureLoader {
  47455. /**
  47456. * Defines wether the loader supports cascade loading the different faces.
  47457. */
  47458. readonly supportCascades: boolean;
  47459. /**
  47460. * This returns if the loader support the current file information.
  47461. * @param extension defines the file extension of the file being loaded
  47462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47463. * @param fallback defines the fallback internal texture if any
  47464. * @param isBase64 defines whether the texture is encoded as a base64
  47465. * @param isBuffer defines whether the texture data are stored as a buffer
  47466. * @returns true if the loader can load the specified file
  47467. */
  47468. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47469. /**
  47470. * Transform the url before loading if required.
  47471. * @param rootUrl the url of the texture
  47472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47473. * @returns the transformed texture
  47474. */
  47475. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47476. /**
  47477. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47478. * @param rootUrl the url of the texture
  47479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47480. * @returns the fallback texture
  47481. */
  47482. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47483. /**
  47484. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47485. * @param data contains the texture data
  47486. * @param texture defines the BabylonJS internal texture
  47487. * @param createPolynomials will be true if polynomials have been requested
  47488. * @param onLoad defines the callback to trigger once the texture is ready
  47489. * @param onError defines the callback to trigger in case of error
  47490. */
  47491. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47492. /**
  47493. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47494. * @param data contains the texture data
  47495. * @param texture defines the BabylonJS internal texture
  47496. * @param callback defines the method to call once ready to upload
  47497. */
  47498. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47499. }
  47500. }
  47501. declare module BABYLON {
  47502. /**
  47503. * Options for the default xr helper
  47504. */
  47505. export class WebXRDefaultExperienceOptions {
  47506. /**
  47507. * Floor meshes that should be used for teleporting
  47508. */
  47509. floorMeshes: Array<AbstractMesh>;
  47510. }
  47511. /**
  47512. * Default experience which provides a similar setup to the previous webVRExperience
  47513. */
  47514. export class WebXRDefaultExperience {
  47515. /**
  47516. * Base experience
  47517. */
  47518. baseExperience: WebXRExperienceHelper;
  47519. /**
  47520. * Input experience extension
  47521. */
  47522. input: WebXRInput;
  47523. /**
  47524. * Loads the controller models
  47525. */
  47526. controllerModelLoader: WebXRControllerModelLoader;
  47527. /**
  47528. * Enables laser pointer and selection
  47529. */
  47530. pointerSelection: WebXRControllerPointerSelection;
  47531. /**
  47532. * Enables teleportation
  47533. */
  47534. teleportation: WebXRControllerTeleportation;
  47535. /**
  47536. * Enables ui for enetering/exiting xr
  47537. */
  47538. enterExitUI: WebXREnterExitUI;
  47539. /**
  47540. * Default output canvas xr should render to
  47541. */
  47542. outputCanvas: WebXRManagedOutputCanvas;
  47543. /**
  47544. * Creates the default xr experience
  47545. * @param scene scene
  47546. * @param options options for basic configuration
  47547. * @returns resulting WebXRDefaultExperience
  47548. */
  47549. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47550. private constructor();
  47551. /**
  47552. * DIsposes of the experience helper
  47553. */
  47554. dispose(): void;
  47555. }
  47556. }
  47557. declare module BABYLON {
  47558. /** @hidden */
  47559. export var _forceSceneHelpersToBundle: boolean;
  47560. interface Scene {
  47561. /**
  47562. * Creates a default light for the scene.
  47563. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47564. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47565. */
  47566. createDefaultLight(replace?: boolean): void;
  47567. /**
  47568. * Creates a default camera for the scene.
  47569. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47570. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47571. * @param replace has default false, when true replaces the active camera in the scene
  47572. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47573. */
  47574. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47575. /**
  47576. * Creates a default camera and a default light.
  47577. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47578. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47579. * @param replace has the default false, when true replaces the active camera/light in the scene
  47580. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47581. */
  47582. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47583. /**
  47584. * Creates a new sky box
  47585. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47586. * @param environmentTexture defines the texture to use as environment texture
  47587. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47588. * @param scale defines the overall scale of the skybox
  47589. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47590. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47591. * @returns a new mesh holding the sky box
  47592. */
  47593. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47594. /**
  47595. * Creates a new environment
  47596. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47597. * @param options defines the options you can use to configure the environment
  47598. * @returns the new EnvironmentHelper
  47599. */
  47600. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47601. /**
  47602. * Creates a new VREXperienceHelper
  47603. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47604. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47605. * @returns a new VREXperienceHelper
  47606. */
  47607. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47608. /**
  47609. * Creates a new WebXRDefaultExperience
  47610. * @see http://doc.babylonjs.com/how_to/webxr
  47611. * @param options experience options
  47612. * @returns a promise for a new WebXRDefaultExperience
  47613. */
  47614. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47615. }
  47616. }
  47617. declare module BABYLON {
  47618. /**
  47619. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47620. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47621. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47622. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47623. */
  47624. export class VideoDome extends TransformNode {
  47625. /**
  47626. * Define the video source as a Monoscopic panoramic 360 video.
  47627. */
  47628. static readonly MODE_MONOSCOPIC: number;
  47629. /**
  47630. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47631. */
  47632. static readonly MODE_TOPBOTTOM: number;
  47633. /**
  47634. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47635. */
  47636. static readonly MODE_SIDEBYSIDE: number;
  47637. private _halfDome;
  47638. private _useDirectMapping;
  47639. /**
  47640. * The video texture being displayed on the sphere
  47641. */
  47642. protected _videoTexture: VideoTexture;
  47643. /**
  47644. * Gets the video texture being displayed on the sphere
  47645. */
  47646. readonly videoTexture: VideoTexture;
  47647. /**
  47648. * The skybox material
  47649. */
  47650. protected _material: BackgroundMaterial;
  47651. /**
  47652. * The surface used for the skybox
  47653. */
  47654. protected _mesh: Mesh;
  47655. /**
  47656. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  47657. */
  47658. private _halfDomeMask;
  47659. /**
  47660. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47661. * Also see the options.resolution property.
  47662. */
  47663. fovMultiplier: number;
  47664. private _videoMode;
  47665. /**
  47666. * Gets or set the current video mode for the video. It can be:
  47667. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47668. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47669. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47670. */
  47671. videoMode: number;
  47672. /**
  47673. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  47674. *
  47675. */
  47676. /**
  47677. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  47678. */
  47679. halfDome: boolean;
  47680. /**
  47681. * Oberserver used in Stereoscopic VR Mode.
  47682. */
  47683. private _onBeforeCameraRenderObserver;
  47684. /**
  47685. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47686. * @param name Element's name, child elements will append suffixes for their own names.
  47687. * @param urlsOrVideo defines the url(s) or the video element to use
  47688. * @param options An object containing optional or exposed sub element properties
  47689. */
  47690. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47691. resolution?: number;
  47692. clickToPlay?: boolean;
  47693. autoPlay?: boolean;
  47694. loop?: boolean;
  47695. size?: number;
  47696. poster?: string;
  47697. faceForward?: boolean;
  47698. useDirectMapping?: boolean;
  47699. halfDomeMode?: boolean;
  47700. }, scene: Scene);
  47701. private _changeVideoMode;
  47702. /**
  47703. * Releases resources associated with this node.
  47704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47706. */
  47707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47708. }
  47709. }
  47710. declare module BABYLON {
  47711. /**
  47712. * This class can be used to get instrumentation data from a Babylon engine
  47713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47714. */
  47715. export class EngineInstrumentation implements IDisposable {
  47716. /**
  47717. * Define the instrumented engine.
  47718. */
  47719. engine: Engine;
  47720. private _captureGPUFrameTime;
  47721. private _gpuFrameTimeToken;
  47722. private _gpuFrameTime;
  47723. private _captureShaderCompilationTime;
  47724. private _shaderCompilationTime;
  47725. private _onBeginFrameObserver;
  47726. private _onEndFrameObserver;
  47727. private _onBeforeShaderCompilationObserver;
  47728. private _onAfterShaderCompilationObserver;
  47729. /**
  47730. * Gets the perf counter used for GPU frame time
  47731. */
  47732. readonly gpuFrameTimeCounter: PerfCounter;
  47733. /**
  47734. * Gets the GPU frame time capture status
  47735. */
  47736. /**
  47737. * Enable or disable the GPU frame time capture
  47738. */
  47739. captureGPUFrameTime: boolean;
  47740. /**
  47741. * Gets the perf counter used for shader compilation time
  47742. */
  47743. readonly shaderCompilationTimeCounter: PerfCounter;
  47744. /**
  47745. * Gets the shader compilation time capture status
  47746. */
  47747. /**
  47748. * Enable or disable the shader compilation time capture
  47749. */
  47750. captureShaderCompilationTime: boolean;
  47751. /**
  47752. * Instantiates a new engine instrumentation.
  47753. * This class can be used to get instrumentation data from a Babylon engine
  47754. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47755. * @param engine Defines the engine to instrument
  47756. */
  47757. constructor(
  47758. /**
  47759. * Define the instrumented engine.
  47760. */
  47761. engine: Engine);
  47762. /**
  47763. * Dispose and release associated resources.
  47764. */
  47765. dispose(): void;
  47766. }
  47767. }
  47768. declare module BABYLON {
  47769. /**
  47770. * This class can be used to get instrumentation data from a Babylon engine
  47771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47772. */
  47773. export class SceneInstrumentation implements IDisposable {
  47774. /**
  47775. * Defines the scene to instrument
  47776. */
  47777. scene: Scene;
  47778. private _captureActiveMeshesEvaluationTime;
  47779. private _activeMeshesEvaluationTime;
  47780. private _captureRenderTargetsRenderTime;
  47781. private _renderTargetsRenderTime;
  47782. private _captureFrameTime;
  47783. private _frameTime;
  47784. private _captureRenderTime;
  47785. private _renderTime;
  47786. private _captureInterFrameTime;
  47787. private _interFrameTime;
  47788. private _captureParticlesRenderTime;
  47789. private _particlesRenderTime;
  47790. private _captureSpritesRenderTime;
  47791. private _spritesRenderTime;
  47792. private _capturePhysicsTime;
  47793. private _physicsTime;
  47794. private _captureAnimationsTime;
  47795. private _animationsTime;
  47796. private _captureCameraRenderTime;
  47797. private _cameraRenderTime;
  47798. private _onBeforeActiveMeshesEvaluationObserver;
  47799. private _onAfterActiveMeshesEvaluationObserver;
  47800. private _onBeforeRenderTargetsRenderObserver;
  47801. private _onAfterRenderTargetsRenderObserver;
  47802. private _onAfterRenderObserver;
  47803. private _onBeforeDrawPhaseObserver;
  47804. private _onAfterDrawPhaseObserver;
  47805. private _onBeforeAnimationsObserver;
  47806. private _onBeforeParticlesRenderingObserver;
  47807. private _onAfterParticlesRenderingObserver;
  47808. private _onBeforeSpritesRenderingObserver;
  47809. private _onAfterSpritesRenderingObserver;
  47810. private _onBeforePhysicsObserver;
  47811. private _onAfterPhysicsObserver;
  47812. private _onAfterAnimationsObserver;
  47813. private _onBeforeCameraRenderObserver;
  47814. private _onAfterCameraRenderObserver;
  47815. /**
  47816. * Gets the perf counter used for active meshes evaluation time
  47817. */
  47818. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47819. /**
  47820. * Gets the active meshes evaluation time capture status
  47821. */
  47822. /**
  47823. * Enable or disable the active meshes evaluation time capture
  47824. */
  47825. captureActiveMeshesEvaluationTime: boolean;
  47826. /**
  47827. * Gets the perf counter used for render targets render time
  47828. */
  47829. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47830. /**
  47831. * Gets the render targets render time capture status
  47832. */
  47833. /**
  47834. * Enable or disable the render targets render time capture
  47835. */
  47836. captureRenderTargetsRenderTime: boolean;
  47837. /**
  47838. * Gets the perf counter used for particles render time
  47839. */
  47840. readonly particlesRenderTimeCounter: PerfCounter;
  47841. /**
  47842. * Gets the particles render time capture status
  47843. */
  47844. /**
  47845. * Enable or disable the particles render time capture
  47846. */
  47847. captureParticlesRenderTime: boolean;
  47848. /**
  47849. * Gets the perf counter used for sprites render time
  47850. */
  47851. readonly spritesRenderTimeCounter: PerfCounter;
  47852. /**
  47853. * Gets the sprites render time capture status
  47854. */
  47855. /**
  47856. * Enable or disable the sprites render time capture
  47857. */
  47858. captureSpritesRenderTime: boolean;
  47859. /**
  47860. * Gets the perf counter used for physics time
  47861. */
  47862. readonly physicsTimeCounter: PerfCounter;
  47863. /**
  47864. * Gets the physics time capture status
  47865. */
  47866. /**
  47867. * Enable or disable the physics time capture
  47868. */
  47869. capturePhysicsTime: boolean;
  47870. /**
  47871. * Gets the perf counter used for animations time
  47872. */
  47873. readonly animationsTimeCounter: PerfCounter;
  47874. /**
  47875. * Gets the animations time capture status
  47876. */
  47877. /**
  47878. * Enable or disable the animations time capture
  47879. */
  47880. captureAnimationsTime: boolean;
  47881. /**
  47882. * Gets the perf counter used for frame time capture
  47883. */
  47884. readonly frameTimeCounter: PerfCounter;
  47885. /**
  47886. * Gets the frame time capture status
  47887. */
  47888. /**
  47889. * Enable or disable the frame time capture
  47890. */
  47891. captureFrameTime: boolean;
  47892. /**
  47893. * Gets the perf counter used for inter-frames time capture
  47894. */
  47895. readonly interFrameTimeCounter: PerfCounter;
  47896. /**
  47897. * Gets the inter-frames time capture status
  47898. */
  47899. /**
  47900. * Enable or disable the inter-frames time capture
  47901. */
  47902. captureInterFrameTime: boolean;
  47903. /**
  47904. * Gets the perf counter used for render time capture
  47905. */
  47906. readonly renderTimeCounter: PerfCounter;
  47907. /**
  47908. * Gets the render time capture status
  47909. */
  47910. /**
  47911. * Enable or disable the render time capture
  47912. */
  47913. captureRenderTime: boolean;
  47914. /**
  47915. * Gets the perf counter used for camera render time capture
  47916. */
  47917. readonly cameraRenderTimeCounter: PerfCounter;
  47918. /**
  47919. * Gets the camera render time capture status
  47920. */
  47921. /**
  47922. * Enable or disable the camera render time capture
  47923. */
  47924. captureCameraRenderTime: boolean;
  47925. /**
  47926. * Gets the perf counter used for draw calls
  47927. */
  47928. readonly drawCallsCounter: PerfCounter;
  47929. /**
  47930. * Instantiates a new scene instrumentation.
  47931. * This class can be used to get instrumentation data from a Babylon engine
  47932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47933. * @param scene Defines the scene to instrument
  47934. */
  47935. constructor(
  47936. /**
  47937. * Defines the scene to instrument
  47938. */
  47939. scene: Scene);
  47940. /**
  47941. * Dispose and release associated resources.
  47942. */
  47943. dispose(): void;
  47944. }
  47945. }
  47946. declare module BABYLON {
  47947. /** @hidden */
  47948. export var glowMapGenerationPixelShader: {
  47949. name: string;
  47950. shader: string;
  47951. };
  47952. }
  47953. declare module BABYLON {
  47954. /** @hidden */
  47955. export var glowMapGenerationVertexShader: {
  47956. name: string;
  47957. shader: string;
  47958. };
  47959. }
  47960. declare module BABYLON {
  47961. /**
  47962. * Effect layer options. This helps customizing the behaviour
  47963. * of the effect layer.
  47964. */
  47965. export interface IEffectLayerOptions {
  47966. /**
  47967. * Multiplication factor apply to the canvas size to compute the render target size
  47968. * used to generated the objects (the smaller the faster).
  47969. */
  47970. mainTextureRatio: number;
  47971. /**
  47972. * Enforces a fixed size texture to ensure effect stability across devices.
  47973. */
  47974. mainTextureFixedSize?: number;
  47975. /**
  47976. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47977. */
  47978. alphaBlendingMode: number;
  47979. /**
  47980. * The camera attached to the layer.
  47981. */
  47982. camera: Nullable<Camera>;
  47983. /**
  47984. * The rendering group to draw the layer in.
  47985. */
  47986. renderingGroupId: number;
  47987. }
  47988. /**
  47989. * The effect layer Helps adding post process effect blended with the main pass.
  47990. *
  47991. * This can be for instance use to generate glow or higlight effects on the scene.
  47992. *
  47993. * The effect layer class can not be used directly and is intented to inherited from to be
  47994. * customized per effects.
  47995. */
  47996. export abstract class EffectLayer {
  47997. private _vertexBuffers;
  47998. private _indexBuffer;
  47999. private _cachedDefines;
  48000. private _effectLayerMapGenerationEffect;
  48001. private _effectLayerOptions;
  48002. private _mergeEffect;
  48003. protected _scene: Scene;
  48004. protected _engine: Engine;
  48005. protected _maxSize: number;
  48006. protected _mainTextureDesiredSize: ISize;
  48007. protected _mainTexture: RenderTargetTexture;
  48008. protected _shouldRender: boolean;
  48009. protected _postProcesses: PostProcess[];
  48010. protected _textures: BaseTexture[];
  48011. protected _emissiveTextureAndColor: {
  48012. texture: Nullable<BaseTexture>;
  48013. color: Color4;
  48014. };
  48015. /**
  48016. * The name of the layer
  48017. */
  48018. name: string;
  48019. /**
  48020. * The clear color of the texture used to generate the glow map.
  48021. */
  48022. neutralColor: Color4;
  48023. /**
  48024. * Specifies wether the highlight layer is enabled or not.
  48025. */
  48026. isEnabled: boolean;
  48027. /**
  48028. * Gets the camera attached to the layer.
  48029. */
  48030. readonly camera: Nullable<Camera>;
  48031. /**
  48032. * Gets the rendering group id the layer should render in.
  48033. */
  48034. renderingGroupId: number;
  48035. /**
  48036. * An event triggered when the effect layer has been disposed.
  48037. */
  48038. onDisposeObservable: Observable<EffectLayer>;
  48039. /**
  48040. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48041. */
  48042. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48043. /**
  48044. * An event triggered when the generated texture is being merged in the scene.
  48045. */
  48046. onBeforeComposeObservable: Observable<EffectLayer>;
  48047. /**
  48048. * An event triggered when the generated texture has been merged in the scene.
  48049. */
  48050. onAfterComposeObservable: Observable<EffectLayer>;
  48051. /**
  48052. * An event triggered when the efffect layer changes its size.
  48053. */
  48054. onSizeChangedObservable: Observable<EffectLayer>;
  48055. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48056. /**
  48057. * Instantiates a new effect Layer and references it in the scene.
  48058. * @param name The name of the layer
  48059. * @param scene The scene to use the layer in
  48060. */
  48061. constructor(
  48062. /** The Friendly of the effect in the scene */
  48063. name: string, scene: Scene);
  48064. /**
  48065. * Get the effect name of the layer.
  48066. * @return The effect name
  48067. */
  48068. abstract getEffectName(): string;
  48069. /**
  48070. * Checks for the readiness of the element composing the layer.
  48071. * @param subMesh the mesh to check for
  48072. * @param useInstances specify wether or not to use instances to render the mesh
  48073. * @return true if ready otherwise, false
  48074. */
  48075. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48076. /**
  48077. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48078. * @returns true if the effect requires stencil during the main canvas render pass.
  48079. */
  48080. abstract needStencil(): boolean;
  48081. /**
  48082. * Create the merge effect. This is the shader use to blit the information back
  48083. * to the main canvas at the end of the scene rendering.
  48084. * @returns The effect containing the shader used to merge the effect on the main canvas
  48085. */
  48086. protected abstract _createMergeEffect(): Effect;
  48087. /**
  48088. * Creates the render target textures and post processes used in the effect layer.
  48089. */
  48090. protected abstract _createTextureAndPostProcesses(): void;
  48091. /**
  48092. * Implementation specific of rendering the generating effect on the main canvas.
  48093. * @param effect The effect used to render through
  48094. */
  48095. protected abstract _internalRender(effect: Effect): void;
  48096. /**
  48097. * Sets the required values for both the emissive texture and and the main color.
  48098. */
  48099. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48100. /**
  48101. * Free any resources and references associated to a mesh.
  48102. * Internal use
  48103. * @param mesh The mesh to free.
  48104. */
  48105. abstract _disposeMesh(mesh: Mesh): void;
  48106. /**
  48107. * Serializes this layer (Glow or Highlight for example)
  48108. * @returns a serialized layer object
  48109. */
  48110. abstract serialize?(): any;
  48111. /**
  48112. * Initializes the effect layer with the required options.
  48113. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48114. */
  48115. protected _init(options: Partial<IEffectLayerOptions>): void;
  48116. /**
  48117. * Generates the index buffer of the full screen quad blending to the main canvas.
  48118. */
  48119. private _generateIndexBuffer;
  48120. /**
  48121. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48122. */
  48123. private _generateVertexBuffer;
  48124. /**
  48125. * Sets the main texture desired size which is the closest power of two
  48126. * of the engine canvas size.
  48127. */
  48128. private _setMainTextureSize;
  48129. /**
  48130. * Creates the main texture for the effect layer.
  48131. */
  48132. protected _createMainTexture(): void;
  48133. /**
  48134. * Adds specific effects defines.
  48135. * @param defines The defines to add specifics to.
  48136. */
  48137. protected _addCustomEffectDefines(defines: string[]): void;
  48138. /**
  48139. * Checks for the readiness of the element composing the layer.
  48140. * @param subMesh the mesh to check for
  48141. * @param useInstances specify wether or not to use instances to render the mesh
  48142. * @param emissiveTexture the associated emissive texture used to generate the glow
  48143. * @return true if ready otherwise, false
  48144. */
  48145. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48146. /**
  48147. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48148. */
  48149. render(): void;
  48150. /**
  48151. * Determine if a given mesh will be used in the current effect.
  48152. * @param mesh mesh to test
  48153. * @returns true if the mesh will be used
  48154. */
  48155. hasMesh(mesh: AbstractMesh): boolean;
  48156. /**
  48157. * Returns true if the layer contains information to display, otherwise false.
  48158. * @returns true if the glow layer should be rendered
  48159. */
  48160. shouldRender(): boolean;
  48161. /**
  48162. * Returns true if the mesh should render, otherwise false.
  48163. * @param mesh The mesh to render
  48164. * @returns true if it should render otherwise false
  48165. */
  48166. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48167. /**
  48168. * Returns true if the mesh can be rendered, otherwise false.
  48169. * @param mesh The mesh to render
  48170. * @param material The material used on the mesh
  48171. * @returns true if it can be rendered otherwise false
  48172. */
  48173. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48174. /**
  48175. * Returns true if the mesh should render, otherwise false.
  48176. * @param mesh The mesh to render
  48177. * @returns true if it should render otherwise false
  48178. */
  48179. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48180. /**
  48181. * Renders the submesh passed in parameter to the generation map.
  48182. */
  48183. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48184. /**
  48185. * Rebuild the required buffers.
  48186. * @hidden Internal use only.
  48187. */ private _rebuild(): void;
  48188. /**
  48189. * Dispose only the render target textures and post process.
  48190. */
  48191. private _disposeTextureAndPostProcesses;
  48192. /**
  48193. * Dispose the highlight layer and free resources.
  48194. */
  48195. dispose(): void;
  48196. /**
  48197. * Gets the class name of the effect layer
  48198. * @returns the string with the class name of the effect layer
  48199. */
  48200. getClassName(): string;
  48201. /**
  48202. * Creates an effect layer from parsed effect layer data
  48203. * @param parsedEffectLayer defines effect layer data
  48204. * @param scene defines the current scene
  48205. * @param rootUrl defines the root URL containing the effect layer information
  48206. * @returns a parsed effect Layer
  48207. */
  48208. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48209. }
  48210. }
  48211. declare module BABYLON {
  48212. interface AbstractScene {
  48213. /**
  48214. * The list of effect layers (highlights/glow) added to the scene
  48215. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48216. * @see http://doc.babylonjs.com/how_to/glow_layer
  48217. */
  48218. effectLayers: Array<EffectLayer>;
  48219. /**
  48220. * Removes the given effect layer from this scene.
  48221. * @param toRemove defines the effect layer to remove
  48222. * @returns the index of the removed effect layer
  48223. */
  48224. removeEffectLayer(toRemove: EffectLayer): number;
  48225. /**
  48226. * Adds the given effect layer to this scene
  48227. * @param newEffectLayer defines the effect layer to add
  48228. */
  48229. addEffectLayer(newEffectLayer: EffectLayer): void;
  48230. }
  48231. /**
  48232. * Defines the layer scene component responsible to manage any effect layers
  48233. * in a given scene.
  48234. */
  48235. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48236. /**
  48237. * The component name helpfull to identify the component in the list of scene components.
  48238. */
  48239. readonly name: string;
  48240. /**
  48241. * The scene the component belongs to.
  48242. */
  48243. scene: Scene;
  48244. private _engine;
  48245. private _renderEffects;
  48246. private _needStencil;
  48247. private _previousStencilState;
  48248. /**
  48249. * Creates a new instance of the component for the given scene
  48250. * @param scene Defines the scene to register the component in
  48251. */
  48252. constructor(scene: Scene);
  48253. /**
  48254. * Registers the component in a given scene
  48255. */
  48256. register(): void;
  48257. /**
  48258. * Rebuilds the elements related to this component in case of
  48259. * context lost for instance.
  48260. */
  48261. rebuild(): void;
  48262. /**
  48263. * Serializes the component data to the specified json object
  48264. * @param serializationObject The object to serialize to
  48265. */
  48266. serialize(serializationObject: any): void;
  48267. /**
  48268. * Adds all the elements from the container to the scene
  48269. * @param container the container holding the elements
  48270. */
  48271. addFromContainer(container: AbstractScene): void;
  48272. /**
  48273. * Removes all the elements in the container from the scene
  48274. * @param container contains the elements to remove
  48275. * @param dispose if the removed element should be disposed (default: false)
  48276. */
  48277. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48278. /**
  48279. * Disposes the component and the associated ressources.
  48280. */
  48281. dispose(): void;
  48282. private _isReadyForMesh;
  48283. private _renderMainTexture;
  48284. private _setStencil;
  48285. private _setStencilBack;
  48286. private _draw;
  48287. private _drawCamera;
  48288. private _drawRenderingGroup;
  48289. }
  48290. }
  48291. declare module BABYLON {
  48292. /** @hidden */
  48293. export var glowMapMergePixelShader: {
  48294. name: string;
  48295. shader: string;
  48296. };
  48297. }
  48298. declare module BABYLON {
  48299. /** @hidden */
  48300. export var glowMapMergeVertexShader: {
  48301. name: string;
  48302. shader: string;
  48303. };
  48304. }
  48305. declare module BABYLON {
  48306. interface AbstractScene {
  48307. /**
  48308. * Return a the first highlight layer of the scene with a given name.
  48309. * @param name The name of the highlight layer to look for.
  48310. * @return The highlight layer if found otherwise null.
  48311. */
  48312. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48313. }
  48314. /**
  48315. * Glow layer options. This helps customizing the behaviour
  48316. * of the glow layer.
  48317. */
  48318. export interface IGlowLayerOptions {
  48319. /**
  48320. * Multiplication factor apply to the canvas size to compute the render target size
  48321. * used to generated the glowing objects (the smaller the faster).
  48322. */
  48323. mainTextureRatio: number;
  48324. /**
  48325. * Enforces a fixed size texture to ensure resize independant blur.
  48326. */
  48327. mainTextureFixedSize?: number;
  48328. /**
  48329. * How big is the kernel of the blur texture.
  48330. */
  48331. blurKernelSize: number;
  48332. /**
  48333. * The camera attached to the layer.
  48334. */
  48335. camera: Nullable<Camera>;
  48336. /**
  48337. * Enable MSAA by chosing the number of samples.
  48338. */
  48339. mainTextureSamples?: number;
  48340. /**
  48341. * The rendering group to draw the layer in.
  48342. */
  48343. renderingGroupId: number;
  48344. }
  48345. /**
  48346. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48347. *
  48348. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48349. * glowy meshes to your scene.
  48350. *
  48351. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48352. */
  48353. export class GlowLayer extends EffectLayer {
  48354. /**
  48355. * Effect Name of the layer.
  48356. */
  48357. static readonly EffectName: string;
  48358. /**
  48359. * The default blur kernel size used for the glow.
  48360. */
  48361. static DefaultBlurKernelSize: number;
  48362. /**
  48363. * The default texture size ratio used for the glow.
  48364. */
  48365. static DefaultTextureRatio: number;
  48366. /**
  48367. * Sets the kernel size of the blur.
  48368. */
  48369. /**
  48370. * Gets the kernel size of the blur.
  48371. */
  48372. blurKernelSize: number;
  48373. /**
  48374. * Sets the glow intensity.
  48375. */
  48376. /**
  48377. * Gets the glow intensity.
  48378. */
  48379. intensity: number;
  48380. private _options;
  48381. private _intensity;
  48382. private _horizontalBlurPostprocess1;
  48383. private _verticalBlurPostprocess1;
  48384. private _horizontalBlurPostprocess2;
  48385. private _verticalBlurPostprocess2;
  48386. private _blurTexture1;
  48387. private _blurTexture2;
  48388. private _postProcesses1;
  48389. private _postProcesses2;
  48390. private _includedOnlyMeshes;
  48391. private _excludedMeshes;
  48392. /**
  48393. * Callback used to let the user override the color selection on a per mesh basis
  48394. */
  48395. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48396. /**
  48397. * Callback used to let the user override the texture selection on a per mesh basis
  48398. */
  48399. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48400. /**
  48401. * Instantiates a new glow Layer and references it to the scene.
  48402. * @param name The name of the layer
  48403. * @param scene The scene to use the layer in
  48404. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48405. */
  48406. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48407. /**
  48408. * Get the effect name of the layer.
  48409. * @return The effect name
  48410. */
  48411. getEffectName(): string;
  48412. /**
  48413. * Create the merge effect. This is the shader use to blit the information back
  48414. * to the main canvas at the end of the scene rendering.
  48415. */
  48416. protected _createMergeEffect(): Effect;
  48417. /**
  48418. * Creates the render target textures and post processes used in the glow layer.
  48419. */
  48420. protected _createTextureAndPostProcesses(): void;
  48421. /**
  48422. * Checks for the readiness of the element composing the layer.
  48423. * @param subMesh the mesh to check for
  48424. * @param useInstances specify wether or not to use instances to render the mesh
  48425. * @param emissiveTexture the associated emissive texture used to generate the glow
  48426. * @return true if ready otherwise, false
  48427. */
  48428. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48429. /**
  48430. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48431. */
  48432. needStencil(): boolean;
  48433. /**
  48434. * Returns true if the mesh can be rendered, otherwise false.
  48435. * @param mesh The mesh to render
  48436. * @param material The material used on the mesh
  48437. * @returns true if it can be rendered otherwise false
  48438. */
  48439. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48440. /**
  48441. * Implementation specific of rendering the generating effect on the main canvas.
  48442. * @param effect The effect used to render through
  48443. */
  48444. protected _internalRender(effect: Effect): void;
  48445. /**
  48446. * Sets the required values for both the emissive texture and and the main color.
  48447. */
  48448. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48449. /**
  48450. * Returns true if the mesh should render, otherwise false.
  48451. * @param mesh The mesh to render
  48452. * @returns true if it should render otherwise false
  48453. */
  48454. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48455. /**
  48456. * Adds specific effects defines.
  48457. * @param defines The defines to add specifics to.
  48458. */
  48459. protected _addCustomEffectDefines(defines: string[]): void;
  48460. /**
  48461. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48462. * @param mesh The mesh to exclude from the glow layer
  48463. */
  48464. addExcludedMesh(mesh: Mesh): void;
  48465. /**
  48466. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48467. * @param mesh The mesh to remove
  48468. */
  48469. removeExcludedMesh(mesh: Mesh): void;
  48470. /**
  48471. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48472. * @param mesh The mesh to include in the glow layer
  48473. */
  48474. addIncludedOnlyMesh(mesh: Mesh): void;
  48475. /**
  48476. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48477. * @param mesh The mesh to remove
  48478. */
  48479. removeIncludedOnlyMesh(mesh: Mesh): void;
  48480. /**
  48481. * Determine if a given mesh will be used in the glow layer
  48482. * @param mesh The mesh to test
  48483. * @returns true if the mesh will be highlighted by the current glow layer
  48484. */
  48485. hasMesh(mesh: AbstractMesh): boolean;
  48486. /**
  48487. * Free any resources and references associated to a mesh.
  48488. * Internal use
  48489. * @param mesh The mesh to free.
  48490. * @hidden
  48491. */ private _disposeMesh(mesh: Mesh): void;
  48492. /**
  48493. * Gets the class name of the effect layer
  48494. * @returns the string with the class name of the effect layer
  48495. */
  48496. getClassName(): string;
  48497. /**
  48498. * Serializes this glow layer
  48499. * @returns a serialized glow layer object
  48500. */
  48501. serialize(): any;
  48502. /**
  48503. * Creates a Glow Layer from parsed glow layer data
  48504. * @param parsedGlowLayer defines glow layer data
  48505. * @param scene defines the current scene
  48506. * @param rootUrl defines the root URL containing the glow layer information
  48507. * @returns a parsed Glow Layer
  48508. */
  48509. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48510. }
  48511. }
  48512. declare module BABYLON {
  48513. /** @hidden */
  48514. export var glowBlurPostProcessPixelShader: {
  48515. name: string;
  48516. shader: string;
  48517. };
  48518. }
  48519. declare module BABYLON {
  48520. interface AbstractScene {
  48521. /**
  48522. * Return a the first highlight layer of the scene with a given name.
  48523. * @param name The name of the highlight layer to look for.
  48524. * @return The highlight layer if found otherwise null.
  48525. */
  48526. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48527. }
  48528. /**
  48529. * Highlight layer options. This helps customizing the behaviour
  48530. * of the highlight layer.
  48531. */
  48532. export interface IHighlightLayerOptions {
  48533. /**
  48534. * Multiplication factor apply to the canvas size to compute the render target size
  48535. * used to generated the glowing objects (the smaller the faster).
  48536. */
  48537. mainTextureRatio: number;
  48538. /**
  48539. * Enforces a fixed size texture to ensure resize independant blur.
  48540. */
  48541. mainTextureFixedSize?: number;
  48542. /**
  48543. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48544. * of the picture to blur (the smaller the faster).
  48545. */
  48546. blurTextureSizeRatio: number;
  48547. /**
  48548. * How big in texel of the blur texture is the vertical blur.
  48549. */
  48550. blurVerticalSize: number;
  48551. /**
  48552. * How big in texel of the blur texture is the horizontal blur.
  48553. */
  48554. blurHorizontalSize: number;
  48555. /**
  48556. * Alpha blending mode used to apply the blur. Default is combine.
  48557. */
  48558. alphaBlendingMode: number;
  48559. /**
  48560. * The camera attached to the layer.
  48561. */
  48562. camera: Nullable<Camera>;
  48563. /**
  48564. * Should we display highlight as a solid stroke?
  48565. */
  48566. isStroke?: boolean;
  48567. /**
  48568. * The rendering group to draw the layer in.
  48569. */
  48570. renderingGroupId: number;
  48571. }
  48572. /**
  48573. * The highlight layer Helps adding a glow effect around a mesh.
  48574. *
  48575. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48576. * glowy meshes to your scene.
  48577. *
  48578. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48579. */
  48580. export class HighlightLayer extends EffectLayer {
  48581. name: string;
  48582. /**
  48583. * Effect Name of the highlight layer.
  48584. */
  48585. static readonly EffectName: string;
  48586. /**
  48587. * The neutral color used during the preparation of the glow effect.
  48588. * This is black by default as the blend operation is a blend operation.
  48589. */
  48590. static NeutralColor: Color4;
  48591. /**
  48592. * Stencil value used for glowing meshes.
  48593. */
  48594. static GlowingMeshStencilReference: number;
  48595. /**
  48596. * Stencil value used for the other meshes in the scene.
  48597. */
  48598. static NormalMeshStencilReference: number;
  48599. /**
  48600. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48601. */
  48602. innerGlow: boolean;
  48603. /**
  48604. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48605. */
  48606. outerGlow: boolean;
  48607. /**
  48608. * Specifies the horizontal size of the blur.
  48609. */
  48610. /**
  48611. * Gets the horizontal size of the blur.
  48612. */
  48613. blurHorizontalSize: number;
  48614. /**
  48615. * Specifies the vertical size of the blur.
  48616. */
  48617. /**
  48618. * Gets the vertical size of the blur.
  48619. */
  48620. blurVerticalSize: number;
  48621. /**
  48622. * An event triggered when the highlight layer is being blurred.
  48623. */
  48624. onBeforeBlurObservable: Observable<HighlightLayer>;
  48625. /**
  48626. * An event triggered when the highlight layer has been blurred.
  48627. */
  48628. onAfterBlurObservable: Observable<HighlightLayer>;
  48629. private _instanceGlowingMeshStencilReference;
  48630. private _options;
  48631. private _downSamplePostprocess;
  48632. private _horizontalBlurPostprocess;
  48633. private _verticalBlurPostprocess;
  48634. private _blurTexture;
  48635. private _meshes;
  48636. private _excludedMeshes;
  48637. /**
  48638. * Instantiates a new highlight Layer and references it to the scene..
  48639. * @param name The name of the layer
  48640. * @param scene The scene to use the layer in
  48641. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48642. */
  48643. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48644. /**
  48645. * Get the effect name of the layer.
  48646. * @return The effect name
  48647. */
  48648. getEffectName(): string;
  48649. /**
  48650. * Create the merge effect. This is the shader use to blit the information back
  48651. * to the main canvas at the end of the scene rendering.
  48652. */
  48653. protected _createMergeEffect(): Effect;
  48654. /**
  48655. * Creates the render target textures and post processes used in the highlight layer.
  48656. */
  48657. protected _createTextureAndPostProcesses(): void;
  48658. /**
  48659. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48660. */
  48661. needStencil(): boolean;
  48662. /**
  48663. * Checks for the readiness of the element composing the layer.
  48664. * @param subMesh the mesh to check for
  48665. * @param useInstances specify wether or not to use instances to render the mesh
  48666. * @param emissiveTexture the associated emissive texture used to generate the glow
  48667. * @return true if ready otherwise, false
  48668. */
  48669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48670. /**
  48671. * Implementation specific of rendering the generating effect on the main canvas.
  48672. * @param effect The effect used to render through
  48673. */
  48674. protected _internalRender(effect: Effect): void;
  48675. /**
  48676. * Returns true if the layer contains information to display, otherwise false.
  48677. */
  48678. shouldRender(): boolean;
  48679. /**
  48680. * Returns true if the mesh should render, otherwise false.
  48681. * @param mesh The mesh to render
  48682. * @returns true if it should render otherwise false
  48683. */
  48684. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48685. /**
  48686. * Sets the required values for both the emissive texture and and the main color.
  48687. */
  48688. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48689. /**
  48690. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48691. * @param mesh The mesh to exclude from the highlight layer
  48692. */
  48693. addExcludedMesh(mesh: Mesh): void;
  48694. /**
  48695. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48696. * @param mesh The mesh to highlight
  48697. */
  48698. removeExcludedMesh(mesh: Mesh): void;
  48699. /**
  48700. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48701. * @param mesh mesh to test
  48702. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48703. */
  48704. hasMesh(mesh: AbstractMesh): boolean;
  48705. /**
  48706. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48707. * @param mesh The mesh to highlight
  48708. * @param color The color of the highlight
  48709. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48710. */
  48711. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48712. /**
  48713. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48714. * @param mesh The mesh to highlight
  48715. */
  48716. removeMesh(mesh: Mesh): void;
  48717. /**
  48718. * Force the stencil to the normal expected value for none glowing parts
  48719. */
  48720. private _defaultStencilReference;
  48721. /**
  48722. * Free any resources and references associated to a mesh.
  48723. * Internal use
  48724. * @param mesh The mesh to free.
  48725. * @hidden
  48726. */ private _disposeMesh(mesh: Mesh): void;
  48727. /**
  48728. * Dispose the highlight layer and free resources.
  48729. */
  48730. dispose(): void;
  48731. /**
  48732. * Gets the class name of the effect layer
  48733. * @returns the string with the class name of the effect layer
  48734. */
  48735. getClassName(): string;
  48736. /**
  48737. * Serializes this Highlight layer
  48738. * @returns a serialized Highlight layer object
  48739. */
  48740. serialize(): any;
  48741. /**
  48742. * Creates a Highlight layer from parsed Highlight layer data
  48743. * @param parsedHightlightLayer defines the Highlight layer data
  48744. * @param scene defines the current scene
  48745. * @param rootUrl defines the root URL containing the Highlight layer information
  48746. * @returns a parsed Highlight layer
  48747. */
  48748. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48749. }
  48750. }
  48751. declare module BABYLON {
  48752. interface AbstractScene {
  48753. /**
  48754. * The list of layers (background and foreground) of the scene
  48755. */
  48756. layers: Array<Layer>;
  48757. }
  48758. /**
  48759. * Defines the layer scene component responsible to manage any layers
  48760. * in a given scene.
  48761. */
  48762. export class LayerSceneComponent implements ISceneComponent {
  48763. /**
  48764. * The component name helpfull to identify the component in the list of scene components.
  48765. */
  48766. readonly name: string;
  48767. /**
  48768. * The scene the component belongs to.
  48769. */
  48770. scene: Scene;
  48771. private _engine;
  48772. /**
  48773. * Creates a new instance of the component for the given scene
  48774. * @param scene Defines the scene to register the component in
  48775. */
  48776. constructor(scene: Scene);
  48777. /**
  48778. * Registers the component in a given scene
  48779. */
  48780. register(): void;
  48781. /**
  48782. * Rebuilds the elements related to this component in case of
  48783. * context lost for instance.
  48784. */
  48785. rebuild(): void;
  48786. /**
  48787. * Disposes the component and the associated ressources.
  48788. */
  48789. dispose(): void;
  48790. private _draw;
  48791. private _drawCameraPredicate;
  48792. private _drawCameraBackground;
  48793. private _drawCameraForeground;
  48794. private _drawRenderTargetPredicate;
  48795. private _drawRenderTargetBackground;
  48796. private _drawRenderTargetForeground;
  48797. /**
  48798. * Adds all the elements from the container to the scene
  48799. * @param container the container holding the elements
  48800. */
  48801. addFromContainer(container: AbstractScene): void;
  48802. /**
  48803. * Removes all the elements in the container from the scene
  48804. * @param container contains the elements to remove
  48805. * @param dispose if the removed element should be disposed (default: false)
  48806. */
  48807. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48808. }
  48809. }
  48810. declare module BABYLON {
  48811. /** @hidden */
  48812. export var layerPixelShader: {
  48813. name: string;
  48814. shader: string;
  48815. };
  48816. }
  48817. declare module BABYLON {
  48818. /** @hidden */
  48819. export var layerVertexShader: {
  48820. name: string;
  48821. shader: string;
  48822. };
  48823. }
  48824. declare module BABYLON {
  48825. /**
  48826. * This represents a full screen 2d layer.
  48827. * This can be useful to display a picture in the background of your scene for instance.
  48828. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48829. */
  48830. export class Layer {
  48831. /**
  48832. * Define the name of the layer.
  48833. */
  48834. name: string;
  48835. /**
  48836. * Define the texture the layer should display.
  48837. */
  48838. texture: Nullable<Texture>;
  48839. /**
  48840. * Is the layer in background or foreground.
  48841. */
  48842. isBackground: boolean;
  48843. /**
  48844. * Define the color of the layer (instead of texture).
  48845. */
  48846. color: Color4;
  48847. /**
  48848. * Define the scale of the layer in order to zoom in out of the texture.
  48849. */
  48850. scale: Vector2;
  48851. /**
  48852. * Define an offset for the layer in order to shift the texture.
  48853. */
  48854. offset: Vector2;
  48855. /**
  48856. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48857. */
  48858. alphaBlendingMode: number;
  48859. /**
  48860. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48861. * Alpha test will not mix with the background color in case of transparency.
  48862. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48863. */
  48864. alphaTest: boolean;
  48865. /**
  48866. * Define a mask to restrict the layer to only some of the scene cameras.
  48867. */
  48868. layerMask: number;
  48869. /**
  48870. * Define the list of render target the layer is visible into.
  48871. */
  48872. renderTargetTextures: RenderTargetTexture[];
  48873. /**
  48874. * Define if the layer is only used in renderTarget or if it also
  48875. * renders in the main frame buffer of the canvas.
  48876. */
  48877. renderOnlyInRenderTargetTextures: boolean;
  48878. private _scene;
  48879. private _vertexBuffers;
  48880. private _indexBuffer;
  48881. private _effect;
  48882. private _alphaTestEffect;
  48883. /**
  48884. * An event triggered when the layer is disposed.
  48885. */
  48886. onDisposeObservable: Observable<Layer>;
  48887. private _onDisposeObserver;
  48888. /**
  48889. * Back compatibility with callback before the onDisposeObservable existed.
  48890. * The set callback will be triggered when the layer has been disposed.
  48891. */
  48892. onDispose: () => void;
  48893. /**
  48894. * An event triggered before rendering the scene
  48895. */
  48896. onBeforeRenderObservable: Observable<Layer>;
  48897. private _onBeforeRenderObserver;
  48898. /**
  48899. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48900. * The set callback will be triggered just before rendering the layer.
  48901. */
  48902. onBeforeRender: () => void;
  48903. /**
  48904. * An event triggered after rendering the scene
  48905. */
  48906. onAfterRenderObservable: Observable<Layer>;
  48907. private _onAfterRenderObserver;
  48908. /**
  48909. * Back compatibility with callback before the onAfterRenderObservable existed.
  48910. * The set callback will be triggered just after rendering the layer.
  48911. */
  48912. onAfterRender: () => void;
  48913. /**
  48914. * Instantiates a new layer.
  48915. * This represents a full screen 2d layer.
  48916. * This can be useful to display a picture in the background of your scene for instance.
  48917. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48918. * @param name Define the name of the layer in the scene
  48919. * @param imgUrl Define the url of the texture to display in the layer
  48920. * @param scene Define the scene the layer belongs to
  48921. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48922. * @param color Defines a color for the layer
  48923. */
  48924. constructor(
  48925. /**
  48926. * Define the name of the layer.
  48927. */
  48928. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48929. private _createIndexBuffer;
  48930. /** @hidden */ private _rebuild(): void;
  48931. /**
  48932. * Renders the layer in the scene.
  48933. */
  48934. render(): void;
  48935. /**
  48936. * Disposes and releases the associated ressources.
  48937. */
  48938. dispose(): void;
  48939. }
  48940. }
  48941. declare module BABYLON {
  48942. /** @hidden */
  48943. export var lensFlarePixelShader: {
  48944. name: string;
  48945. shader: string;
  48946. };
  48947. }
  48948. declare module BABYLON {
  48949. /** @hidden */
  48950. export var lensFlareVertexShader: {
  48951. name: string;
  48952. shader: string;
  48953. };
  48954. }
  48955. declare module BABYLON {
  48956. /**
  48957. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48958. * It is usually composed of several `lensFlare`.
  48959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48960. */
  48961. export class LensFlareSystem {
  48962. /**
  48963. * Define the name of the lens flare system
  48964. */
  48965. name: string;
  48966. /**
  48967. * List of lens flares used in this system.
  48968. */
  48969. lensFlares: LensFlare[];
  48970. /**
  48971. * Define a limit from the border the lens flare can be visible.
  48972. */
  48973. borderLimit: number;
  48974. /**
  48975. * Define a viewport border we do not want to see the lens flare in.
  48976. */
  48977. viewportBorder: number;
  48978. /**
  48979. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48980. */
  48981. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48982. /**
  48983. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48984. */
  48985. layerMask: number;
  48986. /**
  48987. * Define the id of the lens flare system in the scene.
  48988. * (equal to name by default)
  48989. */
  48990. id: string;
  48991. private _scene;
  48992. private _emitter;
  48993. private _vertexBuffers;
  48994. private _indexBuffer;
  48995. private _effect;
  48996. private _positionX;
  48997. private _positionY;
  48998. private _isEnabled;
  48999. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49000. /**
  49001. * Instantiates a lens flare system.
  49002. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49003. * It is usually composed of several `lensFlare`.
  49004. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49005. * @param name Define the name of the lens flare system in the scene
  49006. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49007. * @param scene Define the scene the lens flare system belongs to
  49008. */
  49009. constructor(
  49010. /**
  49011. * Define the name of the lens flare system
  49012. */
  49013. name: string, emitter: any, scene: Scene);
  49014. /**
  49015. * Define if the lens flare system is enabled.
  49016. */
  49017. isEnabled: boolean;
  49018. /**
  49019. * Get the scene the effects belongs to.
  49020. * @returns the scene holding the lens flare system
  49021. */
  49022. getScene(): Scene;
  49023. /**
  49024. * Get the emitter of the lens flare system.
  49025. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49026. * @returns the emitter of the lens flare system
  49027. */
  49028. getEmitter(): any;
  49029. /**
  49030. * Set the emitter of the lens flare system.
  49031. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49032. * @param newEmitter Define the new emitter of the system
  49033. */
  49034. setEmitter(newEmitter: any): void;
  49035. /**
  49036. * Get the lens flare system emitter position.
  49037. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49038. * @returns the position
  49039. */
  49040. getEmitterPosition(): Vector3;
  49041. /**
  49042. * @hidden
  49043. */
  49044. computeEffectivePosition(globalViewport: Viewport): boolean;
  49045. /** @hidden */ private _isVisible(): boolean;
  49046. /**
  49047. * @hidden
  49048. */
  49049. render(): boolean;
  49050. /**
  49051. * Dispose and release the lens flare with its associated resources.
  49052. */
  49053. dispose(): void;
  49054. /**
  49055. * Parse a lens flare system from a JSON repressentation
  49056. * @param parsedLensFlareSystem Define the JSON to parse
  49057. * @param scene Define the scene the parsed system should be instantiated in
  49058. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49059. * @returns the parsed system
  49060. */
  49061. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49062. /**
  49063. * Serialize the current Lens Flare System into a JSON representation.
  49064. * @returns the serialized JSON
  49065. */
  49066. serialize(): any;
  49067. }
  49068. }
  49069. declare module BABYLON {
  49070. /**
  49071. * This represents one of the lens effect in a `lensFlareSystem`.
  49072. * It controls one of the indiviual texture used in the effect.
  49073. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49074. */
  49075. export class LensFlare {
  49076. /**
  49077. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49078. */
  49079. size: number;
  49080. /**
  49081. * 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.
  49082. */
  49083. position: number;
  49084. /**
  49085. * Define the lens color.
  49086. */
  49087. color: Color3;
  49088. /**
  49089. * Define the lens texture.
  49090. */
  49091. texture: Nullable<Texture>;
  49092. /**
  49093. * Define the alpha mode to render this particular lens.
  49094. */
  49095. alphaMode: number;
  49096. private _system;
  49097. /**
  49098. * Creates a new Lens Flare.
  49099. * This represents one of the lens effect in a `lensFlareSystem`.
  49100. * It controls one of the indiviual texture used in the effect.
  49101. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49102. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49103. * @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.
  49104. * @param color Define the lens color
  49105. * @param imgUrl Define the lens texture url
  49106. * @param system Define the `lensFlareSystem` this flare is part of
  49107. * @returns The newly created Lens Flare
  49108. */
  49109. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49110. /**
  49111. * Instantiates a new Lens Flare.
  49112. * This represents one of the lens effect in a `lensFlareSystem`.
  49113. * It controls one of the indiviual texture used in the effect.
  49114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49115. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49116. * @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.
  49117. * @param color Define the lens color
  49118. * @param imgUrl Define the lens texture url
  49119. * @param system Define the `lensFlareSystem` this flare is part of
  49120. */
  49121. constructor(
  49122. /**
  49123. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49124. */
  49125. size: number,
  49126. /**
  49127. * 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.
  49128. */
  49129. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49130. /**
  49131. * Dispose and release the lens flare with its associated resources.
  49132. */
  49133. dispose(): void;
  49134. }
  49135. }
  49136. declare module BABYLON {
  49137. interface AbstractScene {
  49138. /**
  49139. * The list of lens flare system added to the scene
  49140. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49141. */
  49142. lensFlareSystems: Array<LensFlareSystem>;
  49143. /**
  49144. * Removes the given lens flare system from this scene.
  49145. * @param toRemove The lens flare system to remove
  49146. * @returns The index of the removed lens flare system
  49147. */
  49148. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49149. /**
  49150. * Adds the given lens flare system to this scene
  49151. * @param newLensFlareSystem The lens flare system to add
  49152. */
  49153. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49154. /**
  49155. * Gets a lens flare system using its name
  49156. * @param name defines the name to look for
  49157. * @returns the lens flare system or null if not found
  49158. */
  49159. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49160. /**
  49161. * Gets a lens flare system using its id
  49162. * @param id defines the id to look for
  49163. * @returns the lens flare system or null if not found
  49164. */
  49165. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49166. }
  49167. /**
  49168. * Defines the lens flare scene component responsible to manage any lens flares
  49169. * in a given scene.
  49170. */
  49171. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49172. /**
  49173. * The component name helpfull to identify the component in the list of scene components.
  49174. */
  49175. readonly name: string;
  49176. /**
  49177. * The scene the component belongs to.
  49178. */
  49179. scene: Scene;
  49180. /**
  49181. * Creates a new instance of the component for the given scene
  49182. * @param scene Defines the scene to register the component in
  49183. */
  49184. constructor(scene: Scene);
  49185. /**
  49186. * Registers the component in a given scene
  49187. */
  49188. register(): void;
  49189. /**
  49190. * Rebuilds the elements related to this component in case of
  49191. * context lost for instance.
  49192. */
  49193. rebuild(): void;
  49194. /**
  49195. * Adds all the elements from the container to the scene
  49196. * @param container the container holding the elements
  49197. */
  49198. addFromContainer(container: AbstractScene): void;
  49199. /**
  49200. * Removes all the elements in the container from the scene
  49201. * @param container contains the elements to remove
  49202. * @param dispose if the removed element should be disposed (default: false)
  49203. */
  49204. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49205. /**
  49206. * Serializes the component data to the specified json object
  49207. * @param serializationObject The object to serialize to
  49208. */
  49209. serialize(serializationObject: any): void;
  49210. /**
  49211. * Disposes the component and the associated ressources.
  49212. */
  49213. dispose(): void;
  49214. private _draw;
  49215. }
  49216. }
  49217. declare module BABYLON {
  49218. /**
  49219. * Defines the shadow generator component responsible to manage any shadow generators
  49220. * in a given scene.
  49221. */
  49222. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49223. /**
  49224. * The component name helpfull to identify the component in the list of scene components.
  49225. */
  49226. readonly name: string;
  49227. /**
  49228. * The scene the component belongs to.
  49229. */
  49230. scene: Scene;
  49231. /**
  49232. * Creates a new instance of the component for the given scene
  49233. * @param scene Defines the scene to register the component in
  49234. */
  49235. constructor(scene: Scene);
  49236. /**
  49237. * Registers the component in a given scene
  49238. */
  49239. register(): void;
  49240. /**
  49241. * Rebuilds the elements related to this component in case of
  49242. * context lost for instance.
  49243. */
  49244. rebuild(): void;
  49245. /**
  49246. * Serializes the component data to the specified json object
  49247. * @param serializationObject The object to serialize to
  49248. */
  49249. serialize(serializationObject: any): void;
  49250. /**
  49251. * Adds all the elements from the container to the scene
  49252. * @param container the container holding the elements
  49253. */
  49254. addFromContainer(container: AbstractScene): void;
  49255. /**
  49256. * Removes all the elements in the container from the scene
  49257. * @param container contains the elements to remove
  49258. * @param dispose if the removed element should be disposed (default: false)
  49259. */
  49260. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49261. /**
  49262. * Rebuilds the elements related to this component in case of
  49263. * context lost for instance.
  49264. */
  49265. dispose(): void;
  49266. private _gatherRenderTargets;
  49267. }
  49268. }
  49269. declare module BABYLON {
  49270. /**
  49271. * A point light is a light defined by an unique point in world space.
  49272. * The light is emitted in every direction from this point.
  49273. * A good example of a point light is a standard light bulb.
  49274. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49275. */
  49276. export class PointLight extends ShadowLight {
  49277. private _shadowAngle;
  49278. /**
  49279. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49280. * This specifies what angle the shadow will use to be created.
  49281. *
  49282. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49283. */
  49284. /**
  49285. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49286. * This specifies what angle the shadow will use to be created.
  49287. *
  49288. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49289. */
  49290. shadowAngle: number;
  49291. /**
  49292. * Gets the direction if it has been set.
  49293. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49294. */
  49295. /**
  49296. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49297. */
  49298. direction: Vector3;
  49299. /**
  49300. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49301. * A PointLight emits the light in every direction.
  49302. * It can cast shadows.
  49303. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49304. * ```javascript
  49305. * var pointLight = new PointLight("pl", camera.position, scene);
  49306. * ```
  49307. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49308. * @param name The light friendly name
  49309. * @param position The position of the point light in the scene
  49310. * @param scene The scene the lights belongs to
  49311. */
  49312. constructor(name: string, position: Vector3, scene: Scene);
  49313. /**
  49314. * Returns the string "PointLight"
  49315. * @returns the class name
  49316. */
  49317. getClassName(): string;
  49318. /**
  49319. * Returns the integer 0.
  49320. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49321. */
  49322. getTypeID(): number;
  49323. /**
  49324. * Specifies wether or not the shadowmap should be a cube texture.
  49325. * @returns true if the shadowmap needs to be a cube texture.
  49326. */
  49327. needCube(): boolean;
  49328. /**
  49329. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49330. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49331. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49332. */
  49333. getShadowDirection(faceIndex?: number): Vector3;
  49334. /**
  49335. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49336. * - fov = PI / 2
  49337. * - aspect ratio : 1.0
  49338. * - z-near and far equal to the active camera minZ and maxZ.
  49339. * Returns the PointLight.
  49340. */
  49341. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49342. protected _buildUniformLayout(): void;
  49343. /**
  49344. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49345. * @param effect The effect to update
  49346. * @param lightIndex The index of the light in the effect to update
  49347. * @returns The point light
  49348. */
  49349. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49350. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49351. /**
  49352. * Prepares the list of defines specific to the light type.
  49353. * @param defines the list of defines
  49354. * @param lightIndex defines the index of the light for the effect
  49355. */
  49356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49357. }
  49358. }
  49359. declare module BABYLON {
  49360. /**
  49361. * Header information of HDR texture files.
  49362. */
  49363. export interface HDRInfo {
  49364. /**
  49365. * The height of the texture in pixels.
  49366. */
  49367. height: number;
  49368. /**
  49369. * The width of the texture in pixels.
  49370. */
  49371. width: number;
  49372. /**
  49373. * The index of the beginning of the data in the binary file.
  49374. */
  49375. dataPosition: number;
  49376. }
  49377. /**
  49378. * This groups tools to convert HDR texture to native colors array.
  49379. */
  49380. export class HDRTools {
  49381. private static Ldexp;
  49382. private static Rgbe2float;
  49383. private static readStringLine;
  49384. /**
  49385. * Reads header information from an RGBE texture stored in a native array.
  49386. * More information on this format are available here:
  49387. * https://en.wikipedia.org/wiki/RGBE_image_format
  49388. *
  49389. * @param uint8array The binary file stored in native array.
  49390. * @return The header information.
  49391. */
  49392. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49393. /**
  49394. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49395. * This RGBE texture needs to store the information as a panorama.
  49396. *
  49397. * More information on this format are available here:
  49398. * https://en.wikipedia.org/wiki/RGBE_image_format
  49399. *
  49400. * @param buffer The binary file stored in an array buffer.
  49401. * @param size The expected size of the extracted cubemap.
  49402. * @return The Cube Map information.
  49403. */
  49404. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49405. /**
  49406. * Returns the pixels data extracted from an RGBE texture.
  49407. * This pixels will be stored left to right up to down in the R G B order in one array.
  49408. *
  49409. * More information on this format are available here:
  49410. * https://en.wikipedia.org/wiki/RGBE_image_format
  49411. *
  49412. * @param uint8array The binary file stored in an array buffer.
  49413. * @param hdrInfo The header information of the file.
  49414. * @return The pixels data in RGB right to left up to down order.
  49415. */
  49416. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49417. private static RGBE_ReadPixels_RLE;
  49418. }
  49419. }
  49420. declare module BABYLON {
  49421. /**
  49422. * This represents a texture coming from an HDR input.
  49423. *
  49424. * The only supported format is currently panorama picture stored in RGBE format.
  49425. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49426. */
  49427. export class HDRCubeTexture extends BaseTexture {
  49428. private static _facesMapping;
  49429. private _generateHarmonics;
  49430. private _noMipmap;
  49431. private _textureMatrix;
  49432. private _size;
  49433. private _onLoad;
  49434. private _onError;
  49435. /**
  49436. * The texture URL.
  49437. */
  49438. url: string;
  49439. /**
  49440. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49441. */
  49442. coordinatesMode: number;
  49443. protected _isBlocking: boolean;
  49444. /**
  49445. * Sets wether or not the texture is blocking during loading.
  49446. */
  49447. /**
  49448. * Gets wether or not the texture is blocking during loading.
  49449. */
  49450. isBlocking: boolean;
  49451. protected _rotationY: number;
  49452. /**
  49453. * Sets texture matrix rotation angle around Y axis in radians.
  49454. */
  49455. /**
  49456. * Gets texture matrix rotation angle around Y axis radians.
  49457. */
  49458. rotationY: number;
  49459. /**
  49460. * Gets or sets the center of the bounding box associated with the cube texture
  49461. * It must define where the camera used to render the texture was set
  49462. */
  49463. boundingBoxPosition: Vector3;
  49464. private _boundingBoxSize;
  49465. /**
  49466. * Gets or sets the size of the bounding box associated with the cube texture
  49467. * When defined, the cubemap will switch to local mode
  49468. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49469. * @example https://www.babylonjs-playground.com/#RNASML
  49470. */
  49471. boundingBoxSize: Vector3;
  49472. /**
  49473. * Instantiates an HDRTexture from the following parameters.
  49474. *
  49475. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49476. * @param scene The scene the texture will be used in
  49477. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49478. * @param noMipmap Forces to not generate the mipmap if true
  49479. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49480. * @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)
  49481. * @param reserved Reserved flag for internal use.
  49482. */
  49483. 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>);
  49484. /**
  49485. * Get the current class name of the texture useful for serialization or dynamic coding.
  49486. * @returns "HDRCubeTexture"
  49487. */
  49488. getClassName(): string;
  49489. /**
  49490. * Occurs when the file is raw .hdr file.
  49491. */
  49492. private loadTexture;
  49493. clone(): HDRCubeTexture;
  49494. delayLoad(): void;
  49495. /**
  49496. * Get the texture reflection matrix used to rotate/transform the reflection.
  49497. * @returns the reflection matrix
  49498. */
  49499. getReflectionTextureMatrix(): Matrix;
  49500. /**
  49501. * Set the texture reflection matrix used to rotate/transform the reflection.
  49502. * @param value Define the reflection matrix to set
  49503. */
  49504. setReflectionTextureMatrix(value: Matrix): void;
  49505. /**
  49506. * Parses a JSON representation of an HDR Texture in order to create the texture
  49507. * @param parsedTexture Define the JSON representation
  49508. * @param scene Define the scene the texture should be created in
  49509. * @param rootUrl Define the root url in case we need to load relative dependencies
  49510. * @returns the newly created texture after parsing
  49511. */
  49512. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49513. serialize(): any;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * Class used to control physics engine
  49519. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49520. */
  49521. export class PhysicsEngine implements IPhysicsEngine {
  49522. private _physicsPlugin;
  49523. /**
  49524. * Global value used to control the smallest number supported by the simulation
  49525. */
  49526. static Epsilon: number;
  49527. private _impostors;
  49528. private _joints;
  49529. /**
  49530. * Gets the gravity vector used by the simulation
  49531. */
  49532. gravity: Vector3;
  49533. /**
  49534. * Factory used to create the default physics plugin.
  49535. * @returns The default physics plugin
  49536. */
  49537. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49538. /**
  49539. * Creates a new Physics Engine
  49540. * @param gravity defines the gravity vector used by the simulation
  49541. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49542. */
  49543. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49544. /**
  49545. * Sets the gravity vector used by the simulation
  49546. * @param gravity defines the gravity vector to use
  49547. */
  49548. setGravity(gravity: Vector3): void;
  49549. /**
  49550. * Set the time step of the physics engine.
  49551. * Default is 1/60.
  49552. * To slow it down, enter 1/600 for example.
  49553. * To speed it up, 1/30
  49554. * @param newTimeStep defines the new timestep to apply to this world.
  49555. */
  49556. setTimeStep(newTimeStep?: number): void;
  49557. /**
  49558. * Get the time step of the physics engine.
  49559. * @returns the current time step
  49560. */
  49561. getTimeStep(): number;
  49562. /**
  49563. * Release all resources
  49564. */
  49565. dispose(): void;
  49566. /**
  49567. * Gets the name of the current physics plugin
  49568. * @returns the name of the plugin
  49569. */
  49570. getPhysicsPluginName(): string;
  49571. /**
  49572. * Adding a new impostor for the impostor tracking.
  49573. * This will be done by the impostor itself.
  49574. * @param impostor the impostor to add
  49575. */
  49576. addImpostor(impostor: PhysicsImpostor): void;
  49577. /**
  49578. * Remove an impostor from the engine.
  49579. * This impostor and its mesh will not longer be updated by the physics engine.
  49580. * @param impostor the impostor to remove
  49581. */
  49582. removeImpostor(impostor: PhysicsImpostor): void;
  49583. /**
  49584. * Add a joint to the physics engine
  49585. * @param mainImpostor defines the main impostor to which the joint is added.
  49586. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49587. * @param joint defines the joint that will connect both impostors.
  49588. */
  49589. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49590. /**
  49591. * Removes a joint from the simulation
  49592. * @param mainImpostor defines the impostor used with the joint
  49593. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49594. * @param joint defines the joint to remove
  49595. */
  49596. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49597. /**
  49598. * Called by the scene. No need to call it.
  49599. * @param delta defines the timespam between frames
  49600. */ private _step(delta: number): void;
  49601. /**
  49602. * Gets the current plugin used to run the simulation
  49603. * @returns current plugin
  49604. */
  49605. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49606. /**
  49607. * Gets the list of physic impostors
  49608. * @returns an array of PhysicsImpostor
  49609. */
  49610. getImpostors(): Array<PhysicsImpostor>;
  49611. /**
  49612. * Gets the impostor for a physics enabled object
  49613. * @param object defines the object impersonated by the impostor
  49614. * @returns the PhysicsImpostor or null if not found
  49615. */
  49616. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49617. /**
  49618. * Gets the impostor for a physics body object
  49619. * @param body defines physics body used by the impostor
  49620. * @returns the PhysicsImpostor or null if not found
  49621. */
  49622. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49623. /**
  49624. * Does a raycast in the physics world
  49625. * @param from when should the ray start?
  49626. * @param to when should the ray end?
  49627. * @returns PhysicsRaycastResult
  49628. */
  49629. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49630. }
  49631. }
  49632. declare module BABYLON {
  49633. /** @hidden */
  49634. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49635. private _useDeltaForWorldStep;
  49636. world: any;
  49637. name: string;
  49638. private _physicsMaterials;
  49639. private _fixedTimeStep;
  49640. private _cannonRaycastResult;
  49641. private _raycastResult;
  49642. private _physicsBodysToRemoveAfterStep;
  49643. BJSCANNON: any;
  49644. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49645. setGravity(gravity: Vector3): void;
  49646. setTimeStep(timeStep: number): void;
  49647. getTimeStep(): number;
  49648. executeStep(delta: number): void;
  49649. private _removeMarkedPhysicsBodiesFromWorld;
  49650. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49651. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49652. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49653. private _processChildMeshes;
  49654. removePhysicsBody(impostor: PhysicsImpostor): void;
  49655. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49656. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49657. private _addMaterial;
  49658. private _checkWithEpsilon;
  49659. private _createShape;
  49660. private _createHeightmap;
  49661. private _minus90X;
  49662. private _plus90X;
  49663. private _tmpPosition;
  49664. private _tmpDeltaPosition;
  49665. private _tmpUnityRotation;
  49666. private _updatePhysicsBodyTransformation;
  49667. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49668. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49669. isSupported(): boolean;
  49670. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49671. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49672. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49673. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49674. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49675. getBodyMass(impostor: PhysicsImpostor): number;
  49676. getBodyFriction(impostor: PhysicsImpostor): number;
  49677. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49678. getBodyRestitution(impostor: PhysicsImpostor): number;
  49679. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49680. sleepBody(impostor: PhysicsImpostor): void;
  49681. wakeUpBody(impostor: PhysicsImpostor): void;
  49682. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49683. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49684. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49685. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49686. getRadius(impostor: PhysicsImpostor): number;
  49687. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49688. dispose(): void;
  49689. private _extendNamespace;
  49690. /**
  49691. * Does a raycast in the physics world
  49692. * @param from when should the ray start?
  49693. * @param to when should the ray end?
  49694. * @returns PhysicsRaycastResult
  49695. */
  49696. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49697. }
  49698. }
  49699. declare module BABYLON {
  49700. /** @hidden */
  49701. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49702. world: any;
  49703. name: string;
  49704. BJSOIMO: any;
  49705. private _raycastResult;
  49706. constructor(iterations?: number, oimoInjection?: any);
  49707. setGravity(gravity: Vector3): void;
  49708. setTimeStep(timeStep: number): void;
  49709. getTimeStep(): number;
  49710. private _tmpImpostorsArray;
  49711. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49712. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49713. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49714. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49715. private _tmpPositionVector;
  49716. removePhysicsBody(impostor: PhysicsImpostor): void;
  49717. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49718. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49719. isSupported(): boolean;
  49720. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49721. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49722. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49723. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49724. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49725. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49726. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49727. getBodyMass(impostor: PhysicsImpostor): number;
  49728. getBodyFriction(impostor: PhysicsImpostor): number;
  49729. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49730. getBodyRestitution(impostor: PhysicsImpostor): number;
  49731. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49732. sleepBody(impostor: PhysicsImpostor): void;
  49733. wakeUpBody(impostor: PhysicsImpostor): void;
  49734. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49735. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49736. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49737. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49738. getRadius(impostor: PhysicsImpostor): number;
  49739. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49740. dispose(): void;
  49741. /**
  49742. * Does a raycast in the physics world
  49743. * @param from when should the ray start?
  49744. * @param to when should the ray end?
  49745. * @returns PhysicsRaycastResult
  49746. */
  49747. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49748. }
  49749. }
  49750. declare module BABYLON {
  49751. /**
  49752. * Class containing static functions to help procedurally build meshes
  49753. */
  49754. export class RibbonBuilder {
  49755. /**
  49756. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49757. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49758. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49759. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49760. * * 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
  49761. * * 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
  49762. * * 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
  49763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49764. * * 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
  49765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49766. * * 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
  49767. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49768. * * 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
  49769. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49771. * @param name defines the name of the mesh
  49772. * @param options defines the options used to create the mesh
  49773. * @param scene defines the hosting scene
  49774. * @returns the ribbon mesh
  49775. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49777. */
  49778. static CreateRibbon(name: string, options: {
  49779. pathArray: Vector3[][];
  49780. closeArray?: boolean;
  49781. closePath?: boolean;
  49782. offset?: number;
  49783. updatable?: boolean;
  49784. sideOrientation?: number;
  49785. frontUVs?: Vector4;
  49786. backUVs?: Vector4;
  49787. instance?: Mesh;
  49788. invertUV?: boolean;
  49789. uvs?: Vector2[];
  49790. colors?: Color4[];
  49791. }, scene?: Nullable<Scene>): Mesh;
  49792. }
  49793. }
  49794. declare module BABYLON {
  49795. /**
  49796. * Class containing static functions to help procedurally build meshes
  49797. */
  49798. export class ShapeBuilder {
  49799. /**
  49800. * 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.
  49801. * * 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.
  49802. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49803. * * 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.
  49804. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49805. * * 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
  49806. * * 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
  49807. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49809. * * 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
  49810. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49812. * @param name defines the name of the mesh
  49813. * @param options defines the options used to create the mesh
  49814. * @param scene defines the hosting scene
  49815. * @returns the extruded shape mesh
  49816. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49818. */
  49819. static ExtrudeShape(name: string, options: {
  49820. shape: Vector3[];
  49821. path: Vector3[];
  49822. scale?: number;
  49823. rotation?: number;
  49824. cap?: number;
  49825. updatable?: boolean;
  49826. sideOrientation?: number;
  49827. frontUVs?: Vector4;
  49828. backUVs?: Vector4;
  49829. instance?: Mesh;
  49830. invertUV?: boolean;
  49831. }, scene?: Nullable<Scene>): Mesh;
  49832. /**
  49833. * Creates an custom extruded shape mesh.
  49834. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49835. * * 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.
  49836. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49837. * * 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
  49838. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49839. * * 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
  49840. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49841. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49842. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49843. * * 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
  49844. * * 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
  49845. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49847. * * 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
  49848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49850. * @param name defines the name of the mesh
  49851. * @param options defines the options used to create the mesh
  49852. * @param scene defines the hosting scene
  49853. * @returns the custom extruded shape mesh
  49854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49855. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49857. */
  49858. static ExtrudeShapeCustom(name: string, options: {
  49859. shape: Vector3[];
  49860. path: Vector3[];
  49861. scaleFunction?: any;
  49862. rotationFunction?: any;
  49863. ribbonCloseArray?: boolean;
  49864. ribbonClosePath?: boolean;
  49865. cap?: number;
  49866. updatable?: boolean;
  49867. sideOrientation?: number;
  49868. frontUVs?: Vector4;
  49869. backUVs?: Vector4;
  49870. instance?: Mesh;
  49871. invertUV?: boolean;
  49872. }, scene?: Nullable<Scene>): Mesh;
  49873. private static _ExtrudeShapeGeneric;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. /**
  49878. * AmmoJS Physics plugin
  49879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49880. * @see https://github.com/kripken/ammo.js/
  49881. */
  49882. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49883. private _useDeltaForWorldStep;
  49884. /**
  49885. * Reference to the Ammo library
  49886. */
  49887. bjsAMMO: any;
  49888. /**
  49889. * Created ammoJS world which physics bodies are added to
  49890. */
  49891. world: any;
  49892. /**
  49893. * Name of the plugin
  49894. */
  49895. name: string;
  49896. private _timeStep;
  49897. private _fixedTimeStep;
  49898. private _maxSteps;
  49899. private _tmpQuaternion;
  49900. private _tmpAmmoTransform;
  49901. private _tmpAmmoQuaternion;
  49902. private _tmpAmmoConcreteContactResultCallback;
  49903. private _collisionConfiguration;
  49904. private _dispatcher;
  49905. private _overlappingPairCache;
  49906. private _solver;
  49907. private _softBodySolver;
  49908. private _tmpAmmoVectorA;
  49909. private _tmpAmmoVectorB;
  49910. private _tmpAmmoVectorC;
  49911. private _tmpAmmoVectorD;
  49912. private _tmpContactCallbackResult;
  49913. private _tmpAmmoVectorRCA;
  49914. private _tmpAmmoVectorRCB;
  49915. private _raycastResult;
  49916. private static readonly DISABLE_COLLISION_FLAG;
  49917. private static readonly KINEMATIC_FLAG;
  49918. private static readonly DISABLE_DEACTIVATION_FLAG;
  49919. /**
  49920. * Initializes the ammoJS plugin
  49921. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49922. * @param ammoInjection can be used to inject your own ammo reference
  49923. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49924. */
  49925. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49926. /**
  49927. * Sets the gravity of the physics world (m/(s^2))
  49928. * @param gravity Gravity to set
  49929. */
  49930. setGravity(gravity: Vector3): void;
  49931. /**
  49932. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49933. * @param timeStep timestep to use in seconds
  49934. */
  49935. setTimeStep(timeStep: number): void;
  49936. /**
  49937. * 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)
  49938. * @param fixedTimeStep fixedTimeStep to use in seconds
  49939. */
  49940. setFixedTimeStep(fixedTimeStep: number): void;
  49941. /**
  49942. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49943. * @param maxSteps the maximum number of steps by the physics engine per frame
  49944. */
  49945. setMaxSteps(maxSteps: number): void;
  49946. /**
  49947. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49948. * @returns the current timestep in seconds
  49949. */
  49950. getTimeStep(): number;
  49951. private _isImpostorInContact;
  49952. private _isImpostorPairInContact;
  49953. private _stepSimulation;
  49954. /**
  49955. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49956. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49957. * After the step the babylon meshes are set to the position of the physics imposters
  49958. * @param delta amount of time to step forward
  49959. * @param impostors array of imposters to update before/after the step
  49960. */
  49961. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49962. /**
  49963. * Update babylon mesh to match physics world object
  49964. * @param impostor imposter to match
  49965. */
  49966. private _afterSoftStep;
  49967. /**
  49968. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49969. * @param impostor imposter to match
  49970. */
  49971. private _ropeStep;
  49972. /**
  49973. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49974. * @param impostor imposter to match
  49975. */
  49976. private _softbodyOrClothStep;
  49977. private _tmpVector;
  49978. private _tmpMatrix;
  49979. /**
  49980. * Applies an impulse on the imposter
  49981. * @param impostor imposter to apply impulse to
  49982. * @param force amount of force to be applied to the imposter
  49983. * @param contactPoint the location to apply the impulse on the imposter
  49984. */
  49985. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49986. /**
  49987. * Applies a force on the imposter
  49988. * @param impostor imposter to apply force
  49989. * @param force amount of force to be applied to the imposter
  49990. * @param contactPoint the location to apply the force on the imposter
  49991. */
  49992. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49993. /**
  49994. * Creates a physics body using the plugin
  49995. * @param impostor the imposter to create the physics body on
  49996. */
  49997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49998. /**
  49999. * Removes the physics body from the imposter and disposes of the body's memory
  50000. * @param impostor imposter to remove the physics body from
  50001. */
  50002. removePhysicsBody(impostor: PhysicsImpostor): void;
  50003. /**
  50004. * Generates a joint
  50005. * @param impostorJoint the imposter joint to create the joint with
  50006. */
  50007. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50008. /**
  50009. * Removes a joint
  50010. * @param impostorJoint the imposter joint to remove the joint from
  50011. */
  50012. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50013. private _addMeshVerts;
  50014. /**
  50015. * Initialise the soft body vertices to match its object's (mesh) vertices
  50016. * Softbody vertices (nodes) are in world space and to match this
  50017. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50018. * @param impostor to create the softbody for
  50019. */
  50020. private _softVertexData;
  50021. /**
  50022. * Create an impostor's soft body
  50023. * @param impostor to create the softbody for
  50024. */
  50025. private _createSoftbody;
  50026. /**
  50027. * Create cloth for an impostor
  50028. * @param impostor to create the softbody for
  50029. */
  50030. private _createCloth;
  50031. /**
  50032. * Create rope for an impostor
  50033. * @param impostor to create the softbody for
  50034. */
  50035. private _createRope;
  50036. private _addHullVerts;
  50037. private _createShape;
  50038. /**
  50039. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50040. * @param impostor imposter containing the physics body and babylon object
  50041. */
  50042. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50043. /**
  50044. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50045. * @param impostor imposter containing the physics body and babylon object
  50046. * @param newPosition new position
  50047. * @param newRotation new rotation
  50048. */
  50049. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50050. /**
  50051. * If this plugin is supported
  50052. * @returns true if its supported
  50053. */
  50054. isSupported(): boolean;
  50055. /**
  50056. * Sets the linear velocity of the physics body
  50057. * @param impostor imposter to set the velocity on
  50058. * @param velocity velocity to set
  50059. */
  50060. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50061. /**
  50062. * Sets the angular velocity of the physics body
  50063. * @param impostor imposter to set the velocity on
  50064. * @param velocity velocity to set
  50065. */
  50066. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50067. /**
  50068. * gets the linear velocity
  50069. * @param impostor imposter to get linear velocity from
  50070. * @returns linear velocity
  50071. */
  50072. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50073. /**
  50074. * gets the angular velocity
  50075. * @param impostor imposter to get angular velocity from
  50076. * @returns angular velocity
  50077. */
  50078. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50079. /**
  50080. * Sets the mass of physics body
  50081. * @param impostor imposter to set the mass on
  50082. * @param mass mass to set
  50083. */
  50084. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50085. /**
  50086. * Gets the mass of the physics body
  50087. * @param impostor imposter to get the mass from
  50088. * @returns mass
  50089. */
  50090. getBodyMass(impostor: PhysicsImpostor): number;
  50091. /**
  50092. * Gets friction of the impostor
  50093. * @param impostor impostor to get friction from
  50094. * @returns friction value
  50095. */
  50096. getBodyFriction(impostor: PhysicsImpostor): number;
  50097. /**
  50098. * Sets friction of the impostor
  50099. * @param impostor impostor to set friction on
  50100. * @param friction friction value
  50101. */
  50102. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50103. /**
  50104. * Gets restitution of the impostor
  50105. * @param impostor impostor to get restitution from
  50106. * @returns restitution value
  50107. */
  50108. getBodyRestitution(impostor: PhysicsImpostor): number;
  50109. /**
  50110. * Sets resitution of the impostor
  50111. * @param impostor impostor to set resitution on
  50112. * @param restitution resitution value
  50113. */
  50114. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50115. /**
  50116. * Gets pressure inside the impostor
  50117. * @param impostor impostor to get pressure from
  50118. * @returns pressure value
  50119. */
  50120. getBodyPressure(impostor: PhysicsImpostor): number;
  50121. /**
  50122. * Sets pressure inside a soft body impostor
  50123. * Cloth and rope must remain 0 pressure
  50124. * @param impostor impostor to set pressure on
  50125. * @param pressure pressure value
  50126. */
  50127. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50128. /**
  50129. * Gets stiffness of the impostor
  50130. * @param impostor impostor to get stiffness from
  50131. * @returns pressure value
  50132. */
  50133. getBodyStiffness(impostor: PhysicsImpostor): number;
  50134. /**
  50135. * Sets stiffness of the impostor
  50136. * @param impostor impostor to set stiffness on
  50137. * @param stiffness stiffness value from 0 to 1
  50138. */
  50139. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50140. /**
  50141. * Gets velocityIterations of the impostor
  50142. * @param impostor impostor to get velocity iterations from
  50143. * @returns velocityIterations value
  50144. */
  50145. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50146. /**
  50147. * Sets velocityIterations of the impostor
  50148. * @param impostor impostor to set velocity iterations on
  50149. * @param velocityIterations velocityIterations value
  50150. */
  50151. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50152. /**
  50153. * Gets positionIterations of the impostor
  50154. * @param impostor impostor to get position iterations from
  50155. * @returns positionIterations value
  50156. */
  50157. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50158. /**
  50159. * Sets positionIterations of the impostor
  50160. * @param impostor impostor to set position on
  50161. * @param positionIterations positionIterations value
  50162. */
  50163. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50164. /**
  50165. * Append an anchor to a cloth object
  50166. * @param impostor is the cloth impostor to add anchor to
  50167. * @param otherImpostor is the rigid impostor to anchor to
  50168. * @param width ratio across width from 0 to 1
  50169. * @param height ratio up height from 0 to 1
  50170. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50171. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50172. */
  50173. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50174. /**
  50175. * Append an hook to a rope object
  50176. * @param impostor is the rope impostor to add hook to
  50177. * @param otherImpostor is the rigid impostor to hook to
  50178. * @param length ratio along the rope from 0 to 1
  50179. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50180. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50181. */
  50182. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50183. /**
  50184. * Sleeps the physics body and stops it from being active
  50185. * @param impostor impostor to sleep
  50186. */
  50187. sleepBody(impostor: PhysicsImpostor): void;
  50188. /**
  50189. * Activates the physics body
  50190. * @param impostor impostor to activate
  50191. */
  50192. wakeUpBody(impostor: PhysicsImpostor): void;
  50193. /**
  50194. * Updates the distance parameters of the joint
  50195. * @param joint joint to update
  50196. * @param maxDistance maximum distance of the joint
  50197. * @param minDistance minimum distance of the joint
  50198. */
  50199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50200. /**
  50201. * Sets a motor on the joint
  50202. * @param joint joint to set motor on
  50203. * @param speed speed of the motor
  50204. * @param maxForce maximum force of the motor
  50205. * @param motorIndex index of the motor
  50206. */
  50207. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50208. /**
  50209. * Sets the motors limit
  50210. * @param joint joint to set limit on
  50211. * @param upperLimit upper limit
  50212. * @param lowerLimit lower limit
  50213. */
  50214. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50215. /**
  50216. * Syncs the position and rotation of a mesh with the impostor
  50217. * @param mesh mesh to sync
  50218. * @param impostor impostor to update the mesh with
  50219. */
  50220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50221. /**
  50222. * Gets the radius of the impostor
  50223. * @param impostor impostor to get radius from
  50224. * @returns the radius
  50225. */
  50226. getRadius(impostor: PhysicsImpostor): number;
  50227. /**
  50228. * Gets the box size of the impostor
  50229. * @param impostor impostor to get box size from
  50230. * @param result the resulting box size
  50231. */
  50232. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50233. /**
  50234. * Disposes of the impostor
  50235. */
  50236. dispose(): void;
  50237. /**
  50238. * Does a raycast in the physics world
  50239. * @param from when should the ray start?
  50240. * @param to when should the ray end?
  50241. * @returns PhysicsRaycastResult
  50242. */
  50243. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50244. }
  50245. }
  50246. declare module BABYLON {
  50247. interface AbstractScene {
  50248. /**
  50249. * The list of reflection probes added to the scene
  50250. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50251. */
  50252. reflectionProbes: Array<ReflectionProbe>;
  50253. /**
  50254. * Removes the given reflection probe from this scene.
  50255. * @param toRemove The reflection probe to remove
  50256. * @returns The index of the removed reflection probe
  50257. */
  50258. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50259. /**
  50260. * Adds the given reflection probe to this scene.
  50261. * @param newReflectionProbe The reflection probe to add
  50262. */
  50263. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50264. }
  50265. /**
  50266. * Class used to generate realtime reflection / refraction cube textures
  50267. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50268. */
  50269. export class ReflectionProbe {
  50270. /** defines the name of the probe */
  50271. name: string;
  50272. private _scene;
  50273. private _renderTargetTexture;
  50274. private _projectionMatrix;
  50275. private _viewMatrix;
  50276. private _target;
  50277. private _add;
  50278. private _attachedMesh;
  50279. private _invertYAxis;
  50280. /** Gets or sets probe position (center of the cube map) */
  50281. position: Vector3;
  50282. /**
  50283. * Creates a new reflection probe
  50284. * @param name defines the name of the probe
  50285. * @param size defines the texture resolution (for each face)
  50286. * @param scene defines the hosting scene
  50287. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50288. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50289. */
  50290. constructor(
  50291. /** defines the name of the probe */
  50292. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50293. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50294. samples: number;
  50295. /** Gets or sets the refresh rate to use (on every frame by default) */
  50296. refreshRate: number;
  50297. /**
  50298. * Gets the hosting scene
  50299. * @returns a Scene
  50300. */
  50301. getScene(): Scene;
  50302. /** Gets the internal CubeTexture used to render to */
  50303. readonly cubeTexture: RenderTargetTexture;
  50304. /** Gets the list of meshes to render */
  50305. readonly renderList: Nullable<AbstractMesh[]>;
  50306. /**
  50307. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50308. * @param mesh defines the mesh to attach to
  50309. */
  50310. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50311. /**
  50312. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50313. * @param renderingGroupId The rendering group id corresponding to its index
  50314. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50315. */
  50316. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50317. /**
  50318. * Clean all associated resources
  50319. */
  50320. dispose(): void;
  50321. /**
  50322. * Converts the reflection probe information to a readable string for debug purpose.
  50323. * @param fullDetails Supports for multiple levels of logging within scene loading
  50324. * @returns the human readable reflection probe info
  50325. */
  50326. toString(fullDetails?: boolean): string;
  50327. /**
  50328. * Get the class name of the relfection probe.
  50329. * @returns "ReflectionProbe"
  50330. */
  50331. getClassName(): string;
  50332. /**
  50333. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50334. * @returns The JSON representation of the texture
  50335. */
  50336. serialize(): any;
  50337. /**
  50338. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50339. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50340. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50341. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50342. * @returns The parsed reflection probe if successful
  50343. */
  50344. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50345. }
  50346. }
  50347. declare module BABYLON {
  50348. /** @hidden */
  50349. export var _BabylonLoaderRegistered: boolean;
  50350. }
  50351. declare module BABYLON {
  50352. /**
  50353. * The Physically based simple base material of BJS.
  50354. *
  50355. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50356. * It is used as the base class for both the specGloss and metalRough conventions.
  50357. */
  50358. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50359. /**
  50360. * Number of Simultaneous lights allowed on the material.
  50361. */
  50362. maxSimultaneousLights: number;
  50363. /**
  50364. * If sets to true, disables all the lights affecting the material.
  50365. */
  50366. disableLighting: boolean;
  50367. /**
  50368. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50369. */
  50370. environmentTexture: BaseTexture;
  50371. /**
  50372. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50373. */
  50374. invertNormalMapX: boolean;
  50375. /**
  50376. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50377. */
  50378. invertNormalMapY: boolean;
  50379. /**
  50380. * Normal map used in the model.
  50381. */
  50382. normalTexture: BaseTexture;
  50383. /**
  50384. * Emissivie color used to self-illuminate the model.
  50385. */
  50386. emissiveColor: Color3;
  50387. /**
  50388. * Emissivie texture used to self-illuminate the model.
  50389. */
  50390. emissiveTexture: BaseTexture;
  50391. /**
  50392. * Occlusion Channel Strenght.
  50393. */
  50394. occlusionStrength: number;
  50395. /**
  50396. * Occlusion Texture of the material (adding extra occlusion effects).
  50397. */
  50398. occlusionTexture: BaseTexture;
  50399. /**
  50400. * Defines the alpha limits in alpha test mode.
  50401. */
  50402. alphaCutOff: number;
  50403. /**
  50404. * Gets the current double sided mode.
  50405. */
  50406. /**
  50407. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50408. */
  50409. doubleSided: boolean;
  50410. /**
  50411. * Stores the pre-calculated light information of a mesh in a texture.
  50412. */
  50413. lightmapTexture: BaseTexture;
  50414. /**
  50415. * If true, the light map contains occlusion information instead of lighting info.
  50416. */
  50417. useLightmapAsShadowmap: boolean;
  50418. /**
  50419. * Instantiates a new PBRMaterial instance.
  50420. *
  50421. * @param name The material name
  50422. * @param scene The scene the material will be use in.
  50423. */
  50424. constructor(name: string, scene: Scene);
  50425. getClassName(): string;
  50426. }
  50427. }
  50428. declare module BABYLON {
  50429. /**
  50430. * The PBR material of BJS following the metal roughness convention.
  50431. *
  50432. * This fits to the PBR convention in the GLTF definition:
  50433. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50434. */
  50435. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50436. /**
  50437. * The base color has two different interpretations depending on the value of metalness.
  50438. * When the material is a metal, the base color is the specific measured reflectance value
  50439. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50440. * of the material.
  50441. */
  50442. baseColor: Color3;
  50443. /**
  50444. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50445. * well as opacity information in the alpha channel.
  50446. */
  50447. baseTexture: BaseTexture;
  50448. /**
  50449. * Specifies the metallic scalar value of the material.
  50450. * Can also be used to scale the metalness values of the metallic texture.
  50451. */
  50452. metallic: number;
  50453. /**
  50454. * Specifies the roughness scalar value of the material.
  50455. * Can also be used to scale the roughness values of the metallic texture.
  50456. */
  50457. roughness: number;
  50458. /**
  50459. * Texture containing both the metallic value in the B channel and the
  50460. * roughness value in the G channel to keep better precision.
  50461. */
  50462. metallicRoughnessTexture: BaseTexture;
  50463. /**
  50464. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50465. *
  50466. * @param name The material name
  50467. * @param scene The scene the material will be use in.
  50468. */
  50469. constructor(name: string, scene: Scene);
  50470. /**
  50471. * Return the currrent class name of the material.
  50472. */
  50473. getClassName(): string;
  50474. /**
  50475. * Makes a duplicate of the current material.
  50476. * @param name - name to use for the new material.
  50477. */
  50478. clone(name: string): PBRMetallicRoughnessMaterial;
  50479. /**
  50480. * Serialize the material to a parsable JSON object.
  50481. */
  50482. serialize(): any;
  50483. /**
  50484. * Parses a JSON object correponding to the serialize function.
  50485. */
  50486. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50487. }
  50488. }
  50489. declare module BABYLON {
  50490. /**
  50491. * The PBR material of BJS following the specular glossiness convention.
  50492. *
  50493. * This fits to the PBR convention in the GLTF definition:
  50494. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50495. */
  50496. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50497. /**
  50498. * Specifies the diffuse color of the material.
  50499. */
  50500. diffuseColor: Color3;
  50501. /**
  50502. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50503. * channel.
  50504. */
  50505. diffuseTexture: BaseTexture;
  50506. /**
  50507. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50508. */
  50509. specularColor: Color3;
  50510. /**
  50511. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50512. */
  50513. glossiness: number;
  50514. /**
  50515. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50516. */
  50517. specularGlossinessTexture: BaseTexture;
  50518. /**
  50519. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50520. *
  50521. * @param name The material name
  50522. * @param scene The scene the material will be use in.
  50523. */
  50524. constructor(name: string, scene: Scene);
  50525. /**
  50526. * Return the currrent class name of the material.
  50527. */
  50528. getClassName(): string;
  50529. /**
  50530. * Makes a duplicate of the current material.
  50531. * @param name - name to use for the new material.
  50532. */
  50533. clone(name: string): PBRSpecularGlossinessMaterial;
  50534. /**
  50535. * Serialize the material to a parsable JSON object.
  50536. */
  50537. serialize(): any;
  50538. /**
  50539. * Parses a JSON object correponding to the serialize function.
  50540. */
  50541. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50542. }
  50543. }
  50544. declare module BABYLON {
  50545. /**
  50546. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50547. * It can help converting any input color in a desired output one. This can then be used to create effects
  50548. * from sepia, black and white to sixties or futuristic rendering...
  50549. *
  50550. * The only supported format is currently 3dl.
  50551. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50552. */
  50553. export class ColorGradingTexture extends BaseTexture {
  50554. /**
  50555. * The current texture matrix. (will always be identity in color grading texture)
  50556. */
  50557. private _textureMatrix;
  50558. /**
  50559. * The texture URL.
  50560. */
  50561. url: string;
  50562. /**
  50563. * Empty line regex stored for GC.
  50564. */
  50565. private static _noneEmptyLineRegex;
  50566. private _engine;
  50567. /**
  50568. * Instantiates a ColorGradingTexture from the following parameters.
  50569. *
  50570. * @param url The location of the color gradind data (currently only supporting 3dl)
  50571. * @param scene The scene the texture will be used in
  50572. */
  50573. constructor(url: string, scene: Scene);
  50574. /**
  50575. * Returns the texture matrix used in most of the material.
  50576. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50577. */
  50578. getTextureMatrix(): Matrix;
  50579. /**
  50580. * Occurs when the file being loaded is a .3dl LUT file.
  50581. */
  50582. private load3dlTexture;
  50583. /**
  50584. * Starts the loading process of the texture.
  50585. */
  50586. private loadTexture;
  50587. /**
  50588. * Clones the color gradind texture.
  50589. */
  50590. clone(): ColorGradingTexture;
  50591. /**
  50592. * Called during delayed load for textures.
  50593. */
  50594. delayLoad(): void;
  50595. /**
  50596. * Parses a color grading texture serialized by Babylon.
  50597. * @param parsedTexture The texture information being parsedTexture
  50598. * @param scene The scene to load the texture in
  50599. * @param rootUrl The root url of the data assets to load
  50600. * @return A color gradind texture
  50601. */
  50602. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50603. /**
  50604. * Serializes the LUT texture to json format.
  50605. */
  50606. serialize(): any;
  50607. }
  50608. }
  50609. declare module BABYLON {
  50610. /**
  50611. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50612. */
  50613. export class EquiRectangularCubeTexture extends BaseTexture {
  50614. /** The six faces of the cube. */
  50615. private static _FacesMapping;
  50616. private _noMipmap;
  50617. private _onLoad;
  50618. private _onError;
  50619. /** The size of the cubemap. */
  50620. private _size;
  50621. /** The buffer of the image. */
  50622. private _buffer;
  50623. /** The width of the input image. */
  50624. private _width;
  50625. /** The height of the input image. */
  50626. private _height;
  50627. /** The URL to the image. */
  50628. url: string;
  50629. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50630. coordinatesMode: number;
  50631. /**
  50632. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50633. * @param url The location of the image
  50634. * @param scene The scene the texture will be used in
  50635. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50636. * @param noMipmap Forces to not generate the mipmap if true
  50637. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50638. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50639. * @param onLoad — defines a callback called when texture is loaded
  50640. * @param onError — defines a callback called if there is an error
  50641. */
  50642. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50643. /**
  50644. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50645. */
  50646. private loadImage;
  50647. /**
  50648. * Convert the image buffer into a cubemap and create a CubeTexture.
  50649. */
  50650. private loadTexture;
  50651. /**
  50652. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50653. * @param buffer The ArrayBuffer that should be converted.
  50654. * @returns The buffer as Float32Array.
  50655. */
  50656. private getFloat32ArrayFromArrayBuffer;
  50657. /**
  50658. * Get the current class name of the texture useful for serialization or dynamic coding.
  50659. * @returns "EquiRectangularCubeTexture"
  50660. */
  50661. getClassName(): string;
  50662. /**
  50663. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50664. * @returns A clone of the current EquiRectangularCubeTexture.
  50665. */
  50666. clone(): EquiRectangularCubeTexture;
  50667. }
  50668. }
  50669. declare module BABYLON {
  50670. /**
  50671. * Based on jsTGALoader - Javascript loader for TGA file
  50672. * By Vincent Thibault
  50673. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50674. */
  50675. export class TGATools {
  50676. private static _TYPE_INDEXED;
  50677. private static _TYPE_RGB;
  50678. private static _TYPE_GREY;
  50679. private static _TYPE_RLE_INDEXED;
  50680. private static _TYPE_RLE_RGB;
  50681. private static _TYPE_RLE_GREY;
  50682. private static _ORIGIN_MASK;
  50683. private static _ORIGIN_SHIFT;
  50684. private static _ORIGIN_BL;
  50685. private static _ORIGIN_BR;
  50686. private static _ORIGIN_UL;
  50687. private static _ORIGIN_UR;
  50688. /**
  50689. * Gets the header of a TGA file
  50690. * @param data defines the TGA data
  50691. * @returns the header
  50692. */
  50693. static GetTGAHeader(data: Uint8Array): any;
  50694. /**
  50695. * Uploads TGA content to a Babylon Texture
  50696. * @hidden
  50697. */
  50698. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50699. /** @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;
  50700. /** @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;
  50701. /** @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;
  50702. /** @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;
  50703. /** @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;
  50704. /** @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;
  50705. }
  50706. }
  50707. declare module BABYLON {
  50708. /**
  50709. * Implementation of the TGA Texture Loader.
  50710. * @hidden
  50711. */
  50712. export class _TGATextureLoader implements IInternalTextureLoader {
  50713. /**
  50714. * Defines wether the loader supports cascade loading the different faces.
  50715. */
  50716. readonly supportCascades: boolean;
  50717. /**
  50718. * This returns if the loader support the current file information.
  50719. * @param extension defines the file extension of the file being loaded
  50720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50721. * @param fallback defines the fallback internal texture if any
  50722. * @param isBase64 defines whether the texture is encoded as a base64
  50723. * @param isBuffer defines whether the texture data are stored as a buffer
  50724. * @returns true if the loader can load the specified file
  50725. */
  50726. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50727. /**
  50728. * Transform the url before loading if required.
  50729. * @param rootUrl the url of the texture
  50730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50731. * @returns the transformed texture
  50732. */
  50733. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50734. /**
  50735. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50736. * @param rootUrl the url of the texture
  50737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50738. * @returns the fallback texture
  50739. */
  50740. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50741. /**
  50742. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50743. * @param data contains the texture data
  50744. * @param texture defines the BabylonJS internal texture
  50745. * @param createPolynomials will be true if polynomials have been requested
  50746. * @param onLoad defines the callback to trigger once the texture is ready
  50747. * @param onError defines the callback to trigger in case of error
  50748. */
  50749. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50750. /**
  50751. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50752. * @param data contains the texture data
  50753. * @param texture defines the BabylonJS internal texture
  50754. * @param callback defines the method to call once ready to upload
  50755. */
  50756. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50757. }
  50758. }
  50759. declare module BABYLON {
  50760. /**
  50761. * Info about the .basis files
  50762. */
  50763. class BasisFileInfo {
  50764. /**
  50765. * If the file has alpha
  50766. */
  50767. hasAlpha: boolean;
  50768. /**
  50769. * Info about each image of the basis file
  50770. */
  50771. images: Array<{
  50772. levels: Array<{
  50773. width: number;
  50774. height: number;
  50775. transcodedPixels: ArrayBufferView;
  50776. }>;
  50777. }>;
  50778. }
  50779. /**
  50780. * Result of transcoding a basis file
  50781. */
  50782. class TranscodeResult {
  50783. /**
  50784. * Info about the .basis file
  50785. */
  50786. fileInfo: BasisFileInfo;
  50787. /**
  50788. * Format to use when loading the file
  50789. */
  50790. format: number;
  50791. }
  50792. /**
  50793. * Configuration options for the Basis transcoder
  50794. */
  50795. export class BasisTranscodeConfiguration {
  50796. /**
  50797. * Supported compression formats used to determine the supported output format of the transcoder
  50798. */
  50799. supportedCompressionFormats?: {
  50800. /**
  50801. * etc1 compression format
  50802. */
  50803. etc1?: boolean;
  50804. /**
  50805. * s3tc compression format
  50806. */
  50807. s3tc?: boolean;
  50808. /**
  50809. * pvrtc compression format
  50810. */
  50811. pvrtc?: boolean;
  50812. /**
  50813. * etc2 compression format
  50814. */
  50815. etc2?: boolean;
  50816. };
  50817. /**
  50818. * If mipmap levels should be loaded for transcoded images (Default: true)
  50819. */
  50820. loadMipmapLevels?: boolean;
  50821. /**
  50822. * Index of a single image to load (Default: all images)
  50823. */
  50824. loadSingleImage?: number;
  50825. }
  50826. /**
  50827. * Used to load .Basis files
  50828. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50829. */
  50830. export class BasisTools {
  50831. private static _IgnoreSupportedFormats;
  50832. /**
  50833. * URL to use when loading the basis transcoder
  50834. */
  50835. static JSModuleURL: string;
  50836. /**
  50837. * URL to use when loading the wasm module for the transcoder
  50838. */
  50839. static WasmModuleURL: string;
  50840. /**
  50841. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50842. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50843. * @returns internal format corresponding to the Basis format
  50844. */
  50845. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50846. private static _WorkerPromise;
  50847. private static _Worker;
  50848. private static _actionId;
  50849. private static _CreateWorkerAsync;
  50850. /**
  50851. * Transcodes a loaded image file to compressed pixel data
  50852. * @param imageData image data to transcode
  50853. * @param config configuration options for the transcoding
  50854. * @returns a promise resulting in the transcoded image
  50855. */
  50856. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50857. /**
  50858. * Loads a texture from the transcode result
  50859. * @param texture texture load to
  50860. * @param transcodeResult the result of transcoding the basis file to load from
  50861. */
  50862. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50863. }
  50864. }
  50865. declare module BABYLON {
  50866. /**
  50867. * Loader for .basis file format
  50868. */
  50869. export class _BasisTextureLoader implements IInternalTextureLoader {
  50870. /**
  50871. * Defines whether the loader supports cascade loading the different faces.
  50872. */
  50873. readonly supportCascades: boolean;
  50874. /**
  50875. * This returns if the loader support the current file information.
  50876. * @param extension defines the file extension of the file being loaded
  50877. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50878. * @param fallback defines the fallback internal texture if any
  50879. * @param isBase64 defines whether the texture is encoded as a base64
  50880. * @param isBuffer defines whether the texture data are stored as a buffer
  50881. * @returns true if the loader can load the specified file
  50882. */
  50883. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50884. /**
  50885. * Transform the url before loading if required.
  50886. * @param rootUrl the url of the texture
  50887. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50888. * @returns the transformed texture
  50889. */
  50890. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50891. /**
  50892. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50893. * @param rootUrl the url of the texture
  50894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50895. * @returns the fallback texture
  50896. */
  50897. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50898. /**
  50899. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50900. * @param data contains the texture data
  50901. * @param texture defines the BabylonJS internal texture
  50902. * @param createPolynomials will be true if polynomials have been requested
  50903. * @param onLoad defines the callback to trigger once the texture is ready
  50904. * @param onError defines the callback to trigger in case of error
  50905. */
  50906. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50907. /**
  50908. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50909. * @param data contains the texture data
  50910. * @param texture defines the BabylonJS internal texture
  50911. * @param callback defines the method to call once ready to upload
  50912. */
  50913. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50914. }
  50915. }
  50916. declare module BABYLON {
  50917. /**
  50918. * 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.
  50919. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50920. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50921. */
  50922. export class CustomProceduralTexture extends ProceduralTexture {
  50923. private _animate;
  50924. private _time;
  50925. private _config;
  50926. private _texturePath;
  50927. /**
  50928. * Instantiates a new Custom Procedural Texture.
  50929. * 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.
  50930. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50931. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50932. * @param name Define the name of the texture
  50933. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50934. * @param size Define the size of the texture to create
  50935. * @param scene Define the scene the texture belongs to
  50936. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50937. * @param generateMipMaps Define if the texture should creates mip maps or not
  50938. */
  50939. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50940. private _loadJson;
  50941. /**
  50942. * Is the texture ready to be used ? (rendered at least once)
  50943. * @returns true if ready, otherwise, false.
  50944. */
  50945. isReady(): boolean;
  50946. /**
  50947. * Render the texture to its associated render target.
  50948. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50949. */
  50950. render(useCameraPostProcess?: boolean): void;
  50951. /**
  50952. * Update the list of dependant textures samplers in the shader.
  50953. */
  50954. updateTextures(): void;
  50955. /**
  50956. * Update the uniform values of the procedural texture in the shader.
  50957. */
  50958. updateShaderUniforms(): void;
  50959. /**
  50960. * Define if the texture animates or not.
  50961. */
  50962. animate: boolean;
  50963. }
  50964. }
  50965. declare module BABYLON {
  50966. /** @hidden */
  50967. export var noisePixelShader: {
  50968. name: string;
  50969. shader: string;
  50970. };
  50971. }
  50972. declare module BABYLON {
  50973. /**
  50974. * Class used to generate noise procedural textures
  50975. */
  50976. export class NoiseProceduralTexture extends ProceduralTexture {
  50977. private _time;
  50978. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50979. brightness: number;
  50980. /** Defines the number of octaves to process */
  50981. octaves: number;
  50982. /** Defines the level of persistence (0.8 by default) */
  50983. persistence: number;
  50984. /** Gets or sets animation speed factor (default is 1) */
  50985. animationSpeedFactor: number;
  50986. /**
  50987. * Creates a new NoiseProceduralTexture
  50988. * @param name defines the name fo the texture
  50989. * @param size defines the size of the texture (default is 256)
  50990. * @param scene defines the hosting scene
  50991. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50992. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50993. */
  50994. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50995. private _updateShaderUniforms;
  50996. protected _getDefines(): string;
  50997. /** Generate the current state of the procedural texture */
  50998. render(useCameraPostProcess?: boolean): void;
  50999. /**
  51000. * Serializes this noise procedural texture
  51001. * @returns a serialized noise procedural texture object
  51002. */
  51003. serialize(): any;
  51004. /**
  51005. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51006. * @param parsedTexture defines parsed texture data
  51007. * @param scene defines the current scene
  51008. * @param rootUrl defines the root URL containing noise procedural texture information
  51009. * @returns a parsed NoiseProceduralTexture
  51010. */
  51011. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51012. }
  51013. }
  51014. declare module BABYLON {
  51015. /**
  51016. * Raw cube texture where the raw buffers are passed in
  51017. */
  51018. export class RawCubeTexture extends CubeTexture {
  51019. /**
  51020. * Creates a cube texture where the raw buffers are passed in.
  51021. * @param scene defines the scene the texture is attached to
  51022. * @param data defines the array of data to use to create each face
  51023. * @param size defines the size of the textures
  51024. * @param format defines the format of the data
  51025. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51026. * @param generateMipMaps defines if the engine should generate the mip levels
  51027. * @param invertY defines if data must be stored with Y axis inverted
  51028. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51029. * @param compression defines the compression used (null by default)
  51030. */
  51031. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51032. /**
  51033. * Updates the raw cube texture.
  51034. * @param data defines the data to store
  51035. * @param format defines the data format
  51036. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51037. * @param invertY defines if data must be stored with Y axis inverted
  51038. * @param compression defines the compression used (null by default)
  51039. * @param level defines which level of the texture to update
  51040. */
  51041. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51042. /**
  51043. * Updates a raw cube texture with RGBD encoded data.
  51044. * @param data defines the array of data [mipmap][face] to use to create each face
  51045. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51046. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51047. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51048. * @returns a promsie that resolves when the operation is complete
  51049. */
  51050. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51051. /**
  51052. * Clones the raw cube texture.
  51053. * @return a new cube texture
  51054. */
  51055. clone(): CubeTexture;
  51056. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51057. }
  51058. }
  51059. declare module BABYLON {
  51060. /**
  51061. * Class used to store 3D textures containing user data
  51062. */
  51063. export class RawTexture3D extends Texture {
  51064. /** Gets or sets the texture format to use */
  51065. format: number;
  51066. private _engine;
  51067. /**
  51068. * Create a new RawTexture3D
  51069. * @param data defines the data of the texture
  51070. * @param width defines the width of the texture
  51071. * @param height defines the height of the texture
  51072. * @param depth defines the depth of the texture
  51073. * @param format defines the texture format to use
  51074. * @param scene defines the hosting scene
  51075. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51076. * @param invertY defines if texture must be stored with Y axis inverted
  51077. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51078. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51079. */
  51080. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51081. /** Gets or sets the texture format to use */
  51082. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51083. /**
  51084. * Update the texture with new data
  51085. * @param data defines the data to store in the texture
  51086. */
  51087. update(data: ArrayBufferView): void;
  51088. }
  51089. }
  51090. declare module BABYLON {
  51091. /**
  51092. * Creates a refraction texture used by refraction channel of the standard material.
  51093. * It is like a mirror but to see through a material.
  51094. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51095. */
  51096. export class RefractionTexture extends RenderTargetTexture {
  51097. /**
  51098. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51099. * 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.
  51100. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51101. */
  51102. refractionPlane: Plane;
  51103. /**
  51104. * Define how deep under the surface we should see.
  51105. */
  51106. depth: number;
  51107. /**
  51108. * Creates a refraction texture used by refraction channel of the standard material.
  51109. * It is like a mirror but to see through a material.
  51110. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51111. * @param name Define the texture name
  51112. * @param size Define the size of the underlying texture
  51113. * @param scene Define the scene the refraction belongs to
  51114. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51115. */
  51116. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51117. /**
  51118. * Clone the refraction texture.
  51119. * @returns the cloned texture
  51120. */
  51121. clone(): RefractionTexture;
  51122. /**
  51123. * Serialize the texture to a JSON representation you could use in Parse later on
  51124. * @returns the serialized JSON representation
  51125. */
  51126. serialize(): any;
  51127. }
  51128. }
  51129. declare module BABYLON {
  51130. /**
  51131. * Defines the options related to the creation of an HtmlElementTexture
  51132. */
  51133. export interface IHtmlElementTextureOptions {
  51134. /**
  51135. * Defines wether mip maps should be created or not.
  51136. */
  51137. generateMipMaps?: boolean;
  51138. /**
  51139. * Defines the sampling mode of the texture.
  51140. */
  51141. samplingMode?: number;
  51142. /**
  51143. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51144. */
  51145. engine: Nullable<Engine>;
  51146. /**
  51147. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51148. */
  51149. scene: Nullable<Scene>;
  51150. }
  51151. /**
  51152. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51153. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51154. * is automatically managed.
  51155. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51156. * in your application.
  51157. *
  51158. * As the update is not automatic, you need to call them manually.
  51159. */
  51160. export class HtmlElementTexture extends BaseTexture {
  51161. /**
  51162. * The texture URL.
  51163. */
  51164. element: HTMLVideoElement | HTMLCanvasElement;
  51165. private static readonly DefaultOptions;
  51166. private _textureMatrix;
  51167. private _engine;
  51168. private _isVideo;
  51169. private _generateMipMaps;
  51170. private _samplingMode;
  51171. /**
  51172. * Instantiates a HtmlElementTexture from the following parameters.
  51173. *
  51174. * @param name Defines the name of the texture
  51175. * @param element Defines the video or canvas the texture is filled with
  51176. * @param options Defines the other none mandatory texture creation options
  51177. */
  51178. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51179. private _createInternalTexture;
  51180. /**
  51181. * Returns the texture matrix used in most of the material.
  51182. */
  51183. getTextureMatrix(): Matrix;
  51184. /**
  51185. * Updates the content of the texture.
  51186. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51187. */
  51188. update(invertY?: Nullable<boolean>): void;
  51189. }
  51190. }
  51191. declare module BABYLON {
  51192. /**
  51193. * Enum used to define the target of a block
  51194. */
  51195. export enum NodeMaterialBlockTargets {
  51196. /** Vertex shader */
  51197. Vertex = 1,
  51198. /** Fragment shader */
  51199. Fragment = 2,
  51200. /** Neutral */
  51201. Neutral = 4,
  51202. /** Vertex and Fragment */
  51203. VertexAndFragment = 3
  51204. }
  51205. }
  51206. declare module BABYLON {
  51207. /**
  51208. * Defines the kind of connection point for node based material
  51209. */
  51210. export enum NodeMaterialBlockConnectionPointTypes {
  51211. /** Float */
  51212. Float = 1,
  51213. /** Int */
  51214. Int = 2,
  51215. /** Vector2 */
  51216. Vector2 = 4,
  51217. /** Vector3 */
  51218. Vector3 = 8,
  51219. /** Vector4 */
  51220. Vector4 = 16,
  51221. /** Color3 */
  51222. Color3 = 32,
  51223. /** Color4 */
  51224. Color4 = 64,
  51225. /** Matrix */
  51226. Matrix = 128,
  51227. /** Detect type based on connection */
  51228. AutoDetect = 1024,
  51229. /** Output type that will be defined by input type */
  51230. BasedOnInput = 2048
  51231. }
  51232. }
  51233. declare module BABYLON {
  51234. /**
  51235. * Root class for all node material optimizers
  51236. */
  51237. export class NodeMaterialOptimizer {
  51238. /**
  51239. * Function used to optimize a NodeMaterial graph
  51240. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51241. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51242. */
  51243. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51244. }
  51245. }
  51246. declare module BABYLON {
  51247. /**
  51248. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51249. */
  51250. export class TransformBlock extends NodeMaterialBlock {
  51251. /**
  51252. * Defines the value to use to complement W value to transform it to a Vector4
  51253. */
  51254. complementW: number;
  51255. /**
  51256. * Defines the value to use to complement z value to transform it to a Vector4
  51257. */
  51258. complementZ: number;
  51259. /**
  51260. * Creates a new TransformBlock
  51261. * @param name defines the block name
  51262. */
  51263. constructor(name: string);
  51264. /**
  51265. * Gets the current class name
  51266. * @returns the class name
  51267. */
  51268. getClassName(): string;
  51269. /**
  51270. * Gets the vector input
  51271. */
  51272. readonly vector: NodeMaterialConnectionPoint;
  51273. /**
  51274. * Gets the output component
  51275. */
  51276. readonly output: NodeMaterialConnectionPoint;
  51277. /**
  51278. * Gets the matrix transform input
  51279. */
  51280. readonly transform: NodeMaterialConnectionPoint;
  51281. protected _buildBlock(state: NodeMaterialBuildState): this;
  51282. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51283. protected _dumpPropertiesCode(): string;
  51284. }
  51285. }
  51286. declare module BABYLON {
  51287. /**
  51288. * Block used to output the vertex position
  51289. */
  51290. export class VertexOutputBlock extends NodeMaterialBlock {
  51291. /**
  51292. * Creates a new VertexOutputBlock
  51293. * @param name defines the block name
  51294. */
  51295. constructor(name: string);
  51296. /**
  51297. * Gets the current class name
  51298. * @returns the class name
  51299. */
  51300. getClassName(): string;
  51301. /**
  51302. * Gets the vector input component
  51303. */
  51304. readonly vector: NodeMaterialConnectionPoint;
  51305. protected _buildBlock(state: NodeMaterialBuildState): this;
  51306. }
  51307. }
  51308. declare module BABYLON {
  51309. /**
  51310. * Block used to output the final color
  51311. */
  51312. export class FragmentOutputBlock extends NodeMaterialBlock {
  51313. /**
  51314. * Create a new FragmentOutputBlock
  51315. * @param name defines the block name
  51316. */
  51317. constructor(name: string);
  51318. /**
  51319. * Gets the current class name
  51320. * @returns the class name
  51321. */
  51322. getClassName(): string;
  51323. /**
  51324. * Gets the rgba input component
  51325. */
  51326. readonly rgba: NodeMaterialConnectionPoint;
  51327. /**
  51328. * Gets the rgb input component
  51329. */
  51330. readonly rgb: NodeMaterialConnectionPoint;
  51331. /**
  51332. * Gets the a input component
  51333. */
  51334. readonly a: NodeMaterialConnectionPoint;
  51335. protected _buildBlock(state: NodeMaterialBuildState): this;
  51336. }
  51337. }
  51338. declare module BABYLON {
  51339. /**
  51340. * Enum used to define system values e.g. values automatically provided by the system
  51341. */
  51342. export enum NodeMaterialSystemValues {
  51343. /** World */
  51344. World = 1,
  51345. /** View */
  51346. View = 2,
  51347. /** Projection */
  51348. Projection = 3,
  51349. /** ViewProjection */
  51350. ViewProjection = 4,
  51351. /** WorldView */
  51352. WorldView = 5,
  51353. /** WorldViewProjection */
  51354. WorldViewProjection = 6,
  51355. /** CameraPosition */
  51356. CameraPosition = 7,
  51357. /** Fog Color */
  51358. FogColor = 8
  51359. }
  51360. }
  51361. declare module BABYLON {
  51362. /**
  51363. * Block used to read a reflection texture from a sampler
  51364. */
  51365. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51366. private _define3DName;
  51367. private _defineCubicName;
  51368. private _defineExplicitName;
  51369. private _defineProjectionName;
  51370. private _defineLocalCubicName;
  51371. private _defineSphericalName;
  51372. private _definePlanarName;
  51373. private _defineEquirectangularName;
  51374. private _defineMirroredEquirectangularFixedName;
  51375. private _defineEquirectangularFixedName;
  51376. private _defineSkyboxName;
  51377. private _cubeSamplerName;
  51378. private _2DSamplerName;
  51379. private _positionUVWName;
  51380. private _directionWName;
  51381. private _reflectionCoordsName;
  51382. private _reflection2DCoordsName;
  51383. private _reflectionColorName;
  51384. private _reflectionMatrixName;
  51385. /**
  51386. * Gets or sets the texture associated with the node
  51387. */
  51388. texture: Nullable<BaseTexture>;
  51389. /**
  51390. * Create a new TextureBlock
  51391. * @param name defines the block name
  51392. */
  51393. constructor(name: string);
  51394. /**
  51395. * Gets the current class name
  51396. * @returns the class name
  51397. */
  51398. getClassName(): string;
  51399. /**
  51400. * Gets the world position input component
  51401. */
  51402. readonly position: NodeMaterialConnectionPoint;
  51403. /**
  51404. * Gets the world position input component
  51405. */
  51406. readonly worldPosition: NodeMaterialConnectionPoint;
  51407. /**
  51408. * Gets the world normal input component
  51409. */
  51410. readonly worldNormal: NodeMaterialConnectionPoint;
  51411. /**
  51412. * Gets the world input component
  51413. */
  51414. readonly world: NodeMaterialConnectionPoint;
  51415. /**
  51416. * Gets the camera (or eye) position component
  51417. */
  51418. readonly cameraPosition: NodeMaterialConnectionPoint;
  51419. /**
  51420. * Gets the view input component
  51421. */
  51422. readonly view: NodeMaterialConnectionPoint;
  51423. /**
  51424. * Gets the rgb output component
  51425. */
  51426. readonly rgb: NodeMaterialConnectionPoint;
  51427. /**
  51428. * Gets the r output component
  51429. */
  51430. readonly r: NodeMaterialConnectionPoint;
  51431. /**
  51432. * Gets the g output component
  51433. */
  51434. readonly g: NodeMaterialConnectionPoint;
  51435. /**
  51436. * Gets the b output component
  51437. */
  51438. readonly b: NodeMaterialConnectionPoint;
  51439. autoConfigure(material: NodeMaterial): void;
  51440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51441. isReady(): boolean;
  51442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51443. private _injectVertexCode;
  51444. private _writeOutput;
  51445. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51446. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51447. }
  51448. }
  51449. declare module BABYLON {
  51450. /**
  51451. * Interface used to configure the node material editor
  51452. */
  51453. export interface INodeMaterialEditorOptions {
  51454. /** Define the URl to load node editor script */
  51455. editorURL?: string;
  51456. }
  51457. /** @hidden */
  51458. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51459. /** BONES */
  51460. NUM_BONE_INFLUENCERS: number;
  51461. BonesPerMesh: number;
  51462. BONETEXTURE: boolean;
  51463. /** MORPH TARGETS */
  51464. MORPHTARGETS: boolean;
  51465. MORPHTARGETS_NORMAL: boolean;
  51466. MORPHTARGETS_TANGENT: boolean;
  51467. MORPHTARGETS_UV: boolean;
  51468. NUM_MORPH_INFLUENCERS: number;
  51469. /** IMAGE PROCESSING */
  51470. IMAGEPROCESSING: boolean;
  51471. VIGNETTE: boolean;
  51472. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51473. VIGNETTEBLENDMODEOPAQUE: boolean;
  51474. TONEMAPPING: boolean;
  51475. TONEMAPPING_ACES: boolean;
  51476. CONTRAST: boolean;
  51477. EXPOSURE: boolean;
  51478. COLORCURVES: boolean;
  51479. COLORGRADING: boolean;
  51480. COLORGRADING3D: boolean;
  51481. SAMPLER3DGREENDEPTH: boolean;
  51482. SAMPLER3DBGRMAP: boolean;
  51483. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51484. /** MISC. */
  51485. BUMPDIRECTUV: number;
  51486. constructor();
  51487. setValue(name: string, value: boolean): void;
  51488. }
  51489. /**
  51490. * Class used to configure NodeMaterial
  51491. */
  51492. export interface INodeMaterialOptions {
  51493. /**
  51494. * Defines if blocks should emit comments
  51495. */
  51496. emitComments: boolean;
  51497. }
  51498. /**
  51499. * Class used to create a node based material built by assembling shader blocks
  51500. */
  51501. export class NodeMaterial extends PushMaterial {
  51502. private static _BuildIdGenerator;
  51503. private _options;
  51504. private _vertexCompilationState;
  51505. private _fragmentCompilationState;
  51506. private _sharedData;
  51507. private _buildId;
  51508. private _buildWasSuccessful;
  51509. private _cachedWorldViewMatrix;
  51510. private _cachedWorldViewProjectionMatrix;
  51511. private _optimizers;
  51512. private _animationFrame;
  51513. /** Define the URl to load node editor script */
  51514. static EditorURL: string;
  51515. private BJSNODEMATERIALEDITOR;
  51516. /** Get the inspector from bundle or global */
  51517. private _getGlobalNodeMaterialEditor;
  51518. /**
  51519. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  51520. */
  51521. ignoreAlpha: boolean;
  51522. /**
  51523. * Defines the maximum number of lights that can be used in the material
  51524. */
  51525. maxSimultaneousLights: number;
  51526. /**
  51527. * Observable raised when the material is built
  51528. */
  51529. onBuildObservable: Observable<NodeMaterial>;
  51530. /**
  51531. * Gets or sets the root nodes of the material vertex shader
  51532. */ private _vertexOutputNodes: NodeMaterialBlock[];
  51533. /**
  51534. * Gets or sets the root nodes of the material fragment (pixel) shader
  51535. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  51536. /** Gets or sets options to control the node material overall behavior */
  51537. options: INodeMaterialOptions;
  51538. /**
  51539. * Default configuration related to image processing available in the standard Material.
  51540. */
  51541. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51542. /**
  51543. * Gets the image processing configuration used either in this material.
  51544. */
  51545. /**
  51546. * Sets the Default image processing configuration used either in the this material.
  51547. *
  51548. * If sets to null, the scene one is in use.
  51549. */
  51550. imageProcessingConfiguration: ImageProcessingConfiguration;
  51551. /**
  51552. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51553. */
  51554. attachedBlocks: NodeMaterialBlock[];
  51555. /**
  51556. * Create a new node based material
  51557. * @param name defines the material name
  51558. * @param scene defines the hosting scene
  51559. * @param options defines creation option
  51560. */
  51561. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51562. /**
  51563. * Gets the current class name of the material e.g. "NodeMaterial"
  51564. * @returns the class name
  51565. */
  51566. getClassName(): string;
  51567. /**
  51568. * Keep track of the image processing observer to allow dispose and replace.
  51569. */
  51570. private _imageProcessingObserver;
  51571. /**
  51572. * Attaches a new image processing configuration to the Standard Material.
  51573. * @param configuration
  51574. */
  51575. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51576. /**
  51577. * Get a block by its name
  51578. * @param name defines the name of the block to retrieve
  51579. * @returns the required block or null if not found
  51580. */
  51581. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  51582. /**
  51583. * Get a block by its name
  51584. * @param predicate defines the predicate used to find the good candidate
  51585. * @returns the required block or null if not found
  51586. */
  51587. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  51588. /**
  51589. * Get an input block by its name
  51590. * @param predicate defines the predicate used to find the good candidate
  51591. * @returns the required input block or null if not found
  51592. */
  51593. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  51594. /**
  51595. * Gets the list of input blocks attached to this material
  51596. * @returns an array of InputBlocks
  51597. */
  51598. getInputBlocks(): InputBlock[];
  51599. /**
  51600. * Adds a new optimizer to the list of optimizers
  51601. * @param optimizer defines the optimizers to add
  51602. * @returns the current material
  51603. */
  51604. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51605. /**
  51606. * Remove an optimizer from the list of optimizers
  51607. * @param optimizer defines the optimizers to remove
  51608. * @returns the current material
  51609. */
  51610. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51611. /**
  51612. * Add a new block to the list of output nodes
  51613. * @param node defines the node to add
  51614. * @returns the current material
  51615. */
  51616. addOutputNode(node: NodeMaterialBlock): this;
  51617. /**
  51618. * Remove a block from the list of root nodes
  51619. * @param node defines the node to remove
  51620. * @returns the current material
  51621. */
  51622. removeOutputNode(node: NodeMaterialBlock): this;
  51623. private _addVertexOutputNode;
  51624. private _removeVertexOutputNode;
  51625. private _addFragmentOutputNode;
  51626. private _removeFragmentOutputNode;
  51627. /**
  51628. * Specifies if the material will require alpha blending
  51629. * @returns a boolean specifying if alpha blending is needed
  51630. */
  51631. needAlphaBlending(): boolean;
  51632. /**
  51633. * Specifies if this material should be rendered in alpha test mode
  51634. * @returns a boolean specifying if an alpha test is needed.
  51635. */
  51636. needAlphaTesting(): boolean;
  51637. private _initializeBlock;
  51638. private _resetDualBlocks;
  51639. /**
  51640. * Build the material and generates the inner effect
  51641. * @param verbose defines if the build should log activity
  51642. */
  51643. build(verbose?: boolean): void;
  51644. /**
  51645. * Runs an otpimization phase to try to improve the shader code
  51646. */
  51647. optimize(): void;
  51648. private _prepareDefinesForAttributes;
  51649. /**
  51650. * Get if the submesh is ready to be used and all its information available.
  51651. * Child classes can use it to update shaders
  51652. * @param mesh defines the mesh to check
  51653. * @param subMesh defines which submesh to check
  51654. * @param useInstances specifies that instances should be used
  51655. * @returns a boolean indicating that the submesh is ready or not
  51656. */
  51657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51658. /**
  51659. * Get a string representing the shaders built by the current node graph
  51660. */
  51661. readonly compiledShaders: string;
  51662. /**
  51663. * Binds the world matrix to the material
  51664. * @param world defines the world transformation matrix
  51665. */
  51666. bindOnlyWorldMatrix(world: Matrix): void;
  51667. /**
  51668. * Binds the submesh to this material by preparing the effect and shader to draw
  51669. * @param world defines the world transformation matrix
  51670. * @param mesh defines the mesh containing the submesh
  51671. * @param subMesh defines the submesh to bind the material to
  51672. */
  51673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51674. /**
  51675. * Gets the active textures from the material
  51676. * @returns an array of textures
  51677. */
  51678. getActiveTextures(): BaseTexture[];
  51679. /**
  51680. * Gets the list of texture blocks
  51681. * @returns an array of texture blocks
  51682. */
  51683. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  51684. /**
  51685. * Specifies if the material uses a texture
  51686. * @param texture defines the texture to check against the material
  51687. * @returns a boolean specifying if the material uses the texture
  51688. */
  51689. hasTexture(texture: BaseTexture): boolean;
  51690. /**
  51691. * Disposes the material
  51692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51694. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51695. */
  51696. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51697. /** Creates the node editor window. */
  51698. private _createNodeEditor;
  51699. /**
  51700. * Launch the node material editor
  51701. * @param config Define the configuration of the editor
  51702. * @return a promise fulfilled when the node editor is visible
  51703. */
  51704. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51705. /**
  51706. * Clear the current material
  51707. */
  51708. clear(): void;
  51709. /**
  51710. * Clear the current material and set it to a default state
  51711. */
  51712. setToDefault(): void;
  51713. /**
  51714. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  51715. * @param url defines the url to load from
  51716. * @returns a promise that will fullfil when the material is fully loaded
  51717. */
  51718. loadAsync(url: string): Promise<unknown>;
  51719. private _gatherBlocks;
  51720. /**
  51721. * Generate a string containing the code declaration required to create an equivalent of this material
  51722. * @returns a string
  51723. */
  51724. generateCode(): string;
  51725. /**
  51726. * Serializes this material in a JSON representation
  51727. * @returns the serialized material object
  51728. */
  51729. serialize(): any;
  51730. private _restoreConnections;
  51731. /**
  51732. * Clear the current graph and load a new one from a serialization object
  51733. * @param source defines the JSON representation of the material
  51734. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51735. */
  51736. loadFromSerialization(source: any, rootUrl?: string): void;
  51737. /**
  51738. * Creates a node material from parsed material data
  51739. * @param source defines the JSON representation of the material
  51740. * @param scene defines the hosting scene
  51741. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51742. * @returns a new node material
  51743. */
  51744. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51745. /**
  51746. * Creates a new node material set to default basic configuration
  51747. * @param name defines the name of the material
  51748. * @param scene defines the hosting scene
  51749. * @returns a new NodeMaterial
  51750. */
  51751. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  51752. }
  51753. }
  51754. declare module BABYLON {
  51755. /**
  51756. * Block used to read a texture from a sampler
  51757. */
  51758. export class TextureBlock extends NodeMaterialBlock {
  51759. private _defineName;
  51760. private _samplerName;
  51761. private _transformedUVName;
  51762. private _textureTransformName;
  51763. private _textureInfoName;
  51764. /**
  51765. * Gets or sets the texture associated with the node
  51766. */
  51767. texture: Nullable<Texture>;
  51768. /**
  51769. * Create a new TextureBlock
  51770. * @param name defines the block name
  51771. */
  51772. constructor(name: string);
  51773. /**
  51774. * Gets the current class name
  51775. * @returns the class name
  51776. */
  51777. getClassName(): string;
  51778. /**
  51779. * Gets the uv input component
  51780. */
  51781. readonly uv: NodeMaterialConnectionPoint;
  51782. /**
  51783. * Gets the rgba output component
  51784. */
  51785. readonly rgba: NodeMaterialConnectionPoint;
  51786. /**
  51787. * Gets the rgb output component
  51788. */
  51789. readonly rgb: NodeMaterialConnectionPoint;
  51790. /**
  51791. * Gets the r output component
  51792. */
  51793. readonly r: NodeMaterialConnectionPoint;
  51794. /**
  51795. * Gets the g output component
  51796. */
  51797. readonly g: NodeMaterialConnectionPoint;
  51798. /**
  51799. * Gets the b output component
  51800. */
  51801. readonly b: NodeMaterialConnectionPoint;
  51802. /**
  51803. * Gets the a output component
  51804. */
  51805. readonly a: NodeMaterialConnectionPoint;
  51806. readonly target: NodeMaterialBlockTargets;
  51807. autoConfigure(material: NodeMaterial): void;
  51808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51809. isReady(): boolean;
  51810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51811. private readonly _isMixed;
  51812. private _injectVertexCode;
  51813. private _writeOutput;
  51814. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51815. protected _dumpPropertiesCode(): string;
  51816. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51817. }
  51818. }
  51819. declare module BABYLON {
  51820. /**
  51821. * Class used to store shared data between 2 NodeMaterialBuildState
  51822. */
  51823. export class NodeMaterialBuildStateSharedData {
  51824. /**
  51825. * Gets the list of emitted varyings
  51826. */
  51827. temps: string[];
  51828. /**
  51829. * Gets the list of emitted varyings
  51830. */
  51831. varyings: string[];
  51832. /**
  51833. * Gets the varying declaration string
  51834. */
  51835. varyingDeclaration: string;
  51836. /**
  51837. * Input blocks
  51838. */
  51839. inputBlocks: InputBlock[];
  51840. /**
  51841. * Input blocks
  51842. */
  51843. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  51844. /**
  51845. * Bindable blocks (Blocks that need to set data to the effect)
  51846. */
  51847. bindableBlocks: NodeMaterialBlock[];
  51848. /**
  51849. * List of blocks that can provide a compilation fallback
  51850. */
  51851. blocksWithFallbacks: NodeMaterialBlock[];
  51852. /**
  51853. * List of blocks that can provide a define update
  51854. */
  51855. blocksWithDefines: NodeMaterialBlock[];
  51856. /**
  51857. * List of blocks that can provide a repeatable content
  51858. */
  51859. repeatableContentBlocks: NodeMaterialBlock[];
  51860. /**
  51861. * List of blocks that can provide a dynamic list of uniforms
  51862. */
  51863. dynamicUniformBlocks: NodeMaterialBlock[];
  51864. /**
  51865. * List of blocks that can block the isReady function for the material
  51866. */
  51867. blockingBlocks: NodeMaterialBlock[];
  51868. /**
  51869. * Gets the list of animated inputs
  51870. */
  51871. animatedInputs: InputBlock[];
  51872. /**
  51873. * Build Id used to avoid multiple recompilations
  51874. */
  51875. buildId: number;
  51876. /** List of emitted variables */
  51877. variableNames: {
  51878. [key: string]: number;
  51879. };
  51880. /** List of emitted defines */
  51881. defineNames: {
  51882. [key: string]: number;
  51883. };
  51884. /** Should emit comments? */
  51885. emitComments: boolean;
  51886. /** Emit build activity */
  51887. verbose: boolean;
  51888. /** Gets or sets the hosting scene */
  51889. scene: Scene;
  51890. /**
  51891. * Gets the compilation hints emitted at compilation time
  51892. */
  51893. hints: {
  51894. needWorldViewMatrix: boolean;
  51895. needWorldViewProjectionMatrix: boolean;
  51896. needAlphaBlending: boolean;
  51897. needAlphaTesting: boolean;
  51898. };
  51899. /**
  51900. * List of compilation checks
  51901. */
  51902. checks: {
  51903. emitVertex: boolean;
  51904. emitFragment: boolean;
  51905. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51906. };
  51907. /** Creates a new shared data */
  51908. constructor();
  51909. /**
  51910. * Emits console errors and exceptions if there is a failing check
  51911. */
  51912. emitErrors(): void;
  51913. }
  51914. }
  51915. declare module BABYLON {
  51916. /**
  51917. * Class used to store node based material build state
  51918. */
  51919. export class NodeMaterialBuildState {
  51920. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51921. supportUniformBuffers: boolean;
  51922. /**
  51923. * Gets the list of emitted attributes
  51924. */
  51925. attributes: string[];
  51926. /**
  51927. * Gets the list of emitted uniforms
  51928. */
  51929. uniforms: string[];
  51930. /**
  51931. * Gets the list of emitted uniform buffers
  51932. */
  51933. uniformBuffers: string[];
  51934. /**
  51935. * Gets the list of emitted samplers
  51936. */
  51937. samplers: string[];
  51938. /**
  51939. * Gets the list of emitted functions
  51940. */
  51941. functions: {
  51942. [key: string]: string;
  51943. };
  51944. /**
  51945. * Gets the list of emitted extensions
  51946. */
  51947. extensions: {
  51948. [key: string]: string;
  51949. };
  51950. /**
  51951. * Gets the target of the compilation state
  51952. */
  51953. target: NodeMaterialBlockTargets;
  51954. /**
  51955. * Gets the list of emitted counters
  51956. */
  51957. counters: {
  51958. [key: string]: number;
  51959. };
  51960. /**
  51961. * Shared data between multiple NodeMaterialBuildState instances
  51962. */
  51963. sharedData: NodeMaterialBuildStateSharedData;
  51964. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  51965. /** @hidden */ private _attributeDeclaration: string;
  51966. /** @hidden */ private _uniformDeclaration: string;
  51967. /** @hidden */ private _samplerDeclaration: string;
  51968. /** @hidden */ private _varyingTransfer: string;
  51969. private _repeatableContentAnchorIndex;
  51970. /** @hidden */ private _builtCompilationString: string;
  51971. /**
  51972. * Gets the emitted compilation strings
  51973. */
  51974. compilationString: string;
  51975. /**
  51976. * Finalize the compilation strings
  51977. * @param state defines the current compilation state
  51978. */
  51979. finalize(state: NodeMaterialBuildState): void;
  51980. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  51981. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  51982. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  51983. /** @hidden */ private _excludeVariableName(name: string): void;
  51984. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51985. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  51986. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  51987. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51988. replaceStrings?: {
  51989. search: RegExp;
  51990. replace: string;
  51991. }[];
  51992. repeatKey?: string;
  51993. }): string;
  51994. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51995. repeatKey?: string;
  51996. removeAttributes?: boolean;
  51997. removeUniforms?: boolean;
  51998. removeVaryings?: boolean;
  51999. removeIfDef?: boolean;
  52000. replaceStrings?: {
  52001. search: RegExp;
  52002. replace: string;
  52003. }[];
  52004. }, storeKey?: string): void;
  52005. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52006. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52007. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52008. }
  52009. }
  52010. declare module BABYLON {
  52011. /**
  52012. * Defines a block that can be used inside a node based material
  52013. */
  52014. export class NodeMaterialBlock {
  52015. private _buildId;
  52016. private _buildTarget;
  52017. private _target;
  52018. private _isFinalMerger;
  52019. private _isInput;
  52020. /** @hidden */ private _codeVariableName: string;
  52021. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52022. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52023. /** @hidden */ private _preparationId: number;
  52024. /**
  52025. * Gets or sets the name of the block
  52026. */
  52027. name: string;
  52028. /**
  52029. * Gets or sets the unique id of the node
  52030. */
  52031. uniqueId: number;
  52032. /**
  52033. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52034. */
  52035. readonly isFinalMerger: boolean;
  52036. /**
  52037. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52038. */
  52039. readonly isInput: boolean;
  52040. /**
  52041. * Gets or sets the build Id
  52042. */
  52043. buildId: number;
  52044. /**
  52045. * Gets or sets the target of the block
  52046. */
  52047. target: NodeMaterialBlockTargets;
  52048. /**
  52049. * Gets the list of input points
  52050. */
  52051. readonly inputs: NodeMaterialConnectionPoint[];
  52052. /** Gets the list of output points */
  52053. readonly outputs: NodeMaterialConnectionPoint[];
  52054. /**
  52055. * Find an input by its name
  52056. * @param name defines the name of the input to look for
  52057. * @returns the input or null if not found
  52058. */
  52059. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52060. /**
  52061. * Find an output by its name
  52062. * @param name defines the name of the outputto look for
  52063. * @returns the output or null if not found
  52064. */
  52065. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52066. /**
  52067. * Creates a new NodeMaterialBlock
  52068. * @param name defines the block name
  52069. * @param target defines the target of that block (Vertex by default)
  52070. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52071. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52072. */
  52073. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52074. /**
  52075. * Initialize the block and prepare the context for build
  52076. * @param state defines the state that will be used for the build
  52077. */
  52078. initialize(state: NodeMaterialBuildState): void;
  52079. /**
  52080. * Bind data to effect. Will only be called for blocks with isBindable === true
  52081. * @param effect defines the effect to bind data to
  52082. * @param nodeMaterial defines the hosting NodeMaterial
  52083. * @param mesh defines the mesh that will be rendered
  52084. */
  52085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52086. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52087. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52088. protected _writeFloat(value: number): string;
  52089. /**
  52090. * Gets the current class name e.g. "NodeMaterialBlock"
  52091. * @returns the class name
  52092. */
  52093. getClassName(): string;
  52094. /**
  52095. * Register a new input. Must be called inside a block constructor
  52096. * @param name defines the connection point name
  52097. * @param type defines the connection point type
  52098. * @param isOptional defines a boolean indicating that this input can be omitted
  52099. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52100. * @returns the current block
  52101. */
  52102. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52103. /**
  52104. * Register a new output. Must be called inside a block constructor
  52105. * @param name defines the connection point name
  52106. * @param type defines the connection point type
  52107. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52108. * @returns the current block
  52109. */
  52110. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52111. /**
  52112. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52113. * @param forOutput defines an optional connection point to check compatibility with
  52114. * @returns the first available input or null
  52115. */
  52116. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52117. /**
  52118. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52119. * @param forBlock defines an optional block to check compatibility with
  52120. * @returns the first available input or null
  52121. */
  52122. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52123. /**
  52124. * Gets the sibling of the given output
  52125. * @param current defines the current output
  52126. * @returns the next output in the list or null
  52127. */
  52128. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52129. /**
  52130. * Connect current block with another block
  52131. * @param other defines the block to connect with
  52132. * @param options define the various options to help pick the right connections
  52133. * @returns the current block
  52134. */
  52135. connectTo(other: NodeMaterialBlock, options?: {
  52136. input?: string;
  52137. output?: string;
  52138. outputSwizzle?: string;
  52139. }): this | undefined;
  52140. protected _buildBlock(state: NodeMaterialBuildState): void;
  52141. /**
  52142. * Add uniforms, samplers and uniform buffers at compilation time
  52143. * @param state defines the state to update
  52144. * @param nodeMaterial defines the node material requesting the update
  52145. * @param defines defines the material defines to update
  52146. */
  52147. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52148. /**
  52149. * Add potential fallbacks if shader compilation fails
  52150. * @param mesh defines the mesh to be rendered
  52151. * @param fallbacks defines the current prioritized list of fallbacks
  52152. */
  52153. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52154. /**
  52155. * Update defines for shader compilation
  52156. * @param mesh defines the mesh to be rendered
  52157. * @param nodeMaterial defines the node material requesting the update
  52158. * @param defines defines the material defines to update
  52159. * @param useInstances specifies that instances should be used
  52160. */
  52161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52162. /**
  52163. * Lets the block try to connect some inputs automatically
  52164. * @param material defines the hosting NodeMaterial
  52165. */
  52166. autoConfigure(material: NodeMaterial): void;
  52167. /**
  52168. * Function called when a block is declared as repeatable content generator
  52169. * @param vertexShaderState defines the current compilation state for the vertex shader
  52170. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52171. * @param mesh defines the mesh to be rendered
  52172. * @param defines defines the material defines to update
  52173. */
  52174. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52175. /**
  52176. * Checks if the block is ready
  52177. * @param mesh defines the mesh to be rendered
  52178. * @param nodeMaterial defines the node material requesting the update
  52179. * @param defines defines the material defines to update
  52180. * @param useInstances specifies that instances should be used
  52181. * @returns true if the block is ready
  52182. */
  52183. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52184. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52185. private _processBuild;
  52186. /**
  52187. * Compile the current node and generate the shader code
  52188. * @param state defines the current compilation state (uniforms, samplers, current string)
  52189. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52190. * @returns true if already built
  52191. */
  52192. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52193. protected _inputRename(name: string): string;
  52194. protected _outputRename(name: string): string;
  52195. protected _dumpPropertiesCode(): string;
  52196. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52197. /**
  52198. * Clone the current block to a new identical block
  52199. * @param scene defines the hosting scene
  52200. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52201. * @returns a copy of the current block
  52202. */
  52203. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52204. /**
  52205. * Serializes this block in a JSON representation
  52206. * @returns the serialized block object
  52207. */
  52208. serialize(): any;
  52209. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52210. }
  52211. }
  52212. declare module BABYLON {
  52213. /**
  52214. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52215. */
  52216. export enum NodeMaterialBlockConnectionPointMode {
  52217. /** Value is an uniform */
  52218. Uniform = 0,
  52219. /** Value is a mesh attribute */
  52220. Attribute = 1,
  52221. /** Value is a varying between vertex and fragment shaders */
  52222. Varying = 2,
  52223. /** Mode is undefined */
  52224. Undefined = 3
  52225. }
  52226. }
  52227. declare module BABYLON {
  52228. /**
  52229. * Enum defining the type of animations supported by InputBlock
  52230. */
  52231. export enum AnimatedInputBlockTypes {
  52232. /** No animation */
  52233. None = 0,
  52234. /** Time based animation. Will only work for floats */
  52235. Time = 1
  52236. }
  52237. }
  52238. declare module BABYLON {
  52239. /**
  52240. * Block used to expose an input value
  52241. */
  52242. export class InputBlock extends NodeMaterialBlock {
  52243. private _mode;
  52244. private _associatedVariableName;
  52245. private _storedValue;
  52246. private _valueCallback;
  52247. private _type;
  52248. private _animationType;
  52249. /** Gets or set a value used to limit the range of float values */
  52250. min: number;
  52251. /** Gets or set a value used to limit the range of float values */
  52252. max: number;
  52253. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  52254. matrixMode: number;
  52255. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52256. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52257. visibleInInspector: boolean;
  52258. /**
  52259. * Gets or sets the connection point type (default is float)
  52260. */
  52261. readonly type: NodeMaterialBlockConnectionPointTypes;
  52262. /**
  52263. * Creates a new InputBlock
  52264. * @param name defines the block name
  52265. * @param target defines the target of that block (Vertex by default)
  52266. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52267. */
  52268. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52269. /**
  52270. * Gets the output component
  52271. */
  52272. readonly output: NodeMaterialConnectionPoint;
  52273. /**
  52274. * Set the source of this connection point to a vertex attribute
  52275. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52276. * @returns the current connection point
  52277. */
  52278. setAsAttribute(attributeName?: string): InputBlock;
  52279. /**
  52280. * Set the source of this connection point to a system value
  52281. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  52282. * @returns the current connection point
  52283. */
  52284. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  52285. /**
  52286. * Gets or sets the value of that point.
  52287. * Please note that this value will be ignored if valueCallback is defined
  52288. */
  52289. value: any;
  52290. /**
  52291. * Gets or sets a callback used to get the value of that point.
  52292. * Please note that setting this value will force the connection point to ignore the value property
  52293. */
  52294. valueCallback: () => any;
  52295. /**
  52296. * Gets or sets the associated variable name in the shader
  52297. */
  52298. associatedVariableName: string;
  52299. /** Gets or sets the type of animation applied to the input */
  52300. animationType: AnimatedInputBlockTypes;
  52301. /**
  52302. * Gets a boolean indicating that this connection point not defined yet
  52303. */
  52304. readonly isUndefined: boolean;
  52305. /**
  52306. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52307. * In this case the connection point name must be the name of the uniform to use.
  52308. * Can only be set on inputs
  52309. */
  52310. isUniform: boolean;
  52311. /**
  52312. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52313. * In this case the connection point name must be the name of the attribute to use
  52314. * Can only be set on inputs
  52315. */
  52316. isAttribute: boolean;
  52317. /**
  52318. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52319. * Can only be set on exit points
  52320. */
  52321. isVarying: boolean;
  52322. /**
  52323. * Gets a boolean indicating that the current connection point is a system value
  52324. */
  52325. readonly isSystemValue: boolean;
  52326. /**
  52327. * Gets or sets the current well known value or null if not defined as a system value
  52328. */
  52329. systemValue: Nullable<NodeMaterialSystemValues>;
  52330. /**
  52331. * Gets the current class name
  52332. * @returns the class name
  52333. */
  52334. getClassName(): string;
  52335. /**
  52336. * Animate the input if animationType !== None
  52337. * @param scene defines the rendering scene
  52338. */
  52339. animate(scene: Scene): void;
  52340. private _emitDefine;
  52341. initialize(state: NodeMaterialBuildState): void;
  52342. /**
  52343. * Set the input block to its default value (based on its type)
  52344. */
  52345. setDefaultValue(): void;
  52346. protected _dumpPropertiesCode(): string;
  52347. private _emit;
  52348. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52349. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  52350. protected _buildBlock(state: NodeMaterialBuildState): void;
  52351. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52352. }
  52353. }
  52354. declare module BABYLON {
  52355. /**
  52356. * Defines a connection point for a block
  52357. */
  52358. export class NodeMaterialConnectionPoint {
  52359. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  52360. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52361. private _endpoints;
  52362. private _associatedVariableName;
  52363. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52364. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52365. private _type;
  52366. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  52367. /**
  52368. * Gets or sets the additional types supported byt this connection point
  52369. */
  52370. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52371. /**
  52372. * Gets or sets the associated variable name in the shader
  52373. */
  52374. associatedVariableName: string;
  52375. /**
  52376. * Gets or sets the connection point type (default is float)
  52377. */
  52378. type: NodeMaterialBlockConnectionPointTypes;
  52379. /**
  52380. * Gets or sets the connection point name
  52381. */
  52382. name: string;
  52383. /**
  52384. * Gets or sets a boolean indicating that this connection point can be omitted
  52385. */
  52386. isOptional: boolean;
  52387. /**
  52388. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52389. */
  52390. define: string;
  52391. /** Gets or sets the target of that connection point */
  52392. target: NodeMaterialBlockTargets;
  52393. /**
  52394. * Gets a boolean indicating that the current point is connected
  52395. */
  52396. readonly isConnected: boolean;
  52397. /**
  52398. * Gets a boolean indicating that the current point is connected to an input block
  52399. */
  52400. readonly isConnectedToInputBlock: boolean;
  52401. /**
  52402. * Gets a the connected input block (if any)
  52403. */
  52404. readonly connectInputBlock: Nullable<InputBlock>;
  52405. /** Get the other side of the connection (if any) */
  52406. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52407. /** Get the block that owns this connection point */
  52408. readonly ownerBlock: NodeMaterialBlock;
  52409. /** Get the block connected on the other side of this connection (if any) */
  52410. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52411. /** Get the block connected on the endpoints of this connection (if any) */
  52412. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52413. /** Gets the list of connected endpoints */
  52414. readonly endpoints: NodeMaterialConnectionPoint[];
  52415. /** Gets a boolean indicating if that output point is connected to at least one input */
  52416. readonly hasEndpoints: boolean;
  52417. /**
  52418. * Creates a new connection point
  52419. * @param name defines the connection point name
  52420. * @param ownerBlock defines the block hosting this connection point
  52421. */
  52422. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52423. /**
  52424. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52425. * @returns the class name
  52426. */
  52427. getClassName(): string;
  52428. /**
  52429. * Gets an boolean indicating if the current point can be connected to another point
  52430. * @param connectionPoint defines the other connection point
  52431. * @returns true if the connection is possible
  52432. */
  52433. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52434. /**
  52435. * Connect this point to another connection point
  52436. * @param connectionPoint defines the other connection point
  52437. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52438. * @returns the current connection point
  52439. */
  52440. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52441. /**
  52442. * Disconnect this point from one of his endpoint
  52443. * @param endpoint defines the other connection point
  52444. * @returns the current connection point
  52445. */
  52446. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52447. /**
  52448. * Serializes this point in a JSON representation
  52449. * @returns the serialized point object
  52450. */
  52451. serialize(): any;
  52452. }
  52453. }
  52454. declare module BABYLON {
  52455. /**
  52456. * Block used to add support for vertex skinning (bones)
  52457. */
  52458. export class BonesBlock extends NodeMaterialBlock {
  52459. /**
  52460. * Creates a new BonesBlock
  52461. * @param name defines the block name
  52462. */
  52463. constructor(name: string);
  52464. /**
  52465. * Initialize the block and prepare the context for build
  52466. * @param state defines the state that will be used for the build
  52467. */
  52468. initialize(state: NodeMaterialBuildState): void;
  52469. /**
  52470. * Gets the current class name
  52471. * @returns the class name
  52472. */
  52473. getClassName(): string;
  52474. /**
  52475. * Gets the matrix indices input component
  52476. */
  52477. readonly matricesIndices: NodeMaterialConnectionPoint;
  52478. /**
  52479. * Gets the matrix weights input component
  52480. */
  52481. readonly matricesWeights: NodeMaterialConnectionPoint;
  52482. /**
  52483. * Gets the extra matrix indices input component
  52484. */
  52485. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52486. /**
  52487. * Gets the extra matrix weights input component
  52488. */
  52489. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52490. /**
  52491. * Gets the world input component
  52492. */
  52493. readonly world: NodeMaterialConnectionPoint;
  52494. /**
  52495. * Gets the output component
  52496. */
  52497. readonly output: NodeMaterialConnectionPoint;
  52498. autoConfigure(material: NodeMaterial): void;
  52499. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52502. protected _buildBlock(state: NodeMaterialBuildState): this;
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. /**
  52507. * Block used to add support for instances
  52508. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52509. */
  52510. export class InstancesBlock extends NodeMaterialBlock {
  52511. /**
  52512. * Creates a new InstancesBlock
  52513. * @param name defines the block name
  52514. */
  52515. constructor(name: string);
  52516. /**
  52517. * Gets the current class name
  52518. * @returns the class name
  52519. */
  52520. getClassName(): string;
  52521. /**
  52522. * Gets the first world row input component
  52523. */
  52524. readonly world0: NodeMaterialConnectionPoint;
  52525. /**
  52526. * Gets the second world row input component
  52527. */
  52528. readonly world1: NodeMaterialConnectionPoint;
  52529. /**
  52530. * Gets the third world row input component
  52531. */
  52532. readonly world2: NodeMaterialConnectionPoint;
  52533. /**
  52534. * Gets the forth world row input component
  52535. */
  52536. readonly world3: NodeMaterialConnectionPoint;
  52537. /**
  52538. * Gets the world input component
  52539. */
  52540. readonly world: NodeMaterialConnectionPoint;
  52541. /**
  52542. * Gets the output component
  52543. */
  52544. readonly output: NodeMaterialConnectionPoint;
  52545. autoConfigure(material: NodeMaterial): void;
  52546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52547. protected _buildBlock(state: NodeMaterialBuildState): this;
  52548. }
  52549. }
  52550. declare module BABYLON {
  52551. /**
  52552. * Block used to add morph targets support to vertex shader
  52553. */
  52554. export class MorphTargetsBlock extends NodeMaterialBlock {
  52555. private _repeatableContentAnchor;
  52556. private _repeatebleContentGenerated;
  52557. /**
  52558. * Create a new MorphTargetsBlock
  52559. * @param name defines the block name
  52560. */
  52561. constructor(name: string);
  52562. /**
  52563. * Gets the current class name
  52564. * @returns the class name
  52565. */
  52566. getClassName(): string;
  52567. /**
  52568. * Gets the position input component
  52569. */
  52570. readonly position: NodeMaterialConnectionPoint;
  52571. /**
  52572. * Gets the normal input component
  52573. */
  52574. readonly normal: NodeMaterialConnectionPoint;
  52575. /**
  52576. * Gets the tangent input component
  52577. */
  52578. readonly tangent: NodeMaterialConnectionPoint;
  52579. /**
  52580. * Gets the tangent input component
  52581. */
  52582. readonly uv: NodeMaterialConnectionPoint;
  52583. /**
  52584. * Gets the position output component
  52585. */
  52586. readonly positionOutput: NodeMaterialConnectionPoint;
  52587. /**
  52588. * Gets the normal output component
  52589. */
  52590. readonly normalOutput: NodeMaterialConnectionPoint;
  52591. /**
  52592. * Gets the tangent output component
  52593. */
  52594. readonly tangentOutput: NodeMaterialConnectionPoint;
  52595. /**
  52596. * Gets the tangent output component
  52597. */
  52598. readonly uvOutput: NodeMaterialConnectionPoint;
  52599. initialize(state: NodeMaterialBuildState): void;
  52600. autoConfigure(material: NodeMaterial): void;
  52601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52602. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52603. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52604. protected _buildBlock(state: NodeMaterialBuildState): this;
  52605. }
  52606. }
  52607. declare module BABYLON {
  52608. /**
  52609. * Block used to get data information from a light
  52610. */
  52611. export class LightInformationBlock extends NodeMaterialBlock {
  52612. private _lightDataDefineName;
  52613. private _lightColorDefineName;
  52614. /**
  52615. * Gets or sets the light associated with this block
  52616. */
  52617. light: Nullable<Light>;
  52618. /**
  52619. * Creates a new LightInformationBlock
  52620. * @param name defines the block name
  52621. */
  52622. constructor(name: string);
  52623. /**
  52624. * Gets the current class name
  52625. * @returns the class name
  52626. */
  52627. getClassName(): string;
  52628. /**
  52629. * Gets the world position input component
  52630. */
  52631. readonly worldPosition: NodeMaterialConnectionPoint;
  52632. /**
  52633. * Gets the direction output component
  52634. */
  52635. readonly direction: NodeMaterialConnectionPoint;
  52636. /**
  52637. * Gets the direction output component
  52638. */
  52639. readonly color: NodeMaterialConnectionPoint;
  52640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52641. protected _buildBlock(state: NodeMaterialBuildState): this;
  52642. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52643. }
  52644. }
  52645. declare module BABYLON {
  52646. /**
  52647. * Block used to add an alpha test in the fragment shader
  52648. */
  52649. export class AlphaTestBlock extends NodeMaterialBlock {
  52650. /**
  52651. * Gets or sets the alpha value where alpha testing happens
  52652. */
  52653. alphaCutOff: number;
  52654. /**
  52655. * Create a new AlphaTestBlock
  52656. * @param name defines the block name
  52657. */
  52658. constructor(name: string);
  52659. /**
  52660. * Gets the current class name
  52661. * @returns the class name
  52662. */
  52663. getClassName(): string;
  52664. /**
  52665. * Gets the color input component
  52666. */
  52667. readonly color: NodeMaterialConnectionPoint;
  52668. /**
  52669. * Gets the alpha input component
  52670. */
  52671. readonly alpha: NodeMaterialConnectionPoint;
  52672. protected _buildBlock(state: NodeMaterialBuildState): this;
  52673. protected _dumpPropertiesCode(): string;
  52674. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52675. }
  52676. }
  52677. declare module BABYLON {
  52678. /**
  52679. * Block used to add image processing support to fragment shader
  52680. */
  52681. export class ImageProcessingBlock extends NodeMaterialBlock {
  52682. /**
  52683. * Create a new ImageProcessingBlock
  52684. * @param name defines the block name
  52685. */
  52686. constructor(name: string);
  52687. /**
  52688. * Gets the current class name
  52689. * @returns the class name
  52690. */
  52691. getClassName(): string;
  52692. /**
  52693. * Gets the color input component
  52694. */
  52695. readonly color: NodeMaterialConnectionPoint;
  52696. /**
  52697. * Gets the output component
  52698. */
  52699. readonly output: NodeMaterialConnectionPoint;
  52700. /**
  52701. * Initialize the block and prepare the context for build
  52702. * @param state defines the state that will be used for the build
  52703. */
  52704. initialize(state: NodeMaterialBuildState): void;
  52705. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52708. protected _buildBlock(state: NodeMaterialBuildState): this;
  52709. }
  52710. }
  52711. declare module BABYLON {
  52712. /**
  52713. * Block used to pertub normals based on a normal map
  52714. */
  52715. export class PerturbNormalBlock extends NodeMaterialBlock {
  52716. private _tangentSpaceParameterName;
  52717. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  52718. invertX: boolean;
  52719. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  52720. invertY: boolean;
  52721. /**
  52722. * Create a new PerturbNormalBlock
  52723. * @param name defines the block name
  52724. */
  52725. constructor(name: string);
  52726. /**
  52727. * Gets the current class name
  52728. * @returns the class name
  52729. */
  52730. getClassName(): string;
  52731. /**
  52732. * Gets the world position input component
  52733. */
  52734. readonly worldPosition: NodeMaterialConnectionPoint;
  52735. /**
  52736. * Gets the world normal input component
  52737. */
  52738. readonly worldNormal: NodeMaterialConnectionPoint;
  52739. /**
  52740. * Gets the uv input component
  52741. */
  52742. readonly uv: NodeMaterialConnectionPoint;
  52743. /**
  52744. * Gets the normal map color input component
  52745. */
  52746. readonly normalMapColor: NodeMaterialConnectionPoint;
  52747. /**
  52748. * Gets the strength input component
  52749. */
  52750. readonly strength: NodeMaterialConnectionPoint;
  52751. /**
  52752. * Gets the output component
  52753. */
  52754. readonly output: NodeMaterialConnectionPoint;
  52755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52757. autoConfigure(material: NodeMaterial): void;
  52758. protected _buildBlock(state: NodeMaterialBuildState): this;
  52759. protected _dumpPropertiesCode(): string;
  52760. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52761. }
  52762. }
  52763. declare module BABYLON {
  52764. /**
  52765. * Block used to add support for scene fog
  52766. */
  52767. export class FogBlock extends NodeMaterialBlock {
  52768. private _fogDistanceName;
  52769. private _fogParameters;
  52770. /**
  52771. * Create a new FogBlock
  52772. * @param name defines the block name
  52773. */
  52774. constructor(name: string);
  52775. /**
  52776. * Gets the current class name
  52777. * @returns the class name
  52778. */
  52779. getClassName(): string;
  52780. /**
  52781. * Gets the world position input component
  52782. */
  52783. readonly worldPosition: NodeMaterialConnectionPoint;
  52784. /**
  52785. * Gets the view input component
  52786. */
  52787. readonly view: NodeMaterialConnectionPoint;
  52788. /**
  52789. * Gets the color input component
  52790. */
  52791. readonly input: NodeMaterialConnectionPoint;
  52792. /**
  52793. * Gets the fog color input component
  52794. */
  52795. readonly fogColor: NodeMaterialConnectionPoint;
  52796. /**
  52797. * Gets the output component
  52798. */
  52799. readonly output: NodeMaterialConnectionPoint;
  52800. autoConfigure(material: NodeMaterial): void;
  52801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52803. protected _buildBlock(state: NodeMaterialBuildState): this;
  52804. }
  52805. }
  52806. declare module BABYLON {
  52807. /**
  52808. * Block used to add light in the fragment shader
  52809. */
  52810. export class LightBlock extends NodeMaterialBlock {
  52811. private _lightId;
  52812. /**
  52813. * Gets or sets the light associated with this block
  52814. */
  52815. light: Nullable<Light>;
  52816. /**
  52817. * Create a new LightBlock
  52818. * @param name defines the block name
  52819. */
  52820. constructor(name: string);
  52821. /**
  52822. * Gets the current class name
  52823. * @returns the class name
  52824. */
  52825. getClassName(): string;
  52826. /**
  52827. * Gets the world position input component
  52828. */
  52829. readonly worldPosition: NodeMaterialConnectionPoint;
  52830. /**
  52831. * Gets the world normal input component
  52832. */
  52833. readonly worldNormal: NodeMaterialConnectionPoint;
  52834. /**
  52835. * Gets the camera (or eye) position component
  52836. */
  52837. readonly cameraPosition: NodeMaterialConnectionPoint;
  52838. /**
  52839. * Gets the diffuse output component
  52840. */
  52841. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52842. /**
  52843. * Gets the specular output component
  52844. */
  52845. readonly specularOutput: NodeMaterialConnectionPoint;
  52846. autoConfigure(material: NodeMaterial): void;
  52847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52848. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52850. private _injectVertexCode;
  52851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52852. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52853. }
  52854. }
  52855. declare module BABYLON {
  52856. /**
  52857. * Block used to multiply 2 values
  52858. */
  52859. export class MultiplyBlock extends NodeMaterialBlock {
  52860. /**
  52861. * Creates a new MultiplyBlock
  52862. * @param name defines the block name
  52863. */
  52864. constructor(name: string);
  52865. /**
  52866. * Gets the current class name
  52867. * @returns the class name
  52868. */
  52869. getClassName(): string;
  52870. /**
  52871. * Gets the left operand input component
  52872. */
  52873. readonly left: NodeMaterialConnectionPoint;
  52874. /**
  52875. * Gets the right operand input component
  52876. */
  52877. readonly right: NodeMaterialConnectionPoint;
  52878. /**
  52879. * Gets the output component
  52880. */
  52881. readonly output: NodeMaterialConnectionPoint;
  52882. protected _buildBlock(state: NodeMaterialBuildState): this;
  52883. }
  52884. }
  52885. declare module BABYLON {
  52886. /**
  52887. * Block used to add 2 vectors
  52888. */
  52889. export class AddBlock extends NodeMaterialBlock {
  52890. /**
  52891. * Creates a new AddBlock
  52892. * @param name defines the block name
  52893. */
  52894. constructor(name: string);
  52895. /**
  52896. * Gets the current class name
  52897. * @returns the class name
  52898. */
  52899. getClassName(): string;
  52900. /**
  52901. * Gets the left operand input component
  52902. */
  52903. readonly left: NodeMaterialConnectionPoint;
  52904. /**
  52905. * Gets the right operand input component
  52906. */
  52907. readonly right: NodeMaterialConnectionPoint;
  52908. /**
  52909. * Gets the output component
  52910. */
  52911. readonly output: NodeMaterialConnectionPoint;
  52912. protected _buildBlock(state: NodeMaterialBuildState): this;
  52913. }
  52914. }
  52915. declare module BABYLON {
  52916. /**
  52917. * Block used to scale a vector by a float
  52918. */
  52919. export class ScaleBlock extends NodeMaterialBlock {
  52920. /**
  52921. * Creates a new ScaleBlock
  52922. * @param name defines the block name
  52923. */
  52924. constructor(name: string);
  52925. /**
  52926. * Gets the current class name
  52927. * @returns the class name
  52928. */
  52929. getClassName(): string;
  52930. /**
  52931. * Gets the input component
  52932. */
  52933. readonly input: NodeMaterialConnectionPoint;
  52934. /**
  52935. * Gets the factor input component
  52936. */
  52937. readonly factor: NodeMaterialConnectionPoint;
  52938. /**
  52939. * Gets the output component
  52940. */
  52941. readonly output: NodeMaterialConnectionPoint;
  52942. protected _buildBlock(state: NodeMaterialBuildState): this;
  52943. }
  52944. }
  52945. declare module BABYLON {
  52946. /**
  52947. * Block used to clamp a float
  52948. */
  52949. export class ClampBlock extends NodeMaterialBlock {
  52950. /** Gets or sets the minimum range */
  52951. minimum: number;
  52952. /** Gets or sets the maximum range */
  52953. maximum: number;
  52954. /**
  52955. * Creates a new ClampBlock
  52956. * @param name defines the block name
  52957. */
  52958. constructor(name: string);
  52959. /**
  52960. * Gets the current class name
  52961. * @returns the class name
  52962. */
  52963. getClassName(): string;
  52964. /**
  52965. * Gets the value input component
  52966. */
  52967. readonly value: NodeMaterialConnectionPoint;
  52968. /**
  52969. * Gets the output component
  52970. */
  52971. readonly output: NodeMaterialConnectionPoint;
  52972. protected _buildBlock(state: NodeMaterialBuildState): this;
  52973. protected _dumpPropertiesCode(): string;
  52974. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52975. }
  52976. }
  52977. declare module BABYLON {
  52978. /**
  52979. * Block used to apply a cross product between 2 vectors
  52980. */
  52981. export class CrossBlock extends NodeMaterialBlock {
  52982. /**
  52983. * Creates a new CrossBlock
  52984. * @param name defines the block name
  52985. */
  52986. constructor(name: string);
  52987. /**
  52988. * Gets the current class name
  52989. * @returns the class name
  52990. */
  52991. getClassName(): string;
  52992. /**
  52993. * Gets the left operand input component
  52994. */
  52995. readonly left: NodeMaterialConnectionPoint;
  52996. /**
  52997. * Gets the right operand input component
  52998. */
  52999. readonly right: NodeMaterialConnectionPoint;
  53000. /**
  53001. * Gets the output component
  53002. */
  53003. readonly output: NodeMaterialConnectionPoint;
  53004. protected _buildBlock(state: NodeMaterialBuildState): this;
  53005. }
  53006. }
  53007. declare module BABYLON {
  53008. /**
  53009. * Block used to apply a dot product between 2 vectors
  53010. */
  53011. export class DotBlock extends NodeMaterialBlock {
  53012. /**
  53013. * Creates a new DotBlock
  53014. * @param name defines the block name
  53015. */
  53016. constructor(name: string);
  53017. /**
  53018. * Gets the current class name
  53019. * @returns the class name
  53020. */
  53021. getClassName(): string;
  53022. /**
  53023. * Gets the left operand input component
  53024. */
  53025. readonly left: NodeMaterialConnectionPoint;
  53026. /**
  53027. * Gets the right operand input component
  53028. */
  53029. readonly right: NodeMaterialConnectionPoint;
  53030. /**
  53031. * Gets the output component
  53032. */
  53033. readonly output: NodeMaterialConnectionPoint;
  53034. protected _buildBlock(state: NodeMaterialBuildState): this;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /**
  53039. * Block used to remap a float from a range to a new one
  53040. */
  53041. export class RemapBlock extends NodeMaterialBlock {
  53042. /**
  53043. * Gets or sets the source range
  53044. */
  53045. sourceRange: Vector2;
  53046. /**
  53047. * Gets or sets the target range
  53048. */
  53049. targetRange: Vector2;
  53050. /**
  53051. * Creates a new RemapBlock
  53052. * @param name defines the block name
  53053. */
  53054. constructor(name: string);
  53055. /**
  53056. * Gets the current class name
  53057. * @returns the class name
  53058. */
  53059. getClassName(): string;
  53060. /**
  53061. * Gets the input component
  53062. */
  53063. readonly input: NodeMaterialConnectionPoint;
  53064. /**
  53065. * Gets the source min input component
  53066. */
  53067. readonly sourceMin: NodeMaterialConnectionPoint;
  53068. /**
  53069. * Gets the source max input component
  53070. */
  53071. readonly sourceMax: NodeMaterialConnectionPoint;
  53072. /**
  53073. * Gets the target min input component
  53074. */
  53075. readonly targetMin: NodeMaterialConnectionPoint;
  53076. /**
  53077. * Gets the target max input component
  53078. */
  53079. readonly targetMax: NodeMaterialConnectionPoint;
  53080. /**
  53081. * Gets the output component
  53082. */
  53083. readonly output: NodeMaterialConnectionPoint;
  53084. protected _buildBlock(state: NodeMaterialBuildState): this;
  53085. protected _dumpPropertiesCode(): string;
  53086. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53087. }
  53088. }
  53089. declare module BABYLON {
  53090. /**
  53091. * Block used to normalize a vector
  53092. */
  53093. export class NormalizeBlock extends NodeMaterialBlock {
  53094. /**
  53095. * Creates a new NormalizeBlock
  53096. * @param name defines the block name
  53097. */
  53098. constructor(name: string);
  53099. /**
  53100. * Gets the current class name
  53101. * @returns the class name
  53102. */
  53103. getClassName(): string;
  53104. /**
  53105. * Gets the input component
  53106. */
  53107. readonly input: NodeMaterialConnectionPoint;
  53108. /**
  53109. * Gets the output component
  53110. */
  53111. readonly output: NodeMaterialConnectionPoint;
  53112. protected _buildBlock(state: NodeMaterialBuildState): this;
  53113. }
  53114. }
  53115. declare module BABYLON {
  53116. /**
  53117. * Operations supported by the Trigonometry block
  53118. */
  53119. export enum TrigonometryBlockOperations {
  53120. /** Cos */
  53121. Cos = 0,
  53122. /** Sin */
  53123. Sin = 1,
  53124. /** Abs */
  53125. Abs = 2,
  53126. /** Exp */
  53127. Exp = 3,
  53128. /** Exp2 */
  53129. Exp2 = 4,
  53130. /** Round */
  53131. Round = 5,
  53132. /** Floor */
  53133. Floor = 6,
  53134. /** Ceiling */
  53135. Ceiling = 7,
  53136. /** Square root */
  53137. Sqrt = 8
  53138. }
  53139. /**
  53140. * Block used to apply trigonometry operation to floats
  53141. */
  53142. export class TrigonometryBlock extends NodeMaterialBlock {
  53143. /**
  53144. * Gets or sets the operation applied by the block
  53145. */
  53146. operation: TrigonometryBlockOperations;
  53147. /**
  53148. * Creates a new TrigonometryBlock
  53149. * @param name defines the block name
  53150. */
  53151. constructor(name: string);
  53152. /**
  53153. * Gets the current class name
  53154. * @returns the class name
  53155. */
  53156. getClassName(): string;
  53157. /**
  53158. * Gets the input component
  53159. */
  53160. readonly input: NodeMaterialConnectionPoint;
  53161. /**
  53162. * Gets the output component
  53163. */
  53164. readonly output: NodeMaterialConnectionPoint;
  53165. protected _buildBlock(state: NodeMaterialBuildState): this;
  53166. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53167. }
  53168. }
  53169. declare module BABYLON {
  53170. /**
  53171. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53172. */
  53173. export class ColorMergerBlock extends NodeMaterialBlock {
  53174. /**
  53175. * Create a new ColorMergerBlock
  53176. * @param name defines the block name
  53177. */
  53178. constructor(name: string);
  53179. /**
  53180. * Gets the current class name
  53181. * @returns the class name
  53182. */
  53183. getClassName(): string;
  53184. /**
  53185. * Gets the r component (input)
  53186. */
  53187. readonly r: NodeMaterialConnectionPoint;
  53188. /**
  53189. * Gets the g component (input)
  53190. */
  53191. readonly g: NodeMaterialConnectionPoint;
  53192. /**
  53193. * Gets the b component (input)
  53194. */
  53195. readonly b: NodeMaterialConnectionPoint;
  53196. /**
  53197. * Gets the a component (input)
  53198. */
  53199. readonly a: NodeMaterialConnectionPoint;
  53200. /**
  53201. * Gets the rgba component (output)
  53202. */
  53203. readonly rgba: NodeMaterialConnectionPoint;
  53204. /**
  53205. * Gets the rgb component (output)
  53206. */
  53207. readonly rgb: NodeMaterialConnectionPoint;
  53208. protected _buildBlock(state: NodeMaterialBuildState): this;
  53209. }
  53210. }
  53211. declare module BABYLON {
  53212. /**
  53213. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53214. */
  53215. export class VectorMergerBlock extends NodeMaterialBlock {
  53216. /**
  53217. * Create a new VectorMergerBlock
  53218. * @param name defines the block name
  53219. */
  53220. constructor(name: string);
  53221. /**
  53222. * Gets the current class name
  53223. * @returns the class name
  53224. */
  53225. getClassName(): string;
  53226. /**
  53227. * Gets the x component (input)
  53228. */
  53229. readonly x: NodeMaterialConnectionPoint;
  53230. /**
  53231. * Gets the y component (input)
  53232. */
  53233. readonly y: NodeMaterialConnectionPoint;
  53234. /**
  53235. * Gets the z component (input)
  53236. */
  53237. readonly z: NodeMaterialConnectionPoint;
  53238. /**
  53239. * Gets the w component (input)
  53240. */
  53241. readonly w: NodeMaterialConnectionPoint;
  53242. /**
  53243. * Gets the xyzw component (output)
  53244. */
  53245. readonly xyzw: NodeMaterialConnectionPoint;
  53246. /**
  53247. * Gets the xyz component (output)
  53248. */
  53249. readonly xyz: NodeMaterialConnectionPoint;
  53250. /**
  53251. * Gets the xy component (output)
  53252. */
  53253. readonly xy: NodeMaterialConnectionPoint;
  53254. protected _buildBlock(state: NodeMaterialBuildState): this;
  53255. }
  53256. }
  53257. declare module BABYLON {
  53258. /**
  53259. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53260. */
  53261. export class ColorSplitterBlock extends NodeMaterialBlock {
  53262. /**
  53263. * Create a new ColorSplitterBlock
  53264. * @param name defines the block name
  53265. */
  53266. constructor(name: string);
  53267. /**
  53268. * Gets the current class name
  53269. * @returns the class name
  53270. */
  53271. getClassName(): string;
  53272. /**
  53273. * Gets the rgba component (input)
  53274. */
  53275. readonly rgba: NodeMaterialConnectionPoint;
  53276. /**
  53277. * Gets the rgb component (input)
  53278. */
  53279. readonly rgbIn: NodeMaterialConnectionPoint;
  53280. /**
  53281. * Gets the rgb component (output)
  53282. */
  53283. readonly rgbOut: NodeMaterialConnectionPoint;
  53284. /**
  53285. * Gets the r component (output)
  53286. */
  53287. readonly r: NodeMaterialConnectionPoint;
  53288. /**
  53289. * Gets the g component (output)
  53290. */
  53291. readonly g: NodeMaterialConnectionPoint;
  53292. /**
  53293. * Gets the b component (output)
  53294. */
  53295. readonly b: NodeMaterialConnectionPoint;
  53296. /**
  53297. * Gets the a component (output)
  53298. */
  53299. readonly a: NodeMaterialConnectionPoint;
  53300. protected _inputRename(name: string): string;
  53301. protected _outputRename(name: string): string;
  53302. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53303. }
  53304. }
  53305. declare module BABYLON {
  53306. /**
  53307. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53308. */
  53309. export class VectorSplitterBlock extends NodeMaterialBlock {
  53310. /**
  53311. * Create a new VectorSplitterBlock
  53312. * @param name defines the block name
  53313. */
  53314. constructor(name: string);
  53315. /**
  53316. * Gets the current class name
  53317. * @returns the class name
  53318. */
  53319. getClassName(): string;
  53320. /**
  53321. * Gets the xyzw component (input)
  53322. */
  53323. readonly xyzw: NodeMaterialConnectionPoint;
  53324. /**
  53325. * Gets the xyz component (input)
  53326. */
  53327. readonly xyzIn: NodeMaterialConnectionPoint;
  53328. /**
  53329. * Gets the xy component (input)
  53330. */
  53331. readonly xyIn: NodeMaterialConnectionPoint;
  53332. /**
  53333. * Gets the xyz component (output)
  53334. */
  53335. readonly xyzOut: NodeMaterialConnectionPoint;
  53336. /**
  53337. * Gets the xy component (output)
  53338. */
  53339. readonly xyOut: NodeMaterialConnectionPoint;
  53340. /**
  53341. * Gets the x component (output)
  53342. */
  53343. readonly x: NodeMaterialConnectionPoint;
  53344. /**
  53345. * Gets the y component (output)
  53346. */
  53347. readonly y: NodeMaterialConnectionPoint;
  53348. /**
  53349. * Gets the z component (output)
  53350. */
  53351. readonly z: NodeMaterialConnectionPoint;
  53352. /**
  53353. * Gets the w component (output)
  53354. */
  53355. readonly w: NodeMaterialConnectionPoint;
  53356. protected _inputRename(name: string): string;
  53357. protected _outputRename(name: string): string;
  53358. protected _buildBlock(state: NodeMaterialBuildState): this;
  53359. }
  53360. }
  53361. declare module BABYLON {
  53362. /**
  53363. * Block used to lerp 2 values
  53364. */
  53365. export class LerpBlock extends NodeMaterialBlock {
  53366. /**
  53367. * Creates a new LerpBlock
  53368. * @param name defines the block name
  53369. */
  53370. constructor(name: string);
  53371. /**
  53372. * Gets the current class name
  53373. * @returns the class name
  53374. */
  53375. getClassName(): string;
  53376. /**
  53377. * Gets the left operand input component
  53378. */
  53379. readonly left: NodeMaterialConnectionPoint;
  53380. /**
  53381. * Gets the right operand input component
  53382. */
  53383. readonly right: NodeMaterialConnectionPoint;
  53384. /**
  53385. * Gets the gradient operand input component
  53386. */
  53387. readonly gradient: NodeMaterialConnectionPoint;
  53388. /**
  53389. * Gets the output component
  53390. */
  53391. readonly output: NodeMaterialConnectionPoint;
  53392. protected _buildBlock(state: NodeMaterialBuildState): this;
  53393. }
  53394. }
  53395. declare module BABYLON {
  53396. /**
  53397. * Block used to divide 2 vectors
  53398. */
  53399. export class DivideBlock extends NodeMaterialBlock {
  53400. /**
  53401. * Creates a new DivideBlock
  53402. * @param name defines the block name
  53403. */
  53404. constructor(name: string);
  53405. /**
  53406. * Gets the current class name
  53407. * @returns the class name
  53408. */
  53409. getClassName(): string;
  53410. /**
  53411. * Gets the left operand input component
  53412. */
  53413. readonly left: NodeMaterialConnectionPoint;
  53414. /**
  53415. * Gets the right operand input component
  53416. */
  53417. readonly right: NodeMaterialConnectionPoint;
  53418. /**
  53419. * Gets the output component
  53420. */
  53421. readonly output: NodeMaterialConnectionPoint;
  53422. protected _buildBlock(state: NodeMaterialBuildState): this;
  53423. }
  53424. }
  53425. declare module BABYLON {
  53426. /**
  53427. * Block used to subtract 2 vectors
  53428. */
  53429. export class SubtractBlock extends NodeMaterialBlock {
  53430. /**
  53431. * Creates a new SubtractBlock
  53432. * @param name defines the block name
  53433. */
  53434. constructor(name: string);
  53435. /**
  53436. * Gets the current class name
  53437. * @returns the class name
  53438. */
  53439. getClassName(): string;
  53440. /**
  53441. * Gets the left operand input component
  53442. */
  53443. readonly left: NodeMaterialConnectionPoint;
  53444. /**
  53445. * Gets the right operand input component
  53446. */
  53447. readonly right: NodeMaterialConnectionPoint;
  53448. /**
  53449. * Gets the output component
  53450. */
  53451. readonly output: NodeMaterialConnectionPoint;
  53452. protected _buildBlock(state: NodeMaterialBuildState): this;
  53453. }
  53454. }
  53455. declare module BABYLON {
  53456. /**
  53457. * Block used to step a value
  53458. */
  53459. export class StepBlock extends NodeMaterialBlock {
  53460. /**
  53461. * Creates a new AddBlock
  53462. * @param name defines the block name
  53463. */
  53464. constructor(name: string);
  53465. /**
  53466. * Gets the current class name
  53467. * @returns the class name
  53468. */
  53469. getClassName(): string;
  53470. /**
  53471. * Gets the value operand input component
  53472. */
  53473. readonly value: NodeMaterialConnectionPoint;
  53474. /**
  53475. * Gets the edge operand input component
  53476. */
  53477. readonly edge: NodeMaterialConnectionPoint;
  53478. /**
  53479. * Gets the output component
  53480. */
  53481. readonly output: NodeMaterialConnectionPoint;
  53482. protected _buildBlock(state: NodeMaterialBuildState): this;
  53483. }
  53484. }
  53485. declare module BABYLON {
  53486. /**
  53487. * Block used to get the opposite (1 - x) of a value
  53488. */
  53489. export class OneMinusBlock extends NodeMaterialBlock {
  53490. /**
  53491. * Creates a new OneMinusBlock
  53492. * @param name defines the block name
  53493. */
  53494. constructor(name: string);
  53495. /**
  53496. * Gets the current class name
  53497. * @returns the class name
  53498. */
  53499. getClassName(): string;
  53500. /**
  53501. * Gets the input component
  53502. */
  53503. readonly input: NodeMaterialConnectionPoint;
  53504. /**
  53505. * Gets the output component
  53506. */
  53507. readonly output: NodeMaterialConnectionPoint;
  53508. protected _buildBlock(state: NodeMaterialBuildState): this;
  53509. }
  53510. }
  53511. declare module BABYLON {
  53512. /**
  53513. * Block used to get the view direction
  53514. */
  53515. export class ViewDirectionBlock extends NodeMaterialBlock {
  53516. /**
  53517. * Creates a new ViewDirectionBlock
  53518. * @param name defines the block name
  53519. */
  53520. constructor(name: string);
  53521. /**
  53522. * Gets the current class name
  53523. * @returns the class name
  53524. */
  53525. getClassName(): string;
  53526. /**
  53527. * Gets the world position component
  53528. */
  53529. readonly worldPosition: NodeMaterialConnectionPoint;
  53530. /**
  53531. * Gets the camera position component
  53532. */
  53533. readonly cameraPosition: NodeMaterialConnectionPoint;
  53534. /**
  53535. * Gets the output component
  53536. */
  53537. readonly output: NodeMaterialConnectionPoint;
  53538. autoConfigure(material: NodeMaterial): void;
  53539. protected _buildBlock(state: NodeMaterialBuildState): this;
  53540. }
  53541. }
  53542. declare module BABYLON {
  53543. /**
  53544. * Block used to compute fresnel value
  53545. */
  53546. export class FresnelBlock extends NodeMaterialBlock {
  53547. /**
  53548. * Create a new FresnelBlock
  53549. * @param name defines the block name
  53550. */
  53551. constructor(name: string);
  53552. /**
  53553. * Gets the current class name
  53554. * @returns the class name
  53555. */
  53556. getClassName(): string;
  53557. /**
  53558. * Gets the world normal input component
  53559. */
  53560. readonly worldNormal: NodeMaterialConnectionPoint;
  53561. /**
  53562. * Gets the view direction input component
  53563. */
  53564. readonly viewDirection: NodeMaterialConnectionPoint;
  53565. /**
  53566. * Gets the bias input component
  53567. */
  53568. readonly bias: NodeMaterialConnectionPoint;
  53569. /**
  53570. * Gets the camera (or eye) position component
  53571. */
  53572. readonly power: NodeMaterialConnectionPoint;
  53573. /**
  53574. * Gets the fresnel output component
  53575. */
  53576. readonly fresnel: NodeMaterialConnectionPoint;
  53577. autoConfigure(material: NodeMaterial): void;
  53578. protected _buildBlock(state: NodeMaterialBuildState): this;
  53579. }
  53580. }
  53581. declare module BABYLON {
  53582. /**
  53583. * Block used to get the max of 2 values
  53584. */
  53585. export class MaxBlock extends NodeMaterialBlock {
  53586. /**
  53587. * Creates a new MaxBlock
  53588. * @param name defines the block name
  53589. */
  53590. constructor(name: string);
  53591. /**
  53592. * Gets the current class name
  53593. * @returns the class name
  53594. */
  53595. getClassName(): string;
  53596. /**
  53597. * Gets the left operand input component
  53598. */
  53599. readonly left: NodeMaterialConnectionPoint;
  53600. /**
  53601. * Gets the right operand input component
  53602. */
  53603. readonly right: NodeMaterialConnectionPoint;
  53604. /**
  53605. * Gets the output component
  53606. */
  53607. readonly output: NodeMaterialConnectionPoint;
  53608. protected _buildBlock(state: NodeMaterialBuildState): this;
  53609. }
  53610. }
  53611. declare module BABYLON {
  53612. /**
  53613. * Block used to get the min of 2 values
  53614. */
  53615. export class MinBlock extends NodeMaterialBlock {
  53616. /**
  53617. * Creates a new MinBlock
  53618. * @param name defines the block name
  53619. */
  53620. constructor(name: string);
  53621. /**
  53622. * Gets the current class name
  53623. * @returns the class name
  53624. */
  53625. getClassName(): string;
  53626. /**
  53627. * Gets the left operand input component
  53628. */
  53629. readonly left: NodeMaterialConnectionPoint;
  53630. /**
  53631. * Gets the right operand input component
  53632. */
  53633. readonly right: NodeMaterialConnectionPoint;
  53634. /**
  53635. * Gets the output component
  53636. */
  53637. readonly output: NodeMaterialConnectionPoint;
  53638. protected _buildBlock(state: NodeMaterialBuildState): this;
  53639. }
  53640. }
  53641. declare module BABYLON {
  53642. /**
  53643. * Block used to get the distance between 2 values
  53644. */
  53645. export class DistanceBlock extends NodeMaterialBlock {
  53646. /**
  53647. * Creates a new DistanceBlock
  53648. * @param name defines the block name
  53649. */
  53650. constructor(name: string);
  53651. /**
  53652. * Gets the current class name
  53653. * @returns the class name
  53654. */
  53655. getClassName(): string;
  53656. /**
  53657. * Gets the left operand input component
  53658. */
  53659. readonly left: NodeMaterialConnectionPoint;
  53660. /**
  53661. * Gets the right operand input component
  53662. */
  53663. readonly right: NodeMaterialConnectionPoint;
  53664. /**
  53665. * Gets the output component
  53666. */
  53667. readonly output: NodeMaterialConnectionPoint;
  53668. protected _buildBlock(state: NodeMaterialBuildState): this;
  53669. }
  53670. }
  53671. declare module BABYLON {
  53672. /**
  53673. * Block used to get the length of a vector
  53674. */
  53675. export class LengthBlock extends NodeMaterialBlock {
  53676. /**
  53677. * Creates a new LengthBlock
  53678. * @param name defines the block name
  53679. */
  53680. constructor(name: string);
  53681. /**
  53682. * Gets the current class name
  53683. * @returns the class name
  53684. */
  53685. getClassName(): string;
  53686. /**
  53687. * Gets the value input component
  53688. */
  53689. readonly value: NodeMaterialConnectionPoint;
  53690. /**
  53691. * Gets the output component
  53692. */
  53693. readonly output: NodeMaterialConnectionPoint;
  53694. protected _buildBlock(state: NodeMaterialBuildState): this;
  53695. }
  53696. }
  53697. declare module BABYLON {
  53698. /**
  53699. * Block used to get negative version of a value (i.e. x * -1)
  53700. */
  53701. export class NegateBlock extends NodeMaterialBlock {
  53702. /**
  53703. * Creates a new NegateBlock
  53704. * @param name defines the block name
  53705. */
  53706. constructor(name: string);
  53707. /**
  53708. * Gets the current class name
  53709. * @returns the class name
  53710. */
  53711. getClassName(): string;
  53712. /**
  53713. * Gets the value input component
  53714. */
  53715. readonly value: NodeMaterialConnectionPoint;
  53716. /**
  53717. * Gets the output component
  53718. */
  53719. readonly output: NodeMaterialConnectionPoint;
  53720. protected _buildBlock(state: NodeMaterialBuildState): this;
  53721. }
  53722. }
  53723. declare module BABYLON {
  53724. /**
  53725. * Block used to get the value of the first parameter raised to the power of the second
  53726. */
  53727. export class PowBlock extends NodeMaterialBlock {
  53728. /**
  53729. * Creates a new PowBlock
  53730. * @param name defines the block name
  53731. */
  53732. constructor(name: string);
  53733. /**
  53734. * Gets the current class name
  53735. * @returns the class name
  53736. */
  53737. getClassName(): string;
  53738. /**
  53739. * Gets the value operand input component
  53740. */
  53741. readonly value: NodeMaterialConnectionPoint;
  53742. /**
  53743. * Gets the power operand input component
  53744. */
  53745. readonly power: NodeMaterialConnectionPoint;
  53746. /**
  53747. * Gets the output component
  53748. */
  53749. readonly output: NodeMaterialConnectionPoint;
  53750. protected _buildBlock(state: NodeMaterialBuildState): this;
  53751. }
  53752. }
  53753. declare module BABYLON {
  53754. /**
  53755. * Effect Render Options
  53756. */
  53757. export interface IEffectRendererOptions {
  53758. /**
  53759. * Defines the vertices positions.
  53760. */
  53761. positions?: number[];
  53762. /**
  53763. * Defines the indices.
  53764. */
  53765. indices?: number[];
  53766. }
  53767. /**
  53768. * Helper class to render one or more effects
  53769. */
  53770. export class EffectRenderer {
  53771. private engine;
  53772. private static _DefaultOptions;
  53773. private _vertexBuffers;
  53774. private _indexBuffer;
  53775. private _ringBufferIndex;
  53776. private _ringScreenBuffer;
  53777. private _fullscreenViewport;
  53778. private _getNextFrameBuffer;
  53779. /**
  53780. * Creates an effect renderer
  53781. * @param engine the engine to use for rendering
  53782. * @param options defines the options of the effect renderer
  53783. */
  53784. constructor(engine: Engine, options?: IEffectRendererOptions);
  53785. /**
  53786. * Sets the current viewport in normalized coordinates 0-1
  53787. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53788. */
  53789. setViewport(viewport?: Viewport): void;
  53790. /**
  53791. * Binds the embedded attributes buffer to the effect.
  53792. * @param effect Defines the effect to bind the attributes for
  53793. */
  53794. bindBuffers(effect: Effect): void;
  53795. /**
  53796. * Sets the current effect wrapper to use during draw.
  53797. * The effect needs to be ready before calling this api.
  53798. * This also sets the default full screen position attribute.
  53799. * @param effectWrapper Defines the effect to draw with
  53800. */
  53801. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53802. /**
  53803. * Draws a full screen quad.
  53804. */
  53805. draw(): void;
  53806. /**
  53807. * renders one or more effects to a specified texture
  53808. * @param effectWrappers list of effects to renderer
  53809. * @param outputTexture texture to draw to, if null it will render to the screen
  53810. */
  53811. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53812. /**
  53813. * Disposes of the effect renderer
  53814. */
  53815. dispose(): void;
  53816. }
  53817. /**
  53818. * Options to create an EffectWrapper
  53819. */
  53820. interface EffectWrapperCreationOptions {
  53821. /**
  53822. * Engine to use to create the effect
  53823. */
  53824. engine: Engine;
  53825. /**
  53826. * Fragment shader for the effect
  53827. */
  53828. fragmentShader: string;
  53829. /**
  53830. * Vertex shader for the effect
  53831. */
  53832. vertexShader?: string;
  53833. /**
  53834. * Attributes to use in the shader
  53835. */
  53836. attributeNames?: Array<string>;
  53837. /**
  53838. * Uniforms to use in the shader
  53839. */
  53840. uniformNames?: Array<string>;
  53841. /**
  53842. * Texture sampler names to use in the shader
  53843. */
  53844. samplerNames?: Array<string>;
  53845. /**
  53846. * The friendly name of the effect displayed in Spector.
  53847. */
  53848. name?: string;
  53849. }
  53850. /**
  53851. * Wraps an effect to be used for rendering
  53852. */
  53853. export class EffectWrapper {
  53854. /**
  53855. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53856. */
  53857. onApplyObservable: Observable<{}>;
  53858. /**
  53859. * The underlying effect
  53860. */
  53861. effect: Effect;
  53862. /**
  53863. * Creates an effect to be renderer
  53864. * @param creationOptions options to create the effect
  53865. */
  53866. constructor(creationOptions: EffectWrapperCreationOptions);
  53867. /**
  53868. * Disposes of the effect wrapper
  53869. */
  53870. dispose(): void;
  53871. }
  53872. }
  53873. declare module BABYLON {
  53874. /**
  53875. * Helper class to push actions to a pool of workers.
  53876. */
  53877. export class WorkerPool implements IDisposable {
  53878. private _workerInfos;
  53879. private _pendingActions;
  53880. /**
  53881. * Constructor
  53882. * @param workers Array of workers to use for actions
  53883. */
  53884. constructor(workers: Array<Worker>);
  53885. /**
  53886. * Terminates all workers and clears any pending actions.
  53887. */
  53888. dispose(): void;
  53889. /**
  53890. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53891. * pended until a worker has completed its action.
  53892. * @param action The action to perform. Call onComplete when the action is complete.
  53893. */
  53894. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53895. private _execute;
  53896. }
  53897. }
  53898. declare module BABYLON {
  53899. /**
  53900. * Configuration for Draco compression
  53901. */
  53902. export interface IDracoCompressionConfiguration {
  53903. /**
  53904. * Configuration for the decoder.
  53905. */
  53906. decoder: {
  53907. /**
  53908. * The url to the WebAssembly module.
  53909. */
  53910. wasmUrl?: string;
  53911. /**
  53912. * The url to the WebAssembly binary.
  53913. */
  53914. wasmBinaryUrl?: string;
  53915. /**
  53916. * The url to the fallback JavaScript module.
  53917. */
  53918. fallbackUrl?: string;
  53919. };
  53920. }
  53921. /**
  53922. * Draco compression (https://google.github.io/draco/)
  53923. *
  53924. * This class wraps the Draco module.
  53925. *
  53926. * **Encoder**
  53927. *
  53928. * The encoder is not currently implemented.
  53929. *
  53930. * **Decoder**
  53931. *
  53932. * 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.
  53933. *
  53934. * To update the configuration, use the following code:
  53935. * ```javascript
  53936. * DracoCompression.Configuration = {
  53937. * decoder: {
  53938. * wasmUrl: "<url to the WebAssembly library>",
  53939. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53940. * fallbackUrl: "<url to the fallback JavaScript library>",
  53941. * }
  53942. * };
  53943. * ```
  53944. *
  53945. * 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.
  53946. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53947. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53948. *
  53949. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53950. * ```javascript
  53951. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53952. * ```
  53953. *
  53954. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53955. */
  53956. export class DracoCompression implements IDisposable {
  53957. private _workerPoolPromise?;
  53958. private _decoderModulePromise?;
  53959. /**
  53960. * The configuration. Defaults to the following urls:
  53961. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53962. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53963. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53964. */
  53965. static Configuration: IDracoCompressionConfiguration;
  53966. /**
  53967. * Returns true if the decoder configuration is available.
  53968. */
  53969. static readonly DecoderAvailable: boolean;
  53970. /**
  53971. * Default number of workers to create when creating the draco compression object.
  53972. */
  53973. static DefaultNumWorkers: number;
  53974. private static GetDefaultNumWorkers;
  53975. private static _Default;
  53976. /**
  53977. * Default instance for the draco compression object.
  53978. */
  53979. static readonly Default: DracoCompression;
  53980. /**
  53981. * Constructor
  53982. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53983. */
  53984. constructor(numWorkers?: number);
  53985. /**
  53986. * Stop all async operations and release resources.
  53987. */
  53988. dispose(): void;
  53989. /**
  53990. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53991. * @returns a promise that resolves when ready
  53992. */
  53993. whenReadyAsync(): Promise<void>;
  53994. /**
  53995. * Decode Draco compressed mesh data to vertex data.
  53996. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53997. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53998. * @returns A promise that resolves with the decoded vertex data
  53999. */
  54000. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54001. [kind: string]: number;
  54002. }): Promise<VertexData>;
  54003. }
  54004. }
  54005. declare module BABYLON {
  54006. /**
  54007. * Class for building Constructive Solid Geometry
  54008. */
  54009. export class CSG {
  54010. private polygons;
  54011. /**
  54012. * The world matrix
  54013. */
  54014. matrix: Matrix;
  54015. /**
  54016. * Stores the position
  54017. */
  54018. position: Vector3;
  54019. /**
  54020. * Stores the rotation
  54021. */
  54022. rotation: Vector3;
  54023. /**
  54024. * Stores the rotation quaternion
  54025. */
  54026. rotationQuaternion: Nullable<Quaternion>;
  54027. /**
  54028. * Stores the scaling vector
  54029. */
  54030. scaling: Vector3;
  54031. /**
  54032. * Convert the Mesh to CSG
  54033. * @param mesh The Mesh to convert to CSG
  54034. * @returns A new CSG from the Mesh
  54035. */
  54036. static FromMesh(mesh: Mesh): CSG;
  54037. /**
  54038. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54039. * @param polygons Polygons used to construct a CSG solid
  54040. */
  54041. private static FromPolygons;
  54042. /**
  54043. * Clones, or makes a deep copy, of the CSG
  54044. * @returns A new CSG
  54045. */
  54046. clone(): CSG;
  54047. /**
  54048. * Unions this CSG with another CSG
  54049. * @param csg The CSG to union against this CSG
  54050. * @returns The unioned CSG
  54051. */
  54052. union(csg: CSG): CSG;
  54053. /**
  54054. * Unions this CSG with another CSG in place
  54055. * @param csg The CSG to union against this CSG
  54056. */
  54057. unionInPlace(csg: CSG): void;
  54058. /**
  54059. * Subtracts this CSG with another CSG
  54060. * @param csg The CSG to subtract against this CSG
  54061. * @returns A new CSG
  54062. */
  54063. subtract(csg: CSG): CSG;
  54064. /**
  54065. * Subtracts this CSG with another CSG in place
  54066. * @param csg The CSG to subtact against this CSG
  54067. */
  54068. subtractInPlace(csg: CSG): void;
  54069. /**
  54070. * Intersect this CSG with another CSG
  54071. * @param csg The CSG to intersect against this CSG
  54072. * @returns A new CSG
  54073. */
  54074. intersect(csg: CSG): CSG;
  54075. /**
  54076. * Intersects this CSG with another CSG in place
  54077. * @param csg The CSG to intersect against this CSG
  54078. */
  54079. intersectInPlace(csg: CSG): void;
  54080. /**
  54081. * Return a new CSG solid with solid and empty space switched. This solid is
  54082. * not modified.
  54083. * @returns A new CSG solid with solid and empty space switched
  54084. */
  54085. inverse(): CSG;
  54086. /**
  54087. * Inverses the CSG in place
  54088. */
  54089. inverseInPlace(): void;
  54090. /**
  54091. * This is used to keep meshes transformations so they can be restored
  54092. * when we build back a Babylon Mesh
  54093. * NB : All CSG operations are performed in world coordinates
  54094. * @param csg The CSG to copy the transform attributes from
  54095. * @returns This CSG
  54096. */
  54097. copyTransformAttributes(csg: CSG): CSG;
  54098. /**
  54099. * Build Raw mesh from CSG
  54100. * Coordinates here are in world space
  54101. * @param name The name of the mesh geometry
  54102. * @param scene The Scene
  54103. * @param keepSubMeshes Specifies if the submeshes should be kept
  54104. * @returns A new Mesh
  54105. */
  54106. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54107. /**
  54108. * Build Mesh from CSG taking material and transforms into account
  54109. * @param name The name of the Mesh
  54110. * @param material The material of the Mesh
  54111. * @param scene The Scene
  54112. * @param keepSubMeshes Specifies if submeshes should be kept
  54113. * @returns The new Mesh
  54114. */
  54115. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54116. }
  54117. }
  54118. declare module BABYLON {
  54119. /**
  54120. * Class used to create a trail following a mesh
  54121. */
  54122. export class TrailMesh extends Mesh {
  54123. private _generator;
  54124. private _autoStart;
  54125. private _running;
  54126. private _diameter;
  54127. private _length;
  54128. private _sectionPolygonPointsCount;
  54129. private _sectionVectors;
  54130. private _sectionNormalVectors;
  54131. private _beforeRenderObserver;
  54132. /**
  54133. * @constructor
  54134. * @param name The value used by scene.getMeshByName() to do a lookup.
  54135. * @param generator The mesh to generate a trail.
  54136. * @param scene The scene to add this mesh to.
  54137. * @param diameter Diameter of trailing mesh. Default is 1.
  54138. * @param length Length of trailing mesh. Default is 60.
  54139. * @param autoStart Automatically start trailing mesh. Default true.
  54140. */
  54141. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54142. /**
  54143. * "TrailMesh"
  54144. * @returns "TrailMesh"
  54145. */
  54146. getClassName(): string;
  54147. private _createMesh;
  54148. /**
  54149. * Start trailing mesh.
  54150. */
  54151. start(): void;
  54152. /**
  54153. * Stop trailing mesh.
  54154. */
  54155. stop(): void;
  54156. /**
  54157. * Update trailing mesh geometry.
  54158. */
  54159. update(): void;
  54160. /**
  54161. * Returns a new TrailMesh object.
  54162. * @param name is a string, the name given to the new mesh
  54163. * @param newGenerator use new generator object for cloned trail mesh
  54164. * @returns a new mesh
  54165. */
  54166. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54167. /**
  54168. * Serializes this trail mesh
  54169. * @param serializationObject object to write serialization to
  54170. */
  54171. serialize(serializationObject: any): void;
  54172. /**
  54173. * Parses a serialized trail mesh
  54174. * @param parsedMesh the serialized mesh
  54175. * @param scene the scene to create the trail mesh in
  54176. * @returns the created trail mesh
  54177. */
  54178. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54179. }
  54180. }
  54181. declare module BABYLON {
  54182. /**
  54183. * Class containing static functions to help procedurally build meshes
  54184. */
  54185. export class TiledBoxBuilder {
  54186. /**
  54187. * Creates a box mesh
  54188. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  54189. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54191. * * 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
  54192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54193. * @param name defines the name of the mesh
  54194. * @param options defines the options used to create the mesh
  54195. * @param scene defines the hosting scene
  54196. * @returns the box mesh
  54197. */
  54198. static CreateTiledBox(name: string, options: {
  54199. pattern?: number;
  54200. width?: number;
  54201. height?: number;
  54202. depth?: number;
  54203. tileSize?: number;
  54204. tileWidth?: number;
  54205. tileHeight?: number;
  54206. alignHorizontal?: number;
  54207. alignVertical?: number;
  54208. faceUV?: Vector4[];
  54209. faceColors?: Color4[];
  54210. sideOrientation?: number;
  54211. updatable?: boolean;
  54212. }, scene?: Nullable<Scene>): Mesh;
  54213. }
  54214. }
  54215. declare module BABYLON {
  54216. /**
  54217. * Class containing static functions to help procedurally build meshes
  54218. */
  54219. export class TorusKnotBuilder {
  54220. /**
  54221. * Creates a torus knot mesh
  54222. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54223. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54224. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54225. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54227. * * 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
  54228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54229. * @param name defines the name of the mesh
  54230. * @param options defines the options used to create the mesh
  54231. * @param scene defines the hosting scene
  54232. * @returns the torus knot mesh
  54233. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54234. */
  54235. static CreateTorusKnot(name: string, options: {
  54236. radius?: number;
  54237. tube?: number;
  54238. radialSegments?: number;
  54239. tubularSegments?: number;
  54240. p?: number;
  54241. q?: number;
  54242. updatable?: boolean;
  54243. sideOrientation?: number;
  54244. frontUVs?: Vector4;
  54245. backUVs?: Vector4;
  54246. }, scene: any): Mesh;
  54247. }
  54248. }
  54249. declare module BABYLON {
  54250. /**
  54251. * Polygon
  54252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54253. */
  54254. export class Polygon {
  54255. /**
  54256. * Creates a rectangle
  54257. * @param xmin bottom X coord
  54258. * @param ymin bottom Y coord
  54259. * @param xmax top X coord
  54260. * @param ymax top Y coord
  54261. * @returns points that make the resulting rectation
  54262. */
  54263. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54264. /**
  54265. * Creates a circle
  54266. * @param radius radius of circle
  54267. * @param cx scale in x
  54268. * @param cy scale in y
  54269. * @param numberOfSides number of sides that make up the circle
  54270. * @returns points that make the resulting circle
  54271. */
  54272. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54273. /**
  54274. * Creates a polygon from input string
  54275. * @param input Input polygon data
  54276. * @returns the parsed points
  54277. */
  54278. static Parse(input: string): Vector2[];
  54279. /**
  54280. * Starts building a polygon from x and y coordinates
  54281. * @param x x coordinate
  54282. * @param y y coordinate
  54283. * @returns the started path2
  54284. */
  54285. static StartingAt(x: number, y: number): Path2;
  54286. }
  54287. /**
  54288. * Builds a polygon
  54289. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54290. */
  54291. export class PolygonMeshBuilder {
  54292. private _points;
  54293. private _outlinepoints;
  54294. private _holes;
  54295. private _name;
  54296. private _scene;
  54297. private _epoints;
  54298. private _eholes;
  54299. private _addToepoint;
  54300. /**
  54301. * Babylon reference to the earcut plugin.
  54302. */
  54303. bjsEarcut: any;
  54304. /**
  54305. * Creates a PolygonMeshBuilder
  54306. * @param name name of the builder
  54307. * @param contours Path of the polygon
  54308. * @param scene scene to add to when creating the mesh
  54309. * @param earcutInjection can be used to inject your own earcut reference
  54310. */
  54311. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54312. /**
  54313. * Adds a whole within the polygon
  54314. * @param hole Array of points defining the hole
  54315. * @returns this
  54316. */
  54317. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54318. /**
  54319. * Creates the polygon
  54320. * @param updatable If the mesh should be updatable
  54321. * @param depth The depth of the mesh created
  54322. * @returns the created mesh
  54323. */
  54324. build(updatable?: boolean, depth?: number): Mesh;
  54325. /**
  54326. * Creates the polygon
  54327. * @param depth The depth of the mesh created
  54328. * @returns the created VertexData
  54329. */
  54330. buildVertexData(depth?: number): VertexData;
  54331. /**
  54332. * Adds a side to the polygon
  54333. * @param positions points that make the polygon
  54334. * @param normals normals of the polygon
  54335. * @param uvs uvs of the polygon
  54336. * @param indices indices of the polygon
  54337. * @param bounds bounds of the polygon
  54338. * @param points points of the polygon
  54339. * @param depth depth of the polygon
  54340. * @param flip flip of the polygon
  54341. */
  54342. private addSide;
  54343. }
  54344. }
  54345. declare module BABYLON {
  54346. /**
  54347. * Class containing static functions to help procedurally build meshes
  54348. */
  54349. export class PolygonBuilder {
  54350. /**
  54351. * Creates a polygon mesh
  54352. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54353. * * 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
  54354. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54356. * * 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)
  54357. * * Remember you can only change the shape positions, not their number when updating a polygon
  54358. * @param name defines the name of the mesh
  54359. * @param options defines the options used to create the mesh
  54360. * @param scene defines the hosting scene
  54361. * @param earcutInjection can be used to inject your own earcut reference
  54362. * @returns the polygon mesh
  54363. */
  54364. static CreatePolygon(name: string, options: {
  54365. shape: Vector3[];
  54366. holes?: Vector3[][];
  54367. depth?: number;
  54368. faceUV?: Vector4[];
  54369. faceColors?: Color4[];
  54370. updatable?: boolean;
  54371. sideOrientation?: number;
  54372. frontUVs?: Vector4;
  54373. backUVs?: Vector4;
  54374. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54375. /**
  54376. * Creates an extruded polygon mesh, with depth in the Y direction.
  54377. * * 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)
  54378. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54379. * @param name defines the name of the mesh
  54380. * @param options defines the options used to create the mesh
  54381. * @param scene defines the hosting scene
  54382. * @param earcutInjection can be used to inject your own earcut reference
  54383. * @returns the polygon mesh
  54384. */
  54385. static ExtrudePolygon(name: string, options: {
  54386. shape: Vector3[];
  54387. holes?: Vector3[][];
  54388. depth?: number;
  54389. faceUV?: Vector4[];
  54390. faceColors?: Color4[];
  54391. updatable?: boolean;
  54392. sideOrientation?: number;
  54393. frontUVs?: Vector4;
  54394. backUVs?: Vector4;
  54395. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54396. }
  54397. }
  54398. declare module BABYLON {
  54399. /**
  54400. * Class containing static functions to help procedurally build meshes
  54401. */
  54402. export class LatheBuilder {
  54403. /**
  54404. * Creates lathe mesh.
  54405. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54406. * * 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
  54407. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54408. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54409. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54410. * * 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
  54411. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54412. * * 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
  54413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54414. * * 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
  54415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54417. * @param name defines the name of the mesh
  54418. * @param options defines the options used to create the mesh
  54419. * @param scene defines the hosting scene
  54420. * @returns the lathe mesh
  54421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54422. */
  54423. static CreateLathe(name: string, options: {
  54424. shape: Vector3[];
  54425. radius?: number;
  54426. tessellation?: number;
  54427. clip?: number;
  54428. arc?: number;
  54429. closed?: boolean;
  54430. updatable?: boolean;
  54431. sideOrientation?: number;
  54432. frontUVs?: Vector4;
  54433. backUVs?: Vector4;
  54434. cap?: number;
  54435. invertUV?: boolean;
  54436. }, scene?: Nullable<Scene>): Mesh;
  54437. }
  54438. }
  54439. declare module BABYLON {
  54440. /**
  54441. * Class containing static functions to help procedurally build meshes
  54442. */
  54443. export class TiledPlaneBuilder {
  54444. /**
  54445. * Creates a tiled plane mesh
  54446. * * The parameter `pattern` will, depending on value, do nothing or
  54447. * * * flip (reflect about central vertical) alternate tiles across and up
  54448. * * * flip every tile on alternate rows
  54449. * * * rotate (180 degs) alternate tiles across and up
  54450. * * * rotate every tile on alternate rows
  54451. * * * flip and rotate alternate tiles across and up
  54452. * * * flip and rotate every tile on alternate rows
  54453. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54454. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54455. * * 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
  54456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54457. * * 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)
  54458. * * 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)
  54459. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54460. * @param name defines the name of the mesh
  54461. * @param options defines the options used to create the mesh
  54462. * @param scene defines the hosting scene
  54463. * @returns the box mesh
  54464. */
  54465. static CreateTiledPlane(name: string, options: {
  54466. pattern?: number;
  54467. tileSize?: number;
  54468. tileWidth?: number;
  54469. tileHeight?: number;
  54470. size?: number;
  54471. width?: number;
  54472. height?: number;
  54473. alignHorizontal?: number;
  54474. alignVertical?: number;
  54475. sideOrientation?: number;
  54476. frontUVs?: Vector4;
  54477. backUVs?: Vector4;
  54478. updatable?: boolean;
  54479. }, scene?: Nullable<Scene>): Mesh;
  54480. }
  54481. }
  54482. declare module BABYLON {
  54483. /**
  54484. * Class containing static functions to help procedurally build meshes
  54485. */
  54486. export class TubeBuilder {
  54487. /**
  54488. * Creates a tube mesh.
  54489. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54490. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54491. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54492. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54493. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54494. * * 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)
  54495. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54496. * * 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
  54497. * * 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
  54498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54499. * * 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
  54500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54502. * @param name defines the name of the mesh
  54503. * @param options defines the options used to create the mesh
  54504. * @param scene defines the hosting scene
  54505. * @returns the tube mesh
  54506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54507. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54508. */
  54509. static CreateTube(name: string, options: {
  54510. path: Vector3[];
  54511. radius?: number;
  54512. tessellation?: number;
  54513. radiusFunction?: {
  54514. (i: number, distance: number): number;
  54515. };
  54516. cap?: number;
  54517. arc?: number;
  54518. updatable?: boolean;
  54519. sideOrientation?: number;
  54520. frontUVs?: Vector4;
  54521. backUVs?: Vector4;
  54522. instance?: Mesh;
  54523. invertUV?: boolean;
  54524. }, scene?: Nullable<Scene>): Mesh;
  54525. }
  54526. }
  54527. declare module BABYLON {
  54528. /**
  54529. * Class containing static functions to help procedurally build meshes
  54530. */
  54531. export class IcoSphereBuilder {
  54532. /**
  54533. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54534. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54535. * * 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`)
  54536. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54537. * * 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
  54538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54539. * * 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
  54540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54541. * @param name defines the name of the mesh
  54542. * @param options defines the options used to create the mesh
  54543. * @param scene defines the hosting scene
  54544. * @returns the icosahedron mesh
  54545. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54546. */
  54547. static CreateIcoSphere(name: string, options: {
  54548. radius?: number;
  54549. radiusX?: number;
  54550. radiusY?: number;
  54551. radiusZ?: number;
  54552. flat?: boolean;
  54553. subdivisions?: number;
  54554. sideOrientation?: number;
  54555. frontUVs?: Vector4;
  54556. backUVs?: Vector4;
  54557. updatable?: boolean;
  54558. }, scene?: Nullable<Scene>): Mesh;
  54559. }
  54560. }
  54561. declare module BABYLON {
  54562. /**
  54563. * Class containing static functions to help procedurally build meshes
  54564. */
  54565. export class DecalBuilder {
  54566. /**
  54567. * Creates a decal mesh.
  54568. * 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
  54569. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54570. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54571. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54572. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54573. * @param name defines the name of the mesh
  54574. * @param sourceMesh defines the mesh where the decal must be applied
  54575. * @param options defines the options used to create the mesh
  54576. * @param scene defines the hosting scene
  54577. * @returns the decal mesh
  54578. * @see https://doc.babylonjs.com/how_to/decals
  54579. */
  54580. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54581. position?: Vector3;
  54582. normal?: Vector3;
  54583. size?: Vector3;
  54584. angle?: number;
  54585. }): Mesh;
  54586. }
  54587. }
  54588. declare module BABYLON {
  54589. /**
  54590. * Class containing static functions to help procedurally build meshes
  54591. */
  54592. export class MeshBuilder {
  54593. /**
  54594. * Creates a box mesh
  54595. * * The parameter `size` sets the size (float) of each box side (default 1)
  54596. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54597. * * 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)
  54598. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54600. * * 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
  54601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54602. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54603. * @param name defines the name of the mesh
  54604. * @param options defines the options used to create the mesh
  54605. * @param scene defines the hosting scene
  54606. * @returns the box mesh
  54607. */
  54608. static CreateBox(name: string, options: {
  54609. size?: number;
  54610. width?: number;
  54611. height?: number;
  54612. depth?: number;
  54613. faceUV?: Vector4[];
  54614. faceColors?: Color4[];
  54615. sideOrientation?: number;
  54616. frontUVs?: Vector4;
  54617. backUVs?: Vector4;
  54618. updatable?: boolean;
  54619. }, scene?: Nullable<Scene>): Mesh;
  54620. /**
  54621. * Creates a tiled box mesh
  54622. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54624. * @param name defines the name of the mesh
  54625. * @param options defines the options used to create the mesh
  54626. * @param scene defines the hosting scene
  54627. * @returns the tiled box mesh
  54628. */
  54629. static CreateTiledBox(name: string, options: {
  54630. pattern?: number;
  54631. size?: number;
  54632. width?: number;
  54633. height?: number;
  54634. depth: number;
  54635. tileSize?: number;
  54636. tileWidth?: number;
  54637. tileHeight?: number;
  54638. faceUV?: Vector4[];
  54639. faceColors?: Color4[];
  54640. alignHorizontal?: number;
  54641. alignVertical?: number;
  54642. sideOrientation?: number;
  54643. updatable?: boolean;
  54644. }, scene?: Nullable<Scene>): Mesh;
  54645. /**
  54646. * Creates a sphere mesh
  54647. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54648. * * 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`)
  54649. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54650. * * 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
  54651. * * 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)
  54652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54653. * * 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
  54654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54655. * @param name defines the name of the mesh
  54656. * @param options defines the options used to create the mesh
  54657. * @param scene defines the hosting scene
  54658. * @returns the sphere mesh
  54659. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54660. */
  54661. static CreateSphere(name: string, options: {
  54662. segments?: number;
  54663. diameter?: number;
  54664. diameterX?: number;
  54665. diameterY?: number;
  54666. diameterZ?: number;
  54667. arc?: number;
  54668. slice?: number;
  54669. sideOrientation?: number;
  54670. frontUVs?: Vector4;
  54671. backUVs?: Vector4;
  54672. updatable?: boolean;
  54673. }, scene?: Nullable<Scene>): Mesh;
  54674. /**
  54675. * Creates a plane polygonal mesh. By default, this is a disc
  54676. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54677. * * 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
  54678. * * 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
  54679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54680. * * 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
  54681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54682. * @param name defines the name of the mesh
  54683. * @param options defines the options used to create the mesh
  54684. * @param scene defines the hosting scene
  54685. * @returns the plane polygonal mesh
  54686. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54687. */
  54688. static CreateDisc(name: string, options: {
  54689. radius?: number;
  54690. tessellation?: number;
  54691. arc?: number;
  54692. updatable?: boolean;
  54693. sideOrientation?: number;
  54694. frontUVs?: Vector4;
  54695. backUVs?: Vector4;
  54696. }, scene?: Nullable<Scene>): Mesh;
  54697. /**
  54698. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54699. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54700. * * 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`)
  54701. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54702. * * 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
  54703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54704. * * 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
  54705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54706. * @param name defines the name of the mesh
  54707. * @param options defines the options used to create the mesh
  54708. * @param scene defines the hosting scene
  54709. * @returns the icosahedron mesh
  54710. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54711. */
  54712. static CreateIcoSphere(name: string, options: {
  54713. radius?: number;
  54714. radiusX?: number;
  54715. radiusY?: number;
  54716. radiusZ?: number;
  54717. flat?: boolean;
  54718. subdivisions?: number;
  54719. sideOrientation?: number;
  54720. frontUVs?: Vector4;
  54721. backUVs?: Vector4;
  54722. updatable?: boolean;
  54723. }, scene?: Nullable<Scene>): Mesh;
  54724. /**
  54725. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54726. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54727. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54728. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54729. * * 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
  54730. * * 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
  54731. * * 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
  54732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54733. * * 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
  54734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54735. * * 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
  54736. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54737. * * 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
  54738. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54740. * @param name defines the name of the mesh
  54741. * @param options defines the options used to create the mesh
  54742. * @param scene defines the hosting scene
  54743. * @returns the ribbon mesh
  54744. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54745. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54746. */
  54747. static CreateRibbon(name: string, options: {
  54748. pathArray: Vector3[][];
  54749. closeArray?: boolean;
  54750. closePath?: boolean;
  54751. offset?: number;
  54752. updatable?: boolean;
  54753. sideOrientation?: number;
  54754. frontUVs?: Vector4;
  54755. backUVs?: Vector4;
  54756. instance?: Mesh;
  54757. invertUV?: boolean;
  54758. uvs?: Vector2[];
  54759. colors?: Color4[];
  54760. }, scene?: Nullable<Scene>): Mesh;
  54761. /**
  54762. * Creates a cylinder or a cone mesh
  54763. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54764. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54765. * * 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.
  54766. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54767. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54768. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54769. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54770. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  54771. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54772. * * 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).
  54773. * * 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
  54774. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54775. * * 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
  54776. * * 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.
  54777. * * If `enclose` is false, a ring surface is one element.
  54778. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54779. * * 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
  54780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54781. * * 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
  54782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54783. * @param name defines the name of the mesh
  54784. * @param options defines the options used to create the mesh
  54785. * @param scene defines the hosting scene
  54786. * @returns the cylinder mesh
  54787. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54788. */
  54789. static CreateCylinder(name: string, options: {
  54790. height?: number;
  54791. diameterTop?: number;
  54792. diameterBottom?: number;
  54793. diameter?: number;
  54794. tessellation?: number;
  54795. subdivisions?: number;
  54796. arc?: number;
  54797. faceColors?: Color4[];
  54798. faceUV?: Vector4[];
  54799. updatable?: boolean;
  54800. hasRings?: boolean;
  54801. enclose?: boolean;
  54802. cap?: number;
  54803. sideOrientation?: number;
  54804. frontUVs?: Vector4;
  54805. backUVs?: Vector4;
  54806. }, scene?: Nullable<Scene>): Mesh;
  54807. /**
  54808. * Creates a torus mesh
  54809. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54810. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54811. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54813. * * 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
  54814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54815. * @param name defines the name of the mesh
  54816. * @param options defines the options used to create the mesh
  54817. * @param scene defines the hosting scene
  54818. * @returns the torus mesh
  54819. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54820. */
  54821. static CreateTorus(name: string, options: {
  54822. diameter?: number;
  54823. thickness?: number;
  54824. tessellation?: number;
  54825. updatable?: boolean;
  54826. sideOrientation?: number;
  54827. frontUVs?: Vector4;
  54828. backUVs?: Vector4;
  54829. }, scene?: Nullable<Scene>): Mesh;
  54830. /**
  54831. * Creates a torus knot mesh
  54832. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54833. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54834. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54835. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54837. * * 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
  54838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54839. * @param name defines the name of the mesh
  54840. * @param options defines the options used to create the mesh
  54841. * @param scene defines the hosting scene
  54842. * @returns the torus knot mesh
  54843. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54844. */
  54845. static CreateTorusKnot(name: string, options: {
  54846. radius?: number;
  54847. tube?: number;
  54848. radialSegments?: number;
  54849. tubularSegments?: number;
  54850. p?: number;
  54851. q?: number;
  54852. updatable?: boolean;
  54853. sideOrientation?: number;
  54854. frontUVs?: Vector4;
  54855. backUVs?: Vector4;
  54856. }, scene?: Nullable<Scene>): Mesh;
  54857. /**
  54858. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54859. * * 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
  54860. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54861. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54862. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54863. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54864. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54865. * * 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
  54866. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54868. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54869. * @param name defines the name of the new line system
  54870. * @param options defines the options used to create the line system
  54871. * @param scene defines the hosting scene
  54872. * @returns a new line system mesh
  54873. */
  54874. static CreateLineSystem(name: string, options: {
  54875. lines: Vector3[][];
  54876. updatable?: boolean;
  54877. instance?: Nullable<LinesMesh>;
  54878. colors?: Nullable<Color4[][]>;
  54879. useVertexAlpha?: boolean;
  54880. }, scene: Nullable<Scene>): LinesMesh;
  54881. /**
  54882. * Creates a line mesh
  54883. * 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
  54884. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54885. * * The parameter `points` is an array successive Vector3
  54886. * * 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
  54887. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54888. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54889. * * When updating an instance, remember that only point positions can change, not the number of points
  54890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54892. * @param name defines the name of the new line system
  54893. * @param options defines the options used to create the line system
  54894. * @param scene defines the hosting scene
  54895. * @returns a new line mesh
  54896. */
  54897. static CreateLines(name: string, options: {
  54898. points: Vector3[];
  54899. updatable?: boolean;
  54900. instance?: Nullable<LinesMesh>;
  54901. colors?: Color4[];
  54902. useVertexAlpha?: boolean;
  54903. }, scene?: Nullable<Scene>): LinesMesh;
  54904. /**
  54905. * Creates a dashed line mesh
  54906. * * 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
  54907. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54908. * * The parameter `points` is an array successive Vector3
  54909. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54910. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54911. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54912. * * 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
  54913. * * When updating an instance, remember that only point positions can change, not the number of points
  54914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54915. * @param name defines the name of the mesh
  54916. * @param options defines the options used to create the mesh
  54917. * @param scene defines the hosting scene
  54918. * @returns the dashed line mesh
  54919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54920. */
  54921. static CreateDashedLines(name: string, options: {
  54922. points: Vector3[];
  54923. dashSize?: number;
  54924. gapSize?: number;
  54925. dashNb?: number;
  54926. updatable?: boolean;
  54927. instance?: LinesMesh;
  54928. }, scene?: Nullable<Scene>): LinesMesh;
  54929. /**
  54930. * 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.
  54931. * * 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.
  54932. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54933. * * 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.
  54934. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54935. * * 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
  54936. * * 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
  54937. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54939. * * 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
  54940. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54942. * @param name defines the name of the mesh
  54943. * @param options defines the options used to create the mesh
  54944. * @param scene defines the hosting scene
  54945. * @returns the extruded shape mesh
  54946. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54948. */
  54949. static ExtrudeShape(name: string, options: {
  54950. shape: Vector3[];
  54951. path: Vector3[];
  54952. scale?: number;
  54953. rotation?: number;
  54954. cap?: number;
  54955. updatable?: boolean;
  54956. sideOrientation?: number;
  54957. frontUVs?: Vector4;
  54958. backUVs?: Vector4;
  54959. instance?: Mesh;
  54960. invertUV?: boolean;
  54961. }, scene?: Nullable<Scene>): Mesh;
  54962. /**
  54963. * Creates an custom extruded shape mesh.
  54964. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54965. * * 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.
  54966. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54967. * * 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
  54968. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54969. * * 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
  54970. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54971. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54972. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54973. * * 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
  54974. * * 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
  54975. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54977. * * 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
  54978. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54980. * @param name defines the name of the mesh
  54981. * @param options defines the options used to create the mesh
  54982. * @param scene defines the hosting scene
  54983. * @returns the custom extruded shape mesh
  54984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54985. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54987. */
  54988. static ExtrudeShapeCustom(name: string, options: {
  54989. shape: Vector3[];
  54990. path: Vector3[];
  54991. scaleFunction?: any;
  54992. rotationFunction?: any;
  54993. ribbonCloseArray?: boolean;
  54994. ribbonClosePath?: boolean;
  54995. cap?: number;
  54996. updatable?: boolean;
  54997. sideOrientation?: number;
  54998. frontUVs?: Vector4;
  54999. backUVs?: Vector4;
  55000. instance?: Mesh;
  55001. invertUV?: boolean;
  55002. }, scene?: Nullable<Scene>): Mesh;
  55003. /**
  55004. * Creates lathe mesh.
  55005. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55006. * * 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
  55007. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55008. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55009. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55010. * * 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
  55011. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55012. * * 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
  55013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55014. * * 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
  55015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55017. * @param name defines the name of the mesh
  55018. * @param options defines the options used to create the mesh
  55019. * @param scene defines the hosting scene
  55020. * @returns the lathe mesh
  55021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55022. */
  55023. static CreateLathe(name: string, options: {
  55024. shape: Vector3[];
  55025. radius?: number;
  55026. tessellation?: number;
  55027. clip?: number;
  55028. arc?: number;
  55029. closed?: boolean;
  55030. updatable?: boolean;
  55031. sideOrientation?: number;
  55032. frontUVs?: Vector4;
  55033. backUVs?: Vector4;
  55034. cap?: number;
  55035. invertUV?: boolean;
  55036. }, scene?: Nullable<Scene>): Mesh;
  55037. /**
  55038. * Creates a tiled plane mesh
  55039. * * You can set a limited pattern arrangement with the tiles
  55040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55041. * * 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
  55042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55043. * @param name defines the name of the mesh
  55044. * @param options defines the options used to create the mesh
  55045. * @param scene defines the hosting scene
  55046. * @returns the plane mesh
  55047. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55048. */
  55049. static CreateTiledPlane(name: string, options: {
  55050. pattern?: number;
  55051. tileSize?: number;
  55052. tileWidth?: number;
  55053. tileHeight?: number;
  55054. size?: number;
  55055. width?: number;
  55056. height?: number;
  55057. alignHorizontal?: number;
  55058. alignVertical?: number;
  55059. sideOrientation?: number;
  55060. frontUVs?: Vector4;
  55061. backUVs?: Vector4;
  55062. updatable?: boolean;
  55063. }, scene?: Nullable<Scene>): Mesh;
  55064. /**
  55065. * Creates a plane mesh
  55066. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55067. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55068. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55070. * * 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
  55071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55072. * @param name defines the name of the mesh
  55073. * @param options defines the options used to create the mesh
  55074. * @param scene defines the hosting scene
  55075. * @returns the plane mesh
  55076. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55077. */
  55078. static CreatePlane(name: string, options: {
  55079. size?: number;
  55080. width?: number;
  55081. height?: number;
  55082. sideOrientation?: number;
  55083. frontUVs?: Vector4;
  55084. backUVs?: Vector4;
  55085. updatable?: boolean;
  55086. sourcePlane?: Plane;
  55087. }, scene?: Nullable<Scene>): Mesh;
  55088. /**
  55089. * Creates a ground mesh
  55090. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55091. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55093. * @param name defines the name of the mesh
  55094. * @param options defines the options used to create the mesh
  55095. * @param scene defines the hosting scene
  55096. * @returns the ground mesh
  55097. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55098. */
  55099. static CreateGround(name: string, options: {
  55100. width?: number;
  55101. height?: number;
  55102. subdivisions?: number;
  55103. subdivisionsX?: number;
  55104. subdivisionsY?: number;
  55105. updatable?: boolean;
  55106. }, scene?: Nullable<Scene>): Mesh;
  55107. /**
  55108. * Creates a tiled ground mesh
  55109. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55110. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55111. * * 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
  55112. * * 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
  55113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55114. * @param name defines the name of the mesh
  55115. * @param options defines the options used to create the mesh
  55116. * @param scene defines the hosting scene
  55117. * @returns the tiled ground mesh
  55118. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55119. */
  55120. static CreateTiledGround(name: string, options: {
  55121. xmin: number;
  55122. zmin: number;
  55123. xmax: number;
  55124. zmax: number;
  55125. subdivisions?: {
  55126. w: number;
  55127. h: number;
  55128. };
  55129. precision?: {
  55130. w: number;
  55131. h: number;
  55132. };
  55133. updatable?: boolean;
  55134. }, scene?: Nullable<Scene>): Mesh;
  55135. /**
  55136. * Creates a ground mesh from a height map
  55137. * * The parameter `url` sets the URL of the height map image resource.
  55138. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55139. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55140. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55141. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55142. * * 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.
  55143. * * 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).
  55144. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55146. * @param name defines the name of the mesh
  55147. * @param url defines the url to the height map
  55148. * @param options defines the options used to create the mesh
  55149. * @param scene defines the hosting scene
  55150. * @returns the ground mesh
  55151. * @see https://doc.babylonjs.com/babylon101/height_map
  55152. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55153. */
  55154. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55155. width?: number;
  55156. height?: number;
  55157. subdivisions?: number;
  55158. minHeight?: number;
  55159. maxHeight?: number;
  55160. colorFilter?: Color3;
  55161. alphaFilter?: number;
  55162. updatable?: boolean;
  55163. onReady?: (mesh: GroundMesh) => void;
  55164. }, scene?: Nullable<Scene>): GroundMesh;
  55165. /**
  55166. * Creates a polygon mesh
  55167. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55168. * * 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
  55169. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55171. * * 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)
  55172. * * Remember you can only change the shape positions, not their number when updating a polygon
  55173. * @param name defines the name of the mesh
  55174. * @param options defines the options used to create the mesh
  55175. * @param scene defines the hosting scene
  55176. * @param earcutInjection can be used to inject your own earcut reference
  55177. * @returns the polygon mesh
  55178. */
  55179. static CreatePolygon(name: string, options: {
  55180. shape: Vector3[];
  55181. holes?: Vector3[][];
  55182. depth?: number;
  55183. faceUV?: Vector4[];
  55184. faceColors?: Color4[];
  55185. updatable?: boolean;
  55186. sideOrientation?: number;
  55187. frontUVs?: Vector4;
  55188. backUVs?: Vector4;
  55189. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55190. /**
  55191. * Creates an extruded polygon mesh, with depth in the Y direction.
  55192. * * 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)
  55193. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55194. * @param name defines the name of the mesh
  55195. * @param options defines the options used to create the mesh
  55196. * @param scene defines the hosting scene
  55197. * @param earcutInjection can be used to inject your own earcut reference
  55198. * @returns the polygon mesh
  55199. */
  55200. static ExtrudePolygon(name: string, options: {
  55201. shape: Vector3[];
  55202. holes?: Vector3[][];
  55203. depth?: number;
  55204. faceUV?: Vector4[];
  55205. faceColors?: Color4[];
  55206. updatable?: boolean;
  55207. sideOrientation?: number;
  55208. frontUVs?: Vector4;
  55209. backUVs?: Vector4;
  55210. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55211. /**
  55212. * Creates a tube mesh.
  55213. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55214. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55215. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55216. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55217. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55218. * * 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)
  55219. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55220. * * 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
  55221. * * 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
  55222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55223. * * 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
  55224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55226. * @param name defines the name of the mesh
  55227. * @param options defines the options used to create the mesh
  55228. * @param scene defines the hosting scene
  55229. * @returns the tube mesh
  55230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55231. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55232. */
  55233. static CreateTube(name: string, options: {
  55234. path: Vector3[];
  55235. radius?: number;
  55236. tessellation?: number;
  55237. radiusFunction?: {
  55238. (i: number, distance: number): number;
  55239. };
  55240. cap?: number;
  55241. arc?: number;
  55242. updatable?: boolean;
  55243. sideOrientation?: number;
  55244. frontUVs?: Vector4;
  55245. backUVs?: Vector4;
  55246. instance?: Mesh;
  55247. invertUV?: boolean;
  55248. }, scene?: Nullable<Scene>): Mesh;
  55249. /**
  55250. * Creates a polyhedron mesh
  55251. * * 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
  55252. * * The parameter `size` (positive float, default 1) sets the polygon size
  55253. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55254. * * 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`
  55255. * * 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
  55256. * * 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)`)
  55257. * * 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
  55258. * * 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
  55259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55260. * * 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
  55261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55262. * @param name defines the name of the mesh
  55263. * @param options defines the options used to create the mesh
  55264. * @param scene defines the hosting scene
  55265. * @returns the polyhedron mesh
  55266. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55267. */
  55268. static CreatePolyhedron(name: string, options: {
  55269. type?: number;
  55270. size?: number;
  55271. sizeX?: number;
  55272. sizeY?: number;
  55273. sizeZ?: number;
  55274. custom?: any;
  55275. faceUV?: Vector4[];
  55276. faceColors?: Color4[];
  55277. flat?: boolean;
  55278. updatable?: boolean;
  55279. sideOrientation?: number;
  55280. frontUVs?: Vector4;
  55281. backUVs?: Vector4;
  55282. }, scene?: Nullable<Scene>): Mesh;
  55283. /**
  55284. * Creates a decal mesh.
  55285. * 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
  55286. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55287. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55288. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55289. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55290. * @param name defines the name of the mesh
  55291. * @param sourceMesh defines the mesh where the decal must be applied
  55292. * @param options defines the options used to create the mesh
  55293. * @param scene defines the hosting scene
  55294. * @returns the decal mesh
  55295. * @see https://doc.babylonjs.com/how_to/decals
  55296. */
  55297. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55298. position?: Vector3;
  55299. normal?: Vector3;
  55300. size?: Vector3;
  55301. angle?: number;
  55302. }): Mesh;
  55303. }
  55304. }
  55305. declare module BABYLON {
  55306. /**
  55307. * A simplifier interface for future simplification implementations
  55308. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55309. */
  55310. export interface ISimplifier {
  55311. /**
  55312. * Simplification of a given mesh according to the given settings.
  55313. * Since this requires computation, it is assumed that the function runs async.
  55314. * @param settings The settings of the simplification, including quality and distance
  55315. * @param successCallback A callback that will be called after the mesh was simplified.
  55316. * @param errorCallback in case of an error, this callback will be called. optional.
  55317. */
  55318. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55319. }
  55320. /**
  55321. * Expected simplification settings.
  55322. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55323. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55324. */
  55325. export interface ISimplificationSettings {
  55326. /**
  55327. * Gets or sets the expected quality
  55328. */
  55329. quality: number;
  55330. /**
  55331. * Gets or sets the distance when this optimized version should be used
  55332. */
  55333. distance: number;
  55334. /**
  55335. * Gets an already optimized mesh
  55336. */
  55337. optimizeMesh?: boolean;
  55338. }
  55339. /**
  55340. * Class used to specify simplification options
  55341. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55342. */
  55343. export class SimplificationSettings implements ISimplificationSettings {
  55344. /** expected quality */
  55345. quality: number;
  55346. /** distance when this optimized version should be used */
  55347. distance: number;
  55348. /** already optimized mesh */
  55349. optimizeMesh?: boolean | undefined;
  55350. /**
  55351. * Creates a SimplificationSettings
  55352. * @param quality expected quality
  55353. * @param distance distance when this optimized version should be used
  55354. * @param optimizeMesh already optimized mesh
  55355. */
  55356. constructor(
  55357. /** expected quality */
  55358. quality: number,
  55359. /** distance when this optimized version should be used */
  55360. distance: number,
  55361. /** already optimized mesh */
  55362. optimizeMesh?: boolean | undefined);
  55363. }
  55364. /**
  55365. * Interface used to define a simplification task
  55366. */
  55367. export interface ISimplificationTask {
  55368. /**
  55369. * Array of settings
  55370. */
  55371. settings: Array<ISimplificationSettings>;
  55372. /**
  55373. * Simplification type
  55374. */
  55375. simplificationType: SimplificationType;
  55376. /**
  55377. * Mesh to simplify
  55378. */
  55379. mesh: Mesh;
  55380. /**
  55381. * Callback called on success
  55382. */
  55383. successCallback?: () => void;
  55384. /**
  55385. * Defines if parallel processing can be used
  55386. */
  55387. parallelProcessing: boolean;
  55388. }
  55389. /**
  55390. * Queue used to order the simplification tasks
  55391. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55392. */
  55393. export class SimplificationQueue {
  55394. private _simplificationArray;
  55395. /**
  55396. * Gets a boolean indicating that the process is still running
  55397. */
  55398. running: boolean;
  55399. /**
  55400. * Creates a new queue
  55401. */
  55402. constructor();
  55403. /**
  55404. * Adds a new simplification task
  55405. * @param task defines a task to add
  55406. */
  55407. addTask(task: ISimplificationTask): void;
  55408. /**
  55409. * Execute next task
  55410. */
  55411. executeNext(): void;
  55412. /**
  55413. * Execute a simplification task
  55414. * @param task defines the task to run
  55415. */
  55416. runSimplification(task: ISimplificationTask): void;
  55417. private getSimplifier;
  55418. }
  55419. /**
  55420. * The implemented types of simplification
  55421. * At the moment only Quadratic Error Decimation is implemented
  55422. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55423. */
  55424. export enum SimplificationType {
  55425. /** Quadratic error decimation */
  55426. QUADRATIC = 0
  55427. }
  55428. }
  55429. declare module BABYLON {
  55430. interface Scene {
  55431. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  55432. /**
  55433. * Gets or sets the simplification queue attached to the scene
  55434. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55435. */
  55436. simplificationQueue: SimplificationQueue;
  55437. }
  55438. interface Mesh {
  55439. /**
  55440. * Simplify the mesh according to the given array of settings.
  55441. * Function will return immediately and will simplify async
  55442. * @param settings a collection of simplification settings
  55443. * @param parallelProcessing should all levels calculate parallel or one after the other
  55444. * @param simplificationType the type of simplification to run
  55445. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55446. * @returns the current mesh
  55447. */
  55448. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55449. }
  55450. /**
  55451. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55452. * created in a scene
  55453. */
  55454. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55455. /**
  55456. * The component name helpfull to identify the component in the list of scene components.
  55457. */
  55458. readonly name: string;
  55459. /**
  55460. * The scene the component belongs to.
  55461. */
  55462. scene: Scene;
  55463. /**
  55464. * Creates a new instance of the component for the given scene
  55465. * @param scene Defines the scene to register the component in
  55466. */
  55467. constructor(scene: Scene);
  55468. /**
  55469. * Registers the component in a given scene
  55470. */
  55471. register(): void;
  55472. /**
  55473. * Rebuilds the elements related to this component in case of
  55474. * context lost for instance.
  55475. */
  55476. rebuild(): void;
  55477. /**
  55478. * Disposes the component and the associated ressources
  55479. */
  55480. dispose(): void;
  55481. private _beforeCameraUpdate;
  55482. }
  55483. }
  55484. declare module BABYLON {
  55485. /**
  55486. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55487. */
  55488. export interface INavigationEnginePlugin {
  55489. /**
  55490. * plugin name
  55491. */
  55492. name: string;
  55493. /**
  55494. * Creates a navigation mesh
  55495. * @param meshes array of all the geometry used to compute the navigatio mesh
  55496. * @param parameters bunch of parameters used to filter geometry
  55497. */
  55498. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55499. /**
  55500. * Create a navigation mesh debug mesh
  55501. * @param scene is where the mesh will be added
  55502. * @returns debug display mesh
  55503. */
  55504. createDebugNavMesh(scene: Scene): Mesh;
  55505. /**
  55506. * Get a navigation mesh constrained position, closest to the parameter position
  55507. * @param position world position
  55508. * @returns the closest point to position constrained by the navigation mesh
  55509. */
  55510. getClosestPoint(position: Vector3): Vector3;
  55511. /**
  55512. * Get a navigation mesh constrained position, within a particular radius
  55513. * @param position world position
  55514. * @param maxRadius the maximum distance to the constrained world position
  55515. * @returns the closest point to position constrained by the navigation mesh
  55516. */
  55517. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55518. /**
  55519. * Compute the final position from a segment made of destination-position
  55520. * @param position world position
  55521. * @param destination world position
  55522. * @returns the resulting point along the navmesh
  55523. */
  55524. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55525. /**
  55526. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55527. * @param start world position
  55528. * @param end world position
  55529. * @returns array containing world position composing the path
  55530. */
  55531. computePath(start: Vector3, end: Vector3): Vector3[];
  55532. /**
  55533. * If this plugin is supported
  55534. * @returns true if plugin is supported
  55535. */
  55536. isSupported(): boolean;
  55537. /**
  55538. * Create a new Crowd so you can add agents
  55539. * @param maxAgents the maximum agent count in the crowd
  55540. * @param maxAgentRadius the maximum radius an agent can have
  55541. * @param scene to attach the crowd to
  55542. * @returns the crowd you can add agents to
  55543. */
  55544. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55545. /**
  55546. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55547. * The queries will try to find a solution within those bounds
  55548. * default is (1,1,1)
  55549. * @param extent x,y,z value that define the extent around the queries point of reference
  55550. */
  55551. setDefaultQueryExtent(extent: Vector3): void;
  55552. /**
  55553. * Get the Bounding box extent specified by setDefaultQueryExtent
  55554. * @returns the box extent values
  55555. */
  55556. getDefaultQueryExtent(): Vector3;
  55557. /**
  55558. * Release all resources
  55559. */
  55560. dispose(): void;
  55561. }
  55562. /**
  55563. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55564. */
  55565. export interface ICrowd {
  55566. /**
  55567. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55568. * You can attach anything to that node. The node position is updated in the scene update tick.
  55569. * @param pos world position that will be constrained by the navigation mesh
  55570. * @param parameters agent parameters
  55571. * @param transform hooked to the agent that will be update by the scene
  55572. * @returns agent index
  55573. */
  55574. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55575. /**
  55576. * Returns the agent position in world space
  55577. * @param index agent index returned by addAgent
  55578. * @returns world space position
  55579. */
  55580. getAgentPosition(index: number): Vector3;
  55581. /**
  55582. * Gets the agent velocity in world space
  55583. * @param index agent index returned by addAgent
  55584. * @returns world space velocity
  55585. */
  55586. getAgentVelocity(index: number): Vector3;
  55587. /**
  55588. * remove a particular agent previously created
  55589. * @param index agent index returned by addAgent
  55590. */
  55591. removeAgent(index: number): void;
  55592. /**
  55593. * get the list of all agents attached to this crowd
  55594. * @returns list of agent indices
  55595. */
  55596. getAgents(): number[];
  55597. /**
  55598. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55599. * @param deltaTime in seconds
  55600. */
  55601. update(deltaTime: number): void;
  55602. /**
  55603. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55604. * @param index agent index returned by addAgent
  55605. * @param destination targeted world position
  55606. */
  55607. agentGoto(index: number, destination: Vector3): void;
  55608. /**
  55609. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55610. * The queries will try to find a solution within those bounds
  55611. * default is (1,1,1)
  55612. * @param extent x,y,z value that define the extent around the queries point of reference
  55613. */
  55614. setDefaultQueryExtent(extent: Vector3): void;
  55615. /**
  55616. * Get the Bounding box extent specified by setDefaultQueryExtent
  55617. * @returns the box extent values
  55618. */
  55619. getDefaultQueryExtent(): Vector3;
  55620. /**
  55621. * Release all resources
  55622. */
  55623. dispose(): void;
  55624. }
  55625. /**
  55626. * Configures an agent
  55627. */
  55628. export interface IAgentParameters {
  55629. /**
  55630. * Agent radius. [Limit: >= 0]
  55631. */
  55632. radius: number;
  55633. /**
  55634. * Agent height. [Limit: > 0]
  55635. */
  55636. height: number;
  55637. /**
  55638. * Maximum allowed acceleration. [Limit: >= 0]
  55639. */
  55640. maxAcceleration: number;
  55641. /**
  55642. * Maximum allowed speed. [Limit: >= 0]
  55643. */
  55644. maxSpeed: number;
  55645. /**
  55646. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55647. */
  55648. collisionQueryRange: number;
  55649. /**
  55650. * The path visibility optimization range. [Limit: > 0]
  55651. */
  55652. pathOptimizationRange: number;
  55653. /**
  55654. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55655. */
  55656. separationWeight: number;
  55657. }
  55658. /**
  55659. * Configures the navigation mesh creation
  55660. */
  55661. export interface INavMeshParameters {
  55662. /**
  55663. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55664. */
  55665. cs: number;
  55666. /**
  55667. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55668. */
  55669. ch: number;
  55670. /**
  55671. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55672. */
  55673. walkableSlopeAngle: number;
  55674. /**
  55675. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55676. * be considered walkable. [Limit: >= 3] [Units: vx]
  55677. */
  55678. walkableHeight: number;
  55679. /**
  55680. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55681. */
  55682. walkableClimb: number;
  55683. /**
  55684. * The distance to erode/shrink the walkable area of the heightfield away from
  55685. * obstructions. [Limit: >=0] [Units: vx]
  55686. */
  55687. walkableRadius: number;
  55688. /**
  55689. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55690. */
  55691. maxEdgeLen: number;
  55692. /**
  55693. * The maximum distance a simplfied contour's border edges should deviate
  55694. * the original raw contour. [Limit: >=0] [Units: vx]
  55695. */
  55696. maxSimplificationError: number;
  55697. /**
  55698. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55699. */
  55700. minRegionArea: number;
  55701. /**
  55702. * Any regions with a span count smaller than this value will, if possible,
  55703. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55704. */
  55705. mergeRegionArea: number;
  55706. /**
  55707. * The maximum number of vertices allowed for polygons generated during the
  55708. * contour to polygon conversion process. [Limit: >= 3]
  55709. */
  55710. maxVertsPerPoly: number;
  55711. /**
  55712. * Sets the sampling distance to use when generating the detail mesh.
  55713. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55714. */
  55715. detailSampleDist: number;
  55716. /**
  55717. * The maximum distance the detail mesh surface should deviate from heightfield
  55718. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55719. */
  55720. detailSampleMaxError: number;
  55721. }
  55722. }
  55723. declare module BABYLON {
  55724. /**
  55725. * RecastJS navigation plugin
  55726. */
  55727. export class RecastJSPlugin implements INavigationEnginePlugin {
  55728. /**
  55729. * Reference to the Recast library
  55730. */
  55731. bjsRECAST: any;
  55732. /**
  55733. * plugin name
  55734. */
  55735. name: string;
  55736. /**
  55737. * the first navmesh created. We might extend this to support multiple navmeshes
  55738. */
  55739. navMesh: any;
  55740. /**
  55741. * Initializes the recastJS plugin
  55742. * @param recastInjection can be used to inject your own recast reference
  55743. */
  55744. constructor(recastInjection?: any);
  55745. /**
  55746. * Creates a navigation mesh
  55747. * @param meshes array of all the geometry used to compute the navigatio mesh
  55748. * @param parameters bunch of parameters used to filter geometry
  55749. */
  55750. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55751. /**
  55752. * Create a navigation mesh debug mesh
  55753. * @param scene is where the mesh will be added
  55754. * @returns debug display mesh
  55755. */
  55756. createDebugNavMesh(scene: Scene): Mesh;
  55757. /**
  55758. * Get a navigation mesh constrained position, closest to the parameter position
  55759. * @param position world position
  55760. * @returns the closest point to position constrained by the navigation mesh
  55761. */
  55762. getClosestPoint(position: Vector3): Vector3;
  55763. /**
  55764. * Get a navigation mesh constrained position, within a particular radius
  55765. * @param position world position
  55766. * @param maxRadius the maximum distance to the constrained world position
  55767. * @returns the closest point to position constrained by the navigation mesh
  55768. */
  55769. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55770. /**
  55771. * Compute the final position from a segment made of destination-position
  55772. * @param position world position
  55773. * @param destination world position
  55774. * @returns the resulting point along the navmesh
  55775. */
  55776. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55777. /**
  55778. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55779. * @param start world position
  55780. * @param end world position
  55781. * @returns array containing world position composing the path
  55782. */
  55783. computePath(start: Vector3, end: Vector3): Vector3[];
  55784. /**
  55785. * Create a new Crowd so you can add agents
  55786. * @param maxAgents the maximum agent count in the crowd
  55787. * @param maxAgentRadius the maximum radius an agent can have
  55788. * @param scene to attach the crowd to
  55789. * @returns the crowd you can add agents to
  55790. */
  55791. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55792. /**
  55793. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55794. * The queries will try to find a solution within those bounds
  55795. * default is (1,1,1)
  55796. * @param extent x,y,z value that define the extent around the queries point of reference
  55797. */
  55798. setDefaultQueryExtent(extent: Vector3): void;
  55799. /**
  55800. * Get the Bounding box extent specified by setDefaultQueryExtent
  55801. * @returns the box extent values
  55802. */
  55803. getDefaultQueryExtent(): Vector3;
  55804. /**
  55805. * Disposes
  55806. */
  55807. dispose(): void;
  55808. /**
  55809. * If this plugin is supported
  55810. * @returns true if plugin is supported
  55811. */
  55812. isSupported(): boolean;
  55813. }
  55814. /**
  55815. * Recast detour crowd implementation
  55816. */
  55817. export class RecastJSCrowd implements ICrowd {
  55818. /**
  55819. * Recast/detour plugin
  55820. */
  55821. bjsRECASTPlugin: RecastJSPlugin;
  55822. /**
  55823. * Link to the detour crowd
  55824. */
  55825. recastCrowd: any;
  55826. /**
  55827. * One transform per agent
  55828. */
  55829. transforms: TransformNode[];
  55830. /**
  55831. * All agents created
  55832. */
  55833. agents: number[];
  55834. /**
  55835. * Link to the scene is kept to unregister the crowd from the scene
  55836. */
  55837. private _scene;
  55838. /**
  55839. * Observer for crowd updates
  55840. */
  55841. private _onBeforeAnimationsObserver;
  55842. /**
  55843. * Constructor
  55844. * @param plugin recastJS plugin
  55845. * @param maxAgents the maximum agent count in the crowd
  55846. * @param maxAgentRadius the maximum radius an agent can have
  55847. * @param scene to attach the crowd to
  55848. * @returns the crowd you can add agents to
  55849. */
  55850. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55851. /**
  55852. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55853. * You can attach anything to that node. The node position is updated in the scene update tick.
  55854. * @param pos world position that will be constrained by the navigation mesh
  55855. * @param parameters agent parameters
  55856. * @param transform hooked to the agent that will be update by the scene
  55857. * @returns agent index
  55858. */
  55859. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55860. /**
  55861. * Returns the agent position in world space
  55862. * @param index agent index returned by addAgent
  55863. * @returns world space position
  55864. */
  55865. getAgentPosition(index: number): Vector3;
  55866. /**
  55867. * Returns the agent velocity in world space
  55868. * @param index agent index returned by addAgent
  55869. * @returns world space velocity
  55870. */
  55871. getAgentVelocity(index: number): Vector3;
  55872. /**
  55873. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55874. * @param index agent index returned by addAgent
  55875. * @param destination targeted world position
  55876. */
  55877. agentGoto(index: number, destination: Vector3): void;
  55878. /**
  55879. * remove a particular agent previously created
  55880. * @param index agent index returned by addAgent
  55881. */
  55882. removeAgent(index: number): void;
  55883. /**
  55884. * get the list of all agents attached to this crowd
  55885. * @returns list of agent indices
  55886. */
  55887. getAgents(): number[];
  55888. /**
  55889. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55890. * @param deltaTime in seconds
  55891. */
  55892. update(deltaTime: number): void;
  55893. /**
  55894. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55895. * The queries will try to find a solution within those bounds
  55896. * default is (1,1,1)
  55897. * @param extent x,y,z value that define the extent around the queries point of reference
  55898. */
  55899. setDefaultQueryExtent(extent: Vector3): void;
  55900. /**
  55901. * Get the Bounding box extent specified by setDefaultQueryExtent
  55902. * @returns the box extent values
  55903. */
  55904. getDefaultQueryExtent(): Vector3;
  55905. /**
  55906. * Release all resources
  55907. */
  55908. dispose(): void;
  55909. }
  55910. }
  55911. declare module BABYLON {
  55912. /**
  55913. * Class used to enable access to IndexedDB
  55914. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55915. */
  55916. export class Database implements IOfflineProvider {
  55917. private _callbackManifestChecked;
  55918. private _currentSceneUrl;
  55919. private _db;
  55920. private _enableSceneOffline;
  55921. private _enableTexturesOffline;
  55922. private _manifestVersionFound;
  55923. private _mustUpdateRessources;
  55924. private _hasReachedQuota;
  55925. private _isSupported;
  55926. private _idbFactory;
  55927. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55928. private static IsUASupportingBlobStorage;
  55929. /**
  55930. * Gets a boolean indicating if Database storate is enabled (off by default)
  55931. */
  55932. static IDBStorageEnabled: boolean;
  55933. /**
  55934. * Gets a boolean indicating if scene must be saved in the database
  55935. */
  55936. readonly enableSceneOffline: boolean;
  55937. /**
  55938. * Gets a boolean indicating if textures must be saved in the database
  55939. */
  55940. readonly enableTexturesOffline: boolean;
  55941. /**
  55942. * Creates a new Database
  55943. * @param urlToScene defines the url to load the scene
  55944. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55945. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55946. */
  55947. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55948. private static _ParseURL;
  55949. private static _ReturnFullUrlLocation;
  55950. private _checkManifestFile;
  55951. /**
  55952. * Open the database and make it available
  55953. * @param successCallback defines the callback to call on success
  55954. * @param errorCallback defines the callback to call on error
  55955. */
  55956. open(successCallback: () => void, errorCallback: () => void): void;
  55957. /**
  55958. * Loads an image from the database
  55959. * @param url defines the url to load from
  55960. * @param image defines the target DOM image
  55961. */
  55962. loadImage(url: string, image: HTMLImageElement): void;
  55963. private _loadImageFromDBAsync;
  55964. private _saveImageIntoDBAsync;
  55965. private _checkVersionFromDB;
  55966. private _loadVersionFromDBAsync;
  55967. private _saveVersionIntoDBAsync;
  55968. /**
  55969. * Loads a file from database
  55970. * @param url defines the URL to load from
  55971. * @param sceneLoaded defines a callback to call on success
  55972. * @param progressCallBack defines a callback to call when progress changed
  55973. * @param errorCallback defines a callback to call on error
  55974. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55975. */
  55976. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55977. private _loadFileAsync;
  55978. private _saveFileAsync;
  55979. /**
  55980. * Validates if xhr data is correct
  55981. * @param xhr defines the request to validate
  55982. * @param dataType defines the expected data type
  55983. * @returns true if data is correct
  55984. */
  55985. private static _ValidateXHRData;
  55986. }
  55987. }
  55988. declare module BABYLON {
  55989. /** @hidden */
  55990. export var gpuUpdateParticlesPixelShader: {
  55991. name: string;
  55992. shader: string;
  55993. };
  55994. }
  55995. declare module BABYLON {
  55996. /** @hidden */
  55997. export var gpuUpdateParticlesVertexShader: {
  55998. name: string;
  55999. shader: string;
  56000. };
  56001. }
  56002. declare module BABYLON {
  56003. /** @hidden */
  56004. export var clipPlaneFragmentDeclaration2: {
  56005. name: string;
  56006. shader: string;
  56007. };
  56008. }
  56009. declare module BABYLON {
  56010. /** @hidden */
  56011. export var gpuRenderParticlesPixelShader: {
  56012. name: string;
  56013. shader: string;
  56014. };
  56015. }
  56016. declare module BABYLON {
  56017. /** @hidden */
  56018. export var clipPlaneVertexDeclaration2: {
  56019. name: string;
  56020. shader: string;
  56021. };
  56022. }
  56023. declare module BABYLON {
  56024. /** @hidden */
  56025. export var gpuRenderParticlesVertexShader: {
  56026. name: string;
  56027. shader: string;
  56028. };
  56029. }
  56030. declare module BABYLON {
  56031. /**
  56032. * This represents a GPU particle system in Babylon
  56033. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56034. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56035. */
  56036. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56037. /**
  56038. * The layer mask we are rendering the particles through.
  56039. */
  56040. layerMask: number;
  56041. private _capacity;
  56042. private _activeCount;
  56043. private _currentActiveCount;
  56044. private _accumulatedCount;
  56045. private _renderEffect;
  56046. private _updateEffect;
  56047. private _buffer0;
  56048. private _buffer1;
  56049. private _spriteBuffer;
  56050. private _updateVAO;
  56051. private _renderVAO;
  56052. private _targetIndex;
  56053. private _sourceBuffer;
  56054. private _targetBuffer;
  56055. private _engine;
  56056. private _currentRenderId;
  56057. private _started;
  56058. private _stopped;
  56059. private _timeDelta;
  56060. private _randomTexture;
  56061. private _randomTexture2;
  56062. private _attributesStrideSize;
  56063. private _updateEffectOptions;
  56064. private _randomTextureSize;
  56065. private _actualFrame;
  56066. private readonly _rawTextureWidth;
  56067. /**
  56068. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56069. */
  56070. static readonly IsSupported: boolean;
  56071. /**
  56072. * An event triggered when the system is disposed.
  56073. */
  56074. onDisposeObservable: Observable<GPUParticleSystem>;
  56075. /**
  56076. * Gets the maximum number of particles active at the same time.
  56077. * @returns The max number of active particles.
  56078. */
  56079. getCapacity(): number;
  56080. /**
  56081. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56082. * to override the particles.
  56083. */
  56084. forceDepthWrite: boolean;
  56085. /**
  56086. * Gets or set the number of active particles
  56087. */
  56088. activeParticleCount: number;
  56089. private _preWarmDone;
  56090. /**
  56091. * Is this system ready to be used/rendered
  56092. * @return true if the system is ready
  56093. */
  56094. isReady(): boolean;
  56095. /**
  56096. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56097. * @returns True if it has been started, otherwise false.
  56098. */
  56099. isStarted(): boolean;
  56100. /**
  56101. * Starts the particle system and begins to emit
  56102. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56103. */
  56104. start(delay?: number): void;
  56105. /**
  56106. * Stops the particle system.
  56107. */
  56108. stop(): void;
  56109. /**
  56110. * Remove all active particles
  56111. */
  56112. reset(): void;
  56113. /**
  56114. * Returns the string "GPUParticleSystem"
  56115. * @returns a string containing the class name
  56116. */
  56117. getClassName(): string;
  56118. private _colorGradientsTexture;
  56119. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56120. /**
  56121. * Adds a new color gradient
  56122. * @param gradient defines the gradient to use (between 0 and 1)
  56123. * @param color1 defines the color to affect to the specified gradient
  56124. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56125. * @returns the current particle system
  56126. */
  56127. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56128. /**
  56129. * Remove a specific color gradient
  56130. * @param gradient defines the gradient to remove
  56131. * @returns the current particle system
  56132. */
  56133. removeColorGradient(gradient: number): GPUParticleSystem;
  56134. private _angularSpeedGradientsTexture;
  56135. private _sizeGradientsTexture;
  56136. private _velocityGradientsTexture;
  56137. private _limitVelocityGradientsTexture;
  56138. private _dragGradientsTexture;
  56139. private _addFactorGradient;
  56140. /**
  56141. * Adds a new size gradient
  56142. * @param gradient defines the gradient to use (between 0 and 1)
  56143. * @param factor defines the size factor to affect to the specified gradient
  56144. * @returns the current particle system
  56145. */
  56146. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56147. /**
  56148. * Remove a specific size gradient
  56149. * @param gradient defines the gradient to remove
  56150. * @returns the current particle system
  56151. */
  56152. removeSizeGradient(gradient: number): GPUParticleSystem;
  56153. /**
  56154. * Adds a new angular speed gradient
  56155. * @param gradient defines the gradient to use (between 0 and 1)
  56156. * @param factor defines the angular speed to affect to the specified gradient
  56157. * @returns the current particle system
  56158. */
  56159. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56160. /**
  56161. * Remove a specific angular speed gradient
  56162. * @param gradient defines the gradient to remove
  56163. * @returns the current particle system
  56164. */
  56165. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56166. /**
  56167. * Adds a new velocity gradient
  56168. * @param gradient defines the gradient to use (between 0 and 1)
  56169. * @param factor defines the velocity to affect to the specified gradient
  56170. * @returns the current particle system
  56171. */
  56172. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56173. /**
  56174. * Remove a specific velocity gradient
  56175. * @param gradient defines the gradient to remove
  56176. * @returns the current particle system
  56177. */
  56178. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56179. /**
  56180. * Adds a new limit velocity gradient
  56181. * @param gradient defines the gradient to use (between 0 and 1)
  56182. * @param factor defines the limit velocity value to affect to the specified gradient
  56183. * @returns the current particle system
  56184. */
  56185. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56186. /**
  56187. * Remove a specific limit velocity gradient
  56188. * @param gradient defines the gradient to remove
  56189. * @returns the current particle system
  56190. */
  56191. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56192. /**
  56193. * Adds a new drag gradient
  56194. * @param gradient defines the gradient to use (between 0 and 1)
  56195. * @param factor defines the drag value to affect to the specified gradient
  56196. * @returns the current particle system
  56197. */
  56198. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56199. /**
  56200. * Remove a specific drag gradient
  56201. * @param gradient defines the gradient to remove
  56202. * @returns the current particle system
  56203. */
  56204. removeDragGradient(gradient: number): GPUParticleSystem;
  56205. /**
  56206. * Not supported by GPUParticleSystem
  56207. * @param gradient defines the gradient to use (between 0 and 1)
  56208. * @param factor defines the emit rate value to affect to the specified gradient
  56209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56210. * @returns the current particle system
  56211. */
  56212. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56213. /**
  56214. * Not supported by GPUParticleSystem
  56215. * @param gradient defines the gradient to remove
  56216. * @returns the current particle system
  56217. */
  56218. removeEmitRateGradient(gradient: number): IParticleSystem;
  56219. /**
  56220. * Not supported by GPUParticleSystem
  56221. * @param gradient defines the gradient to use (between 0 and 1)
  56222. * @param factor defines the start size value to affect to the specified gradient
  56223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56224. * @returns the current particle system
  56225. */
  56226. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56227. /**
  56228. * Not supported by GPUParticleSystem
  56229. * @param gradient defines the gradient to remove
  56230. * @returns the current particle system
  56231. */
  56232. removeStartSizeGradient(gradient: number): IParticleSystem;
  56233. /**
  56234. * Not supported by GPUParticleSystem
  56235. * @param gradient defines the gradient to use (between 0 and 1)
  56236. * @param min defines the color remap minimal range
  56237. * @param max defines the color remap maximal range
  56238. * @returns the current particle system
  56239. */
  56240. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56241. /**
  56242. * Not supported by GPUParticleSystem
  56243. * @param gradient defines the gradient to remove
  56244. * @returns the current particle system
  56245. */
  56246. removeColorRemapGradient(): IParticleSystem;
  56247. /**
  56248. * Not supported by GPUParticleSystem
  56249. * @param gradient defines the gradient to use (between 0 and 1)
  56250. * @param min defines the alpha remap minimal range
  56251. * @param max defines the alpha remap maximal range
  56252. * @returns the current particle system
  56253. */
  56254. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56255. /**
  56256. * Not supported by GPUParticleSystem
  56257. * @param gradient defines the gradient to remove
  56258. * @returns the current particle system
  56259. */
  56260. removeAlphaRemapGradient(): IParticleSystem;
  56261. /**
  56262. * Not supported by GPUParticleSystem
  56263. * @param gradient defines the gradient to use (between 0 and 1)
  56264. * @param color defines the color to affect to the specified gradient
  56265. * @returns the current particle system
  56266. */
  56267. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56268. /**
  56269. * Not supported by GPUParticleSystem
  56270. * @param gradient defines the gradient to remove
  56271. * @returns the current particle system
  56272. */
  56273. removeRampGradient(): IParticleSystem;
  56274. /**
  56275. * Not supported by GPUParticleSystem
  56276. * @returns the list of ramp gradients
  56277. */
  56278. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56279. /**
  56280. * Not supported by GPUParticleSystem
  56281. * Gets or sets a boolean indicating that ramp gradients must be used
  56282. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56283. */
  56284. useRampGradients: boolean;
  56285. /**
  56286. * Not supported by GPUParticleSystem
  56287. * @param gradient defines the gradient to use (between 0 and 1)
  56288. * @param factor defines the life time factor to affect to the specified gradient
  56289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56290. * @returns the current particle system
  56291. */
  56292. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56293. /**
  56294. * Not supported by GPUParticleSystem
  56295. * @param gradient defines the gradient to remove
  56296. * @returns the current particle system
  56297. */
  56298. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56299. /**
  56300. * Instantiates a GPU particle system.
  56301. * 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.
  56302. * @param name The name of the particle system
  56303. * @param options The options used to create the system
  56304. * @param scene The scene the particle system belongs to
  56305. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56306. */
  56307. constructor(name: string, options: Partial<{
  56308. capacity: number;
  56309. randomTextureSize: number;
  56310. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56311. protected _reset(): void;
  56312. private _createUpdateVAO;
  56313. private _createRenderVAO;
  56314. private _initialize;
  56315. /** @hidden */ private _recreateUpdateEffect(): void;
  56316. /** @hidden */ private _recreateRenderEffect(): void;
  56317. /**
  56318. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56319. * @param preWarm defines if we are in the pre-warmimg phase
  56320. */
  56321. animate(preWarm?: boolean): void;
  56322. private _createFactorGradientTexture;
  56323. private _createSizeGradientTexture;
  56324. private _createAngularSpeedGradientTexture;
  56325. private _createVelocityGradientTexture;
  56326. private _createLimitVelocityGradientTexture;
  56327. private _createDragGradientTexture;
  56328. private _createColorGradientTexture;
  56329. /**
  56330. * Renders the particle system in its current state
  56331. * @param preWarm defines if the system should only update the particles but not render them
  56332. * @returns the current number of particles
  56333. */
  56334. render(preWarm?: boolean): number;
  56335. /**
  56336. * Rebuilds the particle system
  56337. */
  56338. rebuild(): void;
  56339. private _releaseBuffers;
  56340. private _releaseVAOs;
  56341. /**
  56342. * Disposes the particle system and free the associated resources
  56343. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56344. */
  56345. dispose(disposeTexture?: boolean): void;
  56346. /**
  56347. * Clones the particle system.
  56348. * @param name The name of the cloned object
  56349. * @param newEmitter The new emitter to use
  56350. * @returns the cloned particle system
  56351. */
  56352. clone(name: string, newEmitter: any): GPUParticleSystem;
  56353. /**
  56354. * Serializes the particle system to a JSON object.
  56355. * @returns the JSON object
  56356. */
  56357. serialize(): any;
  56358. /**
  56359. * Parses a JSON object to create a GPU particle system.
  56360. * @param parsedParticleSystem The JSON object to parse
  56361. * @param scene The scene to create the particle system in
  56362. * @param rootUrl The root url to use to load external dependencies like texture
  56363. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56364. * @returns the parsed GPU particle system
  56365. */
  56366. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56367. }
  56368. }
  56369. declare module BABYLON {
  56370. /**
  56371. * Represents a set of particle systems working together to create a specific effect
  56372. */
  56373. export class ParticleSystemSet implements IDisposable {
  56374. private _emitterCreationOptions;
  56375. private _emitterNode;
  56376. /**
  56377. * Gets the particle system list
  56378. */
  56379. systems: IParticleSystem[];
  56380. /**
  56381. * Gets the emitter node used with this set
  56382. */
  56383. readonly emitterNode: Nullable<TransformNode>;
  56384. /**
  56385. * Creates a new emitter mesh as a sphere
  56386. * @param options defines the options used to create the sphere
  56387. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56388. * @param scene defines the hosting scene
  56389. */
  56390. setEmitterAsSphere(options: {
  56391. diameter: number;
  56392. segments: number;
  56393. color: Color3;
  56394. }, renderingGroupId: number, scene: Scene): void;
  56395. /**
  56396. * Starts all particle systems of the set
  56397. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56398. */
  56399. start(emitter?: AbstractMesh): void;
  56400. /**
  56401. * Release all associated resources
  56402. */
  56403. dispose(): void;
  56404. /**
  56405. * Serialize the set into a JSON compatible object
  56406. * @returns a JSON compatible representation of the set
  56407. */
  56408. serialize(): any;
  56409. /**
  56410. * Parse a new ParticleSystemSet from a serialized source
  56411. * @param data defines a JSON compatible representation of the set
  56412. * @param scene defines the hosting scene
  56413. * @param gpu defines if we want GPU particles or CPU particles
  56414. * @returns a new ParticleSystemSet
  56415. */
  56416. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56417. }
  56418. }
  56419. declare module BABYLON {
  56420. /**
  56421. * This class is made for on one-liner static method to help creating particle system set.
  56422. */
  56423. export class ParticleHelper {
  56424. /**
  56425. * Gets or sets base Assets URL
  56426. */
  56427. static BaseAssetsUrl: string;
  56428. /**
  56429. * Create a default particle system that you can tweak
  56430. * @param emitter defines the emitter to use
  56431. * @param capacity defines the system capacity (default is 500 particles)
  56432. * @param scene defines the hosting scene
  56433. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56434. * @returns the new Particle system
  56435. */
  56436. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56437. /**
  56438. * This is the main static method (one-liner) of this helper to create different particle systems
  56439. * @param type This string represents the type to the particle system to create
  56440. * @param scene The scene where the particle system should live
  56441. * @param gpu If the system will use gpu
  56442. * @returns the ParticleSystemSet created
  56443. */
  56444. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56445. /**
  56446. * Static function used to export a particle system to a ParticleSystemSet variable.
  56447. * Please note that the emitter shape is not exported
  56448. * @param systems defines the particle systems to export
  56449. * @returns the created particle system set
  56450. */
  56451. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56452. }
  56453. }
  56454. declare module BABYLON {
  56455. interface Engine {
  56456. /**
  56457. * Create an effect to use with particle systems.
  56458. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56459. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56460. * @param uniformsNames defines a list of attribute names
  56461. * @param samplers defines an array of string used to represent textures
  56462. * @param defines defines the string containing the defines to use to compile the shaders
  56463. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56464. * @param onCompiled defines a function to call when the effect creation is successful
  56465. * @param onError defines a function to call when the effect creation has failed
  56466. * @returns the new Effect
  56467. */
  56468. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56469. }
  56470. interface Mesh {
  56471. /**
  56472. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56473. * @returns an array of IParticleSystem
  56474. */
  56475. getEmittedParticleSystems(): IParticleSystem[];
  56476. /**
  56477. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56478. * @returns an array of IParticleSystem
  56479. */
  56480. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56481. }
  56482. /**
  56483. * @hidden
  56484. */
  56485. export var _IDoNeedToBeInTheBuild: number;
  56486. }
  56487. declare module BABYLON {
  56488. interface Scene {
  56489. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  56490. /**
  56491. * Gets the current physics engine
  56492. * @returns a IPhysicsEngine or null if none attached
  56493. */
  56494. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56495. /**
  56496. * Enables physics to the current scene
  56497. * @param gravity defines the scene's gravity for the physics engine
  56498. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56499. * @return a boolean indicating if the physics engine was initialized
  56500. */
  56501. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56502. /**
  56503. * Disables and disposes the physics engine associated with the scene
  56504. */
  56505. disablePhysicsEngine(): void;
  56506. /**
  56507. * Gets a boolean indicating if there is an active physics engine
  56508. * @returns a boolean indicating if there is an active physics engine
  56509. */
  56510. isPhysicsEnabled(): boolean;
  56511. /**
  56512. * Deletes a physics compound impostor
  56513. * @param compound defines the compound to delete
  56514. */
  56515. deleteCompoundImpostor(compound: any): void;
  56516. /**
  56517. * An event triggered when physic simulation is about to be run
  56518. */
  56519. onBeforePhysicsObservable: Observable<Scene>;
  56520. /**
  56521. * An event triggered when physic simulation has been done
  56522. */
  56523. onAfterPhysicsObservable: Observable<Scene>;
  56524. }
  56525. interface AbstractMesh {
  56526. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  56527. /**
  56528. * Gets or sets impostor used for physic simulation
  56529. * @see http://doc.babylonjs.com/features/physics_engine
  56530. */
  56531. physicsImpostor: Nullable<PhysicsImpostor>;
  56532. /**
  56533. * Gets the current physics impostor
  56534. * @see http://doc.babylonjs.com/features/physics_engine
  56535. * @returns a physics impostor or null
  56536. */
  56537. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56538. /** Apply a physic impulse to the mesh
  56539. * @param force defines the force to apply
  56540. * @param contactPoint defines where to apply the force
  56541. * @returns the current mesh
  56542. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56543. */
  56544. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56545. /**
  56546. * Creates a physic joint between two meshes
  56547. * @param otherMesh defines the other mesh to use
  56548. * @param pivot1 defines the pivot to use on this mesh
  56549. * @param pivot2 defines the pivot to use on the other mesh
  56550. * @param options defines additional options (can be plugin dependent)
  56551. * @returns the current mesh
  56552. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56553. */
  56554. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56555. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  56556. }
  56557. /**
  56558. * Defines the physics engine scene component responsible to manage a physics engine
  56559. */
  56560. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56561. /**
  56562. * The component name helpful to identify the component in the list of scene components.
  56563. */
  56564. readonly name: string;
  56565. /**
  56566. * The scene the component belongs to.
  56567. */
  56568. scene: Scene;
  56569. /**
  56570. * Creates a new instance of the component for the given scene
  56571. * @param scene Defines the scene to register the component in
  56572. */
  56573. constructor(scene: Scene);
  56574. /**
  56575. * Registers the component in a given scene
  56576. */
  56577. register(): void;
  56578. /**
  56579. * Rebuilds the elements related to this component in case of
  56580. * context lost for instance.
  56581. */
  56582. rebuild(): void;
  56583. /**
  56584. * Disposes the component and the associated ressources
  56585. */
  56586. dispose(): void;
  56587. }
  56588. }
  56589. declare module BABYLON {
  56590. /**
  56591. * A helper for physics simulations
  56592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56593. */
  56594. export class PhysicsHelper {
  56595. private _scene;
  56596. private _physicsEngine;
  56597. /**
  56598. * Initializes the Physics helper
  56599. * @param scene Babylon.js scene
  56600. */
  56601. constructor(scene: Scene);
  56602. /**
  56603. * Applies a radial explosion impulse
  56604. * @param origin the origin of the explosion
  56605. * @param radiusOrEventOptions the radius or the options of radial explosion
  56606. * @param strength the explosion strength
  56607. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56608. * @returns A physics radial explosion event, or null
  56609. */
  56610. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56611. /**
  56612. * Applies a radial explosion force
  56613. * @param origin the origin of the explosion
  56614. * @param radiusOrEventOptions the radius or the options of radial explosion
  56615. * @param strength the explosion strength
  56616. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56617. * @returns A physics radial explosion event, or null
  56618. */
  56619. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56620. /**
  56621. * Creates a gravitational field
  56622. * @param origin the origin of the explosion
  56623. * @param radiusOrEventOptions the radius or the options of radial explosion
  56624. * @param strength the explosion strength
  56625. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56626. * @returns A physics gravitational field event, or null
  56627. */
  56628. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56629. /**
  56630. * Creates a physics updraft event
  56631. * @param origin the origin of the updraft
  56632. * @param radiusOrEventOptions the radius or the options of the updraft
  56633. * @param strength the strength of the updraft
  56634. * @param height the height of the updraft
  56635. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56636. * @returns A physics updraft event, or null
  56637. */
  56638. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56639. /**
  56640. * Creates a physics vortex event
  56641. * @param origin the of the vortex
  56642. * @param radiusOrEventOptions the radius or the options of the vortex
  56643. * @param strength the strength of the vortex
  56644. * @param height the height of the vortex
  56645. * @returns a Physics vortex event, or null
  56646. * A physics vortex event or null
  56647. */
  56648. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56649. }
  56650. /**
  56651. * Represents a physics radial explosion event
  56652. */
  56653. class PhysicsRadialExplosionEvent {
  56654. private _scene;
  56655. private _options;
  56656. private _sphere;
  56657. private _dataFetched;
  56658. /**
  56659. * Initializes a radial explosioin event
  56660. * @param _scene BabylonJS scene
  56661. * @param _options The options for the vortex event
  56662. */
  56663. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56664. /**
  56665. * Returns the data related to the radial explosion event (sphere).
  56666. * @returns The radial explosion event data
  56667. */
  56668. getData(): PhysicsRadialExplosionEventData;
  56669. /**
  56670. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56671. * @param impostor A physics imposter
  56672. * @param origin the origin of the explosion
  56673. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56674. */
  56675. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56676. /**
  56677. * Triggers affecterd impostors callbacks
  56678. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56679. */
  56680. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56681. /**
  56682. * Disposes the sphere.
  56683. * @param force Specifies if the sphere should be disposed by force
  56684. */
  56685. dispose(force?: boolean): void;
  56686. /*** Helpers ***/
  56687. private _prepareSphere;
  56688. private _intersectsWithSphere;
  56689. }
  56690. /**
  56691. * Represents a gravitational field event
  56692. */
  56693. class PhysicsGravitationalFieldEvent {
  56694. private _physicsHelper;
  56695. private _scene;
  56696. private _origin;
  56697. private _options;
  56698. private _tickCallback;
  56699. private _sphere;
  56700. private _dataFetched;
  56701. /**
  56702. * Initializes the physics gravitational field event
  56703. * @param _physicsHelper A physics helper
  56704. * @param _scene BabylonJS scene
  56705. * @param _origin The origin position of the gravitational field event
  56706. * @param _options The options for the vortex event
  56707. */
  56708. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56709. /**
  56710. * Returns the data related to the gravitational field event (sphere).
  56711. * @returns A gravitational field event
  56712. */
  56713. getData(): PhysicsGravitationalFieldEventData;
  56714. /**
  56715. * Enables the gravitational field.
  56716. */
  56717. enable(): void;
  56718. /**
  56719. * Disables the gravitational field.
  56720. */
  56721. disable(): void;
  56722. /**
  56723. * Disposes the sphere.
  56724. * @param force The force to dispose from the gravitational field event
  56725. */
  56726. dispose(force?: boolean): void;
  56727. private _tick;
  56728. }
  56729. /**
  56730. * Represents a physics updraft event
  56731. */
  56732. class PhysicsUpdraftEvent {
  56733. private _scene;
  56734. private _origin;
  56735. private _options;
  56736. private _physicsEngine;
  56737. private _originTop;
  56738. private _originDirection;
  56739. private _tickCallback;
  56740. private _cylinder;
  56741. private _cylinderPosition;
  56742. private _dataFetched;
  56743. /**
  56744. * Initializes the physics updraft event
  56745. * @param _scene BabylonJS scene
  56746. * @param _origin The origin position of the updraft
  56747. * @param _options The options for the updraft event
  56748. */
  56749. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56750. /**
  56751. * Returns the data related to the updraft event (cylinder).
  56752. * @returns A physics updraft event
  56753. */
  56754. getData(): PhysicsUpdraftEventData;
  56755. /**
  56756. * Enables the updraft.
  56757. */
  56758. enable(): void;
  56759. /**
  56760. * Disables the updraft.
  56761. */
  56762. disable(): void;
  56763. /**
  56764. * Disposes the cylinder.
  56765. * @param force Specifies if the updraft should be disposed by force
  56766. */
  56767. dispose(force?: boolean): void;
  56768. private getImpostorHitData;
  56769. private _tick;
  56770. /*** Helpers ***/
  56771. private _prepareCylinder;
  56772. private _intersectsWithCylinder;
  56773. }
  56774. /**
  56775. * Represents a physics vortex event
  56776. */
  56777. class PhysicsVortexEvent {
  56778. private _scene;
  56779. private _origin;
  56780. private _options;
  56781. private _physicsEngine;
  56782. private _originTop;
  56783. private _tickCallback;
  56784. private _cylinder;
  56785. private _cylinderPosition;
  56786. private _dataFetched;
  56787. /**
  56788. * Initializes the physics vortex event
  56789. * @param _scene The BabylonJS scene
  56790. * @param _origin The origin position of the vortex
  56791. * @param _options The options for the vortex event
  56792. */
  56793. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56794. /**
  56795. * Returns the data related to the vortex event (cylinder).
  56796. * @returns The physics vortex event data
  56797. */
  56798. getData(): PhysicsVortexEventData;
  56799. /**
  56800. * Enables the vortex.
  56801. */
  56802. enable(): void;
  56803. /**
  56804. * Disables the cortex.
  56805. */
  56806. disable(): void;
  56807. /**
  56808. * Disposes the sphere.
  56809. * @param force
  56810. */
  56811. dispose(force?: boolean): void;
  56812. private getImpostorHitData;
  56813. private _tick;
  56814. /*** Helpers ***/
  56815. private _prepareCylinder;
  56816. private _intersectsWithCylinder;
  56817. }
  56818. /**
  56819. * Options fot the radial explosion event
  56820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56821. */
  56822. export class PhysicsRadialExplosionEventOptions {
  56823. /**
  56824. * The radius of the sphere for the radial explosion.
  56825. */
  56826. radius: number;
  56827. /**
  56828. * The strenth of the explosion.
  56829. */
  56830. strength: number;
  56831. /**
  56832. * The strenght of the force in correspondence to the distance of the affected object
  56833. */
  56834. falloff: PhysicsRadialImpulseFalloff;
  56835. /**
  56836. * Sphere options for the radial explosion.
  56837. */
  56838. sphere: {
  56839. segments: number;
  56840. diameter: number;
  56841. };
  56842. /**
  56843. * Sphere options for the radial explosion.
  56844. */
  56845. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56846. }
  56847. /**
  56848. * Options fot the updraft event
  56849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56850. */
  56851. export class PhysicsUpdraftEventOptions {
  56852. /**
  56853. * The radius of the cylinder for the vortex
  56854. */
  56855. radius: number;
  56856. /**
  56857. * The strenth of the updraft.
  56858. */
  56859. strength: number;
  56860. /**
  56861. * The height of the cylinder for the updraft.
  56862. */
  56863. height: number;
  56864. /**
  56865. * The mode for the the updraft.
  56866. */
  56867. updraftMode: PhysicsUpdraftMode;
  56868. }
  56869. /**
  56870. * Options fot the vortex event
  56871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56872. */
  56873. export class PhysicsVortexEventOptions {
  56874. /**
  56875. * The radius of the cylinder for the vortex
  56876. */
  56877. radius: number;
  56878. /**
  56879. * The strenth of the vortex.
  56880. */
  56881. strength: number;
  56882. /**
  56883. * The height of the cylinder for the vortex.
  56884. */
  56885. height: number;
  56886. /**
  56887. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56888. */
  56889. centripetalForceThreshold: number;
  56890. /**
  56891. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56892. */
  56893. centripetalForceMultiplier: number;
  56894. /**
  56895. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56896. */
  56897. centrifugalForceMultiplier: number;
  56898. /**
  56899. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56900. */
  56901. updraftForceMultiplier: number;
  56902. }
  56903. /**
  56904. * The strenght of the force in correspondence to the distance of the affected object
  56905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56906. */
  56907. export enum PhysicsRadialImpulseFalloff {
  56908. /** Defines that impulse is constant in strength across it's whole radius */
  56909. Constant = 0,
  56910. /** Defines that impulse gets weaker if it's further from the origin */
  56911. Linear = 1
  56912. }
  56913. /**
  56914. * The strength of the force in correspondence to the distance of the affected object
  56915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56916. */
  56917. export enum PhysicsUpdraftMode {
  56918. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56919. Center = 0,
  56920. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56921. Perpendicular = 1
  56922. }
  56923. /**
  56924. * Interface for a physics hit data
  56925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56926. */
  56927. export interface PhysicsHitData {
  56928. /**
  56929. * The force applied at the contact point
  56930. */
  56931. force: Vector3;
  56932. /**
  56933. * The contact point
  56934. */
  56935. contactPoint: Vector3;
  56936. /**
  56937. * The distance from the origin to the contact point
  56938. */
  56939. distanceFromOrigin: number;
  56940. }
  56941. /**
  56942. * Interface for radial explosion event data
  56943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56944. */
  56945. export interface PhysicsRadialExplosionEventData {
  56946. /**
  56947. * A sphere used for the radial explosion event
  56948. */
  56949. sphere: Mesh;
  56950. }
  56951. /**
  56952. * Interface for gravitational field event data
  56953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56954. */
  56955. export interface PhysicsGravitationalFieldEventData {
  56956. /**
  56957. * A sphere mesh used for the gravitational field event
  56958. */
  56959. sphere: Mesh;
  56960. }
  56961. /**
  56962. * Interface for updraft event data
  56963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56964. */
  56965. export interface PhysicsUpdraftEventData {
  56966. /**
  56967. * A cylinder used for the updraft event
  56968. */
  56969. cylinder: Mesh;
  56970. }
  56971. /**
  56972. * Interface for vortex event data
  56973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56974. */
  56975. export interface PhysicsVortexEventData {
  56976. /**
  56977. * A cylinder used for the vortex event
  56978. */
  56979. cylinder: Mesh;
  56980. }
  56981. /**
  56982. * Interface for an affected physics impostor
  56983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56984. */
  56985. export interface PhysicsAffectedImpostorWithData {
  56986. /**
  56987. * The impostor affected by the effect
  56988. */
  56989. impostor: PhysicsImpostor;
  56990. /**
  56991. * The data about the hit/horce from the explosion
  56992. */
  56993. hitData: PhysicsHitData;
  56994. }
  56995. }
  56996. declare module BABYLON {
  56997. /** @hidden */
  56998. export var blackAndWhitePixelShader: {
  56999. name: string;
  57000. shader: string;
  57001. };
  57002. }
  57003. declare module BABYLON {
  57004. /**
  57005. * Post process used to render in black and white
  57006. */
  57007. export class BlackAndWhitePostProcess extends PostProcess {
  57008. /**
  57009. * Linear about to convert he result to black and white (default: 1)
  57010. */
  57011. degree: number;
  57012. /**
  57013. * Creates a black and white post process
  57014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57015. * @param name The name of the effect.
  57016. * @param options The required width/height ratio to downsize to before computing the render pass.
  57017. * @param camera The camera to apply the render pass to.
  57018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57019. * @param engine The engine which the post process will be applied. (default: current engine)
  57020. * @param reusable If the post process can be reused on the same frame. (default: false)
  57021. */
  57022. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57023. }
  57024. }
  57025. declare module BABYLON {
  57026. /**
  57027. * This represents a set of one or more post processes in Babylon.
  57028. * A post process can be used to apply a shader to a texture after it is rendered.
  57029. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57030. */
  57031. export class PostProcessRenderEffect {
  57032. private _postProcesses;
  57033. private _getPostProcesses;
  57034. private _singleInstance;
  57035. private _cameras;
  57036. private _indicesForCamera;
  57037. /**
  57038. * Name of the effect
  57039. * @hidden
  57040. */ private _name: string;
  57041. /**
  57042. * Instantiates a post process render effect.
  57043. * A post process can be used to apply a shader to a texture after it is rendered.
  57044. * @param engine The engine the effect is tied to
  57045. * @param name The name of the effect
  57046. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57047. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57048. */
  57049. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57050. /**
  57051. * Checks if all the post processes in the effect are supported.
  57052. */
  57053. readonly isSupported: boolean;
  57054. /**
  57055. * Updates the current state of the effect
  57056. * @hidden
  57057. */ private _update(): void;
  57058. /**
  57059. * Attaches the effect on cameras
  57060. * @param cameras The camera to attach to.
  57061. * @hidden
  57062. */ private _attachCameras(cameras: Camera): void;
  57063. /**
  57064. * Attaches the effect on cameras
  57065. * @param cameras The camera to attach to.
  57066. * @hidden
  57067. */ private _attachCameras(cameras: Camera[]): void;
  57068. /**
  57069. * Detaches the effect on cameras
  57070. * @param cameras The camera to detatch from.
  57071. * @hidden
  57072. */ private _detachCameras(cameras: Camera): void;
  57073. /**
  57074. * Detatches the effect on cameras
  57075. * @param cameras The camera to detatch from.
  57076. * @hidden
  57077. */ private _detachCameras(cameras: Camera[]): void;
  57078. /**
  57079. * Enables the effect on given cameras
  57080. * @param cameras The camera to enable.
  57081. * @hidden
  57082. */ private _enable(cameras: Camera): void;
  57083. /**
  57084. * Enables the effect on given cameras
  57085. * @param cameras The camera to enable.
  57086. * @hidden
  57087. */ private _enable(cameras: Nullable<Camera[]>): void;
  57088. /**
  57089. * Disables the effect on the given cameras
  57090. * @param cameras The camera to disable.
  57091. * @hidden
  57092. */ private _disable(cameras: Camera): void;
  57093. /**
  57094. * Disables the effect on the given cameras
  57095. * @param cameras The camera to disable.
  57096. * @hidden
  57097. */ private _disable(cameras: Nullable<Camera[]>): void;
  57098. /**
  57099. * Gets a list of the post processes contained in the effect.
  57100. * @param camera The camera to get the post processes on.
  57101. * @returns The list of the post processes in the effect.
  57102. */
  57103. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57104. }
  57105. }
  57106. declare module BABYLON {
  57107. /** @hidden */
  57108. export var extractHighlightsPixelShader: {
  57109. name: string;
  57110. shader: string;
  57111. };
  57112. }
  57113. declare module BABYLON {
  57114. /**
  57115. * 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.
  57116. */
  57117. export class ExtractHighlightsPostProcess extends PostProcess {
  57118. /**
  57119. * The luminance threshold, pixels below this value will be set to black.
  57120. */
  57121. threshold: number;
  57122. /** @hidden */ private _exposure: number;
  57123. /**
  57124. * Post process which has the input texture to be used when performing highlight extraction
  57125. * @hidden
  57126. */ private _inputPostProcess: Nullable<PostProcess>;
  57127. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57128. }
  57129. }
  57130. declare module BABYLON {
  57131. /** @hidden */
  57132. export var bloomMergePixelShader: {
  57133. name: string;
  57134. shader: string;
  57135. };
  57136. }
  57137. declare module BABYLON {
  57138. /**
  57139. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57140. */
  57141. export class BloomMergePostProcess extends PostProcess {
  57142. /** Weight of the bloom to be added to the original input. */
  57143. weight: number;
  57144. /**
  57145. * Creates a new instance of @see BloomMergePostProcess
  57146. * @param name The name of the effect.
  57147. * @param originalFromInput Post process which's input will be used for the merge.
  57148. * @param blurred Blurred highlights post process which's output will be used.
  57149. * @param weight Weight of the bloom to be added to the original input.
  57150. * @param options The required width/height ratio to downsize to before computing the render pass.
  57151. * @param camera The camera to apply the render pass to.
  57152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57153. * @param engine The engine which the post process will be applied. (default: current engine)
  57154. * @param reusable If the post process can be reused on the same frame. (default: false)
  57155. * @param textureType Type of textures used when performing the post process. (default: 0)
  57156. * @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)
  57157. */
  57158. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57159. /** Weight of the bloom to be added to the original input. */
  57160. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57161. }
  57162. }
  57163. declare module BABYLON {
  57164. /**
  57165. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57166. */
  57167. export class BloomEffect extends PostProcessRenderEffect {
  57168. private bloomScale;
  57169. /**
  57170. * @hidden Internal
  57171. */ private _effects: Array<PostProcess>;
  57172. /**
  57173. * @hidden Internal
  57174. */ private _downscale: ExtractHighlightsPostProcess;
  57175. private _blurX;
  57176. private _blurY;
  57177. private _merge;
  57178. /**
  57179. * The luminance threshold to find bright areas of the image to bloom.
  57180. */
  57181. threshold: number;
  57182. /**
  57183. * The strength of the bloom.
  57184. */
  57185. weight: number;
  57186. /**
  57187. * Specifies the size of the bloom blur kernel, relative to the final output size
  57188. */
  57189. kernel: number;
  57190. /**
  57191. * Creates a new instance of @see BloomEffect
  57192. * @param scene The scene the effect belongs to.
  57193. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57194. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57195. * @param bloomWeight The the strength of bloom.
  57196. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57197. * @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)
  57198. */
  57199. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57200. /**
  57201. * Disposes each of the internal effects for a given camera.
  57202. * @param camera The camera to dispose the effect on.
  57203. */
  57204. disposeEffects(camera: Camera): void;
  57205. /**
  57206. * @hidden Internal
  57207. */ private _updateEffects(): void;
  57208. /**
  57209. * Internal
  57210. * @returns if all the contained post processes are ready.
  57211. * @hidden
  57212. */ private _isReady(): boolean;
  57213. }
  57214. }
  57215. declare module BABYLON {
  57216. /** @hidden */
  57217. export var chromaticAberrationPixelShader: {
  57218. name: string;
  57219. shader: string;
  57220. };
  57221. }
  57222. declare module BABYLON {
  57223. /**
  57224. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57225. */
  57226. export class ChromaticAberrationPostProcess extends PostProcess {
  57227. /**
  57228. * The amount of seperation of rgb channels (default: 30)
  57229. */
  57230. aberrationAmount: number;
  57231. /**
  57232. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57233. */
  57234. radialIntensity: number;
  57235. /**
  57236. * 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))
  57237. */
  57238. direction: Vector2;
  57239. /**
  57240. * 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))
  57241. */
  57242. centerPosition: Vector2;
  57243. /**
  57244. * Creates a new instance ChromaticAberrationPostProcess
  57245. * @param name The name of the effect.
  57246. * @param screenWidth The width of the screen to apply the effect on.
  57247. * @param screenHeight The height of the screen to apply the effect on.
  57248. * @param options The required width/height ratio to downsize to before computing the render pass.
  57249. * @param camera The camera to apply the render pass to.
  57250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57251. * @param engine The engine which the post process will be applied. (default: current engine)
  57252. * @param reusable If the post process can be reused on the same frame. (default: false)
  57253. * @param textureType Type of textures used when performing the post process. (default: 0)
  57254. * @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)
  57255. */
  57256. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57257. }
  57258. }
  57259. declare module BABYLON {
  57260. /** @hidden */
  57261. export var circleOfConfusionPixelShader: {
  57262. name: string;
  57263. shader: string;
  57264. };
  57265. }
  57266. declare module BABYLON {
  57267. /**
  57268. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57269. */
  57270. export class CircleOfConfusionPostProcess extends PostProcess {
  57271. /**
  57272. * 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.
  57273. */
  57274. lensSize: number;
  57275. /**
  57276. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57277. */
  57278. fStop: number;
  57279. /**
  57280. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57281. */
  57282. focusDistance: number;
  57283. /**
  57284. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57285. */
  57286. focalLength: number;
  57287. private _depthTexture;
  57288. /**
  57289. * Creates a new instance CircleOfConfusionPostProcess
  57290. * @param name The name of the effect.
  57291. * @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.
  57292. * @param options The required width/height ratio to downsize to before computing the render pass.
  57293. * @param camera The camera to apply the render pass to.
  57294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57295. * @param engine The engine which the post process will be applied. (default: current engine)
  57296. * @param reusable If the post process can be reused on the same frame. (default: false)
  57297. * @param textureType Type of textures used when performing the post process. (default: 0)
  57298. * @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)
  57299. */
  57300. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57301. /**
  57302. * 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.
  57303. */
  57304. depthTexture: RenderTargetTexture;
  57305. }
  57306. }
  57307. declare module BABYLON {
  57308. /** @hidden */
  57309. export var colorCorrectionPixelShader: {
  57310. name: string;
  57311. shader: string;
  57312. };
  57313. }
  57314. declare module BABYLON {
  57315. /**
  57316. *
  57317. * This post-process allows the modification of rendered colors by using
  57318. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57319. *
  57320. * The object needs to be provided an url to a texture containing the color
  57321. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57322. * Use an image editing software to tweak the LUT to match your needs.
  57323. *
  57324. * For an example of a color LUT, see here:
  57325. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57326. * For explanations on color grading, see here:
  57327. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57328. *
  57329. */
  57330. export class ColorCorrectionPostProcess extends PostProcess {
  57331. private _colorTableTexture;
  57332. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57333. }
  57334. }
  57335. declare module BABYLON {
  57336. /** @hidden */
  57337. export var convolutionPixelShader: {
  57338. name: string;
  57339. shader: string;
  57340. };
  57341. }
  57342. declare module BABYLON {
  57343. /**
  57344. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57345. * input texture to perform effects such as edge detection or sharpening
  57346. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57347. */
  57348. export class ConvolutionPostProcess extends PostProcess {
  57349. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57350. kernel: number[];
  57351. /**
  57352. * Creates a new instance ConvolutionPostProcess
  57353. * @param name The name of the effect.
  57354. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57355. * @param options The required width/height ratio to downsize to before computing the render pass.
  57356. * @param camera The camera to apply the render pass to.
  57357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57358. * @param engine The engine which the post process will be applied. (default: current engine)
  57359. * @param reusable If the post process can be reused on the same frame. (default: false)
  57360. * @param textureType Type of textures used when performing the post process. (default: 0)
  57361. */
  57362. constructor(name: string,
  57363. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57364. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57365. /**
  57366. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57367. */
  57368. static EdgeDetect0Kernel: number[];
  57369. /**
  57370. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57371. */
  57372. static EdgeDetect1Kernel: number[];
  57373. /**
  57374. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57375. */
  57376. static EdgeDetect2Kernel: number[];
  57377. /**
  57378. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57379. */
  57380. static SharpenKernel: number[];
  57381. /**
  57382. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57383. */
  57384. static EmbossKernel: number[];
  57385. /**
  57386. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57387. */
  57388. static GaussianKernel: number[];
  57389. }
  57390. }
  57391. declare module BABYLON {
  57392. /**
  57393. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57394. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57395. * based on samples that have a large difference in distance than the center pixel.
  57396. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57397. */
  57398. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57399. direction: Vector2;
  57400. /**
  57401. * Creates a new instance CircleOfConfusionPostProcess
  57402. * @param name The name of the effect.
  57403. * @param scene The scene the effect belongs to.
  57404. * @param direction The direction the blur should be applied.
  57405. * @param kernel The size of the kernel used to blur.
  57406. * @param options The required width/height ratio to downsize to before computing the render pass.
  57407. * @param camera The camera to apply the render pass to.
  57408. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57409. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57411. * @param engine The engine which the post process will be applied. (default: current engine)
  57412. * @param reusable If the post process can be reused on the same frame. (default: false)
  57413. * @param textureType Type of textures used when performing the post process. (default: 0)
  57414. * @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)
  57415. */
  57416. 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);
  57417. }
  57418. }
  57419. declare module BABYLON {
  57420. /** @hidden */
  57421. export var depthOfFieldMergePixelShader: {
  57422. name: string;
  57423. shader: string;
  57424. };
  57425. }
  57426. declare module BABYLON {
  57427. /**
  57428. * Options to be set when merging outputs from the default pipeline.
  57429. */
  57430. export class DepthOfFieldMergePostProcessOptions {
  57431. /**
  57432. * The original image to merge on top of
  57433. */
  57434. originalFromInput: PostProcess;
  57435. /**
  57436. * Parameters to perform the merge of the depth of field effect
  57437. */
  57438. depthOfField?: {
  57439. circleOfConfusion: PostProcess;
  57440. blurSteps: Array<PostProcess>;
  57441. };
  57442. /**
  57443. * Parameters to perform the merge of bloom effect
  57444. */
  57445. bloom?: {
  57446. blurred: PostProcess;
  57447. weight: number;
  57448. };
  57449. }
  57450. /**
  57451. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57452. */
  57453. export class DepthOfFieldMergePostProcess extends PostProcess {
  57454. private blurSteps;
  57455. /**
  57456. * Creates a new instance of DepthOfFieldMergePostProcess
  57457. * @param name The name of the effect.
  57458. * @param originalFromInput Post process which's input will be used for the merge.
  57459. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57460. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57461. * @param options The required width/height ratio to downsize to before computing the render pass.
  57462. * @param camera The camera to apply the render pass to.
  57463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57464. * @param engine The engine which the post process will be applied. (default: current engine)
  57465. * @param reusable If the post process can be reused on the same frame. (default: false)
  57466. * @param textureType Type of textures used when performing the post process. (default: 0)
  57467. * @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)
  57468. */
  57469. 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);
  57470. /**
  57471. * Updates the effect with the current post process compile time values and recompiles the shader.
  57472. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57473. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57474. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57475. * @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
  57476. * @param onCompiled Called when the shader has been compiled.
  57477. * @param onError Called if there is an error when compiling a shader.
  57478. */
  57479. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57480. }
  57481. }
  57482. declare module BABYLON {
  57483. /**
  57484. * Specifies the level of max blur that should be applied when using the depth of field effect
  57485. */
  57486. export enum DepthOfFieldEffectBlurLevel {
  57487. /**
  57488. * Subtle blur
  57489. */
  57490. Low = 0,
  57491. /**
  57492. * Medium blur
  57493. */
  57494. Medium = 1,
  57495. /**
  57496. * Large blur
  57497. */
  57498. High = 2
  57499. }
  57500. /**
  57501. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57502. */
  57503. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57504. private _circleOfConfusion;
  57505. /**
  57506. * @hidden Internal, blurs from high to low
  57507. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57508. private _depthOfFieldBlurY;
  57509. private _dofMerge;
  57510. /**
  57511. * @hidden Internal post processes in depth of field effect
  57512. */ private _effects: Array<PostProcess>;
  57513. /**
  57514. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57515. */
  57516. focalLength: number;
  57517. /**
  57518. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57519. */
  57520. fStop: number;
  57521. /**
  57522. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57523. */
  57524. focusDistance: number;
  57525. /**
  57526. * 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.
  57527. */
  57528. lensSize: number;
  57529. /**
  57530. * Creates a new instance DepthOfFieldEffect
  57531. * @param scene The scene the effect belongs to.
  57532. * @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.
  57533. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57534. * @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)
  57535. */
  57536. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57537. /**
  57538. * Get the current class name of the current effet
  57539. * @returns "DepthOfFieldEffect"
  57540. */
  57541. getClassName(): string;
  57542. /**
  57543. * 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.
  57544. */
  57545. depthTexture: RenderTargetTexture;
  57546. /**
  57547. * Disposes each of the internal effects for a given camera.
  57548. * @param camera The camera to dispose the effect on.
  57549. */
  57550. disposeEffects(camera: Camera): void;
  57551. /**
  57552. * @hidden Internal
  57553. */ private _updateEffects(): void;
  57554. /**
  57555. * Internal
  57556. * @returns if all the contained post processes are ready.
  57557. * @hidden
  57558. */ private _isReady(): boolean;
  57559. }
  57560. }
  57561. declare module BABYLON {
  57562. /** @hidden */
  57563. export var displayPassPixelShader: {
  57564. name: string;
  57565. shader: string;
  57566. };
  57567. }
  57568. declare module BABYLON {
  57569. /**
  57570. * DisplayPassPostProcess which produces an output the same as it's input
  57571. */
  57572. export class DisplayPassPostProcess extends PostProcess {
  57573. /**
  57574. * Creates the DisplayPassPostProcess
  57575. * @param name The name of the effect.
  57576. * @param options The required width/height ratio to downsize to before computing the render pass.
  57577. * @param camera The camera to apply the render pass to.
  57578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57579. * @param engine The engine which the post process will be applied. (default: current engine)
  57580. * @param reusable If the post process can be reused on the same frame. (default: false)
  57581. */
  57582. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57583. }
  57584. }
  57585. declare module BABYLON {
  57586. /** @hidden */
  57587. export var filterPixelShader: {
  57588. name: string;
  57589. shader: string;
  57590. };
  57591. }
  57592. declare module BABYLON {
  57593. /**
  57594. * Applies a kernel filter to the image
  57595. */
  57596. export class FilterPostProcess extends PostProcess {
  57597. /** The matrix to be applied to the image */
  57598. kernelMatrix: Matrix;
  57599. /**
  57600. *
  57601. * @param name The name of the effect.
  57602. * @param kernelMatrix The matrix to be applied to the image
  57603. * @param options The required width/height ratio to downsize to before computing the render pass.
  57604. * @param camera The camera to apply the render pass to.
  57605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57606. * @param engine The engine which the post process will be applied. (default: current engine)
  57607. * @param reusable If the post process can be reused on the same frame. (default: false)
  57608. */
  57609. constructor(name: string,
  57610. /** The matrix to be applied to the image */
  57611. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57612. }
  57613. }
  57614. declare module BABYLON {
  57615. /** @hidden */
  57616. export var fxaaPixelShader: {
  57617. name: string;
  57618. shader: string;
  57619. };
  57620. }
  57621. declare module BABYLON {
  57622. /** @hidden */
  57623. export var fxaaVertexShader: {
  57624. name: string;
  57625. shader: string;
  57626. };
  57627. }
  57628. declare module BABYLON {
  57629. /**
  57630. * Fxaa post process
  57631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57632. */
  57633. export class FxaaPostProcess extends PostProcess {
  57634. /** @hidden */
  57635. texelWidth: number;
  57636. /** @hidden */
  57637. texelHeight: number;
  57638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57639. private _getDefines;
  57640. }
  57641. }
  57642. declare module BABYLON {
  57643. /** @hidden */
  57644. export var grainPixelShader: {
  57645. name: string;
  57646. shader: string;
  57647. };
  57648. }
  57649. declare module BABYLON {
  57650. /**
  57651. * The GrainPostProcess adds noise to the image at mid luminance levels
  57652. */
  57653. export class GrainPostProcess extends PostProcess {
  57654. /**
  57655. * The intensity of the grain added (default: 30)
  57656. */
  57657. intensity: number;
  57658. /**
  57659. * If the grain should be randomized on every frame
  57660. */
  57661. animated: boolean;
  57662. /**
  57663. * Creates a new instance of @see GrainPostProcess
  57664. * @param name The name of the effect.
  57665. * @param options The required width/height ratio to downsize to before computing the render pass.
  57666. * @param camera The camera to apply the render pass to.
  57667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57668. * @param engine The engine which the post process will be applied. (default: current engine)
  57669. * @param reusable If the post process can be reused on the same frame. (default: false)
  57670. * @param textureType Type of textures used when performing the post process. (default: 0)
  57671. * @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)
  57672. */
  57673. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57674. }
  57675. }
  57676. declare module BABYLON {
  57677. /** @hidden */
  57678. export var highlightsPixelShader: {
  57679. name: string;
  57680. shader: string;
  57681. };
  57682. }
  57683. declare module BABYLON {
  57684. /**
  57685. * Extracts highlights from the image
  57686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57687. */
  57688. export class HighlightsPostProcess extends PostProcess {
  57689. /**
  57690. * Extracts highlights from the image
  57691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57692. * @param name The name of the effect.
  57693. * @param options The required width/height ratio to downsize to before computing the render pass.
  57694. * @param camera The camera to apply the render pass to.
  57695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57696. * @param engine The engine which the post process will be applied. (default: current engine)
  57697. * @param reusable If the post process can be reused on the same frame. (default: false)
  57698. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57699. */
  57700. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57701. }
  57702. }
  57703. declare module BABYLON {
  57704. /** @hidden */
  57705. export var mrtFragmentDeclaration: {
  57706. name: string;
  57707. shader: string;
  57708. };
  57709. }
  57710. declare module BABYLON {
  57711. /** @hidden */
  57712. export var geometryPixelShader: {
  57713. name: string;
  57714. shader: string;
  57715. };
  57716. }
  57717. declare module BABYLON {
  57718. /** @hidden */
  57719. export var geometryVertexShader: {
  57720. name: string;
  57721. shader: string;
  57722. };
  57723. }
  57724. declare module BABYLON {
  57725. /** @hidden */
  57726. interface ISavedTransformationMatrix {
  57727. world: Matrix;
  57728. viewProjection: Matrix;
  57729. }
  57730. /**
  57731. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57732. */
  57733. export class GeometryBufferRenderer {
  57734. /**
  57735. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57736. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57737. */
  57738. static readonly POSITION_TEXTURE_TYPE: number;
  57739. /**
  57740. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57741. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57742. */
  57743. static readonly VELOCITY_TEXTURE_TYPE: number;
  57744. /**
  57745. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57746. * in order to compute objects velocities when enableVelocity is set to "true"
  57747. * @hidden
  57748. */ private _previousTransformationMatrices: {
  57749. [index: number]: ISavedTransformationMatrix;
  57750. };
  57751. /**
  57752. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57753. * in order to compute objects velocities when enableVelocity is set to "true"
  57754. * @hidden
  57755. */ private _previousBonesTransformationMatrices: {
  57756. [index: number]: Float32Array;
  57757. };
  57758. /**
  57759. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57760. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57761. */
  57762. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57763. private _scene;
  57764. private _multiRenderTarget;
  57765. private _ratio;
  57766. private _enablePosition;
  57767. private _enableVelocity;
  57768. private _positionIndex;
  57769. private _velocityIndex;
  57770. protected _effect: Effect;
  57771. protected _cachedDefines: string;
  57772. /**
  57773. * Set the render list (meshes to be rendered) used in the G buffer.
  57774. */
  57775. renderList: Mesh[];
  57776. /**
  57777. * Gets wether or not G buffer are supported by the running hardware.
  57778. * This requires draw buffer supports
  57779. */
  57780. readonly isSupported: boolean;
  57781. /**
  57782. * Returns the index of the given texture type in the G-Buffer textures array
  57783. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57784. * @returns the index of the given texture type in the G-Buffer textures array
  57785. */
  57786. getTextureIndex(textureType: number): number;
  57787. /**
  57788. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57789. */
  57790. /**
  57791. * Sets whether or not objects positions are enabled for the G buffer.
  57792. */
  57793. enablePosition: boolean;
  57794. /**
  57795. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57796. */
  57797. /**
  57798. * Sets wether or not objects velocities are enabled for the G buffer.
  57799. */
  57800. enableVelocity: boolean;
  57801. /**
  57802. * Gets the scene associated with the buffer.
  57803. */
  57804. readonly scene: Scene;
  57805. /**
  57806. * Gets the ratio used by the buffer during its creation.
  57807. * How big is the buffer related to the main canvas.
  57808. */
  57809. readonly ratio: number;
  57810. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  57811. /**
  57812. * Creates a new G Buffer for the scene
  57813. * @param scene The scene the buffer belongs to
  57814. * @param ratio How big is the buffer related to the main canvas.
  57815. */
  57816. constructor(scene: Scene, ratio?: number);
  57817. /**
  57818. * Checks wether everything is ready to render a submesh to the G buffer.
  57819. * @param subMesh the submesh to check readiness for
  57820. * @param useInstances is the mesh drawn using instance or not
  57821. * @returns true if ready otherwise false
  57822. */
  57823. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57824. /**
  57825. * Gets the current underlying G Buffer.
  57826. * @returns the buffer
  57827. */
  57828. getGBuffer(): MultiRenderTarget;
  57829. /**
  57830. * Gets the number of samples used to render the buffer (anti aliasing).
  57831. */
  57832. /**
  57833. * Sets the number of samples used to render the buffer (anti aliasing).
  57834. */
  57835. samples: number;
  57836. /**
  57837. * Disposes the renderer and frees up associated resources.
  57838. */
  57839. dispose(): void;
  57840. protected _createRenderTargets(): void;
  57841. private _copyBonesTransformationMatrices;
  57842. }
  57843. }
  57844. declare module BABYLON {
  57845. interface Scene {
  57846. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57847. /**
  57848. * Gets or Sets the current geometry buffer associated to the scene.
  57849. */
  57850. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57851. /**
  57852. * Enables a GeometryBufferRender and associates it with the scene
  57853. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57854. * @returns the GeometryBufferRenderer
  57855. */
  57856. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57857. /**
  57858. * Disables the GeometryBufferRender associated with the scene
  57859. */
  57860. disableGeometryBufferRenderer(): void;
  57861. }
  57862. /**
  57863. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57864. * in several rendering techniques.
  57865. */
  57866. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57867. /**
  57868. * The component name helpful to identify the component in the list of scene components.
  57869. */
  57870. readonly name: string;
  57871. /**
  57872. * The scene the component belongs to.
  57873. */
  57874. scene: Scene;
  57875. /**
  57876. * Creates a new instance of the component for the given scene
  57877. * @param scene Defines the scene to register the component in
  57878. */
  57879. constructor(scene: Scene);
  57880. /**
  57881. * Registers the component in a given scene
  57882. */
  57883. register(): void;
  57884. /**
  57885. * Rebuilds the elements related to this component in case of
  57886. * context lost for instance.
  57887. */
  57888. rebuild(): void;
  57889. /**
  57890. * Disposes the component and the associated ressources
  57891. */
  57892. dispose(): void;
  57893. private _gatherRenderTargets;
  57894. }
  57895. }
  57896. declare module BABYLON {
  57897. /** @hidden */
  57898. export var motionBlurPixelShader: {
  57899. name: string;
  57900. shader: string;
  57901. };
  57902. }
  57903. declare module BABYLON {
  57904. /**
  57905. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57906. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57907. * As an example, all you have to do is to create the post-process:
  57908. * var mb = new BABYLON.MotionBlurPostProcess(
  57909. * 'mb', // The name of the effect.
  57910. * scene, // The scene containing the objects to blur according to their velocity.
  57911. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57912. * camera // The camera to apply the render pass to.
  57913. * );
  57914. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57915. */
  57916. export class MotionBlurPostProcess extends PostProcess {
  57917. /**
  57918. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57919. */
  57920. motionStrength: number;
  57921. /**
  57922. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57923. */
  57924. /**
  57925. * Sets the number of iterations to be used for motion blur quality
  57926. */
  57927. motionBlurSamples: number;
  57928. private _motionBlurSamples;
  57929. private _geometryBufferRenderer;
  57930. /**
  57931. * Creates a new instance MotionBlurPostProcess
  57932. * @param name The name of the effect.
  57933. * @param scene The scene containing the objects to blur according to their velocity.
  57934. * @param options The required width/height ratio to downsize to before computing the render pass.
  57935. * @param camera The camera to apply the render pass to.
  57936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57937. * @param engine The engine which the post process will be applied. (default: current engine)
  57938. * @param reusable If the post process can be reused on the same frame. (default: false)
  57939. * @param textureType Type of textures used when performing the post process. (default: 0)
  57940. * @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)
  57941. */
  57942. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57943. /**
  57944. * Excludes the given skinned mesh from computing bones velocities.
  57945. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  57946. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57947. */
  57948. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57949. /**
  57950. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57951. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57952. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57953. */
  57954. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57955. /**
  57956. * Disposes the post process.
  57957. * @param camera The camera to dispose the post process on.
  57958. */
  57959. dispose(camera?: Camera): void;
  57960. }
  57961. }
  57962. declare module BABYLON {
  57963. /** @hidden */
  57964. export var refractionPixelShader: {
  57965. name: string;
  57966. shader: string;
  57967. };
  57968. }
  57969. declare module BABYLON {
  57970. /**
  57971. * Post process which applies a refractin texture
  57972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57973. */
  57974. export class RefractionPostProcess extends PostProcess {
  57975. /** the base color of the refraction (used to taint the rendering) */
  57976. color: Color3;
  57977. /** simulated refraction depth */
  57978. depth: number;
  57979. /** the coefficient of the base color (0 to remove base color tainting) */
  57980. colorLevel: number;
  57981. private _refTexture;
  57982. private _ownRefractionTexture;
  57983. /**
  57984. * Gets or sets the refraction texture
  57985. * Please note that you are responsible for disposing the texture if you set it manually
  57986. */
  57987. refractionTexture: Texture;
  57988. /**
  57989. * Initializes the RefractionPostProcess
  57990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57991. * @param name The name of the effect.
  57992. * @param refractionTextureUrl Url of the refraction texture to use
  57993. * @param color the base color of the refraction (used to taint the rendering)
  57994. * @param depth simulated refraction depth
  57995. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57996. * @param camera The camera to apply the render pass to.
  57997. * @param options The required width/height ratio to downsize to before computing the render pass.
  57998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57999. * @param engine The engine which the post process will be applied. (default: current engine)
  58000. * @param reusable If the post process can be reused on the same frame. (default: false)
  58001. */
  58002. constructor(name: string, refractionTextureUrl: string,
  58003. /** the base color of the refraction (used to taint the rendering) */
  58004. color: Color3,
  58005. /** simulated refraction depth */
  58006. depth: number,
  58007. /** the coefficient of the base color (0 to remove base color tainting) */
  58008. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58009. /**
  58010. * Disposes of the post process
  58011. * @param camera Camera to dispose post process on
  58012. */
  58013. dispose(camera: Camera): void;
  58014. }
  58015. }
  58016. declare module BABYLON {
  58017. /** @hidden */
  58018. export var sharpenPixelShader: {
  58019. name: string;
  58020. shader: string;
  58021. };
  58022. }
  58023. declare module BABYLON {
  58024. /**
  58025. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58026. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58027. */
  58028. export class SharpenPostProcess extends PostProcess {
  58029. /**
  58030. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58031. */
  58032. colorAmount: number;
  58033. /**
  58034. * How much sharpness should be applied (default: 0.3)
  58035. */
  58036. edgeAmount: number;
  58037. /**
  58038. * Creates a new instance ConvolutionPostProcess
  58039. * @param name The name of the effect.
  58040. * @param options The required width/height ratio to downsize to before computing the render pass.
  58041. * @param camera The camera to apply the render pass to.
  58042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58043. * @param engine The engine which the post process will be applied. (default: current engine)
  58044. * @param reusable If the post process can be reused on the same frame. (default: false)
  58045. * @param textureType Type of textures used when performing the post process. (default: 0)
  58046. * @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)
  58047. */
  58048. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58049. }
  58050. }
  58051. declare module BABYLON {
  58052. /**
  58053. * PostProcessRenderPipeline
  58054. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58055. */
  58056. export class PostProcessRenderPipeline {
  58057. private engine;
  58058. private _renderEffects;
  58059. private _renderEffectsForIsolatedPass;
  58060. /**
  58061. * List of inspectable custom properties (used by the Inspector)
  58062. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58063. */
  58064. inspectableCustomProperties: IInspectable[];
  58065. /**
  58066. * @hidden
  58067. */
  58068. protected _cameras: Camera[];
  58069. /** @hidden */ private _name: string;
  58070. /**
  58071. * Gets pipeline name
  58072. */
  58073. readonly name: string;
  58074. /**
  58075. * Initializes a PostProcessRenderPipeline
  58076. * @param engine engine to add the pipeline to
  58077. * @param name name of the pipeline
  58078. */
  58079. constructor(engine: Engine, name: string);
  58080. /**
  58081. * Gets the class name
  58082. * @returns "PostProcessRenderPipeline"
  58083. */
  58084. getClassName(): string;
  58085. /**
  58086. * If all the render effects in the pipeline are supported
  58087. */
  58088. readonly isSupported: boolean;
  58089. /**
  58090. * Adds an effect to the pipeline
  58091. * @param renderEffect the effect to add
  58092. */
  58093. addEffect(renderEffect: PostProcessRenderEffect): void;
  58094. /** @hidden */ private _rebuild(): void;
  58095. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  58096. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58097. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58098. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58099. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  58100. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  58101. /** @hidden */ private _detachCameras(cameras: Camera): void;
  58102. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  58103. /** @hidden */ private _update(): void;
  58104. /** @hidden */ private _reset(): void;
  58105. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58106. /**
  58107. * Disposes of the pipeline
  58108. */
  58109. dispose(): void;
  58110. }
  58111. }
  58112. declare module BABYLON {
  58113. /**
  58114. * PostProcessRenderPipelineManager class
  58115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58116. */
  58117. export class PostProcessRenderPipelineManager {
  58118. private _renderPipelines;
  58119. /**
  58120. * Initializes a PostProcessRenderPipelineManager
  58121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58122. */
  58123. constructor();
  58124. /**
  58125. * Gets the list of supported render pipelines
  58126. */
  58127. readonly supportedPipelines: PostProcessRenderPipeline[];
  58128. /**
  58129. * Adds a pipeline to the manager
  58130. * @param renderPipeline The pipeline to add
  58131. */
  58132. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58133. /**
  58134. * Attaches a camera to the pipeline
  58135. * @param renderPipelineName The name of the pipeline to attach to
  58136. * @param cameras the camera to attach
  58137. * @param unique if the camera can be attached multiple times to the pipeline
  58138. */
  58139. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58140. /**
  58141. * Detaches a camera from the pipeline
  58142. * @param renderPipelineName The name of the pipeline to detach from
  58143. * @param cameras the camera to detach
  58144. */
  58145. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58146. /**
  58147. * Enables an effect by name on a pipeline
  58148. * @param renderPipelineName the name of the pipeline to enable the effect in
  58149. * @param renderEffectName the name of the effect to enable
  58150. * @param cameras the cameras that the effect should be enabled on
  58151. */
  58152. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58153. /**
  58154. * Disables an effect by name on a pipeline
  58155. * @param renderPipelineName the name of the pipeline to disable the effect in
  58156. * @param renderEffectName the name of the effect to disable
  58157. * @param cameras the cameras that the effect should be disabled on
  58158. */
  58159. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58160. /**
  58161. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58162. */
  58163. update(): void;
  58164. /** @hidden */ private _rebuild(): void;
  58165. /**
  58166. * Disposes of the manager and pipelines
  58167. */
  58168. dispose(): void;
  58169. }
  58170. }
  58171. declare module BABYLON {
  58172. interface Scene {
  58173. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58174. /**
  58175. * Gets the postprocess render pipeline manager
  58176. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58177. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58178. */
  58179. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58180. }
  58181. /**
  58182. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58183. */
  58184. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58185. /**
  58186. * The component name helpfull to identify the component in the list of scene components.
  58187. */
  58188. readonly name: string;
  58189. /**
  58190. * The scene the component belongs to.
  58191. */
  58192. scene: Scene;
  58193. /**
  58194. * Creates a new instance of the component for the given scene
  58195. * @param scene Defines the scene to register the component in
  58196. */
  58197. constructor(scene: Scene);
  58198. /**
  58199. * Registers the component in a given scene
  58200. */
  58201. register(): void;
  58202. /**
  58203. * Rebuilds the elements related to this component in case of
  58204. * context lost for instance.
  58205. */
  58206. rebuild(): void;
  58207. /**
  58208. * Disposes the component and the associated ressources
  58209. */
  58210. dispose(): void;
  58211. private _gatherRenderTargets;
  58212. }
  58213. }
  58214. declare module BABYLON {
  58215. /**
  58216. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58217. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58218. */
  58219. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58220. private _scene;
  58221. private _camerasToBeAttached;
  58222. /**
  58223. * ID of the sharpen post process,
  58224. */
  58225. private readonly SharpenPostProcessId;
  58226. /**
  58227. * @ignore
  58228. * ID of the image processing post process;
  58229. */
  58230. readonly ImageProcessingPostProcessId: string;
  58231. /**
  58232. * @ignore
  58233. * ID of the Fast Approximate Anti-Aliasing post process;
  58234. */
  58235. readonly FxaaPostProcessId: string;
  58236. /**
  58237. * ID of the chromatic aberration post process,
  58238. */
  58239. private readonly ChromaticAberrationPostProcessId;
  58240. /**
  58241. * ID of the grain post process
  58242. */
  58243. private readonly GrainPostProcessId;
  58244. /**
  58245. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58246. */
  58247. sharpen: SharpenPostProcess;
  58248. private _sharpenEffect;
  58249. private bloom;
  58250. /**
  58251. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58252. */
  58253. depthOfField: DepthOfFieldEffect;
  58254. /**
  58255. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58256. */
  58257. fxaa: FxaaPostProcess;
  58258. /**
  58259. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58260. */
  58261. imageProcessing: ImageProcessingPostProcess;
  58262. /**
  58263. * Chromatic aberration post process which will shift rgb colors in the image
  58264. */
  58265. chromaticAberration: ChromaticAberrationPostProcess;
  58266. private _chromaticAberrationEffect;
  58267. /**
  58268. * Grain post process which add noise to the image
  58269. */
  58270. grain: GrainPostProcess;
  58271. private _grainEffect;
  58272. /**
  58273. * Glow post process which adds a glow to emissive areas of the image
  58274. */
  58275. private _glowLayer;
  58276. /**
  58277. * Animations which can be used to tweak settings over a period of time
  58278. */
  58279. animations: Animation[];
  58280. private _imageProcessingConfigurationObserver;
  58281. private _sharpenEnabled;
  58282. private _bloomEnabled;
  58283. private _depthOfFieldEnabled;
  58284. private _depthOfFieldBlurLevel;
  58285. private _fxaaEnabled;
  58286. private _imageProcessingEnabled;
  58287. private _defaultPipelineTextureType;
  58288. private _bloomScale;
  58289. private _chromaticAberrationEnabled;
  58290. private _grainEnabled;
  58291. private _buildAllowed;
  58292. /**
  58293. * Gets active scene
  58294. */
  58295. readonly scene: Scene;
  58296. /**
  58297. * Enable or disable the sharpen process from the pipeline
  58298. */
  58299. sharpenEnabled: boolean;
  58300. private _resizeObserver;
  58301. private _hardwareScaleLevel;
  58302. private _bloomKernel;
  58303. /**
  58304. * Specifies the size of the bloom blur kernel, relative to the final output size
  58305. */
  58306. bloomKernel: number;
  58307. /**
  58308. * Specifies the weight of the bloom in the final rendering
  58309. */
  58310. private _bloomWeight;
  58311. /**
  58312. * Specifies the luma threshold for the area that will be blurred by the bloom
  58313. */
  58314. private _bloomThreshold;
  58315. private _hdr;
  58316. /**
  58317. * The strength of the bloom.
  58318. */
  58319. bloomWeight: number;
  58320. /**
  58321. * The strength of the bloom.
  58322. */
  58323. bloomThreshold: number;
  58324. /**
  58325. * The scale of the bloom, lower value will provide better performance.
  58326. */
  58327. bloomScale: number;
  58328. /**
  58329. * Enable or disable the bloom from the pipeline
  58330. */
  58331. bloomEnabled: boolean;
  58332. private _rebuildBloom;
  58333. /**
  58334. * If the depth of field is enabled.
  58335. */
  58336. depthOfFieldEnabled: boolean;
  58337. /**
  58338. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58339. */
  58340. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58341. /**
  58342. * If the anti aliasing is enabled.
  58343. */
  58344. fxaaEnabled: boolean;
  58345. private _samples;
  58346. /**
  58347. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58348. */
  58349. samples: number;
  58350. /**
  58351. * If image processing is enabled.
  58352. */
  58353. imageProcessingEnabled: boolean;
  58354. /**
  58355. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58356. */
  58357. glowLayerEnabled: boolean;
  58358. /**
  58359. * Gets the glow layer (or null if not defined)
  58360. */
  58361. readonly glowLayer: Nullable<GlowLayer>;
  58362. /**
  58363. * Enable or disable the chromaticAberration process from the pipeline
  58364. */
  58365. chromaticAberrationEnabled: boolean;
  58366. /**
  58367. * Enable or disable the grain process from the pipeline
  58368. */
  58369. grainEnabled: boolean;
  58370. /**
  58371. * @constructor
  58372. * @param name - The rendering pipeline name (default: "")
  58373. * @param hdr - If high dynamic range textures should be used (default: true)
  58374. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58375. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58376. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58377. */
  58378. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58379. /**
  58380. * Get the class name
  58381. * @returns "DefaultRenderingPipeline"
  58382. */
  58383. getClassName(): string;
  58384. /**
  58385. * Force the compilation of the entire pipeline.
  58386. */
  58387. prepare(): void;
  58388. private _hasCleared;
  58389. private _prevPostProcess;
  58390. private _prevPrevPostProcess;
  58391. private _setAutoClearAndTextureSharing;
  58392. private _depthOfFieldSceneObserver;
  58393. private _buildPipeline;
  58394. private _disposePostProcesses;
  58395. /**
  58396. * Adds a camera to the pipeline
  58397. * @param camera the camera to be added
  58398. */
  58399. addCamera(camera: Camera): void;
  58400. /**
  58401. * Removes a camera from the pipeline
  58402. * @param camera the camera to remove
  58403. */
  58404. removeCamera(camera: Camera): void;
  58405. /**
  58406. * Dispose of the pipeline and stop all post processes
  58407. */
  58408. dispose(): void;
  58409. /**
  58410. * Serialize the rendering pipeline (Used when exporting)
  58411. * @returns the serialized object
  58412. */
  58413. serialize(): any;
  58414. /**
  58415. * Parse the serialized pipeline
  58416. * @param source Source pipeline.
  58417. * @param scene The scene to load the pipeline to.
  58418. * @param rootUrl The URL of the serialized pipeline.
  58419. * @returns An instantiated pipeline from the serialized object.
  58420. */
  58421. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58422. }
  58423. }
  58424. declare module BABYLON {
  58425. /** @hidden */
  58426. export var lensHighlightsPixelShader: {
  58427. name: string;
  58428. shader: string;
  58429. };
  58430. }
  58431. declare module BABYLON {
  58432. /** @hidden */
  58433. export var depthOfFieldPixelShader: {
  58434. name: string;
  58435. shader: string;
  58436. };
  58437. }
  58438. declare module BABYLON {
  58439. /**
  58440. * BABYLON.JS Chromatic Aberration GLSL Shader
  58441. * Author: Olivier Guyot
  58442. * Separates very slightly R, G and B colors on the edges of the screen
  58443. * Inspired by Francois Tarlier & Martins Upitis
  58444. */
  58445. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58446. /**
  58447. * @ignore
  58448. * The chromatic aberration PostProcess id in the pipeline
  58449. */
  58450. LensChromaticAberrationEffect: string;
  58451. /**
  58452. * @ignore
  58453. * The highlights enhancing PostProcess id in the pipeline
  58454. */
  58455. HighlightsEnhancingEffect: string;
  58456. /**
  58457. * @ignore
  58458. * The depth-of-field PostProcess id in the pipeline
  58459. */
  58460. LensDepthOfFieldEffect: string;
  58461. private _scene;
  58462. private _depthTexture;
  58463. private _grainTexture;
  58464. private _chromaticAberrationPostProcess;
  58465. private _highlightsPostProcess;
  58466. private _depthOfFieldPostProcess;
  58467. private _edgeBlur;
  58468. private _grainAmount;
  58469. private _chromaticAberration;
  58470. private _distortion;
  58471. private _highlightsGain;
  58472. private _highlightsThreshold;
  58473. private _dofDistance;
  58474. private _dofAperture;
  58475. private _dofDarken;
  58476. private _dofPentagon;
  58477. private _blurNoise;
  58478. /**
  58479. * @constructor
  58480. *
  58481. * Effect parameters are as follow:
  58482. * {
  58483. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58484. * edge_blur: number; // from 0 to x (1 for realism)
  58485. * distortion: number; // from 0 to x (1 for realism)
  58486. * grain_amount: number; // from 0 to 1
  58487. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58488. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58489. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58490. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58491. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58492. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58493. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58494. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58495. * }
  58496. * Note: if an effect parameter is unset, effect is disabled
  58497. *
  58498. * @param name The rendering pipeline name
  58499. * @param parameters - An object containing all parameters (see above)
  58500. * @param scene The scene linked to this pipeline
  58501. * @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)
  58502. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58503. */
  58504. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58505. /**
  58506. * Get the class name
  58507. * @returns "LensRenderingPipeline"
  58508. */
  58509. getClassName(): string;
  58510. /**
  58511. * Gets associated scene
  58512. */
  58513. readonly scene: Scene;
  58514. /**
  58515. * Gets or sets the edge blur
  58516. */
  58517. edgeBlur: number;
  58518. /**
  58519. * Gets or sets the grain amount
  58520. */
  58521. grainAmount: number;
  58522. /**
  58523. * Gets or sets the chromatic aberration amount
  58524. */
  58525. chromaticAberration: number;
  58526. /**
  58527. * Gets or sets the depth of field aperture
  58528. */
  58529. dofAperture: number;
  58530. /**
  58531. * Gets or sets the edge distortion
  58532. */
  58533. edgeDistortion: number;
  58534. /**
  58535. * Gets or sets the depth of field distortion
  58536. */
  58537. dofDistortion: number;
  58538. /**
  58539. * Gets or sets the darken out of focus amount
  58540. */
  58541. darkenOutOfFocus: number;
  58542. /**
  58543. * Gets or sets a boolean indicating if blur noise is enabled
  58544. */
  58545. blurNoise: boolean;
  58546. /**
  58547. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58548. */
  58549. pentagonBokeh: boolean;
  58550. /**
  58551. * Gets or sets the highlight grain amount
  58552. */
  58553. highlightsGain: number;
  58554. /**
  58555. * Gets or sets the highlight threshold
  58556. */
  58557. highlightsThreshold: number;
  58558. /**
  58559. * Sets the amount of blur at the edges
  58560. * @param amount blur amount
  58561. */
  58562. setEdgeBlur(amount: number): void;
  58563. /**
  58564. * Sets edge blur to 0
  58565. */
  58566. disableEdgeBlur(): void;
  58567. /**
  58568. * Sets the amout of grain
  58569. * @param amount Amount of grain
  58570. */
  58571. setGrainAmount(amount: number): void;
  58572. /**
  58573. * Set grain amount to 0
  58574. */
  58575. disableGrain(): void;
  58576. /**
  58577. * Sets the chromatic aberration amount
  58578. * @param amount amount of chromatic aberration
  58579. */
  58580. setChromaticAberration(amount: number): void;
  58581. /**
  58582. * Sets chromatic aberration amount to 0
  58583. */
  58584. disableChromaticAberration(): void;
  58585. /**
  58586. * Sets the EdgeDistortion amount
  58587. * @param amount amount of EdgeDistortion
  58588. */
  58589. setEdgeDistortion(amount: number): void;
  58590. /**
  58591. * Sets edge distortion to 0
  58592. */
  58593. disableEdgeDistortion(): void;
  58594. /**
  58595. * Sets the FocusDistance amount
  58596. * @param amount amount of FocusDistance
  58597. */
  58598. setFocusDistance(amount: number): void;
  58599. /**
  58600. * Disables depth of field
  58601. */
  58602. disableDepthOfField(): void;
  58603. /**
  58604. * Sets the Aperture amount
  58605. * @param amount amount of Aperture
  58606. */
  58607. setAperture(amount: number): void;
  58608. /**
  58609. * Sets the DarkenOutOfFocus amount
  58610. * @param amount amount of DarkenOutOfFocus
  58611. */
  58612. setDarkenOutOfFocus(amount: number): void;
  58613. private _pentagonBokehIsEnabled;
  58614. /**
  58615. * Creates a pentagon bokeh effect
  58616. */
  58617. enablePentagonBokeh(): void;
  58618. /**
  58619. * Disables the pentagon bokeh effect
  58620. */
  58621. disablePentagonBokeh(): void;
  58622. /**
  58623. * Enables noise blur
  58624. */
  58625. enableNoiseBlur(): void;
  58626. /**
  58627. * Disables noise blur
  58628. */
  58629. disableNoiseBlur(): void;
  58630. /**
  58631. * Sets the HighlightsGain amount
  58632. * @param amount amount of HighlightsGain
  58633. */
  58634. setHighlightsGain(amount: number): void;
  58635. /**
  58636. * Sets the HighlightsThreshold amount
  58637. * @param amount amount of HighlightsThreshold
  58638. */
  58639. setHighlightsThreshold(amount: number): void;
  58640. /**
  58641. * Disables highlights
  58642. */
  58643. disableHighlights(): void;
  58644. /**
  58645. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58646. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58647. */
  58648. dispose(disableDepthRender?: boolean): void;
  58649. private _createChromaticAberrationPostProcess;
  58650. private _createHighlightsPostProcess;
  58651. private _createDepthOfFieldPostProcess;
  58652. private _createGrainTexture;
  58653. }
  58654. }
  58655. declare module BABYLON {
  58656. /** @hidden */
  58657. export var ssao2PixelShader: {
  58658. name: string;
  58659. shader: string;
  58660. };
  58661. }
  58662. declare module BABYLON {
  58663. /** @hidden */
  58664. export var ssaoCombinePixelShader: {
  58665. name: string;
  58666. shader: string;
  58667. };
  58668. }
  58669. declare module BABYLON {
  58670. /**
  58671. * Render pipeline to produce ssao effect
  58672. */
  58673. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58674. /**
  58675. * @ignore
  58676. * The PassPostProcess id in the pipeline that contains the original scene color
  58677. */
  58678. SSAOOriginalSceneColorEffect: string;
  58679. /**
  58680. * @ignore
  58681. * The SSAO PostProcess id in the pipeline
  58682. */
  58683. SSAORenderEffect: string;
  58684. /**
  58685. * @ignore
  58686. * The horizontal blur PostProcess id in the pipeline
  58687. */
  58688. SSAOBlurHRenderEffect: string;
  58689. /**
  58690. * @ignore
  58691. * The vertical blur PostProcess id in the pipeline
  58692. */
  58693. SSAOBlurVRenderEffect: string;
  58694. /**
  58695. * @ignore
  58696. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58697. */
  58698. SSAOCombineRenderEffect: string;
  58699. /**
  58700. * The output strength of the SSAO post-process. Default value is 1.0.
  58701. */
  58702. totalStrength: number;
  58703. /**
  58704. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58705. */
  58706. maxZ: number;
  58707. /**
  58708. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58709. */
  58710. minZAspect: number;
  58711. private _samples;
  58712. /**
  58713. * Number of samples used for the SSAO calculations. Default value is 8
  58714. */
  58715. samples: number;
  58716. private _textureSamples;
  58717. /**
  58718. * Number of samples to use for antialiasing
  58719. */
  58720. textureSamples: number;
  58721. /**
  58722. * Ratio object used for SSAO ratio and blur ratio
  58723. */
  58724. private _ratio;
  58725. /**
  58726. * Dynamically generated sphere sampler.
  58727. */
  58728. private _sampleSphere;
  58729. /**
  58730. * Blur filter offsets
  58731. */
  58732. private _samplerOffsets;
  58733. private _expensiveBlur;
  58734. /**
  58735. * If bilateral blur should be used
  58736. */
  58737. expensiveBlur: boolean;
  58738. /**
  58739. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58740. */
  58741. radius: number;
  58742. /**
  58743. * The base color of the SSAO post-process
  58744. * The final result is "base + ssao" between [0, 1]
  58745. */
  58746. base: number;
  58747. /**
  58748. * Support test.
  58749. */
  58750. static readonly IsSupported: boolean;
  58751. private _scene;
  58752. private _depthTexture;
  58753. private _normalTexture;
  58754. private _randomTexture;
  58755. private _originalColorPostProcess;
  58756. private _ssaoPostProcess;
  58757. private _blurHPostProcess;
  58758. private _blurVPostProcess;
  58759. private _ssaoCombinePostProcess;
  58760. private _firstUpdate;
  58761. /**
  58762. * Gets active scene
  58763. */
  58764. readonly scene: Scene;
  58765. /**
  58766. * @constructor
  58767. * @param name The rendering pipeline name
  58768. * @param scene The scene linked to this pipeline
  58769. * @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 }
  58770. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58771. */
  58772. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58773. /**
  58774. * Get the class name
  58775. * @returns "SSAO2RenderingPipeline"
  58776. */
  58777. getClassName(): string;
  58778. /**
  58779. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58780. */
  58781. dispose(disableGeometryBufferRenderer?: boolean): void;
  58782. private _createBlurPostProcess;
  58783. /** @hidden */ private _rebuild(): void;
  58784. private _bits;
  58785. private _radicalInverse_VdC;
  58786. private _hammersley;
  58787. private _hemisphereSample_uniform;
  58788. private _generateHemisphere;
  58789. private _createSSAOPostProcess;
  58790. private _createSSAOCombinePostProcess;
  58791. private _createRandomTexture;
  58792. /**
  58793. * Serialize the rendering pipeline (Used when exporting)
  58794. * @returns the serialized object
  58795. */
  58796. serialize(): any;
  58797. /**
  58798. * Parse the serialized pipeline
  58799. * @param source Source pipeline.
  58800. * @param scene The scene to load the pipeline to.
  58801. * @param rootUrl The URL of the serialized pipeline.
  58802. * @returns An instantiated pipeline from the serialized object.
  58803. */
  58804. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58805. }
  58806. }
  58807. declare module BABYLON {
  58808. /** @hidden */
  58809. export var ssaoPixelShader: {
  58810. name: string;
  58811. shader: string;
  58812. };
  58813. }
  58814. declare module BABYLON {
  58815. /**
  58816. * Render pipeline to produce ssao effect
  58817. */
  58818. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58819. /**
  58820. * @ignore
  58821. * The PassPostProcess id in the pipeline that contains the original scene color
  58822. */
  58823. SSAOOriginalSceneColorEffect: string;
  58824. /**
  58825. * @ignore
  58826. * The SSAO PostProcess id in the pipeline
  58827. */
  58828. SSAORenderEffect: string;
  58829. /**
  58830. * @ignore
  58831. * The horizontal blur PostProcess id in the pipeline
  58832. */
  58833. SSAOBlurHRenderEffect: string;
  58834. /**
  58835. * @ignore
  58836. * The vertical blur PostProcess id in the pipeline
  58837. */
  58838. SSAOBlurVRenderEffect: string;
  58839. /**
  58840. * @ignore
  58841. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58842. */
  58843. SSAOCombineRenderEffect: string;
  58844. /**
  58845. * The output strength of the SSAO post-process. Default value is 1.0.
  58846. */
  58847. totalStrength: number;
  58848. /**
  58849. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58850. */
  58851. radius: number;
  58852. /**
  58853. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58854. * Must not be equal to fallOff and superior to fallOff.
  58855. * Default value is 0.0075
  58856. */
  58857. area: number;
  58858. /**
  58859. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58860. * Must not be equal to area and inferior to area.
  58861. * Default value is 0.000001
  58862. */
  58863. fallOff: number;
  58864. /**
  58865. * The base color of the SSAO post-process
  58866. * The final result is "base + ssao" between [0, 1]
  58867. */
  58868. base: number;
  58869. private _scene;
  58870. private _depthTexture;
  58871. private _randomTexture;
  58872. private _originalColorPostProcess;
  58873. private _ssaoPostProcess;
  58874. private _blurHPostProcess;
  58875. private _blurVPostProcess;
  58876. private _ssaoCombinePostProcess;
  58877. private _firstUpdate;
  58878. /**
  58879. * Gets active scene
  58880. */
  58881. readonly scene: Scene;
  58882. /**
  58883. * @constructor
  58884. * @param name - The rendering pipeline name
  58885. * @param scene - The scene linked to this pipeline
  58886. * @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 }
  58887. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58888. */
  58889. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58890. /**
  58891. * Get the class name
  58892. * @returns "SSAORenderingPipeline"
  58893. */
  58894. getClassName(): string;
  58895. /**
  58896. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58897. */
  58898. dispose(disableDepthRender?: boolean): void;
  58899. private _createBlurPostProcess;
  58900. /** @hidden */ private _rebuild(): void;
  58901. private _createSSAOPostProcess;
  58902. private _createSSAOCombinePostProcess;
  58903. private _createRandomTexture;
  58904. }
  58905. }
  58906. declare module BABYLON {
  58907. /** @hidden */
  58908. export var standardPixelShader: {
  58909. name: string;
  58910. shader: string;
  58911. };
  58912. }
  58913. declare module BABYLON {
  58914. /**
  58915. * Standard rendering pipeline
  58916. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58917. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58918. */
  58919. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58920. /**
  58921. * Public members
  58922. */
  58923. /**
  58924. * Post-process which contains the original scene color before the pipeline applies all the effects
  58925. */
  58926. originalPostProcess: Nullable<PostProcess>;
  58927. /**
  58928. * Post-process used to down scale an image x4
  58929. */
  58930. downSampleX4PostProcess: Nullable<PostProcess>;
  58931. /**
  58932. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58933. */
  58934. brightPassPostProcess: Nullable<PostProcess>;
  58935. /**
  58936. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58937. */
  58938. blurHPostProcesses: PostProcess[];
  58939. /**
  58940. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58941. */
  58942. blurVPostProcesses: PostProcess[];
  58943. /**
  58944. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58945. */
  58946. textureAdderPostProcess: Nullable<PostProcess>;
  58947. /**
  58948. * Post-process used to create volumetric lighting effect
  58949. */
  58950. volumetricLightPostProcess: Nullable<PostProcess>;
  58951. /**
  58952. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58953. */
  58954. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58955. /**
  58956. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58957. */
  58958. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58959. /**
  58960. * Post-process used to merge the volumetric light effect and the real scene color
  58961. */
  58962. volumetricLightMergePostProces: Nullable<PostProcess>;
  58963. /**
  58964. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58965. */
  58966. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58967. /**
  58968. * Base post-process used to calculate the average luminance of the final image for HDR
  58969. */
  58970. luminancePostProcess: Nullable<PostProcess>;
  58971. /**
  58972. * Post-processes used to create down sample post-processes in order to get
  58973. * the average luminance of the final image for HDR
  58974. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58975. */
  58976. luminanceDownSamplePostProcesses: PostProcess[];
  58977. /**
  58978. * Post-process used to create a HDR effect (light adaptation)
  58979. */
  58980. hdrPostProcess: Nullable<PostProcess>;
  58981. /**
  58982. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58983. */
  58984. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58985. /**
  58986. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58987. */
  58988. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58989. /**
  58990. * Post-process used to merge the final HDR post-process and the real scene color
  58991. */
  58992. hdrFinalPostProcess: Nullable<PostProcess>;
  58993. /**
  58994. * Post-process used to create a lens flare effect
  58995. */
  58996. lensFlarePostProcess: Nullable<PostProcess>;
  58997. /**
  58998. * Post-process that merges the result of the lens flare post-process and the real scene color
  58999. */
  59000. lensFlareComposePostProcess: Nullable<PostProcess>;
  59001. /**
  59002. * Post-process used to create a motion blur effect
  59003. */
  59004. motionBlurPostProcess: Nullable<PostProcess>;
  59005. /**
  59006. * Post-process used to create a depth of field effect
  59007. */
  59008. depthOfFieldPostProcess: Nullable<PostProcess>;
  59009. /**
  59010. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59011. */
  59012. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59013. /**
  59014. * Represents the brightness threshold in order to configure the illuminated surfaces
  59015. */
  59016. brightThreshold: number;
  59017. /**
  59018. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59019. */
  59020. blurWidth: number;
  59021. /**
  59022. * Sets if the blur for highlighted surfaces must be only horizontal
  59023. */
  59024. horizontalBlur: boolean;
  59025. /**
  59026. * Gets the overall exposure used by the pipeline
  59027. */
  59028. /**
  59029. * Sets the overall exposure used by the pipeline
  59030. */
  59031. exposure: number;
  59032. /**
  59033. * Texture used typically to simulate "dirty" on camera lens
  59034. */
  59035. lensTexture: Nullable<Texture>;
  59036. /**
  59037. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59038. */
  59039. volumetricLightCoefficient: number;
  59040. /**
  59041. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59042. */
  59043. volumetricLightPower: number;
  59044. /**
  59045. * Used the set the blur intensity to smooth the volumetric lights
  59046. */
  59047. volumetricLightBlurScale: number;
  59048. /**
  59049. * Light (spot or directional) used to generate the volumetric lights rays
  59050. * The source light must have a shadow generate so the pipeline can get its
  59051. * depth map
  59052. */
  59053. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59054. /**
  59055. * For eye adaptation, represents the minimum luminance the eye can see
  59056. */
  59057. hdrMinimumLuminance: number;
  59058. /**
  59059. * For eye adaptation, represents the decrease luminance speed
  59060. */
  59061. hdrDecreaseRate: number;
  59062. /**
  59063. * For eye adaptation, represents the increase luminance speed
  59064. */
  59065. hdrIncreaseRate: number;
  59066. /**
  59067. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59068. */
  59069. /**
  59070. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59071. */
  59072. hdrAutoExposure: boolean;
  59073. /**
  59074. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59075. */
  59076. lensColorTexture: Nullable<Texture>;
  59077. /**
  59078. * The overall strengh for the lens flare effect
  59079. */
  59080. lensFlareStrength: number;
  59081. /**
  59082. * Dispersion coefficient for lens flare ghosts
  59083. */
  59084. lensFlareGhostDispersal: number;
  59085. /**
  59086. * Main lens flare halo width
  59087. */
  59088. lensFlareHaloWidth: number;
  59089. /**
  59090. * Based on the lens distortion effect, defines how much the lens flare result
  59091. * is distorted
  59092. */
  59093. lensFlareDistortionStrength: number;
  59094. /**
  59095. * Configures the blur intensity used for for lens flare (halo)
  59096. */
  59097. lensFlareBlurWidth: number;
  59098. /**
  59099. * Lens star texture must be used to simulate rays on the flares and is available
  59100. * in the documentation
  59101. */
  59102. lensStarTexture: Nullable<Texture>;
  59103. /**
  59104. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59105. * flare effect by taking account of the dirt texture
  59106. */
  59107. lensFlareDirtTexture: Nullable<Texture>;
  59108. /**
  59109. * Represents the focal length for the depth of field effect
  59110. */
  59111. depthOfFieldDistance: number;
  59112. /**
  59113. * Represents the blur intensity for the blurred part of the depth of field effect
  59114. */
  59115. depthOfFieldBlurWidth: number;
  59116. /**
  59117. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59118. */
  59119. /**
  59120. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59121. */
  59122. motionStrength: number;
  59123. /**
  59124. * Gets wether or not the motion blur post-process is object based or screen based.
  59125. */
  59126. /**
  59127. * Sets wether or not the motion blur post-process should be object based or screen based
  59128. */
  59129. objectBasedMotionBlur: boolean;
  59130. /**
  59131. * List of animations for the pipeline (IAnimatable implementation)
  59132. */
  59133. animations: Animation[];
  59134. /**
  59135. * Private members
  59136. */
  59137. private _scene;
  59138. private _currentDepthOfFieldSource;
  59139. private _basePostProcess;
  59140. private _fixedExposure;
  59141. private _currentExposure;
  59142. private _hdrAutoExposure;
  59143. private _hdrCurrentLuminance;
  59144. private _motionStrength;
  59145. private _isObjectBasedMotionBlur;
  59146. private _floatTextureType;
  59147. private _camerasToBeAttached;
  59148. private _ratio;
  59149. private _bloomEnabled;
  59150. private _depthOfFieldEnabled;
  59151. private _vlsEnabled;
  59152. private _lensFlareEnabled;
  59153. private _hdrEnabled;
  59154. private _motionBlurEnabled;
  59155. private _fxaaEnabled;
  59156. private _motionBlurSamples;
  59157. private _volumetricLightStepsCount;
  59158. private _samples;
  59159. /**
  59160. * @ignore
  59161. * Specifies if the bloom pipeline is enabled
  59162. */
  59163. BloomEnabled: boolean;
  59164. /**
  59165. * @ignore
  59166. * Specifies if the depth of field pipeline is enabed
  59167. */
  59168. DepthOfFieldEnabled: boolean;
  59169. /**
  59170. * @ignore
  59171. * Specifies if the lens flare pipeline is enabed
  59172. */
  59173. LensFlareEnabled: boolean;
  59174. /**
  59175. * @ignore
  59176. * Specifies if the HDR pipeline is enabled
  59177. */
  59178. HDREnabled: boolean;
  59179. /**
  59180. * @ignore
  59181. * Specifies if the volumetric lights scattering effect is enabled
  59182. */
  59183. VLSEnabled: boolean;
  59184. /**
  59185. * @ignore
  59186. * Specifies if the motion blur effect is enabled
  59187. */
  59188. MotionBlurEnabled: boolean;
  59189. /**
  59190. * Specifies if anti-aliasing is enabled
  59191. */
  59192. fxaaEnabled: boolean;
  59193. /**
  59194. * Specifies the number of steps used to calculate the volumetric lights
  59195. * Typically in interval [50, 200]
  59196. */
  59197. volumetricLightStepsCount: number;
  59198. /**
  59199. * Specifies the number of samples used for the motion blur effect
  59200. * Typically in interval [16, 64]
  59201. */
  59202. motionBlurSamples: number;
  59203. /**
  59204. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59205. */
  59206. samples: number;
  59207. /**
  59208. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59209. * @constructor
  59210. * @param name The rendering pipeline name
  59211. * @param scene The scene linked to this pipeline
  59212. * @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)
  59213. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59214. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59215. */
  59216. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59217. private _buildPipeline;
  59218. private _createDownSampleX4PostProcess;
  59219. private _createBrightPassPostProcess;
  59220. private _createBlurPostProcesses;
  59221. private _createTextureAdderPostProcess;
  59222. private _createVolumetricLightPostProcess;
  59223. private _createLuminancePostProcesses;
  59224. private _createHdrPostProcess;
  59225. private _createLensFlarePostProcess;
  59226. private _createDepthOfFieldPostProcess;
  59227. private _createMotionBlurPostProcess;
  59228. private _getDepthTexture;
  59229. private _disposePostProcesses;
  59230. /**
  59231. * Dispose of the pipeline and stop all post processes
  59232. */
  59233. dispose(): void;
  59234. /**
  59235. * Serialize the rendering pipeline (Used when exporting)
  59236. * @returns the serialized object
  59237. */
  59238. serialize(): any;
  59239. /**
  59240. * Parse the serialized pipeline
  59241. * @param source Source pipeline.
  59242. * @param scene The scene to load the pipeline to.
  59243. * @param rootUrl The URL of the serialized pipeline.
  59244. * @returns An instantiated pipeline from the serialized object.
  59245. */
  59246. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59247. /**
  59248. * Luminance steps
  59249. */
  59250. static LuminanceSteps: number;
  59251. }
  59252. }
  59253. declare module BABYLON {
  59254. /** @hidden */
  59255. export var tonemapPixelShader: {
  59256. name: string;
  59257. shader: string;
  59258. };
  59259. }
  59260. declare module BABYLON {
  59261. /** Defines operator used for tonemapping */
  59262. export enum TonemappingOperator {
  59263. /** Hable */
  59264. Hable = 0,
  59265. /** Reinhard */
  59266. Reinhard = 1,
  59267. /** HejiDawson */
  59268. HejiDawson = 2,
  59269. /** Photographic */
  59270. Photographic = 3
  59271. }
  59272. /**
  59273. * Defines a post process to apply tone mapping
  59274. */
  59275. export class TonemapPostProcess extends PostProcess {
  59276. private _operator;
  59277. /** Defines the required exposure adjustement */
  59278. exposureAdjustment: number;
  59279. /**
  59280. * Creates a new TonemapPostProcess
  59281. * @param name defines the name of the postprocess
  59282. * @param _operator defines the operator to use
  59283. * @param exposureAdjustment defines the required exposure adjustement
  59284. * @param camera defines the camera to use (can be null)
  59285. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59286. * @param engine defines the hosting engine (can be ignore if camera is set)
  59287. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59288. */
  59289. constructor(name: string, _operator: TonemappingOperator,
  59290. /** Defines the required exposure adjustement */
  59291. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59292. }
  59293. }
  59294. declare module BABYLON {
  59295. /** @hidden */
  59296. export var depthVertexShader: {
  59297. name: string;
  59298. shader: string;
  59299. };
  59300. }
  59301. declare module BABYLON {
  59302. /** @hidden */
  59303. export var volumetricLightScatteringPixelShader: {
  59304. name: string;
  59305. shader: string;
  59306. };
  59307. }
  59308. declare module BABYLON {
  59309. /** @hidden */
  59310. export var volumetricLightScatteringPassVertexShader: {
  59311. name: string;
  59312. shader: string;
  59313. };
  59314. }
  59315. declare module BABYLON {
  59316. /** @hidden */
  59317. export var volumetricLightScatteringPassPixelShader: {
  59318. name: string;
  59319. shader: string;
  59320. };
  59321. }
  59322. declare module BABYLON {
  59323. /**
  59324. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59325. */
  59326. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59327. private _volumetricLightScatteringPass;
  59328. private _volumetricLightScatteringRTT;
  59329. private _viewPort;
  59330. private _screenCoordinates;
  59331. private _cachedDefines;
  59332. /**
  59333. * If not undefined, the mesh position is computed from the attached node position
  59334. */
  59335. attachedNode: {
  59336. position: Vector3;
  59337. };
  59338. /**
  59339. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59340. */
  59341. customMeshPosition: Vector3;
  59342. /**
  59343. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59344. */
  59345. useCustomMeshPosition: boolean;
  59346. /**
  59347. * If the post-process should inverse the light scattering direction
  59348. */
  59349. invert: boolean;
  59350. /**
  59351. * The internal mesh used by the post-process
  59352. */
  59353. mesh: Mesh;
  59354. /**
  59355. * @hidden
  59356. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59357. */
  59358. useDiffuseColor: boolean;
  59359. /**
  59360. * Array containing the excluded meshes not rendered in the internal pass
  59361. */
  59362. excludedMeshes: AbstractMesh[];
  59363. /**
  59364. * Controls the overall intensity of the post-process
  59365. */
  59366. exposure: number;
  59367. /**
  59368. * Dissipates each sample's contribution in range [0, 1]
  59369. */
  59370. decay: number;
  59371. /**
  59372. * Controls the overall intensity of each sample
  59373. */
  59374. weight: number;
  59375. /**
  59376. * Controls the density of each sample
  59377. */
  59378. density: number;
  59379. /**
  59380. * @constructor
  59381. * @param name The post-process name
  59382. * @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)
  59383. * @param camera The camera that the post-process will be attached to
  59384. * @param mesh The mesh used to create the light scattering
  59385. * @param samples The post-process quality, default 100
  59386. * @param samplingModeThe post-process filtering mode
  59387. * @param engine The babylon engine
  59388. * @param reusable If the post-process is reusable
  59389. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59390. */
  59391. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59392. /**
  59393. * Returns the string "VolumetricLightScatteringPostProcess"
  59394. * @returns "VolumetricLightScatteringPostProcess"
  59395. */
  59396. getClassName(): string;
  59397. private _isReady;
  59398. /**
  59399. * Sets the new light position for light scattering effect
  59400. * @param position The new custom light position
  59401. */
  59402. setCustomMeshPosition(position: Vector3): void;
  59403. /**
  59404. * Returns the light position for light scattering effect
  59405. * @return Vector3 The custom light position
  59406. */
  59407. getCustomMeshPosition(): Vector3;
  59408. /**
  59409. * Disposes the internal assets and detaches the post-process from the camera
  59410. */
  59411. dispose(camera: Camera): void;
  59412. /**
  59413. * Returns the render target texture used by the post-process
  59414. * @return the render target texture used by the post-process
  59415. */
  59416. getPass(): RenderTargetTexture;
  59417. private _meshExcluded;
  59418. private _createPass;
  59419. private _updateMeshScreenCoordinates;
  59420. /**
  59421. * Creates a default mesh for the Volumeric Light Scattering post-process
  59422. * @param name The mesh name
  59423. * @param scene The scene where to create the mesh
  59424. * @return the default mesh
  59425. */
  59426. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59427. }
  59428. }
  59429. declare module BABYLON {
  59430. interface Scene {
  59431. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  59432. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  59433. /**
  59434. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59435. */
  59436. forceShowBoundingBoxes: boolean;
  59437. /**
  59438. * Gets the bounding box renderer associated with the scene
  59439. * @returns a BoundingBoxRenderer
  59440. */
  59441. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59442. }
  59443. interface AbstractMesh {
  59444. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  59445. /**
  59446. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59447. */
  59448. showBoundingBox: boolean;
  59449. }
  59450. /**
  59451. * Component responsible of rendering the bounding box of the meshes in a scene.
  59452. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59453. */
  59454. export class BoundingBoxRenderer implements ISceneComponent {
  59455. /**
  59456. * The component name helpfull to identify the component in the list of scene components.
  59457. */
  59458. readonly name: string;
  59459. /**
  59460. * The scene the component belongs to.
  59461. */
  59462. scene: Scene;
  59463. /**
  59464. * Color of the bounding box lines placed in front of an object
  59465. */
  59466. frontColor: Color3;
  59467. /**
  59468. * Color of the bounding box lines placed behind an object
  59469. */
  59470. backColor: Color3;
  59471. /**
  59472. * Defines if the renderer should show the back lines or not
  59473. */
  59474. showBackLines: boolean;
  59475. /**
  59476. * @hidden
  59477. */
  59478. renderList: SmartArray<BoundingBox>;
  59479. private _colorShader;
  59480. private _vertexBuffers;
  59481. private _indexBuffer;
  59482. private _fillIndexBuffer;
  59483. private _fillIndexData;
  59484. /**
  59485. * Instantiates a new bounding box renderer in a scene.
  59486. * @param scene the scene the renderer renders in
  59487. */
  59488. constructor(scene: Scene);
  59489. /**
  59490. * Registers the component in a given scene
  59491. */
  59492. register(): void;
  59493. private _evaluateSubMesh;
  59494. private _activeMesh;
  59495. private _prepareRessources;
  59496. private _createIndexBuffer;
  59497. /**
  59498. * Rebuilds the elements related to this component in case of
  59499. * context lost for instance.
  59500. */
  59501. rebuild(): void;
  59502. /**
  59503. * @hidden
  59504. */
  59505. reset(): void;
  59506. /**
  59507. * Render the bounding boxes of a specific rendering group
  59508. * @param renderingGroupId defines the rendering group to render
  59509. */
  59510. render(renderingGroupId: number): void;
  59511. /**
  59512. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59513. * @param mesh Define the mesh to render the occlusion bounding box for
  59514. */
  59515. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59516. /**
  59517. * Dispose and release the resources attached to this renderer.
  59518. */
  59519. dispose(): void;
  59520. }
  59521. }
  59522. declare module BABYLON {
  59523. /** @hidden */
  59524. export var depthPixelShader: {
  59525. name: string;
  59526. shader: string;
  59527. };
  59528. }
  59529. declare module BABYLON {
  59530. /**
  59531. * This represents a depth renderer in Babylon.
  59532. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59533. */
  59534. export class DepthRenderer {
  59535. private _scene;
  59536. private _depthMap;
  59537. private _effect;
  59538. private readonly _storeNonLinearDepth;
  59539. private readonly _clearColor;
  59540. /** Get if the depth renderer is using packed depth or not */
  59541. readonly isPacked: boolean;
  59542. private _cachedDefines;
  59543. private _camera;
  59544. /**
  59545. * Specifiess that the depth renderer will only be used within
  59546. * the camera it is created for.
  59547. * This can help forcing its rendering during the camera processing.
  59548. */
  59549. useOnlyInActiveCamera: boolean;
  59550. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  59551. /**
  59552. * Instantiates a depth renderer
  59553. * @param scene The scene the renderer belongs to
  59554. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59555. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59556. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59557. */
  59558. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59559. /**
  59560. * Creates the depth rendering effect and checks if the effect is ready.
  59561. * @param subMesh The submesh to be used to render the depth map of
  59562. * @param useInstances If multiple world instances should be used
  59563. * @returns if the depth renderer is ready to render the depth map
  59564. */
  59565. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59566. /**
  59567. * Gets the texture which the depth map will be written to.
  59568. * @returns The depth map texture
  59569. */
  59570. getDepthMap(): RenderTargetTexture;
  59571. /**
  59572. * Disposes of the depth renderer.
  59573. */
  59574. dispose(): void;
  59575. }
  59576. }
  59577. declare module BABYLON {
  59578. interface Scene {
  59579. /** @hidden (Backing field) */ private _depthRenderer: {
  59580. [id: string]: DepthRenderer;
  59581. };
  59582. /**
  59583. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59584. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59585. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59586. * @returns the created depth renderer
  59587. */
  59588. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59589. /**
  59590. * Disables a depth renderer for a given camera
  59591. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59592. */
  59593. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59594. }
  59595. /**
  59596. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59597. * in several rendering techniques.
  59598. */
  59599. export class DepthRendererSceneComponent implements ISceneComponent {
  59600. /**
  59601. * The component name helpfull to identify the component in the list of scene components.
  59602. */
  59603. readonly name: string;
  59604. /**
  59605. * The scene the component belongs to.
  59606. */
  59607. scene: Scene;
  59608. /**
  59609. * Creates a new instance of the component for the given scene
  59610. * @param scene Defines the scene to register the component in
  59611. */
  59612. constructor(scene: Scene);
  59613. /**
  59614. * Registers the component in a given scene
  59615. */
  59616. register(): void;
  59617. /**
  59618. * Rebuilds the elements related to this component in case of
  59619. * context lost for instance.
  59620. */
  59621. rebuild(): void;
  59622. /**
  59623. * Disposes the component and the associated ressources
  59624. */
  59625. dispose(): void;
  59626. private _gatherRenderTargets;
  59627. private _gatherActiveCameraRenderTargets;
  59628. }
  59629. }
  59630. declare module BABYLON {
  59631. /** @hidden */
  59632. export var outlinePixelShader: {
  59633. name: string;
  59634. shader: string;
  59635. };
  59636. }
  59637. declare module BABYLON {
  59638. /** @hidden */
  59639. export var outlineVertexShader: {
  59640. name: string;
  59641. shader: string;
  59642. };
  59643. }
  59644. declare module BABYLON {
  59645. interface Scene {
  59646. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  59647. /**
  59648. * Gets the outline renderer associated with the scene
  59649. * @returns a OutlineRenderer
  59650. */
  59651. getOutlineRenderer(): OutlineRenderer;
  59652. }
  59653. interface AbstractMesh {
  59654. /** @hidden (Backing field) */ private _renderOutline: boolean;
  59655. /**
  59656. * Gets or sets a boolean indicating if the outline must be rendered as well
  59657. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59658. */
  59659. renderOutline: boolean;
  59660. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  59661. /**
  59662. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59663. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59664. */
  59665. renderOverlay: boolean;
  59666. }
  59667. /**
  59668. * This class is responsible to draw bothe outline/overlay of meshes.
  59669. * It should not be used directly but through the available method on mesh.
  59670. */
  59671. export class OutlineRenderer implements ISceneComponent {
  59672. /**
  59673. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59674. */
  59675. private static _StencilReference;
  59676. /**
  59677. * The name of the component. Each component must have a unique name.
  59678. */
  59679. name: string;
  59680. /**
  59681. * The scene the component belongs to.
  59682. */
  59683. scene: Scene;
  59684. /**
  59685. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59686. */
  59687. zOffset: number;
  59688. private _engine;
  59689. private _effect;
  59690. private _cachedDefines;
  59691. private _savedDepthWrite;
  59692. /**
  59693. * Instantiates a new outline renderer. (There could be only one per scene).
  59694. * @param scene Defines the scene it belongs to
  59695. */
  59696. constructor(scene: Scene);
  59697. /**
  59698. * Register the component to one instance of a scene.
  59699. */
  59700. register(): void;
  59701. /**
  59702. * Rebuilds the elements related to this component in case of
  59703. * context lost for instance.
  59704. */
  59705. rebuild(): void;
  59706. /**
  59707. * Disposes the component and the associated ressources.
  59708. */
  59709. dispose(): void;
  59710. /**
  59711. * Renders the outline in the canvas.
  59712. * @param subMesh Defines the sumesh to render
  59713. * @param batch Defines the batch of meshes in case of instances
  59714. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59715. */
  59716. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59717. /**
  59718. * Returns whether or not the outline renderer is ready for a given submesh.
  59719. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59720. * @param subMesh Defines the submesh to check readyness for
  59721. * @param useInstances Defines wheter wee are trying to render instances or not
  59722. * @returns true if ready otherwise false
  59723. */
  59724. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59725. private _beforeRenderingMesh;
  59726. private _afterRenderingMesh;
  59727. }
  59728. }
  59729. declare module BABYLON {
  59730. /**
  59731. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59732. * @see http://doc.babylonjs.com/babylon101/sprites
  59733. */
  59734. export class SpritePackedManager extends SpriteManager {
  59735. /** defines the packed manager's name */
  59736. name: string;
  59737. /**
  59738. * Creates a new sprite manager from a packed sprite sheet
  59739. * @param name defines the manager's name
  59740. * @param imgUrl defines the sprite sheet url
  59741. * @param capacity defines the maximum allowed number of sprites
  59742. * @param scene defines the hosting scene
  59743. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59744. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59745. * @param samplingMode defines the smapling mode to use with spritesheet
  59746. * @param fromPacked set to true; do not alter
  59747. */
  59748. constructor(
  59749. /** defines the packed manager's name */
  59750. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59751. }
  59752. }
  59753. declare module BABYLON {
  59754. /**
  59755. * Defines the list of states available for a task inside a AssetsManager
  59756. */
  59757. export enum AssetTaskState {
  59758. /**
  59759. * Initialization
  59760. */
  59761. INIT = 0,
  59762. /**
  59763. * Running
  59764. */
  59765. RUNNING = 1,
  59766. /**
  59767. * Done
  59768. */
  59769. DONE = 2,
  59770. /**
  59771. * Error
  59772. */
  59773. ERROR = 3
  59774. }
  59775. /**
  59776. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59777. */
  59778. export abstract class AbstractAssetTask {
  59779. /**
  59780. * Task name
  59781. */ name: string;
  59782. /**
  59783. * Callback called when the task is successful
  59784. */
  59785. onSuccess: (task: any) => void;
  59786. /**
  59787. * Callback called when the task is not successful
  59788. */
  59789. onError: (task: any, message?: string, exception?: any) => void;
  59790. /**
  59791. * Creates a new AssetsManager
  59792. * @param name defines the name of the task
  59793. */
  59794. constructor(
  59795. /**
  59796. * Task name
  59797. */ name: string);
  59798. private _isCompleted;
  59799. private _taskState;
  59800. private _errorObject;
  59801. /**
  59802. * Get if the task is completed
  59803. */
  59804. readonly isCompleted: boolean;
  59805. /**
  59806. * Gets the current state of the task
  59807. */
  59808. readonly taskState: AssetTaskState;
  59809. /**
  59810. * Gets the current error object (if task is in error)
  59811. */
  59812. readonly errorObject: {
  59813. message?: string;
  59814. exception?: any;
  59815. };
  59816. /**
  59817. * Internal only
  59818. * @hidden
  59819. */ private _setErrorObject(message?: string, exception?: any): void;
  59820. /**
  59821. * Execute the current task
  59822. * @param scene defines the scene where you want your assets to be loaded
  59823. * @param onSuccess is a callback called when the task is successfully executed
  59824. * @param onError is a callback called if an error occurs
  59825. */
  59826. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59827. /**
  59828. * Execute the current task
  59829. * @param scene defines the scene where you want your assets to be loaded
  59830. * @param onSuccess is a callback called when the task is successfully executed
  59831. * @param onError is a callback called if an error occurs
  59832. */
  59833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59834. /**
  59835. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59836. * This can be used with failed tasks that have the reason for failure fixed.
  59837. */
  59838. reset(): void;
  59839. private onErrorCallback;
  59840. private onDoneCallback;
  59841. }
  59842. /**
  59843. * Define the interface used by progress events raised during assets loading
  59844. */
  59845. export interface IAssetsProgressEvent {
  59846. /**
  59847. * Defines the number of remaining tasks to process
  59848. */
  59849. remainingCount: number;
  59850. /**
  59851. * Defines the total number of tasks
  59852. */
  59853. totalCount: number;
  59854. /**
  59855. * Defines the task that was just processed
  59856. */
  59857. task: AbstractAssetTask;
  59858. }
  59859. /**
  59860. * Class used to share progress information about assets loading
  59861. */
  59862. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59863. /**
  59864. * Defines the number of remaining tasks to process
  59865. */
  59866. remainingCount: number;
  59867. /**
  59868. * Defines the total number of tasks
  59869. */
  59870. totalCount: number;
  59871. /**
  59872. * Defines the task that was just processed
  59873. */
  59874. task: AbstractAssetTask;
  59875. /**
  59876. * Creates a AssetsProgressEvent
  59877. * @param remainingCount defines the number of remaining tasks to process
  59878. * @param totalCount defines the total number of tasks
  59879. * @param task defines the task that was just processed
  59880. */
  59881. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59882. }
  59883. /**
  59884. * Define a task used by AssetsManager to load meshes
  59885. */
  59886. export class MeshAssetTask extends AbstractAssetTask {
  59887. /**
  59888. * Defines the name of the task
  59889. */
  59890. name: string;
  59891. /**
  59892. * Defines the list of mesh's names you want to load
  59893. */
  59894. meshesNames: any;
  59895. /**
  59896. * Defines the root url to use as a base to load your meshes and associated resources
  59897. */
  59898. rootUrl: string;
  59899. /**
  59900. * Defines the filename of the scene to load from
  59901. */
  59902. sceneFilename: string;
  59903. /**
  59904. * Gets the list of loaded meshes
  59905. */
  59906. loadedMeshes: Array<AbstractMesh>;
  59907. /**
  59908. * Gets the list of loaded particle systems
  59909. */
  59910. loadedParticleSystems: Array<IParticleSystem>;
  59911. /**
  59912. * Gets the list of loaded skeletons
  59913. */
  59914. loadedSkeletons: Array<Skeleton>;
  59915. /**
  59916. * Gets the list of loaded animation groups
  59917. */
  59918. loadedAnimationGroups: Array<AnimationGroup>;
  59919. /**
  59920. * Callback called when the task is successful
  59921. */
  59922. onSuccess: (task: MeshAssetTask) => void;
  59923. /**
  59924. * Callback called when the task is successful
  59925. */
  59926. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59927. /**
  59928. * Creates a new MeshAssetTask
  59929. * @param name defines the name of the task
  59930. * @param meshesNames defines the list of mesh's names you want to load
  59931. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59932. * @param sceneFilename defines the filename of the scene to load from
  59933. */
  59934. constructor(
  59935. /**
  59936. * Defines the name of the task
  59937. */
  59938. name: string,
  59939. /**
  59940. * Defines the list of mesh's names you want to load
  59941. */
  59942. meshesNames: any,
  59943. /**
  59944. * Defines the root url to use as a base to load your meshes and associated resources
  59945. */
  59946. rootUrl: string,
  59947. /**
  59948. * Defines the filename of the scene to load from
  59949. */
  59950. sceneFilename: string);
  59951. /**
  59952. * Execute the current task
  59953. * @param scene defines the scene where you want your assets to be loaded
  59954. * @param onSuccess is a callback called when the task is successfully executed
  59955. * @param onError is a callback called if an error occurs
  59956. */
  59957. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59958. }
  59959. /**
  59960. * Define a task used by AssetsManager to load text content
  59961. */
  59962. export class TextFileAssetTask extends AbstractAssetTask {
  59963. /**
  59964. * Defines the name of the task
  59965. */
  59966. name: string;
  59967. /**
  59968. * Defines the location of the file to load
  59969. */
  59970. url: string;
  59971. /**
  59972. * Gets the loaded text string
  59973. */
  59974. text: string;
  59975. /**
  59976. * Callback called when the task is successful
  59977. */
  59978. onSuccess: (task: TextFileAssetTask) => void;
  59979. /**
  59980. * Callback called when the task is successful
  59981. */
  59982. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59983. /**
  59984. * Creates a new TextFileAssetTask object
  59985. * @param name defines the name of the task
  59986. * @param url defines the location of the file to load
  59987. */
  59988. constructor(
  59989. /**
  59990. * Defines the name of the task
  59991. */
  59992. name: string,
  59993. /**
  59994. * Defines the location of the file to load
  59995. */
  59996. url: string);
  59997. /**
  59998. * Execute the current task
  59999. * @param scene defines the scene where you want your assets to be loaded
  60000. * @param onSuccess is a callback called when the task is successfully executed
  60001. * @param onError is a callback called if an error occurs
  60002. */
  60003. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60004. }
  60005. /**
  60006. * Define a task used by AssetsManager to load binary data
  60007. */
  60008. export class BinaryFileAssetTask extends AbstractAssetTask {
  60009. /**
  60010. * Defines the name of the task
  60011. */
  60012. name: string;
  60013. /**
  60014. * Defines the location of the file to load
  60015. */
  60016. url: string;
  60017. /**
  60018. * Gets the lodaded data (as an array buffer)
  60019. */
  60020. data: ArrayBuffer;
  60021. /**
  60022. * Callback called when the task is successful
  60023. */
  60024. onSuccess: (task: BinaryFileAssetTask) => void;
  60025. /**
  60026. * Callback called when the task is successful
  60027. */
  60028. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60029. /**
  60030. * Creates a new BinaryFileAssetTask object
  60031. * @param name defines the name of the new task
  60032. * @param url defines the location of the file to load
  60033. */
  60034. constructor(
  60035. /**
  60036. * Defines the name of the task
  60037. */
  60038. name: string,
  60039. /**
  60040. * Defines the location of the file to load
  60041. */
  60042. url: string);
  60043. /**
  60044. * Execute the current task
  60045. * @param scene defines the scene where you want your assets to be loaded
  60046. * @param onSuccess is a callback called when the task is successfully executed
  60047. * @param onError is a callback called if an error occurs
  60048. */
  60049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60050. }
  60051. /**
  60052. * Define a task used by AssetsManager to load images
  60053. */
  60054. export class ImageAssetTask extends AbstractAssetTask {
  60055. /**
  60056. * Defines the name of the task
  60057. */
  60058. name: string;
  60059. /**
  60060. * Defines the location of the image to load
  60061. */
  60062. url: string;
  60063. /**
  60064. * Gets the loaded images
  60065. */
  60066. image: HTMLImageElement;
  60067. /**
  60068. * Callback called when the task is successful
  60069. */
  60070. onSuccess: (task: ImageAssetTask) => void;
  60071. /**
  60072. * Callback called when the task is successful
  60073. */
  60074. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60075. /**
  60076. * Creates a new ImageAssetTask
  60077. * @param name defines the name of the task
  60078. * @param url defines the location of the image to load
  60079. */
  60080. constructor(
  60081. /**
  60082. * Defines the name of the task
  60083. */
  60084. name: string,
  60085. /**
  60086. * Defines the location of the image to load
  60087. */
  60088. url: string);
  60089. /**
  60090. * Execute the current task
  60091. * @param scene defines the scene where you want your assets to be loaded
  60092. * @param onSuccess is a callback called when the task is successfully executed
  60093. * @param onError is a callback called if an error occurs
  60094. */
  60095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60096. }
  60097. /**
  60098. * Defines the interface used by texture loading tasks
  60099. */
  60100. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60101. /**
  60102. * Gets the loaded texture
  60103. */
  60104. texture: TEX;
  60105. }
  60106. /**
  60107. * Define a task used by AssetsManager to load 2D textures
  60108. */
  60109. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60110. /**
  60111. * Defines the name of the task
  60112. */
  60113. name: string;
  60114. /**
  60115. * Defines the location of the file to load
  60116. */
  60117. url: string;
  60118. /**
  60119. * Defines if mipmap should not be generated (default is false)
  60120. */
  60121. noMipmap?: boolean | undefined;
  60122. /**
  60123. * Defines if texture must be inverted on Y axis (default is false)
  60124. */
  60125. invertY?: boolean | undefined;
  60126. /**
  60127. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60128. */
  60129. samplingMode: number;
  60130. /**
  60131. * Gets the loaded texture
  60132. */
  60133. texture: Texture;
  60134. /**
  60135. * Callback called when the task is successful
  60136. */
  60137. onSuccess: (task: TextureAssetTask) => void;
  60138. /**
  60139. * Callback called when the task is successful
  60140. */
  60141. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60142. /**
  60143. * Creates a new TextureAssetTask object
  60144. * @param name defines the name of the task
  60145. * @param url defines the location of the file to load
  60146. * @param noMipmap defines if mipmap should not be generated (default is false)
  60147. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60148. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60149. */
  60150. constructor(
  60151. /**
  60152. * Defines the name of the task
  60153. */
  60154. name: string,
  60155. /**
  60156. * Defines the location of the file to load
  60157. */
  60158. url: string,
  60159. /**
  60160. * Defines if mipmap should not be generated (default is false)
  60161. */
  60162. noMipmap?: boolean | undefined,
  60163. /**
  60164. * Defines if texture must be inverted on Y axis (default is false)
  60165. */
  60166. invertY?: boolean | undefined,
  60167. /**
  60168. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60169. */
  60170. samplingMode?: number);
  60171. /**
  60172. * Execute the current task
  60173. * @param scene defines the scene where you want your assets to be loaded
  60174. * @param onSuccess is a callback called when the task is successfully executed
  60175. * @param onError is a callback called if an error occurs
  60176. */
  60177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60178. }
  60179. /**
  60180. * Define a task used by AssetsManager to load cube textures
  60181. */
  60182. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60183. /**
  60184. * Defines the name of the task
  60185. */
  60186. name: string;
  60187. /**
  60188. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60189. */
  60190. url: string;
  60191. /**
  60192. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60193. */
  60194. extensions?: string[] | undefined;
  60195. /**
  60196. * Defines if mipmaps should not be generated (default is false)
  60197. */
  60198. noMipmap?: boolean | undefined;
  60199. /**
  60200. * Defines the explicit list of files (undefined by default)
  60201. */
  60202. files?: string[] | undefined;
  60203. /**
  60204. * Gets the loaded texture
  60205. */
  60206. texture: CubeTexture;
  60207. /**
  60208. * Callback called when the task is successful
  60209. */
  60210. onSuccess: (task: CubeTextureAssetTask) => void;
  60211. /**
  60212. * Callback called when the task is successful
  60213. */
  60214. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60215. /**
  60216. * Creates a new CubeTextureAssetTask
  60217. * @param name defines the name of the task
  60218. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60219. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60220. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60221. * @param files defines the explicit list of files (undefined by default)
  60222. */
  60223. constructor(
  60224. /**
  60225. * Defines the name of the task
  60226. */
  60227. name: string,
  60228. /**
  60229. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60230. */
  60231. url: string,
  60232. /**
  60233. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60234. */
  60235. extensions?: string[] | undefined,
  60236. /**
  60237. * Defines if mipmaps should not be generated (default is false)
  60238. */
  60239. noMipmap?: boolean | undefined,
  60240. /**
  60241. * Defines the explicit list of files (undefined by default)
  60242. */
  60243. files?: string[] | undefined);
  60244. /**
  60245. * Execute the current task
  60246. * @param scene defines the scene where you want your assets to be loaded
  60247. * @param onSuccess is a callback called when the task is successfully executed
  60248. * @param onError is a callback called if an error occurs
  60249. */
  60250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60251. }
  60252. /**
  60253. * Define a task used by AssetsManager to load HDR cube textures
  60254. */
  60255. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60256. /**
  60257. * Defines the name of the task
  60258. */
  60259. name: string;
  60260. /**
  60261. * Defines the location of the file to load
  60262. */
  60263. url: string;
  60264. /**
  60265. * Defines the desired size (the more it increases the longer the generation will be)
  60266. */
  60267. size: number;
  60268. /**
  60269. * Defines if mipmaps should not be generated (default is false)
  60270. */
  60271. noMipmap: boolean;
  60272. /**
  60273. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60274. */
  60275. generateHarmonics: boolean;
  60276. /**
  60277. * 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)
  60278. */
  60279. gammaSpace: boolean;
  60280. /**
  60281. * Internal Use Only
  60282. */
  60283. reserved: boolean;
  60284. /**
  60285. * Gets the loaded texture
  60286. */
  60287. texture: HDRCubeTexture;
  60288. /**
  60289. * Callback called when the task is successful
  60290. */
  60291. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60292. /**
  60293. * Callback called when the task is successful
  60294. */
  60295. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60296. /**
  60297. * Creates a new HDRCubeTextureAssetTask object
  60298. * @param name defines the name of the task
  60299. * @param url defines the location of the file to load
  60300. * @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.
  60301. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60302. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60303. * @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)
  60304. * @param reserved Internal use only
  60305. */
  60306. constructor(
  60307. /**
  60308. * Defines the name of the task
  60309. */
  60310. name: string,
  60311. /**
  60312. * Defines the location of the file to load
  60313. */
  60314. url: string,
  60315. /**
  60316. * Defines the desired size (the more it increases the longer the generation will be)
  60317. */
  60318. size: number,
  60319. /**
  60320. * Defines if mipmaps should not be generated (default is false)
  60321. */
  60322. noMipmap?: boolean,
  60323. /**
  60324. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60325. */
  60326. generateHarmonics?: boolean,
  60327. /**
  60328. * 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)
  60329. */
  60330. gammaSpace?: boolean,
  60331. /**
  60332. * Internal Use Only
  60333. */
  60334. reserved?: boolean);
  60335. /**
  60336. * Execute the current task
  60337. * @param scene defines the scene where you want your assets to be loaded
  60338. * @param onSuccess is a callback called when the task is successfully executed
  60339. * @param onError is a callback called if an error occurs
  60340. */
  60341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60342. }
  60343. /**
  60344. * Define a task used by AssetsManager to load Equirectangular cube textures
  60345. */
  60346. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60347. /**
  60348. * Defines the name of the task
  60349. */
  60350. name: string;
  60351. /**
  60352. * Defines the location of the file to load
  60353. */
  60354. url: string;
  60355. /**
  60356. * Defines the desired size (the more it increases the longer the generation will be)
  60357. */
  60358. size: number;
  60359. /**
  60360. * Defines if mipmaps should not be generated (default is false)
  60361. */
  60362. noMipmap: boolean;
  60363. /**
  60364. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60365. * but the standard material would require them in Gamma space) (default is true)
  60366. */
  60367. gammaSpace: boolean;
  60368. /**
  60369. * Gets the loaded texture
  60370. */
  60371. texture: EquiRectangularCubeTexture;
  60372. /**
  60373. * Callback called when the task is successful
  60374. */
  60375. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60376. /**
  60377. * Callback called when the task is successful
  60378. */
  60379. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60380. /**
  60381. * Creates a new EquiRectangularCubeTextureAssetTask object
  60382. * @param name defines the name of the task
  60383. * @param url defines the location of the file to load
  60384. * @param size defines the desired size (the more it increases the longer the generation will be)
  60385. * If the size is omitted this implies you are using a preprocessed cubemap.
  60386. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60387. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60388. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60389. * (default is true)
  60390. */
  60391. constructor(
  60392. /**
  60393. * Defines the name of the task
  60394. */
  60395. name: string,
  60396. /**
  60397. * Defines the location of the file to load
  60398. */
  60399. url: string,
  60400. /**
  60401. * Defines the desired size (the more it increases the longer the generation will be)
  60402. */
  60403. size: number,
  60404. /**
  60405. * Defines if mipmaps should not be generated (default is false)
  60406. */
  60407. noMipmap?: boolean,
  60408. /**
  60409. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60410. * but the standard material would require them in Gamma space) (default is true)
  60411. */
  60412. gammaSpace?: boolean);
  60413. /**
  60414. * Execute the current task
  60415. * @param scene defines the scene where you want your assets to be loaded
  60416. * @param onSuccess is a callback called when the task is successfully executed
  60417. * @param onError is a callback called if an error occurs
  60418. */
  60419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60420. }
  60421. /**
  60422. * This class can be used to easily import assets into a scene
  60423. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60424. */
  60425. export class AssetsManager {
  60426. private _scene;
  60427. private _isLoading;
  60428. protected _tasks: AbstractAssetTask[];
  60429. protected _waitingTasksCount: number;
  60430. protected _totalTasksCount: number;
  60431. /**
  60432. * Callback called when all tasks are processed
  60433. */
  60434. onFinish: (tasks: AbstractAssetTask[]) => void;
  60435. /**
  60436. * Callback called when a task is successful
  60437. */
  60438. onTaskSuccess: (task: AbstractAssetTask) => void;
  60439. /**
  60440. * Callback called when a task had an error
  60441. */
  60442. onTaskError: (task: AbstractAssetTask) => void;
  60443. /**
  60444. * Callback called when a task is done (whatever the result is)
  60445. */
  60446. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60447. /**
  60448. * Observable called when all tasks are processed
  60449. */
  60450. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60451. /**
  60452. * Observable called when a task had an error
  60453. */
  60454. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60455. /**
  60456. * Observable called when all tasks were executed
  60457. */
  60458. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60459. /**
  60460. * Observable called when a task is done (whatever the result is)
  60461. */
  60462. onProgressObservable: Observable<IAssetsProgressEvent>;
  60463. /**
  60464. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60465. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60466. */
  60467. useDefaultLoadingScreen: boolean;
  60468. /**
  60469. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60470. * when all assets have been downloaded.
  60471. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60472. */
  60473. autoHideLoadingUI: boolean;
  60474. /**
  60475. * Creates a new AssetsManager
  60476. * @param scene defines the scene to work on
  60477. */
  60478. constructor(scene: Scene);
  60479. /**
  60480. * Add a MeshAssetTask to the list of active tasks
  60481. * @param taskName defines the name of the new task
  60482. * @param meshesNames defines the name of meshes to load
  60483. * @param rootUrl defines the root url to use to locate files
  60484. * @param sceneFilename defines the filename of the scene file
  60485. * @returns a new MeshAssetTask object
  60486. */
  60487. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60488. /**
  60489. * Add a TextFileAssetTask to the list of active tasks
  60490. * @param taskName defines the name of the new task
  60491. * @param url defines the url of the file to load
  60492. * @returns a new TextFileAssetTask object
  60493. */
  60494. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60495. /**
  60496. * Add a BinaryFileAssetTask to the list of active tasks
  60497. * @param taskName defines the name of the new task
  60498. * @param url defines the url of the file to load
  60499. * @returns a new BinaryFileAssetTask object
  60500. */
  60501. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60502. /**
  60503. * Add a ImageAssetTask to the list of active tasks
  60504. * @param taskName defines the name of the new task
  60505. * @param url defines the url of the file to load
  60506. * @returns a new ImageAssetTask object
  60507. */
  60508. addImageTask(taskName: string, url: string): ImageAssetTask;
  60509. /**
  60510. * Add a TextureAssetTask to the list of active tasks
  60511. * @param taskName defines the name of the new task
  60512. * @param url defines the url of the file to load
  60513. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60514. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60515. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60516. * @returns a new TextureAssetTask object
  60517. */
  60518. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60519. /**
  60520. * Add a CubeTextureAssetTask to the list of active tasks
  60521. * @param taskName defines the name of the new task
  60522. * @param url defines the url of the file to load
  60523. * @param extensions defines the extension to use to load the cube map (can be null)
  60524. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60525. * @param files defines the list of files to load (can be null)
  60526. * @returns a new CubeTextureAssetTask object
  60527. */
  60528. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60529. /**
  60530. *
  60531. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60532. * @param taskName defines the name of the new task
  60533. * @param url defines the url of the file to load
  60534. * @param size defines the size you want for the cubemap (can be null)
  60535. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60536. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60537. * @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)
  60538. * @param reserved Internal use only
  60539. * @returns a new HDRCubeTextureAssetTask object
  60540. */
  60541. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60542. /**
  60543. *
  60544. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60545. * @param taskName defines the name of the new task
  60546. * @param url defines the url of the file to load
  60547. * @param size defines the size you want for the cubemap (can be null)
  60548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60549. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60550. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60551. * @returns a new EquiRectangularCubeTextureAssetTask object
  60552. */
  60553. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60554. /**
  60555. * Remove a task from the assets manager.
  60556. * @param task the task to remove
  60557. */
  60558. removeTask(task: AbstractAssetTask): void;
  60559. private _decreaseWaitingTasksCount;
  60560. private _runTask;
  60561. /**
  60562. * Reset the AssetsManager and remove all tasks
  60563. * @return the current instance of the AssetsManager
  60564. */
  60565. reset(): AssetsManager;
  60566. /**
  60567. * Start the loading process
  60568. * @return the current instance of the AssetsManager
  60569. */
  60570. load(): AssetsManager;
  60571. /**
  60572. * Start the loading process as an async operation
  60573. * @return a promise returning the list of failed tasks
  60574. */
  60575. loadAsync(): Promise<void>;
  60576. }
  60577. }
  60578. declare module BABYLON {
  60579. /**
  60580. * Wrapper class for promise with external resolve and reject.
  60581. */
  60582. export class Deferred<T> {
  60583. /**
  60584. * The promise associated with this deferred object.
  60585. */
  60586. readonly promise: Promise<T>;
  60587. private _resolve;
  60588. private _reject;
  60589. /**
  60590. * The resolve method of the promise associated with this deferred object.
  60591. */
  60592. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60593. /**
  60594. * The reject method of the promise associated with this deferred object.
  60595. */
  60596. readonly reject: (reason?: any) => void;
  60597. /**
  60598. * Constructor for this deferred object.
  60599. */
  60600. constructor();
  60601. }
  60602. }
  60603. declare module BABYLON {
  60604. /**
  60605. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60606. */
  60607. export class MeshExploder {
  60608. private _centerMesh;
  60609. private _meshes;
  60610. private _meshesOrigins;
  60611. private _toCenterVectors;
  60612. private _scaledDirection;
  60613. private _newPosition;
  60614. private _centerPosition;
  60615. /**
  60616. * Explodes meshes from a center mesh.
  60617. * @param meshes The meshes to explode.
  60618. * @param centerMesh The mesh to be center of explosion.
  60619. */
  60620. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60621. private _setCenterMesh;
  60622. /**
  60623. * Get class name
  60624. * @returns "MeshExploder"
  60625. */
  60626. getClassName(): string;
  60627. /**
  60628. * "Exploded meshes"
  60629. * @returns Array of meshes with the centerMesh at index 0.
  60630. */
  60631. getMeshes(): Array<Mesh>;
  60632. /**
  60633. * Explodes meshes giving a specific direction
  60634. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60635. */
  60636. explode(direction?: number): void;
  60637. }
  60638. }
  60639. declare module BABYLON {
  60640. /**
  60641. * Class used to help managing file picking and drag'n'drop
  60642. */
  60643. export class FilesInput {
  60644. /**
  60645. * List of files ready to be loaded
  60646. */
  60647. static readonly FilesToLoad: {
  60648. [key: string]: File;
  60649. };
  60650. /**
  60651. * Callback called when a file is processed
  60652. */
  60653. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60654. private _engine;
  60655. private _currentScene;
  60656. private _sceneLoadedCallback;
  60657. private _progressCallback;
  60658. private _additionalRenderLoopLogicCallback;
  60659. private _textureLoadingCallback;
  60660. private _startingProcessingFilesCallback;
  60661. private _onReloadCallback;
  60662. private _errorCallback;
  60663. private _elementToMonitor;
  60664. private _sceneFileToLoad;
  60665. private _filesToLoad;
  60666. /**
  60667. * Creates a new FilesInput
  60668. * @param engine defines the rendering engine
  60669. * @param scene defines the hosting scene
  60670. * @param sceneLoadedCallback callback called when scene is loaded
  60671. * @param progressCallback callback called to track progress
  60672. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60673. * @param textureLoadingCallback callback called when a texture is loading
  60674. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60675. * @param onReloadCallback callback called when a reload is requested
  60676. * @param errorCallback callback call if an error occurs
  60677. */
  60678. 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);
  60679. private _dragEnterHandler;
  60680. private _dragOverHandler;
  60681. private _dropHandler;
  60682. /**
  60683. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60684. * @param elementToMonitor defines the DOM element to track
  60685. */
  60686. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60687. /**
  60688. * Release all associated resources
  60689. */
  60690. dispose(): void;
  60691. private renderFunction;
  60692. private drag;
  60693. private drop;
  60694. private _traverseFolder;
  60695. private _processFiles;
  60696. /**
  60697. * Load files from a drop event
  60698. * @param event defines the drop event to use as source
  60699. */
  60700. loadFiles(event: any): void;
  60701. private _processReload;
  60702. /**
  60703. * Reload the current scene from the loaded files
  60704. */
  60705. reload(): void;
  60706. }
  60707. }
  60708. declare module BABYLON {
  60709. /**
  60710. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60712. */
  60713. export class SceneOptimization {
  60714. /**
  60715. * Defines the priority of this optimization (0 by default which means first in the list)
  60716. */
  60717. priority: number;
  60718. /**
  60719. * Gets a string describing the action executed by the current optimization
  60720. * @returns description string
  60721. */
  60722. getDescription(): string;
  60723. /**
  60724. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60725. * @param scene defines the current scene where to apply this optimization
  60726. * @param optimizer defines the current optimizer
  60727. * @returns true if everything that can be done was applied
  60728. */
  60729. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60730. /**
  60731. * Creates the SceneOptimization object
  60732. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60733. * @param desc defines the description associated with the optimization
  60734. */
  60735. constructor(
  60736. /**
  60737. * Defines the priority of this optimization (0 by default which means first in the list)
  60738. */
  60739. priority?: number);
  60740. }
  60741. /**
  60742. * Defines an optimization used to reduce the size of render target textures
  60743. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60744. */
  60745. export class TextureOptimization extends SceneOptimization {
  60746. /**
  60747. * Defines the priority of this optimization (0 by default which means first in the list)
  60748. */
  60749. priority: number;
  60750. /**
  60751. * 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
  60752. */
  60753. maximumSize: number;
  60754. /**
  60755. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60756. */
  60757. step: number;
  60758. /**
  60759. * Gets a string describing the action executed by the current optimization
  60760. * @returns description string
  60761. */
  60762. getDescription(): string;
  60763. /**
  60764. * Creates the TextureOptimization object
  60765. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60766. * @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
  60767. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60768. */
  60769. constructor(
  60770. /**
  60771. * Defines the priority of this optimization (0 by default which means first in the list)
  60772. */
  60773. priority?: number,
  60774. /**
  60775. * 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
  60776. */
  60777. maximumSize?: number,
  60778. /**
  60779. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60780. */
  60781. step?: number);
  60782. /**
  60783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60784. * @param scene defines the current scene where to apply this optimization
  60785. * @param optimizer defines the current optimizer
  60786. * @returns true if everything that can be done was applied
  60787. */
  60788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60789. }
  60790. /**
  60791. * Defines an optimization used to increase or decrease the rendering resolution
  60792. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60793. */
  60794. export class HardwareScalingOptimization extends SceneOptimization {
  60795. /**
  60796. * Defines the priority of this optimization (0 by default which means first in the list)
  60797. */
  60798. priority: number;
  60799. /**
  60800. * Defines the maximum scale to use (2 by default)
  60801. */
  60802. maximumScale: number;
  60803. /**
  60804. * Defines the step to use between two passes (0.5 by default)
  60805. */
  60806. step: number;
  60807. private _currentScale;
  60808. private _directionOffset;
  60809. /**
  60810. * Gets a string describing the action executed by the current optimization
  60811. * @return description string
  60812. */
  60813. getDescription(): string;
  60814. /**
  60815. * Creates the HardwareScalingOptimization object
  60816. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60817. * @param maximumScale defines the maximum scale to use (2 by default)
  60818. * @param step defines the step to use between two passes (0.5 by default)
  60819. */
  60820. constructor(
  60821. /**
  60822. * Defines the priority of this optimization (0 by default which means first in the list)
  60823. */
  60824. priority?: number,
  60825. /**
  60826. * Defines the maximum scale to use (2 by default)
  60827. */
  60828. maximumScale?: number,
  60829. /**
  60830. * Defines the step to use between two passes (0.5 by default)
  60831. */
  60832. step?: number);
  60833. /**
  60834. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60835. * @param scene defines the current scene where to apply this optimization
  60836. * @param optimizer defines the current optimizer
  60837. * @returns true if everything that can be done was applied
  60838. */
  60839. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60840. }
  60841. /**
  60842. * Defines an optimization used to remove shadows
  60843. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60844. */
  60845. export class ShadowsOptimization extends SceneOptimization {
  60846. /**
  60847. * Gets a string describing the action executed by the current optimization
  60848. * @return description string
  60849. */
  60850. getDescription(): string;
  60851. /**
  60852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60853. * @param scene defines the current scene where to apply this optimization
  60854. * @param optimizer defines the current optimizer
  60855. * @returns true if everything that can be done was applied
  60856. */
  60857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60858. }
  60859. /**
  60860. * Defines an optimization used to turn post-processes off
  60861. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60862. */
  60863. export class PostProcessesOptimization extends SceneOptimization {
  60864. /**
  60865. * Gets a string describing the action executed by the current optimization
  60866. * @return description string
  60867. */
  60868. getDescription(): string;
  60869. /**
  60870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60871. * @param scene defines the current scene where to apply this optimization
  60872. * @param optimizer defines the current optimizer
  60873. * @returns true if everything that can be done was applied
  60874. */
  60875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60876. }
  60877. /**
  60878. * Defines an optimization used to turn lens flares off
  60879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60880. */
  60881. export class LensFlaresOptimization extends SceneOptimization {
  60882. /**
  60883. * Gets a string describing the action executed by the current optimization
  60884. * @return description string
  60885. */
  60886. getDescription(): string;
  60887. /**
  60888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60889. * @param scene defines the current scene where to apply this optimization
  60890. * @param optimizer defines the current optimizer
  60891. * @returns true if everything that can be done was applied
  60892. */
  60893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60894. }
  60895. /**
  60896. * Defines an optimization based on user defined callback.
  60897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60898. */
  60899. export class CustomOptimization extends SceneOptimization {
  60900. /**
  60901. * Callback called to apply the custom optimization.
  60902. */
  60903. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60904. /**
  60905. * Callback called to get custom description
  60906. */
  60907. onGetDescription: () => string;
  60908. /**
  60909. * Gets a string describing the action executed by the current optimization
  60910. * @returns description string
  60911. */
  60912. getDescription(): string;
  60913. /**
  60914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60915. * @param scene defines the current scene where to apply this optimization
  60916. * @param optimizer defines the current optimizer
  60917. * @returns true if everything that can be done was applied
  60918. */
  60919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60920. }
  60921. /**
  60922. * Defines an optimization used to turn particles off
  60923. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60924. */
  60925. export class ParticlesOptimization extends SceneOptimization {
  60926. /**
  60927. * Gets a string describing the action executed by the current optimization
  60928. * @return description string
  60929. */
  60930. getDescription(): string;
  60931. /**
  60932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60933. * @param scene defines the current scene where to apply this optimization
  60934. * @param optimizer defines the current optimizer
  60935. * @returns true if everything that can be done was applied
  60936. */
  60937. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60938. }
  60939. /**
  60940. * Defines an optimization used to turn render targets off
  60941. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60942. */
  60943. export class RenderTargetsOptimization extends SceneOptimization {
  60944. /**
  60945. * Gets a string describing the action executed by the current optimization
  60946. * @return description string
  60947. */
  60948. getDescription(): string;
  60949. /**
  60950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60951. * @param scene defines the current scene where to apply this optimization
  60952. * @param optimizer defines the current optimizer
  60953. * @returns true if everything that can be done was applied
  60954. */
  60955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60956. }
  60957. /**
  60958. * Defines an optimization used to merge meshes with compatible materials
  60959. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60960. */
  60961. export class MergeMeshesOptimization extends SceneOptimization {
  60962. private static _UpdateSelectionTree;
  60963. /**
  60964. * Gets or sets a boolean which defines if optimization octree has to be updated
  60965. */
  60966. /**
  60967. * Gets or sets a boolean which defines if optimization octree has to be updated
  60968. */
  60969. static UpdateSelectionTree: boolean;
  60970. /**
  60971. * Gets a string describing the action executed by the current optimization
  60972. * @return description string
  60973. */
  60974. getDescription(): string;
  60975. private _canBeMerged;
  60976. /**
  60977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60978. * @param scene defines the current scene where to apply this optimization
  60979. * @param optimizer defines the current optimizer
  60980. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60981. * @returns true if everything that can be done was applied
  60982. */
  60983. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60984. }
  60985. /**
  60986. * Defines a list of options used by SceneOptimizer
  60987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60988. */
  60989. export class SceneOptimizerOptions {
  60990. /**
  60991. * Defines the target frame rate to reach (60 by default)
  60992. */
  60993. targetFrameRate: number;
  60994. /**
  60995. * Defines the interval between two checkes (2000ms by default)
  60996. */
  60997. trackerDuration: number;
  60998. /**
  60999. * Gets the list of optimizations to apply
  61000. */
  61001. optimizations: SceneOptimization[];
  61002. /**
  61003. * Creates a new list of options used by SceneOptimizer
  61004. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61005. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61006. */
  61007. constructor(
  61008. /**
  61009. * Defines the target frame rate to reach (60 by default)
  61010. */
  61011. targetFrameRate?: number,
  61012. /**
  61013. * Defines the interval between two checkes (2000ms by default)
  61014. */
  61015. trackerDuration?: number);
  61016. /**
  61017. * Add a new optimization
  61018. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61019. * @returns the current SceneOptimizerOptions
  61020. */
  61021. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61022. /**
  61023. * Add a new custom optimization
  61024. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61025. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61026. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61027. * @returns the current SceneOptimizerOptions
  61028. */
  61029. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61030. /**
  61031. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61032. * @param targetFrameRate defines the target frame rate (60 by default)
  61033. * @returns a SceneOptimizerOptions object
  61034. */
  61035. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61036. /**
  61037. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61038. * @param targetFrameRate defines the target frame rate (60 by default)
  61039. * @returns a SceneOptimizerOptions object
  61040. */
  61041. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61042. /**
  61043. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61044. * @param targetFrameRate defines the target frame rate (60 by default)
  61045. * @returns a SceneOptimizerOptions object
  61046. */
  61047. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61048. }
  61049. /**
  61050. * Class used to run optimizations in order to reach a target frame rate
  61051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61052. */
  61053. export class SceneOptimizer implements IDisposable {
  61054. private _isRunning;
  61055. private _options;
  61056. private _scene;
  61057. private _currentPriorityLevel;
  61058. private _targetFrameRate;
  61059. private _trackerDuration;
  61060. private _currentFrameRate;
  61061. private _sceneDisposeObserver;
  61062. private _improvementMode;
  61063. /**
  61064. * Defines an observable called when the optimizer reaches the target frame rate
  61065. */
  61066. onSuccessObservable: Observable<SceneOptimizer>;
  61067. /**
  61068. * Defines an observable called when the optimizer enables an optimization
  61069. */
  61070. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61071. /**
  61072. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61073. */
  61074. onFailureObservable: Observable<SceneOptimizer>;
  61075. /**
  61076. * Gets a boolean indicating if the optimizer is in improvement mode
  61077. */
  61078. readonly isInImprovementMode: boolean;
  61079. /**
  61080. * Gets the current priority level (0 at start)
  61081. */
  61082. readonly currentPriorityLevel: number;
  61083. /**
  61084. * Gets the current frame rate checked by the SceneOptimizer
  61085. */
  61086. readonly currentFrameRate: number;
  61087. /**
  61088. * Gets or sets the current target frame rate (60 by default)
  61089. */
  61090. /**
  61091. * Gets or sets the current target frame rate (60 by default)
  61092. */
  61093. targetFrameRate: number;
  61094. /**
  61095. * Gets or sets the current interval between two checks (every 2000ms by default)
  61096. */
  61097. /**
  61098. * Gets or sets the current interval between two checks (every 2000ms by default)
  61099. */
  61100. trackerDuration: number;
  61101. /**
  61102. * Gets the list of active optimizations
  61103. */
  61104. readonly optimizations: SceneOptimization[];
  61105. /**
  61106. * Creates a new SceneOptimizer
  61107. * @param scene defines the scene to work on
  61108. * @param options defines the options to use with the SceneOptimizer
  61109. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61110. * @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)
  61111. */
  61112. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61113. /**
  61114. * Stops the current optimizer
  61115. */
  61116. stop(): void;
  61117. /**
  61118. * Reset the optimizer to initial step (current priority level = 0)
  61119. */
  61120. reset(): void;
  61121. /**
  61122. * Start the optimizer. By default it will try to reach a specific framerate
  61123. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61124. */
  61125. start(): void;
  61126. private _checkCurrentState;
  61127. /**
  61128. * Release all resources
  61129. */
  61130. dispose(): void;
  61131. /**
  61132. * Helper function to create a SceneOptimizer with one single line of code
  61133. * @param scene defines the scene to work on
  61134. * @param options defines the options to use with the SceneOptimizer
  61135. * @param onSuccess defines a callback to call on success
  61136. * @param onFailure defines a callback to call on failure
  61137. * @returns the new SceneOptimizer object
  61138. */
  61139. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61140. }
  61141. }
  61142. declare module BABYLON {
  61143. /**
  61144. * Class used to serialize a scene into a string
  61145. */
  61146. export class SceneSerializer {
  61147. /**
  61148. * Clear cache used by a previous serialization
  61149. */
  61150. static ClearCache(): void;
  61151. /**
  61152. * Serialize a scene into a JSON compatible object
  61153. * @param scene defines the scene to serialize
  61154. * @returns a JSON compatible object
  61155. */
  61156. static Serialize(scene: Scene): any;
  61157. /**
  61158. * Serialize a mesh into a JSON compatible object
  61159. * @param toSerialize defines the mesh to serialize
  61160. * @param withParents defines if parents must be serialized as well
  61161. * @param withChildren defines if children must be serialized as well
  61162. * @returns a JSON compatible object
  61163. */
  61164. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61165. }
  61166. }
  61167. declare module BABYLON {
  61168. /**
  61169. * Class used to host texture specific utilities
  61170. */
  61171. export class TextureTools {
  61172. /**
  61173. * Uses the GPU to create a copy texture rescaled at a given size
  61174. * @param texture Texture to copy from
  61175. * @param width defines the desired width
  61176. * @param height defines the desired height
  61177. * @param useBilinearMode defines if bilinear mode has to be used
  61178. * @return the generated texture
  61179. */
  61180. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61181. }
  61182. }
  61183. declare module BABYLON {
  61184. /**
  61185. * This represents the different options available for the video capture.
  61186. */
  61187. export interface VideoRecorderOptions {
  61188. /** Defines the mime type of the video. */
  61189. mimeType: string;
  61190. /** Defines the FPS the video should be recorded at. */
  61191. fps: number;
  61192. /** Defines the chunk size for the recording data. */
  61193. recordChunckSize: number;
  61194. /** The audio tracks to attach to the recording. */
  61195. audioTracks?: MediaStreamTrack[];
  61196. }
  61197. /**
  61198. * This can help with recording videos from BabylonJS.
  61199. * This is based on the available WebRTC functionalities of the browser.
  61200. *
  61201. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61202. */
  61203. export class VideoRecorder {
  61204. private static readonly _defaultOptions;
  61205. /**
  61206. * Returns whether or not the VideoRecorder is available in your browser.
  61207. * @param engine Defines the Babylon Engine.
  61208. * @returns true if supported otherwise false.
  61209. */
  61210. static IsSupported(engine: Engine): boolean;
  61211. private readonly _options;
  61212. private _canvas;
  61213. private _mediaRecorder;
  61214. private _recordedChunks;
  61215. private _fileName;
  61216. private _resolve;
  61217. private _reject;
  61218. /**
  61219. * True when a recording is already in progress.
  61220. */
  61221. readonly isRecording: boolean;
  61222. /**
  61223. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61224. * @param engine Defines the BabylonJS Engine you wish to record.
  61225. * @param options Defines options that can be used to customize the capture.
  61226. */
  61227. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61228. /**
  61229. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61230. */
  61231. stopRecording(): void;
  61232. /**
  61233. * Starts recording the canvas for a max duration specified in parameters.
  61234. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61235. * If null no automatic download will start and you can rely on the promise to get the data back.
  61236. * @param maxDuration Defines the maximum recording time in seconds.
  61237. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61238. * @return A promise callback at the end of the recording with the video data in Blob.
  61239. */
  61240. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61241. /**
  61242. * Releases internal resources used during the recording.
  61243. */
  61244. dispose(): void;
  61245. private _handleDataAvailable;
  61246. private _handleError;
  61247. private _handleStop;
  61248. }
  61249. }
  61250. declare module BABYLON {
  61251. /**
  61252. * Class containing a set of static utilities functions for screenshots
  61253. */
  61254. export class ScreenshotTools {
  61255. /**
  61256. * Captures a screenshot of the current rendering
  61257. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61258. * @param engine defines the rendering engine
  61259. * @param camera defines the source camera
  61260. * @param size This parameter can be set to a single number or to an object with the
  61261. * following (optional) properties: precision, width, height. If a single number is passed,
  61262. * it will be used for both width and height. If an object is passed, the screenshot size
  61263. * will be derived from the parameters. The precision property is a multiplier allowing
  61264. * rendering at a higher or lower resolution
  61265. * @param successCallback defines the callback receives a single parameter which contains the
  61266. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61267. * src parameter of an <img> to display it
  61268. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61269. * Check your browser for supported MIME types
  61270. */
  61271. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61272. /**
  61273. * Captures a screenshot of the current rendering
  61274. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61275. * @param engine defines the rendering engine
  61276. * @param camera defines the source camera
  61277. * @param size This parameter can be set to a single number or to an object with the
  61278. * following (optional) properties: precision, width, height. If a single number is passed,
  61279. * it will be used for both width and height. If an object is passed, the screenshot size
  61280. * will be derived from the parameters. The precision property is a multiplier allowing
  61281. * rendering at a higher or lower resolution
  61282. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61283. * Check your browser for supported MIME types
  61284. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61285. * to the src parameter of an <img> to display it
  61286. */
  61287. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61288. /**
  61289. * Generates an image screenshot from the specified camera.
  61290. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61291. * @param engine The engine to use for rendering
  61292. * @param camera The camera to use for rendering
  61293. * @param size This parameter can be set to a single number or to an object with the
  61294. * following (optional) properties: precision, width, height. If a single number is passed,
  61295. * it will be used for both width and height. If an object is passed, the screenshot size
  61296. * will be derived from the parameters. The precision property is a multiplier allowing
  61297. * rendering at a higher or lower resolution
  61298. * @param successCallback The callback receives a single parameter which contains the
  61299. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61300. * src parameter of an <img> to display it
  61301. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61302. * Check your browser for supported MIME types
  61303. * @param samples Texture samples (default: 1)
  61304. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61305. * @param fileName A name for for the downloaded file.
  61306. */
  61307. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61308. /**
  61309. * Generates an image screenshot from the specified camera.
  61310. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61311. * @param engine The engine to use for rendering
  61312. * @param camera The camera to use for rendering
  61313. * @param size This parameter can be set to a single number or to an object with the
  61314. * following (optional) properties: precision, width, height. If a single number is passed,
  61315. * it will be used for both width and height. If an object is passed, the screenshot size
  61316. * will be derived from the parameters. The precision property is a multiplier allowing
  61317. * rendering at a higher or lower resolution
  61318. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61319. * Check your browser for supported MIME types
  61320. * @param samples Texture samples (default: 1)
  61321. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61322. * @param fileName A name for for the downloaded file.
  61323. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61324. * to the src parameter of an <img> to display it
  61325. */
  61326. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61327. /**
  61328. * Gets height and width for screenshot size
  61329. * @private
  61330. */
  61331. private static _getScreenshotSize;
  61332. }
  61333. }
  61334. declare module BABYLON {
  61335. /**
  61336. * A cursor which tracks a point on a path
  61337. */
  61338. export class PathCursor {
  61339. private path;
  61340. /**
  61341. * Stores path cursor callbacks for when an onchange event is triggered
  61342. */
  61343. private _onchange;
  61344. /**
  61345. * The value of the path cursor
  61346. */
  61347. value: number;
  61348. /**
  61349. * The animation array of the path cursor
  61350. */
  61351. animations: Animation[];
  61352. /**
  61353. * Initializes the path cursor
  61354. * @param path The path to track
  61355. */
  61356. constructor(path: Path2);
  61357. /**
  61358. * Gets the cursor point on the path
  61359. * @returns A point on the path cursor at the cursor location
  61360. */
  61361. getPoint(): Vector3;
  61362. /**
  61363. * Moves the cursor ahead by the step amount
  61364. * @param step The amount to move the cursor forward
  61365. * @returns This path cursor
  61366. */
  61367. moveAhead(step?: number): PathCursor;
  61368. /**
  61369. * Moves the cursor behind by the step amount
  61370. * @param step The amount to move the cursor back
  61371. * @returns This path cursor
  61372. */
  61373. moveBack(step?: number): PathCursor;
  61374. /**
  61375. * Moves the cursor by the step amount
  61376. * If the step amount is greater than one, an exception is thrown
  61377. * @param step The amount to move the cursor
  61378. * @returns This path cursor
  61379. */
  61380. move(step: number): PathCursor;
  61381. /**
  61382. * Ensures that the value is limited between zero and one
  61383. * @returns This path cursor
  61384. */
  61385. private ensureLimits;
  61386. /**
  61387. * Runs onchange callbacks on change (used by the animation engine)
  61388. * @returns This path cursor
  61389. */
  61390. private raiseOnChange;
  61391. /**
  61392. * Executes a function on change
  61393. * @param f A path cursor onchange callback
  61394. * @returns This path cursor
  61395. */
  61396. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61397. }
  61398. }
  61399. declare module BABYLON {
  61400. /** @hidden */
  61401. export var blurPixelShader: {
  61402. name: string;
  61403. shader: string;
  61404. };
  61405. }
  61406. declare module BABYLON {
  61407. /** @hidden */
  61408. export var pointCloudVertexDeclaration: {
  61409. name: string;
  61410. shader: string;
  61411. };
  61412. }
  61413. // Mixins
  61414. interface Window {
  61415. mozIndexedDB: IDBFactory;
  61416. webkitIndexedDB: IDBFactory;
  61417. msIndexedDB: IDBFactory;
  61418. webkitURL: typeof URL;
  61419. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61420. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61421. WebGLRenderingContext: WebGLRenderingContext;
  61422. MSGesture: MSGesture;
  61423. CANNON: any;
  61424. AudioContext: AudioContext;
  61425. webkitAudioContext: AudioContext;
  61426. PointerEvent: any;
  61427. Math: Math;
  61428. Uint8Array: Uint8ArrayConstructor;
  61429. Float32Array: Float32ArrayConstructor;
  61430. mozURL: typeof URL;
  61431. msURL: typeof URL;
  61432. VRFrameData: any; // WebVR, from specs 1.1
  61433. DracoDecoderModule: any;
  61434. setImmediate(handler: (...args: any[]) => void): number;
  61435. }
  61436. interface HTMLCanvasElement {
  61437. requestPointerLock(): void;
  61438. msRequestPointerLock?(): void;
  61439. mozRequestPointerLock?(): void;
  61440. webkitRequestPointerLock?(): void;
  61441. /** Track wether a record is in progress */
  61442. isRecording: boolean;
  61443. /** Capture Stream method defined by some browsers */
  61444. captureStream(fps?: number): MediaStream;
  61445. }
  61446. interface CanvasRenderingContext2D {
  61447. msImageSmoothingEnabled: boolean;
  61448. }
  61449. interface MouseEvent {
  61450. mozMovementX: number;
  61451. mozMovementY: number;
  61452. webkitMovementX: number;
  61453. webkitMovementY: number;
  61454. msMovementX: number;
  61455. msMovementY: number;
  61456. }
  61457. interface Navigator {
  61458. mozGetVRDevices: (any: any) => any;
  61459. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61460. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61461. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61462. webkitGetGamepads(): Gamepad[];
  61463. msGetGamepads(): Gamepad[];
  61464. webkitGamepads(): Gamepad[];
  61465. }
  61466. interface HTMLVideoElement {
  61467. mozSrcObject: any;
  61468. }
  61469. interface Math {
  61470. fround(x: number): number;
  61471. imul(a: number, b: number): number;
  61472. }
  61473. interface WebGLRenderingContext {
  61474. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61475. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61476. vertexAttribDivisor(index: number, divisor: number): void;
  61477. createVertexArray(): any;
  61478. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61479. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61480. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61481. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61482. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61483. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61484. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61485. // Queries
  61486. createQuery(): WebGLQuery;
  61487. deleteQuery(query: WebGLQuery): void;
  61488. beginQuery(target: number, query: WebGLQuery): void;
  61489. endQuery(target: number): void;
  61490. getQueryParameter(query: WebGLQuery, pname: number): any;
  61491. getQuery(target: number, pname: number): any;
  61492. MAX_SAMPLES: number;
  61493. RGBA8: number;
  61494. READ_FRAMEBUFFER: number;
  61495. DRAW_FRAMEBUFFER: number;
  61496. UNIFORM_BUFFER: number;
  61497. HALF_FLOAT_OES: number;
  61498. RGBA16F: number;
  61499. RGBA32F: number;
  61500. R32F: number;
  61501. RG32F: number;
  61502. RGB32F: number;
  61503. R16F: number;
  61504. RG16F: number;
  61505. RGB16F: number;
  61506. RED: number;
  61507. RG: number;
  61508. R8: number;
  61509. RG8: number;
  61510. UNSIGNED_INT_24_8: number;
  61511. DEPTH24_STENCIL8: number;
  61512. /* Multiple Render Targets */
  61513. drawBuffers(buffers: number[]): void;
  61514. readBuffer(src: number): void;
  61515. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61516. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61517. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61518. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61519. // Occlusion Query
  61520. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61521. ANY_SAMPLES_PASSED: number;
  61522. QUERY_RESULT_AVAILABLE: number;
  61523. QUERY_RESULT: number;
  61524. }
  61525. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61526. }
  61527. interface EXT_disjoint_timer_query {
  61528. QUERY_COUNTER_BITS_EXT: number;
  61529. TIME_ELAPSED_EXT: number;
  61530. TIMESTAMP_EXT: number;
  61531. GPU_DISJOINT_EXT: number;
  61532. QUERY_RESULT_EXT: number;
  61533. QUERY_RESULT_AVAILABLE_EXT: number;
  61534. queryCounterEXT(query: WebGLQuery, target: number): void;
  61535. createQueryEXT(): WebGLQuery;
  61536. beginQueryEXT(target: number, query: WebGLQuery): void;
  61537. endQueryEXT(target: number): void;
  61538. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61539. deleteQueryEXT(query: WebGLQuery): void;
  61540. }
  61541. interface WebGLUniformLocation { private _currentState: any;
  61542. }
  61543. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61544. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61545. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61546. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61547. interface WebGLRenderingContext {
  61548. readonly RASTERIZER_DISCARD: number;
  61549. readonly DEPTH_COMPONENT24: number;
  61550. readonly TEXTURE_3D: number;
  61551. readonly TEXTURE_2D_ARRAY: number;
  61552. readonly TEXTURE_COMPARE_FUNC: number;
  61553. readonly TEXTURE_COMPARE_MODE: number;
  61554. readonly COMPARE_REF_TO_TEXTURE: number;
  61555. readonly TEXTURE_WRAP_R: number;
  61556. readonly HALF_FLOAT: number;
  61557. readonly RGB8: number;
  61558. readonly RED_INTEGER: number;
  61559. readonly RG_INTEGER: number;
  61560. readonly RGB_INTEGER: number;
  61561. readonly RGBA_INTEGER: number;
  61562. readonly R8_SNORM: number;
  61563. readonly RG8_SNORM: number;
  61564. readonly RGB8_SNORM: number;
  61565. readonly RGBA8_SNORM: number;
  61566. readonly R8I: number;
  61567. readonly RG8I: number;
  61568. readonly RGB8I: number;
  61569. readonly RGBA8I: number;
  61570. readonly R8UI: number;
  61571. readonly RG8UI: number;
  61572. readonly RGB8UI: number;
  61573. readonly RGBA8UI: number;
  61574. readonly R16I: number;
  61575. readonly RG16I: number;
  61576. readonly RGB16I: number;
  61577. readonly RGBA16I: number;
  61578. readonly R16UI: number;
  61579. readonly RG16UI: number;
  61580. readonly RGB16UI: number;
  61581. readonly RGBA16UI: number;
  61582. readonly R32I: number;
  61583. readonly RG32I: number;
  61584. readonly RGB32I: number;
  61585. readonly RGBA32I: number;
  61586. readonly R32UI: number;
  61587. readonly RG32UI: number;
  61588. readonly RGB32UI: number;
  61589. readonly RGBA32UI: number;
  61590. readonly RGB10_A2UI: number;
  61591. readonly R11F_G11F_B10F: number;
  61592. readonly RGB9_E5: number;
  61593. readonly RGB10_A2: number;
  61594. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61595. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61596. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61597. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61598. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61599. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61600. 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;
  61601. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61602. readonly TRANSFORM_FEEDBACK: number;
  61603. readonly INTERLEAVED_ATTRIBS: number;
  61604. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61605. createTransformFeedback(): WebGLTransformFeedback;
  61606. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61607. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61608. beginTransformFeedback(primitiveMode: number): void;
  61609. endTransformFeedback(): void;
  61610. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61611. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61612. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61613. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61614. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61615. }
  61616. interface ImageBitmap {
  61617. readonly width: number;
  61618. readonly height: number;
  61619. close(): void;
  61620. }
  61621. interface WebGLQuery extends WebGLObject {
  61622. }
  61623. declare var WebGLQuery: {
  61624. prototype: WebGLQuery;
  61625. new(): WebGLQuery;
  61626. };
  61627. interface WebGLSampler extends WebGLObject {
  61628. }
  61629. declare var WebGLSampler: {
  61630. prototype: WebGLSampler;
  61631. new(): WebGLSampler;
  61632. };
  61633. interface WebGLSync extends WebGLObject {
  61634. }
  61635. declare var WebGLSync: {
  61636. prototype: WebGLSync;
  61637. new(): WebGLSync;
  61638. };
  61639. interface WebGLTransformFeedback extends WebGLObject {
  61640. }
  61641. declare var WebGLTransformFeedback: {
  61642. prototype: WebGLTransformFeedback;
  61643. new(): WebGLTransformFeedback;
  61644. };
  61645. interface WebGLVertexArrayObject extends WebGLObject {
  61646. }
  61647. declare var WebGLVertexArrayObject: {
  61648. prototype: WebGLVertexArrayObject;
  61649. new(): WebGLVertexArrayObject;
  61650. };
  61651. // Type definitions for WebVR API
  61652. // Project: https://w3c.github.io/webvr/
  61653. // Definitions by: six a <https://github.com/lostfictions>
  61654. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61655. interface VRDisplay extends EventTarget {
  61656. /**
  61657. * Dictionary of capabilities describing the VRDisplay.
  61658. */
  61659. readonly capabilities: VRDisplayCapabilities;
  61660. /**
  61661. * z-depth defining the far plane of the eye view frustum
  61662. * enables mapping of values in the render target depth
  61663. * attachment to scene coordinates. Initially set to 10000.0.
  61664. */
  61665. depthFar: number;
  61666. /**
  61667. * z-depth defining the near plane of the eye view frustum
  61668. * enables mapping of values in the render target depth
  61669. * attachment to scene coordinates. Initially set to 0.01.
  61670. */
  61671. depthNear: number;
  61672. /**
  61673. * An identifier for this distinct VRDisplay. Used as an
  61674. * association point in the Gamepad API.
  61675. */
  61676. readonly displayId: number;
  61677. /**
  61678. * A display name, a user-readable name identifying it.
  61679. */
  61680. readonly displayName: string;
  61681. readonly isConnected: boolean;
  61682. readonly isPresenting: boolean;
  61683. /**
  61684. * If this VRDisplay supports room-scale experiences, the optional
  61685. * stage attribute contains details on the room-scale parameters.
  61686. */
  61687. readonly stageParameters: VRStageParameters | null;
  61688. /**
  61689. * Passing the value returned by `requestAnimationFrame` to
  61690. * `cancelAnimationFrame` will unregister the callback.
  61691. * @param handle Define the hanle of the request to cancel
  61692. */
  61693. cancelAnimationFrame(handle: number): void;
  61694. /**
  61695. * Stops presenting to the VRDisplay.
  61696. * @returns a promise to know when it stopped
  61697. */
  61698. exitPresent(): Promise<void>;
  61699. /**
  61700. * Return the current VREyeParameters for the given eye.
  61701. * @param whichEye Define the eye we want the parameter for
  61702. * @returns the eye parameters
  61703. */
  61704. getEyeParameters(whichEye: string): VREyeParameters;
  61705. /**
  61706. * Populates the passed VRFrameData with the information required to render
  61707. * the current frame.
  61708. * @param frameData Define the data structure to populate
  61709. * @returns true if ok otherwise false
  61710. */
  61711. getFrameData(frameData: VRFrameData): boolean;
  61712. /**
  61713. * Get the layers currently being presented.
  61714. * @returns the list of VR layers
  61715. */
  61716. getLayers(): VRLayer[];
  61717. /**
  61718. * Return a VRPose containing the future predicted pose of the VRDisplay
  61719. * when the current frame will be presented. The value returned will not
  61720. * change until JavaScript has returned control to the browser.
  61721. *
  61722. * The VRPose will contain the position, orientation, velocity,
  61723. * and acceleration of each of these properties.
  61724. * @returns the pose object
  61725. */
  61726. getPose(): VRPose;
  61727. /**
  61728. * Return the current instantaneous pose of the VRDisplay, with no
  61729. * prediction applied.
  61730. * @returns the current instantaneous pose
  61731. */
  61732. getImmediatePose(): VRPose;
  61733. /**
  61734. * The callback passed to `requestAnimationFrame` will be called
  61735. * any time a new frame should be rendered. When the VRDisplay is
  61736. * presenting the callback will be called at the native refresh
  61737. * rate of the HMD. When not presenting this function acts
  61738. * identically to how window.requestAnimationFrame acts. Content should
  61739. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61740. * asynchronously from other displays and at differing refresh rates.
  61741. * @param callback Define the eaction to run next frame
  61742. * @returns the request handle it
  61743. */
  61744. requestAnimationFrame(callback: FrameRequestCallback): number;
  61745. /**
  61746. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61747. * Repeat calls while already presenting will update the VRLayers being displayed.
  61748. * @param layers Define the list of layer to present
  61749. * @returns a promise to know when the request has been fulfilled
  61750. */
  61751. requestPresent(layers: VRLayer[]): Promise<void>;
  61752. /**
  61753. * Reset the pose for this display, treating its current position and
  61754. * orientation as the "origin/zero" values. VRPose.position,
  61755. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61756. * updated when calling resetPose(). This should be called in only
  61757. * sitting-space experiences.
  61758. */
  61759. resetPose(): void;
  61760. /**
  61761. * The VRLayer provided to the VRDisplay will be captured and presented
  61762. * in the HMD. Calling this function has the same effect on the source
  61763. * canvas as any other operation that uses its source image, and canvases
  61764. * created without preserveDrawingBuffer set to true will be cleared.
  61765. * @param pose Define the pose to submit
  61766. */
  61767. submitFrame(pose?: VRPose): void;
  61768. }
  61769. declare var VRDisplay: {
  61770. prototype: VRDisplay;
  61771. new(): VRDisplay;
  61772. };
  61773. interface VRLayer {
  61774. leftBounds?: number[] | Float32Array | null;
  61775. rightBounds?: number[] | Float32Array | null;
  61776. source?: HTMLCanvasElement | null;
  61777. }
  61778. interface VRDisplayCapabilities {
  61779. readonly canPresent: boolean;
  61780. readonly hasExternalDisplay: boolean;
  61781. readonly hasOrientation: boolean;
  61782. readonly hasPosition: boolean;
  61783. readonly maxLayers: number;
  61784. }
  61785. interface VREyeParameters {
  61786. /** @deprecated */
  61787. readonly fieldOfView: VRFieldOfView;
  61788. readonly offset: Float32Array;
  61789. readonly renderHeight: number;
  61790. readonly renderWidth: number;
  61791. }
  61792. interface VRFieldOfView {
  61793. readonly downDegrees: number;
  61794. readonly leftDegrees: number;
  61795. readonly rightDegrees: number;
  61796. readonly upDegrees: number;
  61797. }
  61798. interface VRFrameData {
  61799. readonly leftProjectionMatrix: Float32Array;
  61800. readonly leftViewMatrix: Float32Array;
  61801. readonly pose: VRPose;
  61802. readonly rightProjectionMatrix: Float32Array;
  61803. readonly rightViewMatrix: Float32Array;
  61804. readonly timestamp: number;
  61805. }
  61806. interface VRPose {
  61807. readonly angularAcceleration: Float32Array | null;
  61808. readonly angularVelocity: Float32Array | null;
  61809. readonly linearAcceleration: Float32Array | null;
  61810. readonly linearVelocity: Float32Array | null;
  61811. readonly orientation: Float32Array | null;
  61812. readonly position: Float32Array | null;
  61813. readonly timestamp: number;
  61814. }
  61815. interface VRStageParameters {
  61816. sittingToStandingTransform?: Float32Array;
  61817. sizeX?: number;
  61818. sizeY?: number;
  61819. }
  61820. interface Navigator {
  61821. getVRDisplays(): Promise<VRDisplay[]>;
  61822. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61823. }
  61824. interface Window {
  61825. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61826. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61827. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61828. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61829. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61830. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61831. }
  61832. interface Gamepad {
  61833. readonly displayId: number;
  61834. }
  61835. type XRSessionMode =
  61836. | "inline"
  61837. | "immersive-vr"
  61838. | "immersive-ar";
  61839. type XRReferenceSpaceType =
  61840. | "viewer"
  61841. | "local"
  61842. | "local-floor"
  61843. | "bounded-floor"
  61844. | "unbounded";
  61845. type XREnvironmentBlendMode =
  61846. | "opaque"
  61847. | "additive"
  61848. | "alpha-blend";
  61849. type XRVisibilityState =
  61850. | "visible"
  61851. | "visible-blurred"
  61852. | "hidden";
  61853. type XRHandedness =
  61854. | "none"
  61855. | "left"
  61856. | "right";
  61857. type XRTargetRayMode =
  61858. | "gaze"
  61859. | "tracked-pointer"
  61860. | "screen";
  61861. type XREye =
  61862. | "none"
  61863. | "left"
  61864. | "right";
  61865. interface XRSpace extends EventTarget {
  61866. }
  61867. interface XRRenderState {
  61868. depthNear?: number;
  61869. depthFar?: number;
  61870. inlineVerticalFieldOfView?: number;
  61871. baseLayer?: XRWebGLLayer;
  61872. }
  61873. interface XRInputSource {
  61874. handedness: XRHandedness;
  61875. targetRayMode: XRTargetRayMode;
  61876. targetRaySpace: XRSpace;
  61877. gripSpace: XRSpace | undefined;
  61878. gamepad: Gamepad | undefined;
  61879. profiles: Array<string>;
  61880. }
  61881. interface XRSession {
  61882. addEventListener: Function;
  61883. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61884. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61885. requestAnimationFrame: Function;
  61886. end(): Promise<void>;
  61887. renderState: XRRenderState;
  61888. inputSources: Array<XRInputSource>;
  61889. }
  61890. interface XRReferenceSpace extends XRSpace {
  61891. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61892. onreset: any;
  61893. }
  61894. interface XRFrame {
  61895. session: XRSession;
  61896. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61897. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61898. }
  61899. interface XRViewerPose extends XRPose {
  61900. views: Array<XRView>;
  61901. }
  61902. interface XRPose {
  61903. transform: XRRigidTransform;
  61904. emulatedPosition: boolean;
  61905. }
  61906. declare var XRWebGLLayer: {
  61907. prototype: XRWebGLLayer;
  61908. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61909. };
  61910. interface XRWebGLLayer {
  61911. framebuffer: WebGLFramebuffer;
  61912. framebufferWidth: number;
  61913. framebufferHeight: number;
  61914. getViewport: Function;
  61915. }
  61916. interface XRRigidTransform {
  61917. position: DOMPointReadOnly;
  61918. orientation: DOMPointReadOnly;
  61919. matrix: Float32Array;
  61920. inverse: XRRigidTransform;
  61921. }
  61922. interface XRView {
  61923. eye: XREye;
  61924. projectionMatrix: Float32Array;
  61925. transform: XRRigidTransform;
  61926. }
  61927. interface XRInputSourceChangeEvent {
  61928. session: XRSession;
  61929. removed: Array<XRInputSource>;
  61930. added: Array<XRInputSource>;
  61931. }
  61932. declare module BABYLON.GUI {
  61933. /**
  61934. * Class used to specific a value and its associated unit
  61935. */
  61936. export class ValueAndUnit {
  61937. /** defines the unit to store */
  61938. unit: number;
  61939. /** defines a boolean indicating if the value can be negative */
  61940. negativeValueAllowed: boolean;
  61941. private _value;
  61942. private _originalUnit;
  61943. /**
  61944. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61945. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61946. */
  61947. ignoreAdaptiveScaling: boolean;
  61948. /**
  61949. * Creates a new ValueAndUnit
  61950. * @param value defines the value to store
  61951. * @param unit defines the unit to store
  61952. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61953. */
  61954. constructor(value: number,
  61955. /** defines the unit to store */
  61956. unit?: number,
  61957. /** defines a boolean indicating if the value can be negative */
  61958. negativeValueAllowed?: boolean);
  61959. /** Gets a boolean indicating if the value is a percentage */
  61960. readonly isPercentage: boolean;
  61961. /** Gets a boolean indicating if the value is store as pixel */
  61962. readonly isPixel: boolean;
  61963. /** Gets direct internal value */
  61964. readonly internalValue: number;
  61965. /**
  61966. * Gets value as pixel
  61967. * @param host defines the root host
  61968. * @param refValue defines the reference value for percentages
  61969. * @returns the value as pixel
  61970. */
  61971. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61972. /**
  61973. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61974. * @param value defines the value to store
  61975. * @param unit defines the unit to store
  61976. * @returns the current ValueAndUnit
  61977. */
  61978. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61979. /**
  61980. * Gets the value accordingly to its unit
  61981. * @param host defines the root host
  61982. * @returns the value
  61983. */
  61984. getValue(host: AdvancedDynamicTexture): number;
  61985. /**
  61986. * Gets a string representation of the value
  61987. * @param host defines the root host
  61988. * @param decimals defines an optional number of decimals to display
  61989. * @returns a string
  61990. */
  61991. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61992. /**
  61993. * Store a value parsed from a string
  61994. * @param source defines the source string
  61995. * @returns true if the value was successfully parsed
  61996. */
  61997. fromString(source: string | number): boolean;
  61998. private static _Regex;
  61999. private static _UNITMODE_PERCENTAGE;
  62000. private static _UNITMODE_PIXEL;
  62001. /** UNITMODE_PERCENTAGE */
  62002. static readonly UNITMODE_PERCENTAGE: number;
  62003. /** UNITMODE_PIXEL */
  62004. static readonly UNITMODE_PIXEL: number;
  62005. }
  62006. }
  62007. declare module BABYLON.GUI {
  62008. /**
  62009. * Define a style used by control to automatically setup properties based on a template.
  62010. * Only support font related properties so far
  62011. */
  62012. export class Style implements BABYLON.IDisposable {
  62013. private _fontFamily;
  62014. private _fontStyle;
  62015. private _fontWeight;
  62016. /** @hidden */ private _host: AdvancedDynamicTexture;
  62017. /** @hidden */ private _fontSize: ValueAndUnit;
  62018. /**
  62019. * BABYLON.Observable raised when the style values are changed
  62020. */
  62021. onChangedObservable: BABYLON.Observable<Style>;
  62022. /**
  62023. * Creates a new style object
  62024. * @param host defines the AdvancedDynamicTexture which hosts this style
  62025. */
  62026. constructor(host: AdvancedDynamicTexture);
  62027. /**
  62028. * Gets or sets the font size
  62029. */
  62030. fontSize: string | number;
  62031. /**
  62032. * Gets or sets the font family
  62033. */
  62034. fontFamily: string;
  62035. /**
  62036. * Gets or sets the font style
  62037. */
  62038. fontStyle: string;
  62039. /** Gets or sets font weight */
  62040. fontWeight: string;
  62041. /** Dispose all associated resources */
  62042. dispose(): void;
  62043. }
  62044. }
  62045. declare module BABYLON.GUI {
  62046. /**
  62047. * Class used to transport BABYLON.Vector2 information for pointer events
  62048. */
  62049. export class Vector2WithInfo extends BABYLON.Vector2 {
  62050. /** defines the current mouse button index */
  62051. buttonIndex: number;
  62052. /**
  62053. * Creates a new Vector2WithInfo
  62054. * @param source defines the vector2 data to transport
  62055. * @param buttonIndex defines the current mouse button index
  62056. */
  62057. constructor(source: BABYLON.Vector2,
  62058. /** defines the current mouse button index */
  62059. buttonIndex?: number);
  62060. }
  62061. /** Class used to provide 2D matrix features */
  62062. export class Matrix2D {
  62063. /** Gets the internal array of 6 floats used to store matrix data */
  62064. m: Float32Array;
  62065. /**
  62066. * Creates a new matrix
  62067. * @param m00 defines value for (0, 0)
  62068. * @param m01 defines value for (0, 1)
  62069. * @param m10 defines value for (1, 0)
  62070. * @param m11 defines value for (1, 1)
  62071. * @param m20 defines value for (2, 0)
  62072. * @param m21 defines value for (2, 1)
  62073. */
  62074. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62075. /**
  62076. * Fills the matrix from direct values
  62077. * @param m00 defines value for (0, 0)
  62078. * @param m01 defines value for (0, 1)
  62079. * @param m10 defines value for (1, 0)
  62080. * @param m11 defines value for (1, 1)
  62081. * @param m20 defines value for (2, 0)
  62082. * @param m21 defines value for (2, 1)
  62083. * @returns the current modified matrix
  62084. */
  62085. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62086. /**
  62087. * Gets matrix determinant
  62088. * @returns the determinant
  62089. */
  62090. determinant(): number;
  62091. /**
  62092. * Inverses the matrix and stores it in a target matrix
  62093. * @param result defines the target matrix
  62094. * @returns the current matrix
  62095. */
  62096. invertToRef(result: Matrix2D): Matrix2D;
  62097. /**
  62098. * Multiplies the current matrix with another one
  62099. * @param other defines the second operand
  62100. * @param result defines the target matrix
  62101. * @returns the current matrix
  62102. */
  62103. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62104. /**
  62105. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62106. * @param x defines the x coordinate to transform
  62107. * @param y defines the x coordinate to transform
  62108. * @param result defines the target vector2
  62109. * @returns the current matrix
  62110. */
  62111. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62112. /**
  62113. * Creates an identity matrix
  62114. * @returns a new matrix
  62115. */
  62116. static Identity(): Matrix2D;
  62117. /**
  62118. * Creates a translation matrix and stores it in a target matrix
  62119. * @param x defines the x coordinate of the translation
  62120. * @param y defines the y coordinate of the translation
  62121. * @param result defines the target matrix
  62122. */
  62123. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62124. /**
  62125. * Creates a scaling matrix and stores it in a target matrix
  62126. * @param x defines the x coordinate of the scaling
  62127. * @param y defines the y coordinate of the scaling
  62128. * @param result defines the target matrix
  62129. */
  62130. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62131. /**
  62132. * Creates a rotation matrix and stores it in a target matrix
  62133. * @param angle defines the rotation angle
  62134. * @param result defines the target matrix
  62135. */
  62136. static RotationToRef(angle: number, result: Matrix2D): void;
  62137. private static _TempPreTranslationMatrix;
  62138. private static _TempPostTranslationMatrix;
  62139. private static _TempRotationMatrix;
  62140. private static _TempScalingMatrix;
  62141. private static _TempCompose0;
  62142. private static _TempCompose1;
  62143. private static _TempCompose2;
  62144. /**
  62145. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62146. * @param tx defines the x coordinate of the translation
  62147. * @param ty defines the y coordinate of the translation
  62148. * @param angle defines the rotation angle
  62149. * @param scaleX defines the x coordinate of the scaling
  62150. * @param scaleY defines the y coordinate of the scaling
  62151. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62152. * @param result defines the target matrix
  62153. */
  62154. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62155. }
  62156. }
  62157. declare module BABYLON.GUI {
  62158. /**
  62159. * Class used to store 2D control sizes
  62160. */
  62161. export class Measure {
  62162. /** defines left coordinate */
  62163. left: number;
  62164. /** defines top coordinate */
  62165. top: number;
  62166. /** defines width dimension */
  62167. width: number;
  62168. /** defines height dimension */
  62169. height: number;
  62170. /**
  62171. * Creates a new measure
  62172. * @param left defines left coordinate
  62173. * @param top defines top coordinate
  62174. * @param width defines width dimension
  62175. * @param height defines height dimension
  62176. */
  62177. constructor(
  62178. /** defines left coordinate */
  62179. left: number,
  62180. /** defines top coordinate */
  62181. top: number,
  62182. /** defines width dimension */
  62183. width: number,
  62184. /** defines height dimension */
  62185. height: number);
  62186. /**
  62187. * Copy from another measure
  62188. * @param other defines the other measure to copy from
  62189. */
  62190. copyFrom(other: Measure): void;
  62191. /**
  62192. * Copy from a group of 4 floats
  62193. * @param left defines left coordinate
  62194. * @param top defines top coordinate
  62195. * @param width defines width dimension
  62196. * @param height defines height dimension
  62197. */
  62198. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62199. /**
  62200. * Computes the axis aligned bounding box measure for two given measures
  62201. * @param a Input measure
  62202. * @param b Input measure
  62203. * @param result the resulting bounding measure
  62204. */
  62205. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62206. /**
  62207. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62208. * @param transform the matrix to transform the measure before computing the AABB
  62209. * @param result the resulting AABB
  62210. */
  62211. transformToRef(transform: Matrix2D, result: Measure): void;
  62212. /**
  62213. * Check equality between this measure and another one
  62214. * @param other defines the other measures
  62215. * @returns true if both measures are equals
  62216. */
  62217. isEqualsTo(other: Measure): boolean;
  62218. /**
  62219. * Creates an empty measure
  62220. * @returns a new measure
  62221. */
  62222. static Empty(): Measure;
  62223. }
  62224. }
  62225. declare module BABYLON.GUI {
  62226. /**
  62227. * Interface used to define a control that can receive focus
  62228. */
  62229. export interface IFocusableControl {
  62230. /**
  62231. * Function called when the control receives the focus
  62232. */
  62233. onFocus(): void;
  62234. /**
  62235. * Function called when the control loses the focus
  62236. */
  62237. onBlur(): void;
  62238. /**
  62239. * Function called to let the control handle keyboard events
  62240. * @param evt defines the current keyboard event
  62241. */
  62242. processKeyboard(evt: KeyboardEvent): void;
  62243. /**
  62244. * Function called to get the list of controls that should not steal the focus from this control
  62245. * @returns an array of controls
  62246. */
  62247. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62248. }
  62249. /**
  62250. * Class used to create texture to support 2D GUI elements
  62251. * @see http://doc.babylonjs.com/how_to/gui
  62252. */
  62253. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62254. private _isDirty;
  62255. private _renderObserver;
  62256. private _resizeObserver;
  62257. private _preKeyboardObserver;
  62258. private _pointerMoveObserver;
  62259. private _pointerObserver;
  62260. private _canvasPointerOutObserver;
  62261. private _background;
  62262. /** @hidden */ private _rootContainer: Container;
  62263. /** @hidden */ private _lastPickedControl: Control;
  62264. /** @hidden */ private _lastControlOver: {
  62265. [pointerId: number]: Control;
  62266. };
  62267. /** @hidden */ private _lastControlDown: {
  62268. [pointerId: number]: Control;
  62269. };
  62270. /** @hidden */ private _capturingControl: {
  62271. [pointerId: number]: Control;
  62272. };
  62273. /** @hidden */ private _shouldBlockPointer: boolean;
  62274. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62275. /** @hidden */ private _linkedControls: Control[];
  62276. private _isFullscreen;
  62277. private _fullscreenViewport;
  62278. private _idealWidth;
  62279. private _idealHeight;
  62280. private _useSmallestIdeal;
  62281. private _renderAtIdealSize;
  62282. private _focusedControl;
  62283. private _blockNextFocusCheck;
  62284. private _renderScale;
  62285. private _rootCanvas;
  62286. private _cursorChanged;
  62287. /**
  62288. * Define type to string to ensure compatibility across browsers
  62289. * Safari doesn't support DataTransfer constructor
  62290. */
  62291. private _clipboardData;
  62292. /**
  62293. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62294. */
  62295. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62296. /**
  62297. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62298. */
  62299. onControlPickedObservable: BABYLON.Observable<Control>;
  62300. /**
  62301. * BABYLON.Observable event triggered before layout is evaluated
  62302. */
  62303. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62304. /**
  62305. * BABYLON.Observable event triggered after the layout was evaluated
  62306. */
  62307. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62308. /**
  62309. * BABYLON.Observable event triggered before the texture is rendered
  62310. */
  62311. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62312. /**
  62313. * BABYLON.Observable event triggered after the texture was rendered
  62314. */
  62315. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62316. /**
  62317. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62318. */
  62319. premulAlpha: boolean;
  62320. /**
  62321. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62322. * Useful when you want more antialiasing
  62323. */
  62324. renderScale: number;
  62325. /** Gets or sets the background color */
  62326. background: string;
  62327. /**
  62328. * Gets or sets the ideal width used to design controls.
  62329. * The GUI will then rescale everything accordingly
  62330. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62331. */
  62332. idealWidth: number;
  62333. /**
  62334. * Gets or sets the ideal height used to design controls.
  62335. * The GUI will then rescale everything accordingly
  62336. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62337. */
  62338. idealHeight: number;
  62339. /**
  62340. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62341. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62342. */
  62343. useSmallestIdeal: boolean;
  62344. /**
  62345. * Gets or sets a boolean indicating if adaptive scaling must be used
  62346. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62347. */
  62348. renderAtIdealSize: boolean;
  62349. /**
  62350. * Gets the underlying layer used to render the texture when in fullscreen mode
  62351. */
  62352. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62353. /**
  62354. * Gets the root container control
  62355. */
  62356. readonly rootContainer: Container;
  62357. /**
  62358. * Returns an array containing the root container.
  62359. * This is mostly used to let the Inspector introspects the ADT
  62360. * @returns an array containing the rootContainer
  62361. */
  62362. getChildren(): Array<Container>;
  62363. /**
  62364. * Will return all controls that are inside this texture
  62365. * @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
  62366. * @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
  62367. * @return all child controls
  62368. */
  62369. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62370. /**
  62371. * Gets or sets the current focused control
  62372. */
  62373. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62374. /**
  62375. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62376. */
  62377. isForeground: boolean;
  62378. /**
  62379. * Gets or set information about clipboardData
  62380. */
  62381. clipboardData: string;
  62382. /**
  62383. * Creates a new AdvancedDynamicTexture
  62384. * @param name defines the name of the texture
  62385. * @param width defines the width of the texture
  62386. * @param height defines the height of the texture
  62387. * @param scene defines the hosting scene
  62388. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62389. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62390. */
  62391. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62392. /**
  62393. * Get the current class name of the texture useful for serialization or dynamic coding.
  62394. * @returns "AdvancedDynamicTexture"
  62395. */
  62396. getClassName(): string;
  62397. /**
  62398. * Function used to execute a function on all controls
  62399. * @param func defines the function to execute
  62400. * @param container defines the container where controls belong. If null the root container will be used
  62401. */
  62402. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62403. private _useInvalidateRectOptimization;
  62404. /**
  62405. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62406. */
  62407. useInvalidateRectOptimization: boolean;
  62408. private _invalidatedRectangle;
  62409. /**
  62410. * Invalidates a rectangle area on the gui texture
  62411. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62412. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62413. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62414. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62415. */
  62416. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62417. /**
  62418. * Marks the texture as dirty forcing a complete update
  62419. */
  62420. markAsDirty(): void;
  62421. /**
  62422. * Helper function used to create a new style
  62423. * @returns a new style
  62424. * @see http://doc.babylonjs.com/how_to/gui#styles
  62425. */
  62426. createStyle(): Style;
  62427. /**
  62428. * Adds a new control to the root container
  62429. * @param control defines the control to add
  62430. * @returns the current texture
  62431. */
  62432. addControl(control: Control): AdvancedDynamicTexture;
  62433. /**
  62434. * Removes a control from the root container
  62435. * @param control defines the control to remove
  62436. * @returns the current texture
  62437. */
  62438. removeControl(control: Control): AdvancedDynamicTexture;
  62439. /**
  62440. * Release all resources
  62441. */
  62442. dispose(): void;
  62443. private _onResize;
  62444. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62445. /**
  62446. * Get screen coordinates for a vector3
  62447. * @param position defines the position to project
  62448. * @param worldMatrix defines the world matrix to use
  62449. * @returns the projected position
  62450. */
  62451. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62452. private _checkUpdate;
  62453. private _clearMeasure;
  62454. private _render;
  62455. /** @hidden */ private _changeCursor(cursor: string): void;
  62456. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  62457. private _doPicking;
  62458. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  62459. [pointerId: number]: Control;
  62460. }, control: Control): void;
  62461. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  62462. /** Attach to all scene events required to support pointer events */
  62463. attach(): void;
  62464. /** @hidden */
  62465. private onClipboardCopy;
  62466. /** @hidden */
  62467. private onClipboardCut;
  62468. /** @hidden */
  62469. private onClipboardPaste;
  62470. /**
  62471. * Register the clipboard Events onto the canvas
  62472. */
  62473. registerClipboardEvents(): void;
  62474. /**
  62475. * Unregister the clipboard Events from the canvas
  62476. */
  62477. unRegisterClipboardEvents(): void;
  62478. /**
  62479. * Connect the texture to a hosting mesh to enable interactions
  62480. * @param mesh defines the mesh to attach to
  62481. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62482. */
  62483. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62484. /**
  62485. * Move the focus to a specific control
  62486. * @param control defines the control which will receive the focus
  62487. */
  62488. moveFocusToControl(control: IFocusableControl): void;
  62489. private _manageFocus;
  62490. private _attachToOnPointerOut;
  62491. /**
  62492. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62493. * @param mesh defines the mesh which will receive the texture
  62494. * @param width defines the texture width (1024 by default)
  62495. * @param height defines the texture height (1024 by default)
  62496. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62497. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62498. * @returns a new AdvancedDynamicTexture
  62499. */
  62500. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62501. /**
  62502. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62503. * In this mode the texture will rely on a layer for its rendering.
  62504. * This allows it to be treated like any other layer.
  62505. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62506. * LayerMask is set through advancedTexture.layer.layerMask
  62507. * @param name defines name for the texture
  62508. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62509. * @param scene defines the hsoting scene
  62510. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62511. * @returns a new AdvancedDynamicTexture
  62512. */
  62513. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62514. }
  62515. }
  62516. declare module BABYLON.GUI {
  62517. /**
  62518. * Root class used for all 2D controls
  62519. * @see http://doc.babylonjs.com/how_to/gui#controls
  62520. */
  62521. export class Control {
  62522. /** defines the name of the control */
  62523. name?: string | undefined;
  62524. /**
  62525. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62526. */
  62527. static AllowAlphaInheritance: boolean;
  62528. private _alpha;
  62529. private _alphaSet;
  62530. private _zIndex;
  62531. /** @hidden */ private _host: AdvancedDynamicTexture;
  62532. /** Gets or sets the control parent */
  62533. parent: BABYLON.Nullable<Container>;
  62534. /** @hidden */ private _currentMeasure: Measure;
  62535. private _fontFamily;
  62536. private _fontStyle;
  62537. private _fontWeight;
  62538. private _fontSize;
  62539. private _font;
  62540. /** @hidden */ private _width: ValueAndUnit;
  62541. /** @hidden */ private _height: ValueAndUnit;
  62542. /** @hidden */
  62543. protected _fontOffset: {
  62544. ascent: number;
  62545. height: number;
  62546. descent: number;
  62547. };
  62548. private _color;
  62549. private _style;
  62550. private _styleObserver;
  62551. /** @hidden */
  62552. protected _horizontalAlignment: number;
  62553. /** @hidden */
  62554. protected _verticalAlignment: number;
  62555. /** @hidden */
  62556. protected _isDirty: boolean;
  62557. /** @hidden */
  62558. protected _wasDirty: boolean;
  62559. /** @hidden */ private _tempParentMeasure: Measure;
  62560. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62561. /** @hidden */
  62562. protected _cachedParentMeasure: Measure;
  62563. private _paddingLeft;
  62564. private _paddingRight;
  62565. private _paddingTop;
  62566. private _paddingBottom;
  62567. /** @hidden */ private _left: ValueAndUnit;
  62568. /** @hidden */ private _top: ValueAndUnit;
  62569. private _scaleX;
  62570. private _scaleY;
  62571. private _rotation;
  62572. private _transformCenterX;
  62573. private _transformCenterY;
  62574. /** @hidden */ private _transformMatrix: Matrix2D;
  62575. /** @hidden */
  62576. protected _invertTransformMatrix: Matrix2D;
  62577. /** @hidden */
  62578. protected _transformedPosition: BABYLON.Vector2;
  62579. private _isMatrixDirty;
  62580. private _cachedOffsetX;
  62581. private _cachedOffsetY;
  62582. private _isVisible;
  62583. private _isHighlighted;
  62584. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62585. private _fontSet;
  62586. private _dummyVector2;
  62587. private _downCount;
  62588. private _enterCount;
  62589. private _doNotRender;
  62590. private _downPointerIds;
  62591. protected _isEnabled: boolean;
  62592. protected _disabledColor: string;
  62593. /** @hidden */
  62594. protected _rebuildLayout: boolean;
  62595. /** @hidden */ private _isClipped: boolean;
  62596. /** @hidden */ private _tag: any;
  62597. /**
  62598. * 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
  62599. */
  62600. uniqueId: number;
  62601. /**
  62602. * Gets or sets an object used to store user defined information for the node
  62603. */
  62604. metadata: any;
  62605. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62606. isHitTestVisible: boolean;
  62607. /** Gets or sets a boolean indicating if the control can block pointer events */
  62608. isPointerBlocker: boolean;
  62609. /** Gets or sets a boolean indicating if the control can be focusable */
  62610. isFocusInvisible: boolean;
  62611. /**
  62612. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62613. * 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
  62614. */
  62615. clipChildren: boolean;
  62616. /**
  62617. * Gets or sets a boolean indicating that control content must be clipped
  62618. * 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
  62619. */
  62620. clipContent: boolean;
  62621. /**
  62622. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62623. */
  62624. useBitmapCache: boolean;
  62625. private _cacheData;
  62626. private _shadowOffsetX;
  62627. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62628. shadowOffsetX: number;
  62629. private _shadowOffsetY;
  62630. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62631. shadowOffsetY: number;
  62632. private _shadowBlur;
  62633. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62634. shadowBlur: number;
  62635. private _shadowColor;
  62636. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62637. shadowColor: string;
  62638. /** Gets or sets the cursor to use when the control is hovered */
  62639. hoverCursor: string;
  62640. /** @hidden */
  62641. protected _linkOffsetX: ValueAndUnit;
  62642. /** @hidden */
  62643. protected _linkOffsetY: ValueAndUnit;
  62644. /** Gets the control type name */
  62645. readonly typeName: string;
  62646. /**
  62647. * Get the current class name of the control.
  62648. * @returns current class name
  62649. */
  62650. getClassName(): string;
  62651. /**
  62652. * An event triggered when the pointer move over the control.
  62653. */
  62654. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62655. /**
  62656. * An event triggered when the pointer move out of the control.
  62657. */
  62658. onPointerOutObservable: BABYLON.Observable<Control>;
  62659. /**
  62660. * An event triggered when the pointer taps the control
  62661. */
  62662. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62663. /**
  62664. * An event triggered when pointer up
  62665. */
  62666. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62667. /**
  62668. * An event triggered when a control is clicked on
  62669. */
  62670. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62671. /**
  62672. * An event triggered when pointer enters the control
  62673. */
  62674. onPointerEnterObservable: BABYLON.Observable<Control>;
  62675. /**
  62676. * An event triggered when the control is marked as dirty
  62677. */
  62678. onDirtyObservable: BABYLON.Observable<Control>;
  62679. /**
  62680. * An event triggered before drawing the control
  62681. */
  62682. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62683. /**
  62684. * An event triggered after the control was drawn
  62685. */
  62686. onAfterDrawObservable: BABYLON.Observable<Control>;
  62687. /**
  62688. * Get the hosting AdvancedDynamicTexture
  62689. */
  62690. readonly host: AdvancedDynamicTexture;
  62691. /** Gets or set information about font offsets (used to render and align text) */
  62692. fontOffset: {
  62693. ascent: number;
  62694. height: number;
  62695. descent: number;
  62696. };
  62697. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62698. alpha: number;
  62699. /**
  62700. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62701. */
  62702. isHighlighted: boolean;
  62703. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62704. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62705. */
  62706. scaleX: number;
  62707. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62708. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62709. */
  62710. scaleY: number;
  62711. /** Gets or sets the rotation angle (0 by default)
  62712. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62713. */
  62714. rotation: number;
  62715. /** Gets or sets the transformation center on Y axis (0 by default)
  62716. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62717. */
  62718. transformCenterY: number;
  62719. /** Gets or sets the transformation center on X axis (0 by default)
  62720. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62721. */
  62722. transformCenterX: number;
  62723. /**
  62724. * Gets or sets the horizontal alignment
  62725. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62726. */
  62727. horizontalAlignment: number;
  62728. /**
  62729. * Gets or sets the vertical alignment
  62730. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62731. */
  62732. verticalAlignment: number;
  62733. /**
  62734. * Gets or sets control width
  62735. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62736. */
  62737. width: string | number;
  62738. /**
  62739. * Gets or sets the control width in pixel
  62740. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62741. */
  62742. widthInPixels: number;
  62743. /**
  62744. * Gets or sets control height
  62745. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62746. */
  62747. height: string | number;
  62748. /**
  62749. * Gets or sets control height in pixel
  62750. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62751. */
  62752. heightInPixels: number;
  62753. /** Gets or set font family */
  62754. fontFamily: string;
  62755. /** Gets or sets font style */
  62756. fontStyle: string;
  62757. /** Gets or sets font weight */
  62758. fontWeight: string;
  62759. /**
  62760. * Gets or sets style
  62761. * @see http://doc.babylonjs.com/how_to/gui#styles
  62762. */
  62763. style: BABYLON.Nullable<Style>;
  62764. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  62765. /** Gets or sets font size in pixels */
  62766. fontSizeInPixels: number;
  62767. /** Gets or sets font size */
  62768. fontSize: string | number;
  62769. /** Gets or sets foreground color */
  62770. color: string;
  62771. /** Gets or sets z index which is used to reorder controls on the z axis */
  62772. zIndex: number;
  62773. /** Gets or sets a boolean indicating if the control can be rendered */
  62774. notRenderable: boolean;
  62775. /** Gets or sets a boolean indicating if the control is visible */
  62776. isVisible: boolean;
  62777. /** Gets a boolean indicating that the control needs to update its rendering */
  62778. readonly isDirty: boolean;
  62779. /**
  62780. * Gets the current linked mesh (or null if none)
  62781. */
  62782. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62783. /**
  62784. * Gets or sets a value indicating the padding to use on the left of the control
  62785. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62786. */
  62787. paddingLeft: string | number;
  62788. /**
  62789. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62790. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62791. */
  62792. paddingLeftInPixels: number;
  62793. /**
  62794. * Gets or sets a value indicating the padding to use on the right of the control
  62795. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62796. */
  62797. paddingRight: string | number;
  62798. /**
  62799. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62800. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62801. */
  62802. paddingRightInPixels: number;
  62803. /**
  62804. * Gets or sets a value indicating the padding to use on the top of the control
  62805. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62806. */
  62807. paddingTop: string | number;
  62808. /**
  62809. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62810. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62811. */
  62812. paddingTopInPixels: number;
  62813. /**
  62814. * Gets or sets a value indicating the padding to use on the bottom of the control
  62815. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62816. */
  62817. paddingBottom: string | number;
  62818. /**
  62819. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62820. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62821. */
  62822. paddingBottomInPixels: number;
  62823. /**
  62824. * Gets or sets a value indicating the left coordinate of the control
  62825. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62826. */
  62827. left: string | number;
  62828. /**
  62829. * Gets or sets a value indicating the left coordinate in pixels of the control
  62830. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62831. */
  62832. leftInPixels: number;
  62833. /**
  62834. * Gets or sets a value indicating the top coordinate of the control
  62835. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62836. */
  62837. top: string | number;
  62838. /**
  62839. * Gets or sets a value indicating the top coordinate in pixels of the control
  62840. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62841. */
  62842. topInPixels: number;
  62843. /**
  62844. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62845. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62846. */
  62847. linkOffsetX: string | number;
  62848. /**
  62849. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62850. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62851. */
  62852. linkOffsetXInPixels: number;
  62853. /**
  62854. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62855. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62856. */
  62857. linkOffsetY: string | number;
  62858. /**
  62859. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62860. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62861. */
  62862. linkOffsetYInPixels: number;
  62863. /** Gets the center coordinate on X axis */
  62864. readonly centerX: number;
  62865. /** Gets the center coordinate on Y axis */
  62866. readonly centerY: number;
  62867. /** Gets or sets if control is Enabled*/
  62868. isEnabled: boolean;
  62869. /** Gets or sets background color of control if it's disabled*/
  62870. disabledColor: string;
  62871. /**
  62872. * Creates a new control
  62873. * @param name defines the name of the control
  62874. */
  62875. constructor(
  62876. /** defines the name of the control */
  62877. name?: string | undefined);
  62878. /** @hidden */
  62879. protected _getTypeName(): string;
  62880. /**
  62881. * Gets the first ascendant in the hierarchy of the given type
  62882. * @param className defines the required type
  62883. * @returns the ascendant or null if not found
  62884. */
  62885. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62886. /** @hidden */ private _resetFontCache(): void;
  62887. /**
  62888. * Determines if a container is an ascendant of the current control
  62889. * @param container defines the container to look for
  62890. * @returns true if the container is one of the ascendant of the control
  62891. */
  62892. isAscendant(container: Control): boolean;
  62893. /**
  62894. * Gets coordinates in local control space
  62895. * @param globalCoordinates defines the coordinates to transform
  62896. * @returns the new coordinates in local space
  62897. */
  62898. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62899. /**
  62900. * Gets coordinates in local control space
  62901. * @param globalCoordinates defines the coordinates to transform
  62902. * @param result defines the target vector2 where to store the result
  62903. * @returns the current control
  62904. */
  62905. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62906. /**
  62907. * Gets coordinates in parent local control space
  62908. * @param globalCoordinates defines the coordinates to transform
  62909. * @returns the new coordinates in parent local space
  62910. */
  62911. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62912. /**
  62913. * Move the current control to a vector3 position projected onto the screen.
  62914. * @param position defines the target position
  62915. * @param scene defines the hosting scene
  62916. */
  62917. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62918. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62919. /**
  62920. * Will return all controls that have this control as ascendant
  62921. * @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
  62922. * @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
  62923. * @return all child controls
  62924. */
  62925. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62926. /**
  62927. * Link current control with a target mesh
  62928. * @param mesh defines the mesh to link with
  62929. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62930. */
  62931. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62932. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62933. /** @hidden */ private _offsetLeft(offset: number): void;
  62934. /** @hidden */ private _offsetTop(offset: number): void;
  62935. /** @hidden */ private _markMatrixAsDirty(): void;
  62936. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  62937. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  62938. /** @hidden */
  62939. protected invalidateRect(): void;
  62940. /** @hidden */ private _markAsDirty(force?: boolean): void;
  62941. /** @hidden */ private _markAllAsDirty(): void;
  62942. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  62943. /** @hidden */
  62944. protected _transform(context?: CanvasRenderingContext2D): void;
  62945. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  62946. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62947. /** @hidden */
  62948. protected _applyStates(context: CanvasRenderingContext2D): void;
  62949. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62950. /** @hidden */
  62951. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62952. protected _evaluateClippingState(parentMeasure: Measure): void;
  62953. /** @hidden */ private _measure(): void;
  62954. /** @hidden */
  62955. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62956. /** @hidden */
  62957. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62958. /** @hidden */
  62959. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62960. /** @hidden */
  62961. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62962. private static _ClipMeasure;
  62963. private _tmpMeasureA;
  62964. private _clip;
  62965. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62966. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62967. /**
  62968. * Tests if a given coordinates belong to the current control
  62969. * @param x defines x coordinate to test
  62970. * @param y defines y coordinate to test
  62971. * @returns true if the coordinates are inside the control
  62972. */
  62973. contains(x: number, y: number): boolean;
  62974. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62975. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62976. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  62977. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  62978. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62979. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62980. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62981. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62982. private _prepareFont;
  62983. /** Releases associated resources */
  62984. dispose(): void;
  62985. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62986. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62987. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62988. private static _VERTICAL_ALIGNMENT_TOP;
  62989. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62990. private static _VERTICAL_ALIGNMENT_CENTER;
  62991. /** HORIZONTAL_ALIGNMENT_LEFT */
  62992. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62993. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62994. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62995. /** HORIZONTAL_ALIGNMENT_CENTER */
  62996. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62997. /** VERTICAL_ALIGNMENT_TOP */
  62998. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62999. /** VERTICAL_ALIGNMENT_BOTTOM */
  63000. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63001. /** VERTICAL_ALIGNMENT_CENTER */
  63002. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63003. private static _FontHeightSizes;
  63004. /** @hidden */ private static _GetFontOffset(font: string): {
  63005. ascent: number;
  63006. height: number;
  63007. descent: number;
  63008. };
  63009. /**
  63010. * Creates a stack panel that can be used to render headers
  63011. * @param control defines the control to associate with the header
  63012. * @param text defines the text of the header
  63013. * @param size defines the size of the header
  63014. * @param options defines options used to configure the header
  63015. * @returns a new StackPanel
  63016. * @ignore
  63017. * @hidden
  63018. */
  63019. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63020. isHorizontal: boolean;
  63021. controlFirst: boolean;
  63022. }) => any;
  63023. /** @hidden */
  63024. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63025. }
  63026. }
  63027. declare module BABYLON.GUI {
  63028. /**
  63029. * Root class for 2D containers
  63030. * @see http://doc.babylonjs.com/how_to/gui#containers
  63031. */
  63032. export class Container extends Control {
  63033. name?: string | undefined;
  63034. /** @hidden */
  63035. protected _children: Control[];
  63036. /** @hidden */
  63037. protected _measureForChildren: Measure;
  63038. /** @hidden */
  63039. protected _background: string;
  63040. /** @hidden */
  63041. protected _adaptWidthToChildren: boolean;
  63042. /** @hidden */
  63043. protected _adaptHeightToChildren: boolean;
  63044. /**
  63045. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63046. */
  63047. logLayoutCycleErrors: boolean;
  63048. /**
  63049. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63050. */
  63051. maxLayoutCycle: number;
  63052. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63053. adaptHeightToChildren: boolean;
  63054. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63055. adaptWidthToChildren: boolean;
  63056. /** Gets or sets background color */
  63057. background: string;
  63058. /** Gets the list of children */
  63059. readonly children: Control[];
  63060. /**
  63061. * Creates a new Container
  63062. * @param name defines the name of the container
  63063. */
  63064. constructor(name?: string | undefined);
  63065. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  63066. /**
  63067. * Gets a child using its name
  63068. * @param name defines the child name to look for
  63069. * @returns the child control if found
  63070. */
  63071. getChildByName(name: string): BABYLON.Nullable<Control>;
  63072. /**
  63073. * Gets a child using its type and its name
  63074. * @param name defines the child name to look for
  63075. * @param type defines the child type to look for
  63076. * @returns the child control if found
  63077. */
  63078. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63079. /**
  63080. * Search for a specific control in children
  63081. * @param control defines the control to look for
  63082. * @returns true if the control is in child list
  63083. */
  63084. containsControl(control: Control): boolean;
  63085. /**
  63086. * Adds a new control to the current container
  63087. * @param control defines the control to add
  63088. * @returns the current container
  63089. */
  63090. addControl(control: BABYLON.Nullable<Control>): Container;
  63091. /**
  63092. * Removes all controls from the current container
  63093. * @returns the current container
  63094. */
  63095. clearControls(): Container;
  63096. /**
  63097. * Removes a control from the current container
  63098. * @param control defines the control to remove
  63099. * @returns the current container
  63100. */
  63101. removeControl(control: Control): Container;
  63102. /** @hidden */ private _reOrderControl(control: Control): void;
  63103. /** @hidden */ private _offsetLeft(offset: number): void;
  63104. /** @hidden */ private _offsetTop(offset: number): void;
  63105. /** @hidden */ private _markAllAsDirty(): void;
  63106. /** @hidden */
  63107. protected _localDraw(context: CanvasRenderingContext2D): void;
  63108. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63109. /** @hidden */
  63110. protected _beforeLayout(): void;
  63111. /** @hidden */
  63112. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63113. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63114. protected _postMeasure(): void;
  63115. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63116. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63117. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63118. /** @hidden */
  63119. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63120. /** Releases associated resources */
  63121. dispose(): void;
  63122. }
  63123. }
  63124. declare module BABYLON.GUI {
  63125. /** Class used to create rectangle container */
  63126. export class Rectangle extends Container {
  63127. name?: string | undefined;
  63128. private _thickness;
  63129. private _cornerRadius;
  63130. /** Gets or sets border thickness */
  63131. thickness: number;
  63132. /** Gets or sets the corner radius angle */
  63133. cornerRadius: number;
  63134. /**
  63135. * Creates a new Rectangle
  63136. * @param name defines the control name
  63137. */
  63138. constructor(name?: string | undefined);
  63139. protected _getTypeName(): string;
  63140. protected _localDraw(context: CanvasRenderingContext2D): void;
  63141. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63142. private _drawRoundedRect;
  63143. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63144. }
  63145. }
  63146. declare module BABYLON.GUI {
  63147. /**
  63148. * Enum that determines the text-wrapping mode to use.
  63149. */
  63150. export enum TextWrapping {
  63151. /**
  63152. * Clip the text when it's larger than Control.width; this is the default mode.
  63153. */
  63154. Clip = 0,
  63155. /**
  63156. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63157. */
  63158. WordWrap = 1,
  63159. /**
  63160. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63161. */
  63162. Ellipsis = 2
  63163. }
  63164. /**
  63165. * Class used to create text block control
  63166. */
  63167. export class TextBlock extends Control {
  63168. /**
  63169. * Defines the name of the control
  63170. */
  63171. name?: string | undefined;
  63172. private _text;
  63173. private _textWrapping;
  63174. private _textHorizontalAlignment;
  63175. private _textVerticalAlignment;
  63176. private _lines;
  63177. private _resizeToFit;
  63178. private _lineSpacing;
  63179. private _outlineWidth;
  63180. private _outlineColor;
  63181. /**
  63182. * An event triggered after the text is changed
  63183. */
  63184. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63185. /**
  63186. * An event triggered after the text was broken up into lines
  63187. */
  63188. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63189. /**
  63190. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63191. */
  63192. readonly lines: any[];
  63193. /**
  63194. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63195. */
  63196. /**
  63197. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63198. */
  63199. resizeToFit: boolean;
  63200. /**
  63201. * Gets or sets a boolean indicating if text must be wrapped
  63202. */
  63203. /**
  63204. * Gets or sets a boolean indicating if text must be wrapped
  63205. */
  63206. textWrapping: TextWrapping | boolean;
  63207. /**
  63208. * Gets or sets text to display
  63209. */
  63210. /**
  63211. * Gets or sets text to display
  63212. */
  63213. text: string;
  63214. /**
  63215. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63216. */
  63217. /**
  63218. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63219. */
  63220. textHorizontalAlignment: number;
  63221. /**
  63222. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63223. */
  63224. /**
  63225. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63226. */
  63227. textVerticalAlignment: number;
  63228. /**
  63229. * Gets or sets line spacing value
  63230. */
  63231. /**
  63232. * Gets or sets line spacing value
  63233. */
  63234. lineSpacing: string | number;
  63235. /**
  63236. * Gets or sets outlineWidth of the text to display
  63237. */
  63238. /**
  63239. * Gets or sets outlineWidth of the text to display
  63240. */
  63241. outlineWidth: number;
  63242. /**
  63243. * Gets or sets outlineColor of the text to display
  63244. */
  63245. /**
  63246. * Gets or sets outlineColor of the text to display
  63247. */
  63248. outlineColor: string;
  63249. /**
  63250. * Creates a new TextBlock object
  63251. * @param name defines the name of the control
  63252. * @param text defines the text to display (emptry string by default)
  63253. */
  63254. constructor(
  63255. /**
  63256. * Defines the name of the control
  63257. */
  63258. name?: string | undefined, text?: string);
  63259. protected _getTypeName(): string;
  63260. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63261. private _drawText;
  63262. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63263. protected _applyStates(context: CanvasRenderingContext2D): void;
  63264. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63265. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63266. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63267. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63268. protected _renderLines(context: CanvasRenderingContext2D): void;
  63269. /**
  63270. * Given a width constraint applied on the text block, find the expected height
  63271. * @returns expected height
  63272. */
  63273. computeExpectedHeight(): number;
  63274. dispose(): void;
  63275. }
  63276. }
  63277. declare module BABYLON.GUI {
  63278. /**
  63279. * Class used to create 2D images
  63280. */
  63281. export class Image extends Control {
  63282. name?: string | undefined;
  63283. private static _WorkingCanvas;
  63284. private _domImage;
  63285. private _imageWidth;
  63286. private _imageHeight;
  63287. private _loaded;
  63288. private _stretch;
  63289. private _source;
  63290. private _autoScale;
  63291. private _sourceLeft;
  63292. private _sourceTop;
  63293. private _sourceWidth;
  63294. private _sourceHeight;
  63295. private _cellWidth;
  63296. private _cellHeight;
  63297. private _cellId;
  63298. private _populateNinePatchSlicesFromImage;
  63299. private _sliceLeft;
  63300. private _sliceRight;
  63301. private _sliceTop;
  63302. private _sliceBottom;
  63303. private _detectPointerOnOpaqueOnly;
  63304. /**
  63305. * BABYLON.Observable notified when the content is loaded
  63306. */
  63307. onImageLoadedObservable: BABYLON.Observable<Image>;
  63308. /**
  63309. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  63310. */
  63311. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  63312. /**
  63313. * Gets a boolean indicating that the content is loaded
  63314. */
  63315. readonly isLoaded: boolean;
  63316. /**
  63317. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63318. */
  63319. populateNinePatchSlicesFromImage: boolean;
  63320. /**
  63321. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63322. * Beware using this as this will comsume more memory as the image has to be stored twice
  63323. */
  63324. detectPointerOnOpaqueOnly: boolean;
  63325. /**
  63326. * Gets or sets the left value for slicing (9-patch)
  63327. */
  63328. sliceLeft: number;
  63329. /**
  63330. * Gets or sets the right value for slicing (9-patch)
  63331. */
  63332. sliceRight: number;
  63333. /**
  63334. * Gets or sets the top value for slicing (9-patch)
  63335. */
  63336. sliceTop: number;
  63337. /**
  63338. * Gets or sets the bottom value for slicing (9-patch)
  63339. */
  63340. sliceBottom: number;
  63341. /**
  63342. * Gets or sets the left coordinate in the source image
  63343. */
  63344. sourceLeft: number;
  63345. /**
  63346. * Gets or sets the top coordinate in the source image
  63347. */
  63348. sourceTop: number;
  63349. /**
  63350. * Gets or sets the width to capture in the source image
  63351. */
  63352. sourceWidth: number;
  63353. /**
  63354. * Gets or sets the height to capture in the source image
  63355. */
  63356. sourceHeight: number;
  63357. /**
  63358. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63359. * @see http://doc.babylonjs.com/how_to/gui#image
  63360. */
  63361. autoScale: boolean;
  63362. /** Gets or sets the streching mode used by the image */
  63363. stretch: number;
  63364. /**
  63365. * Gets or sets the internal DOM image used to render the control
  63366. */
  63367. domImage: HTMLImageElement;
  63368. private _onImageLoaded;
  63369. private _extractNinePatchSliceDataFromImage;
  63370. /**
  63371. * Gets or sets image source url
  63372. */
  63373. source: BABYLON.Nullable<string>;
  63374. /**
  63375. * Checks for svg document with icon id present
  63376. */
  63377. private _svgCheck;
  63378. /**
  63379. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  63380. * given external svg file and icon id
  63381. */
  63382. private _getSVGAttribs;
  63383. /**
  63384. * Gets or sets the cell width to use when animation sheet is enabled
  63385. * @see http://doc.babylonjs.com/how_to/gui#image
  63386. */
  63387. cellWidth: number;
  63388. /**
  63389. * Gets or sets the cell height to use when animation sheet is enabled
  63390. * @see http://doc.babylonjs.com/how_to/gui#image
  63391. */
  63392. cellHeight: number;
  63393. /**
  63394. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63395. * @see http://doc.babylonjs.com/how_to/gui#image
  63396. */
  63397. cellId: number;
  63398. /**
  63399. * Creates a new Image
  63400. * @param name defines the control name
  63401. * @param url defines the image url
  63402. */
  63403. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63404. /**
  63405. * Tests if a given coordinates belong to the current control
  63406. * @param x defines x coordinate to test
  63407. * @param y defines y coordinate to test
  63408. * @returns true if the coordinates are inside the control
  63409. */
  63410. contains(x: number, y: number): boolean;
  63411. protected _getTypeName(): string;
  63412. /** Force the control to synchronize with its content */
  63413. synchronizeSizeWithContent(): void;
  63414. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63415. private _prepareWorkingCanvasForOpaqueDetection;
  63416. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  63417. private _renderCornerPatch;
  63418. private _renderNinePatch;
  63419. dispose(): void;
  63420. /** STRETCH_NONE */
  63421. static readonly STRETCH_NONE: number;
  63422. /** STRETCH_FILL */
  63423. static readonly STRETCH_FILL: number;
  63424. /** STRETCH_UNIFORM */
  63425. static readonly STRETCH_UNIFORM: number;
  63426. /** STRETCH_EXTEND */
  63427. static readonly STRETCH_EXTEND: number;
  63428. /** NINE_PATCH */
  63429. static readonly STRETCH_NINE_PATCH: number;
  63430. }
  63431. }
  63432. declare module BABYLON.GUI {
  63433. /**
  63434. * Class used to create 2D buttons
  63435. */
  63436. export class Button extends Rectangle {
  63437. name?: string | undefined;
  63438. /**
  63439. * Function called to generate a pointer enter animation
  63440. */
  63441. pointerEnterAnimation: () => void;
  63442. /**
  63443. * Function called to generate a pointer out animation
  63444. */
  63445. pointerOutAnimation: () => void;
  63446. /**
  63447. * Function called to generate a pointer down animation
  63448. */
  63449. pointerDownAnimation: () => void;
  63450. /**
  63451. * Function called to generate a pointer up animation
  63452. */
  63453. pointerUpAnimation: () => void;
  63454. /**
  63455. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63456. */
  63457. delegatePickingToChildren: boolean;
  63458. private _image;
  63459. /**
  63460. * Returns the image part of the button (if any)
  63461. */
  63462. readonly image: BABYLON.Nullable<Image>;
  63463. private _textBlock;
  63464. /**
  63465. * Returns the image part of the button (if any)
  63466. */
  63467. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63468. /**
  63469. * Creates a new Button
  63470. * @param name defines the name of the button
  63471. */
  63472. constructor(name?: string | undefined);
  63473. protected _getTypeName(): string;
  63474. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63475. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63476. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63477. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63478. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63479. /**
  63480. * Creates a new button made with an image and a text
  63481. * @param name defines the name of the button
  63482. * @param text defines the text of the button
  63483. * @param imageUrl defines the url of the image
  63484. * @returns a new Button
  63485. */
  63486. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63487. /**
  63488. * Creates a new button made with an image
  63489. * @param name defines the name of the button
  63490. * @param imageUrl defines the url of the image
  63491. * @returns a new Button
  63492. */
  63493. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63494. /**
  63495. * Creates a new button made with a text
  63496. * @param name defines the name of the button
  63497. * @param text defines the text of the button
  63498. * @returns a new Button
  63499. */
  63500. static CreateSimpleButton(name: string, text: string): Button;
  63501. /**
  63502. * Creates a new button made with an image and a centered text
  63503. * @param name defines the name of the button
  63504. * @param text defines the text of the button
  63505. * @param imageUrl defines the url of the image
  63506. * @returns a new Button
  63507. */
  63508. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63509. }
  63510. }
  63511. declare module BABYLON.GUI {
  63512. /**
  63513. * Class used to create a 2D stack panel container
  63514. */
  63515. export class StackPanel extends Container {
  63516. name?: string | undefined;
  63517. private _isVertical;
  63518. private _manualWidth;
  63519. private _manualHeight;
  63520. private _doNotTrackManualChanges;
  63521. /**
  63522. * Gets or sets a boolean indicating that layou warnings should be ignored
  63523. */
  63524. ignoreLayoutWarnings: boolean;
  63525. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63526. isVertical: boolean;
  63527. /**
  63528. * Gets or sets panel width.
  63529. * This value should not be set when in horizontal mode as it will be computed automatically
  63530. */
  63531. width: string | number;
  63532. /**
  63533. * Gets or sets panel height.
  63534. * This value should not be set when in vertical mode as it will be computed automatically
  63535. */
  63536. height: string | number;
  63537. /**
  63538. * Creates a new StackPanel
  63539. * @param name defines control name
  63540. */
  63541. constructor(name?: string | undefined);
  63542. protected _getTypeName(): string;
  63543. /** @hidden */
  63544. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63545. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63546. protected _postMeasure(): void;
  63547. }
  63548. }
  63549. declare module BABYLON.GUI {
  63550. /**
  63551. * Class used to represent a 2D checkbox
  63552. */
  63553. export class Checkbox extends Control {
  63554. name?: string | undefined;
  63555. private _isChecked;
  63556. private _background;
  63557. private _checkSizeRatio;
  63558. private _thickness;
  63559. /** Gets or sets border thickness */
  63560. thickness: number;
  63561. /**
  63562. * BABYLON.Observable raised when isChecked property changes
  63563. */
  63564. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63565. /** Gets or sets a value indicating the ratio between overall size and check size */
  63566. checkSizeRatio: number;
  63567. /** Gets or sets background color */
  63568. background: string;
  63569. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63570. isChecked: boolean;
  63571. /**
  63572. * Creates a new CheckBox
  63573. * @param name defines the control name
  63574. */
  63575. constructor(name?: string | undefined);
  63576. protected _getTypeName(): string;
  63577. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63578. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63579. /**
  63580. * Utility function to easily create a checkbox with a header
  63581. * @param title defines the label to use for the header
  63582. * @param onValueChanged defines the callback to call when value changes
  63583. * @returns a StackPanel containing the checkbox and a textBlock
  63584. */
  63585. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63586. }
  63587. }
  63588. declare module BABYLON.GUI {
  63589. /**
  63590. * Class used to store key control properties
  63591. */
  63592. export class KeyPropertySet {
  63593. /** Width */
  63594. width?: string;
  63595. /** Height */
  63596. height?: string;
  63597. /** Left padding */
  63598. paddingLeft?: string;
  63599. /** Right padding */
  63600. paddingRight?: string;
  63601. /** Top padding */
  63602. paddingTop?: string;
  63603. /** Bottom padding */
  63604. paddingBottom?: string;
  63605. /** Foreground color */
  63606. color?: string;
  63607. /** Background color */
  63608. background?: string;
  63609. }
  63610. /**
  63611. * Class used to create virtual keyboard
  63612. */
  63613. export class VirtualKeyboard extends StackPanel {
  63614. /** BABYLON.Observable raised when a key is pressed */
  63615. onKeyPressObservable: BABYLON.Observable<string>;
  63616. /** Gets or sets default key button width */
  63617. defaultButtonWidth: string;
  63618. /** Gets or sets default key button height */
  63619. defaultButtonHeight: string;
  63620. /** Gets or sets default key button left padding */
  63621. defaultButtonPaddingLeft: string;
  63622. /** Gets or sets default key button right padding */
  63623. defaultButtonPaddingRight: string;
  63624. /** Gets or sets default key button top padding */
  63625. defaultButtonPaddingTop: string;
  63626. /** Gets or sets default key button bottom padding */
  63627. defaultButtonPaddingBottom: string;
  63628. /** Gets or sets default key button foreground color */
  63629. defaultButtonColor: string;
  63630. /** Gets or sets default key button background color */
  63631. defaultButtonBackground: string;
  63632. /** Gets or sets shift button foreground color */
  63633. shiftButtonColor: string;
  63634. /** Gets or sets shift button thickness*/
  63635. selectedShiftThickness: number;
  63636. /** Gets shift key state */
  63637. shiftState: number;
  63638. protected _getTypeName(): string;
  63639. private _createKey;
  63640. /**
  63641. * Adds a new row of keys
  63642. * @param keys defines the list of keys to add
  63643. * @param propertySets defines the associated property sets
  63644. */
  63645. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63646. /**
  63647. * Set the shift key to a specific state
  63648. * @param shiftState defines the new shift state
  63649. */
  63650. applyShiftState(shiftState: number): void;
  63651. private _currentlyConnectedInputText;
  63652. private _connectedInputTexts;
  63653. private _onKeyPressObserver;
  63654. /** Gets the input text control currently attached to the keyboard */
  63655. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63656. /**
  63657. * Connects the keyboard with an input text control
  63658. *
  63659. * @param input defines the target control
  63660. */
  63661. connect(input: InputText): void;
  63662. /**
  63663. * Disconnects the keyboard from connected InputText controls
  63664. *
  63665. * @param input optionally defines a target control, otherwise all are disconnected
  63666. */
  63667. disconnect(input?: InputText): void;
  63668. private _removeConnectedInputObservables;
  63669. /**
  63670. * Release all resources
  63671. */
  63672. dispose(): void;
  63673. /**
  63674. * Creates a new keyboard using a default layout
  63675. *
  63676. * @param name defines control name
  63677. * @returns a new VirtualKeyboard
  63678. */
  63679. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63680. }
  63681. }
  63682. declare module BABYLON.GUI {
  63683. /**
  63684. * Class used to create input text control
  63685. */
  63686. export class InputText extends Control implements IFocusableControl {
  63687. name?: string | undefined;
  63688. private _text;
  63689. private _placeholderText;
  63690. private _background;
  63691. private _focusedBackground;
  63692. private _focusedColor;
  63693. private _placeholderColor;
  63694. private _thickness;
  63695. private _margin;
  63696. private _autoStretchWidth;
  63697. private _maxWidth;
  63698. private _isFocused;
  63699. private _blinkTimeout;
  63700. private _blinkIsEven;
  63701. private _cursorOffset;
  63702. private _scrollLeft;
  63703. private _textWidth;
  63704. private _clickedCoordinate;
  63705. private _deadKey;
  63706. private _addKey;
  63707. private _currentKey;
  63708. private _isTextHighlightOn;
  63709. private _textHighlightColor;
  63710. private _highligherOpacity;
  63711. private _highlightedText;
  63712. private _startHighlightIndex;
  63713. private _endHighlightIndex;
  63714. private _cursorIndex;
  63715. private _onFocusSelectAll;
  63716. private _isPointerDown;
  63717. private _onClipboardObserver;
  63718. private _onPointerDblTapObserver;
  63719. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63720. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63721. promptMessage: string;
  63722. /** Force disable prompt on mobile device */
  63723. disableMobilePrompt: boolean;
  63724. /** BABYLON.Observable raised when the text changes */
  63725. onTextChangedObservable: BABYLON.Observable<InputText>;
  63726. /** BABYLON.Observable raised just before an entered character is to be added */
  63727. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63728. /** BABYLON.Observable raised when the control gets the focus */
  63729. onFocusObservable: BABYLON.Observable<InputText>;
  63730. /** BABYLON.Observable raised when the control loses the focus */
  63731. onBlurObservable: BABYLON.Observable<InputText>;
  63732. /**Observable raised when the text is highlighted */
  63733. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63734. /**Observable raised when copy event is triggered */
  63735. onTextCopyObservable: BABYLON.Observable<InputText>;
  63736. /** BABYLON.Observable raised when cut event is triggered */
  63737. onTextCutObservable: BABYLON.Observable<InputText>;
  63738. /** BABYLON.Observable raised when paste event is triggered */
  63739. onTextPasteObservable: BABYLON.Observable<InputText>;
  63740. /** BABYLON.Observable raised when a key event was processed */
  63741. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63742. /** Gets or sets the maximum width allowed by the control */
  63743. maxWidth: string | number;
  63744. /** Gets the maximum width allowed by the control in pixels */
  63745. readonly maxWidthInPixels: number;
  63746. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63747. highligherOpacity: number;
  63748. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63749. onFocusSelectAll: boolean;
  63750. /** Gets or sets the text hightlight color */
  63751. textHighlightColor: string;
  63752. /** Gets or sets control margin */
  63753. margin: string;
  63754. /** Gets control margin in pixels */
  63755. readonly marginInPixels: number;
  63756. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63757. autoStretchWidth: boolean;
  63758. /** Gets or sets border thickness */
  63759. thickness: number;
  63760. /** Gets or sets the background color when focused */
  63761. focusedBackground: string;
  63762. /** Gets or sets the background color when focused */
  63763. focusedColor: string;
  63764. /** Gets or sets the background color */
  63765. background: string;
  63766. /** Gets or sets the placeholder color */
  63767. placeholderColor: string;
  63768. /** Gets or sets the text displayed when the control is empty */
  63769. placeholderText: string;
  63770. /** Gets or sets the dead key flag */
  63771. deadKey: boolean;
  63772. /** Gets or sets the highlight text */
  63773. highlightedText: string;
  63774. /** Gets or sets if the current key should be added */
  63775. addKey: boolean;
  63776. /** Gets or sets the value of the current key being entered */
  63777. currentKey: string;
  63778. /** Gets or sets the text displayed in the control */
  63779. text: string;
  63780. /** Gets or sets control width */
  63781. width: string | number;
  63782. /**
  63783. * Creates a new InputText
  63784. * @param name defines the control name
  63785. * @param text defines the text of the control
  63786. */
  63787. constructor(name?: string | undefined, text?: string);
  63788. /** @hidden */
  63789. onBlur(): void;
  63790. /** @hidden */
  63791. onFocus(): void;
  63792. protected _getTypeName(): string;
  63793. /**
  63794. * Function called to get the list of controls that should not steal the focus from this control
  63795. * @returns an array of controls
  63796. */
  63797. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63798. /** @hidden */
  63799. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63800. /** @hidden */
  63801. private _updateValueFromCursorIndex;
  63802. /** @hidden */
  63803. private _processDblClick;
  63804. /** @hidden */
  63805. private _selectAllText;
  63806. /**
  63807. * Handles the keyboard event
  63808. * @param evt Defines the KeyboardEvent
  63809. */
  63810. processKeyboard(evt: KeyboardEvent): void;
  63811. /** @hidden */
  63812. private _onCopyText;
  63813. /** @hidden */
  63814. private _onCutText;
  63815. /** @hidden */
  63816. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63817. protected _beforeRenderText(text: string): string;
  63818. dispose(): void;
  63819. }
  63820. }
  63821. declare module BABYLON.GUI {
  63822. /**
  63823. * Class used to create a 2D grid container
  63824. */
  63825. export class Grid extends Container {
  63826. name?: string | undefined;
  63827. private _rowDefinitions;
  63828. private _columnDefinitions;
  63829. private _cells;
  63830. private _childControls;
  63831. /**
  63832. * Gets the number of columns
  63833. */
  63834. readonly columnCount: number;
  63835. /**
  63836. * Gets the number of rows
  63837. */
  63838. readonly rowCount: number;
  63839. /** Gets the list of children */
  63840. readonly children: Control[];
  63841. /** Gets the list of cells (e.g. the containers) */
  63842. readonly cells: {
  63843. [key: string]: Container;
  63844. };
  63845. /**
  63846. * Gets the definition of a specific row
  63847. * @param index defines the index of the row
  63848. * @returns the row definition
  63849. */
  63850. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63851. /**
  63852. * Gets the definition of a specific column
  63853. * @param index defines the index of the column
  63854. * @returns the column definition
  63855. */
  63856. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63857. /**
  63858. * Adds a new row to the grid
  63859. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63860. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63861. * @returns the current grid
  63862. */
  63863. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63864. /**
  63865. * Adds a new column to the grid
  63866. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63867. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63868. * @returns the current grid
  63869. */
  63870. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63871. /**
  63872. * Update a row definition
  63873. * @param index defines the index of the row to update
  63874. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63875. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63876. * @returns the current grid
  63877. */
  63878. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63879. /**
  63880. * Update a column definition
  63881. * @param index defines the index of the column to update
  63882. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63883. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63884. * @returns the current grid
  63885. */
  63886. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63887. /**
  63888. * Gets the list of children stored in a specific cell
  63889. * @param row defines the row to check
  63890. * @param column defines the column to check
  63891. * @returns the list of controls
  63892. */
  63893. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63894. /**
  63895. * Gets a string representing the child cell info (row x column)
  63896. * @param child defines the control to get info from
  63897. * @returns a string containing the child cell info (row x column)
  63898. */
  63899. getChildCellInfo(child: Control): string;
  63900. private _removeCell;
  63901. private _offsetCell;
  63902. /**
  63903. * Remove a column definition at specified index
  63904. * @param index defines the index of the column to remove
  63905. * @returns the current grid
  63906. */
  63907. removeColumnDefinition(index: number): Grid;
  63908. /**
  63909. * Remove a row definition at specified index
  63910. * @param index defines the index of the row to remove
  63911. * @returns the current grid
  63912. */
  63913. removeRowDefinition(index: number): Grid;
  63914. /**
  63915. * Adds a new control to the current grid
  63916. * @param control defines the control to add
  63917. * @param row defines the row where to add the control (0 by default)
  63918. * @param column defines the column where to add the control (0 by default)
  63919. * @returns the current grid
  63920. */
  63921. addControl(control: Control, row?: number, column?: number): Grid;
  63922. /**
  63923. * Removes a control from the current container
  63924. * @param control defines the control to remove
  63925. * @returns the current container
  63926. */
  63927. removeControl(control: Control): Container;
  63928. /**
  63929. * Creates a new Grid
  63930. * @param name defines control name
  63931. */
  63932. constructor(name?: string | undefined);
  63933. protected _getTypeName(): string;
  63934. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63935. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63936. /** Releases associated resources */
  63937. dispose(): void;
  63938. }
  63939. }
  63940. declare module BABYLON.GUI {
  63941. /** Class used to create color pickers */
  63942. export class ColorPicker extends Control {
  63943. name?: string | undefined;
  63944. private static _Epsilon;
  63945. private _colorWheelCanvas;
  63946. private _value;
  63947. private _tmpColor;
  63948. private _pointerStartedOnSquare;
  63949. private _pointerStartedOnWheel;
  63950. private _squareLeft;
  63951. private _squareTop;
  63952. private _squareSize;
  63953. private _h;
  63954. private _s;
  63955. private _v;
  63956. private _lastPointerDownID;
  63957. /**
  63958. * BABYLON.Observable raised when the value changes
  63959. */
  63960. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63961. /** Gets or sets the color of the color picker */
  63962. value: BABYLON.Color3;
  63963. /**
  63964. * Gets or sets control width
  63965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63966. */
  63967. width: string | number;
  63968. /**
  63969. * Gets or sets control height
  63970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63971. */
  63972. /** Gets or sets control height */
  63973. height: string | number;
  63974. /** Gets or sets control size */
  63975. size: string | number;
  63976. /**
  63977. * Creates a new ColorPicker
  63978. * @param name defines the control name
  63979. */
  63980. constructor(name?: string | undefined);
  63981. protected _getTypeName(): string;
  63982. /** @hidden */
  63983. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63984. private _updateSquareProps;
  63985. private _drawGradientSquare;
  63986. private _drawCircle;
  63987. private _createColorWheelCanvas;
  63988. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63989. private _pointerIsDown;
  63990. private _updateValueFromPointer;
  63991. private _isPointOnSquare;
  63992. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63993. /**
  63994. * This function expands the color picker by creating a color picker dialog with manual
  63995. * color value input and the ability to save colors into an array to be used later in
  63996. * subsequent launches of the dialogue.
  63997. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63998. * @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.
  63999. * @returns picked color as a hex string and the saved colors array as hex strings.
  64000. */
  64001. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64002. pickerWidth?: string;
  64003. pickerHeight?: string;
  64004. headerHeight?: string;
  64005. lastColor?: string;
  64006. swatchLimit?: number;
  64007. numSwatchesPerLine?: number;
  64008. savedColors?: Array<string>;
  64009. }): Promise<{
  64010. savedColors?: string[];
  64011. pickedColor: string;
  64012. }>;
  64013. }
  64014. }
  64015. declare module BABYLON.GUI {
  64016. /** Class used to create 2D ellipse containers */
  64017. export class Ellipse extends Container {
  64018. name?: string | undefined;
  64019. private _thickness;
  64020. /** Gets or sets border thickness */
  64021. thickness: number;
  64022. /**
  64023. * Creates a new Ellipse
  64024. * @param name defines the control name
  64025. */
  64026. constructor(name?: string | undefined);
  64027. protected _getTypeName(): string;
  64028. protected _localDraw(context: CanvasRenderingContext2D): void;
  64029. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64030. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64031. }
  64032. }
  64033. declare module BABYLON.GUI {
  64034. /**
  64035. * Class used to create a password control
  64036. */
  64037. export class InputPassword extends InputText {
  64038. protected _beforeRenderText(text: string): string;
  64039. }
  64040. }
  64041. declare module BABYLON.GUI {
  64042. /** Class used to render 2D lines */
  64043. export class Line extends Control {
  64044. name?: string | undefined;
  64045. private _lineWidth;
  64046. private _x1;
  64047. private _y1;
  64048. private _x2;
  64049. private _y2;
  64050. private _dash;
  64051. private _connectedControl;
  64052. private _connectedControlDirtyObserver;
  64053. /** Gets or sets the dash pattern */
  64054. dash: Array<number>;
  64055. /** Gets or sets the control connected with the line end */
  64056. connectedControl: Control;
  64057. /** Gets or sets start coordinates on X axis */
  64058. x1: string | number;
  64059. /** Gets or sets start coordinates on Y axis */
  64060. y1: string | number;
  64061. /** Gets or sets end coordinates on X axis */
  64062. x2: string | number;
  64063. /** Gets or sets end coordinates on Y axis */
  64064. y2: string | number;
  64065. /** Gets or sets line width */
  64066. lineWidth: number;
  64067. /** Gets or sets horizontal alignment */
  64068. horizontalAlignment: number;
  64069. /** Gets or sets vertical alignment */
  64070. verticalAlignment: number;
  64071. private readonly _effectiveX2;
  64072. private readonly _effectiveY2;
  64073. /**
  64074. * Creates a new Line
  64075. * @param name defines the control name
  64076. */
  64077. constructor(name?: string | undefined);
  64078. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  64079. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64080. /**
  64081. * Move one end of the line given 3D cartesian coordinates.
  64082. * @param position Targeted world position
  64083. * @param scene BABYLON.Scene
  64084. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64085. */
  64086. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64087. /**
  64088. * Move one end of the line to a position in screen absolute space.
  64089. * @param projectedPosition Position in screen absolute space (X, Y)
  64090. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64091. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64092. }
  64093. }
  64094. declare module BABYLON.GUI {
  64095. /**
  64096. * Class used to store a point for a MultiLine object.
  64097. * The point can be pure 2D coordinates, a mesh or a control
  64098. */
  64099. export class MultiLinePoint {
  64100. private _multiLine;
  64101. private _x;
  64102. private _y;
  64103. private _control;
  64104. private _mesh;
  64105. private _controlObserver;
  64106. private _meshObserver;
  64107. /** @hidden */ private _point: BABYLON.Vector2;
  64108. /**
  64109. * Creates a new MultiLinePoint
  64110. * @param multiLine defines the source MultiLine object
  64111. */
  64112. constructor(multiLine: MultiLine);
  64113. /** Gets or sets x coordinate */
  64114. x: string | number;
  64115. /** Gets or sets y coordinate */
  64116. y: string | number;
  64117. /** Gets or sets the control associated with this point */
  64118. control: BABYLON.Nullable<Control>;
  64119. /** Gets or sets the mesh associated with this point */
  64120. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64121. /** Resets links */
  64122. resetLinks(): void;
  64123. /**
  64124. * Gets a translation vector
  64125. * @returns the translation vector
  64126. */
  64127. translate(): BABYLON.Vector2;
  64128. private _translatePoint;
  64129. /** Release associated resources */
  64130. dispose(): void;
  64131. }
  64132. }
  64133. declare module BABYLON.GUI {
  64134. /**
  64135. * Class used to create multi line control
  64136. */
  64137. export class MultiLine extends Control {
  64138. name?: string | undefined;
  64139. private _lineWidth;
  64140. private _dash;
  64141. private _points;
  64142. private _minX;
  64143. private _minY;
  64144. private _maxX;
  64145. private _maxY;
  64146. /**
  64147. * Creates a new MultiLine
  64148. * @param name defines the control name
  64149. */
  64150. constructor(name?: string | undefined);
  64151. /** Gets or sets dash pattern */
  64152. dash: Array<number>;
  64153. /**
  64154. * Gets point stored at specified index
  64155. * @param index defines the index to look for
  64156. * @returns the requested point if found
  64157. */
  64158. getAt(index: number): MultiLinePoint;
  64159. /** Function called when a point is updated */
  64160. onPointUpdate: () => void;
  64161. /**
  64162. * Adds new points to the point collection
  64163. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64164. * @returns the list of created MultiLinePoint
  64165. */
  64166. add(...items: (AbstractMesh | Control | {
  64167. x: string | number;
  64168. y: string | number;
  64169. })[]): MultiLinePoint[];
  64170. /**
  64171. * Adds a new point to the point collection
  64172. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64173. * @returns the created MultiLinePoint
  64174. */
  64175. push(item?: (AbstractMesh | Control | {
  64176. x: string | number;
  64177. y: string | number;
  64178. })): MultiLinePoint;
  64179. /**
  64180. * Remove a specific value or point from the active point collection
  64181. * @param value defines the value or point to remove
  64182. */
  64183. remove(value: number | MultiLinePoint): void;
  64184. /**
  64185. * Resets this object to initial state (no point)
  64186. */
  64187. reset(): void;
  64188. /**
  64189. * Resets all links
  64190. */
  64191. resetLinks(): void;
  64192. /** Gets or sets line width */
  64193. lineWidth: number;
  64194. horizontalAlignment: number;
  64195. verticalAlignment: number;
  64196. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64197. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  64198. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64199. dispose(): void;
  64200. }
  64201. }
  64202. declare module BABYLON.GUI {
  64203. /**
  64204. * Class used to create radio button controls
  64205. */
  64206. export class RadioButton extends Control {
  64207. name?: string | undefined;
  64208. private _isChecked;
  64209. private _background;
  64210. private _checkSizeRatio;
  64211. private _thickness;
  64212. /** Gets or sets border thickness */
  64213. thickness: number;
  64214. /** Gets or sets group name */
  64215. group: string;
  64216. /** BABYLON.Observable raised when isChecked is changed */
  64217. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64218. /** Gets or sets a value indicating the ratio between overall size and check size */
  64219. checkSizeRatio: number;
  64220. /** Gets or sets background color */
  64221. background: string;
  64222. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64223. isChecked: boolean;
  64224. /**
  64225. * Creates a new RadioButton
  64226. * @param name defines the control name
  64227. */
  64228. constructor(name?: string | undefined);
  64229. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64230. /**
  64231. * Utility function to easily create a radio button with a header
  64232. * @param title defines the label to use for the header
  64233. * @param group defines the group to use for the radio button
  64234. * @param isChecked defines the initial state of the radio button
  64235. * @param onValueChanged defines the callback to call when value changes
  64236. * @returns a StackPanel containing the radio button and a textBlock
  64237. */
  64238. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64239. }
  64240. }
  64241. declare module BABYLON.GUI {
  64242. /**
  64243. * Class used to create slider controls
  64244. */
  64245. export class BaseSlider extends Control {
  64246. name?: string | undefined;
  64247. protected _thumbWidth: ValueAndUnit;
  64248. private _minimum;
  64249. private _maximum;
  64250. private _value;
  64251. private _isVertical;
  64252. protected _barOffset: ValueAndUnit;
  64253. private _isThumbClamped;
  64254. protected _displayThumb: boolean;
  64255. private _step;
  64256. private _lastPointerDownID;
  64257. protected _effectiveBarOffset: number;
  64258. protected _renderLeft: number;
  64259. protected _renderTop: number;
  64260. protected _renderWidth: number;
  64261. protected _renderHeight: number;
  64262. protected _backgroundBoxLength: number;
  64263. protected _backgroundBoxThickness: number;
  64264. protected _effectiveThumbThickness: number;
  64265. /** BABYLON.Observable raised when the sldier value changes */
  64266. onValueChangedObservable: BABYLON.Observable<number>;
  64267. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64268. displayThumb: boolean;
  64269. /** Gets or sets a step to apply to values (0 by default) */
  64270. step: number;
  64271. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64272. barOffset: string | number;
  64273. /** Gets main bar offset in pixels*/
  64274. readonly barOffsetInPixels: number;
  64275. /** Gets or sets thumb width */
  64276. thumbWidth: string | number;
  64277. /** Gets thumb width in pixels */
  64278. readonly thumbWidthInPixels: number;
  64279. /** Gets or sets minimum value */
  64280. minimum: number;
  64281. /** Gets or sets maximum value */
  64282. maximum: number;
  64283. /** Gets or sets current value */
  64284. value: number;
  64285. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64286. isVertical: boolean;
  64287. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64288. isThumbClamped: boolean;
  64289. /**
  64290. * Creates a new BaseSlider
  64291. * @param name defines the control name
  64292. */
  64293. constructor(name?: string | undefined);
  64294. protected _getTypeName(): string;
  64295. protected _getThumbPosition(): number;
  64296. protected _getThumbThickness(type: string): number;
  64297. protected _prepareRenderingData(type: string): void;
  64298. private _pointerIsDown;
  64299. /** @hidden */
  64300. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64301. }
  64302. }
  64303. declare module BABYLON.GUI {
  64304. /**
  64305. * Class used to create slider controls
  64306. */
  64307. export class Slider extends BaseSlider {
  64308. name?: string | undefined;
  64309. private _background;
  64310. private _borderColor;
  64311. private _isThumbCircle;
  64312. protected _displayValueBar: boolean;
  64313. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64314. displayValueBar: boolean;
  64315. /** Gets or sets border color */
  64316. borderColor: string;
  64317. /** Gets or sets background color */
  64318. background: string;
  64319. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64320. isThumbCircle: boolean;
  64321. /**
  64322. * Creates a new Slider
  64323. * @param name defines the control name
  64324. */
  64325. constructor(name?: string | undefined);
  64326. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64327. }
  64328. }
  64329. declare module BABYLON.GUI {
  64330. /** Class used to create a RadioGroup
  64331. * which contains groups of radio buttons
  64332. */
  64333. export class SelectorGroup {
  64334. /** name of SelectorGroup */
  64335. name: string;
  64336. private _groupPanel;
  64337. private _selectors;
  64338. private _groupHeader;
  64339. /**
  64340. * Creates a new SelectorGroup
  64341. * @param name of group, used as a group heading
  64342. */
  64343. constructor(
  64344. /** name of SelectorGroup */
  64345. name: string);
  64346. /** Gets the groupPanel of the SelectorGroup */
  64347. readonly groupPanel: StackPanel;
  64348. /** Gets the selectors array */
  64349. readonly selectors: StackPanel[];
  64350. /** Gets and sets the group header */
  64351. header: string;
  64352. /** @hidden */
  64353. private _addGroupHeader;
  64354. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  64355. /** Removes the selector at the given position
  64356. * @param selectorNb the position of the selector within the group
  64357. */
  64358. removeSelector(selectorNb: number): void;
  64359. }
  64360. /** Class used to create a CheckboxGroup
  64361. * which contains groups of checkbox buttons
  64362. */
  64363. export class CheckboxGroup extends SelectorGroup {
  64364. /** Adds a checkbox as a control
  64365. * @param text is the label for the selector
  64366. * @param func is the function called when the Selector is checked
  64367. * @param checked is true when Selector is checked
  64368. */
  64369. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64370. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64371. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64372. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64373. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64374. }
  64375. /** Class used to create a RadioGroup
  64376. * which contains groups of radio buttons
  64377. */
  64378. export class RadioGroup extends SelectorGroup {
  64379. private _selectNb;
  64380. /** Adds a radio button as a control
  64381. * @param label is the label for the selector
  64382. * @param func is the function called when the Selector is checked
  64383. * @param checked is true when Selector is checked
  64384. */
  64385. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64386. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64387. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64388. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64389. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64390. }
  64391. /** Class used to create a SliderGroup
  64392. * which contains groups of slider buttons
  64393. */
  64394. export class SliderGroup extends SelectorGroup {
  64395. /**
  64396. * Adds a slider to the SelectorGroup
  64397. * @param label is the label for the SliderBar
  64398. * @param func is the function called when the Slider moves
  64399. * @param unit is a string describing the units used, eg degrees or metres
  64400. * @param min is the minimum value for the Slider
  64401. * @param max is the maximum value for the Slider
  64402. * @param value is the start value for the Slider between min and max
  64403. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64404. */
  64405. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64406. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64407. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64408. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64409. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64410. }
  64411. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64412. * @see http://doc.babylonjs.com/how_to/selector
  64413. */
  64414. export class SelectionPanel extends Rectangle {
  64415. /** name of SelectionPanel */
  64416. name: string;
  64417. /** an array of SelectionGroups */
  64418. groups: SelectorGroup[];
  64419. private _panel;
  64420. private _buttonColor;
  64421. private _buttonBackground;
  64422. private _headerColor;
  64423. private _barColor;
  64424. private _barHeight;
  64425. private _spacerHeight;
  64426. private _labelColor;
  64427. private _groups;
  64428. private _bars;
  64429. /**
  64430. * Creates a new SelectionPanel
  64431. * @param name of SelectionPanel
  64432. * @param groups is an array of SelectionGroups
  64433. */
  64434. constructor(
  64435. /** name of SelectionPanel */
  64436. name: string,
  64437. /** an array of SelectionGroups */
  64438. groups?: SelectorGroup[]);
  64439. protected _getTypeName(): string;
  64440. /** Gets or sets the headerColor */
  64441. headerColor: string;
  64442. private _setHeaderColor;
  64443. /** Gets or sets the button color */
  64444. buttonColor: string;
  64445. private _setbuttonColor;
  64446. /** Gets or sets the label color */
  64447. labelColor: string;
  64448. private _setLabelColor;
  64449. /** Gets or sets the button background */
  64450. buttonBackground: string;
  64451. private _setButtonBackground;
  64452. /** Gets or sets the color of separator bar */
  64453. barColor: string;
  64454. private _setBarColor;
  64455. /** Gets or sets the height of separator bar */
  64456. barHeight: string;
  64457. private _setBarHeight;
  64458. /** Gets or sets the height of spacers*/
  64459. spacerHeight: string;
  64460. private _setSpacerHeight;
  64461. /** Adds a bar between groups */
  64462. private _addSpacer;
  64463. /** Add a group to the selection panel
  64464. * @param group is the selector group to add
  64465. */
  64466. addGroup(group: SelectorGroup): void;
  64467. /** Remove the group from the given position
  64468. * @param groupNb is the position of the group in the list
  64469. */
  64470. removeGroup(groupNb: number): void;
  64471. /** Change a group header label
  64472. * @param label is the new group header label
  64473. * @param groupNb is the number of the group to relabel
  64474. * */
  64475. setHeaderName(label: string, groupNb: number): void;
  64476. /** Change selector label to the one given
  64477. * @param label is the new selector label
  64478. * @param groupNb is the number of the groupcontaining the selector
  64479. * @param selectorNb is the number of the selector within a group to relabel
  64480. * */
  64481. relabel(label: string, groupNb: number, selectorNb: number): void;
  64482. /** For a given group position remove the selector at the given position
  64483. * @param groupNb is the number of the group to remove the selector from
  64484. * @param selectorNb is the number of the selector within the group
  64485. */
  64486. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64487. /** For a given group position of correct type add a checkbox button
  64488. * @param groupNb is the number of the group to remove the selector from
  64489. * @param label is the label for the selector
  64490. * @param func is the function called when the Selector is checked
  64491. * @param checked is true when Selector is checked
  64492. */
  64493. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64494. /** For a given group position of correct type add a radio button
  64495. * @param groupNb is the number of the group to remove the selector from
  64496. * @param label is the label for the selector
  64497. * @param func is the function called when the Selector is checked
  64498. * @param checked is true when Selector is checked
  64499. */
  64500. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64501. /**
  64502. * For a given slider group add a slider
  64503. * @param groupNb is the number of the group to add the slider to
  64504. * @param label is the label for the Slider
  64505. * @param func is the function called when the Slider moves
  64506. * @param unit is a string describing the units used, eg degrees or metres
  64507. * @param min is the minimum value for the Slider
  64508. * @param max is the maximum value for the Slider
  64509. * @param value is the start value for the Slider between min and max
  64510. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64511. */
  64512. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64513. }
  64514. }
  64515. declare module BABYLON.GUI {
  64516. /**
  64517. * Class used to hold a the container for ScrollViewer
  64518. * @hidden
  64519. */
  64520. export class _ScrollViewerWindow extends Container {
  64521. parentClientWidth: number;
  64522. parentClientHeight: number;
  64523. /**
  64524. * Creates a new ScrollViewerWindow
  64525. * @param name of ScrollViewerWindow
  64526. */
  64527. constructor(name?: string);
  64528. protected _getTypeName(): string;
  64529. /** @hidden */
  64530. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64531. protected _postMeasure(): void;
  64532. }
  64533. }
  64534. declare module BABYLON.GUI {
  64535. /**
  64536. * Class used to create slider controls
  64537. */
  64538. export class ScrollBar extends BaseSlider {
  64539. name?: string | undefined;
  64540. private _background;
  64541. private _borderColor;
  64542. private _thumbMeasure;
  64543. /** Gets or sets border color */
  64544. borderColor: string;
  64545. /** Gets or sets background color */
  64546. background: string;
  64547. /**
  64548. * Creates a new Slider
  64549. * @param name defines the control name
  64550. */
  64551. constructor(name?: string | undefined);
  64552. protected _getTypeName(): string;
  64553. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  64554. private _first;
  64555. private _originX;
  64556. private _originY;
  64557. /** @hidden */
  64558. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64559. }
  64560. }
  64561. declare module BABYLON.GUI {
  64562. /**
  64563. * Class used to hold a viewer window and sliders in a grid
  64564. */
  64565. export class ScrollViewer extends Rectangle {
  64566. private _grid;
  64567. private _horizontalBarSpace;
  64568. private _verticalBarSpace;
  64569. private _dragSpace;
  64570. private _horizontalBar;
  64571. private _verticalBar;
  64572. private _barColor;
  64573. private _barBackground;
  64574. private _barSize;
  64575. private _endLeft;
  64576. private _endTop;
  64577. private _window;
  64578. private _pointerIsOver;
  64579. private _wheelPrecision;
  64580. private _onPointerObserver;
  64581. private _clientWidth;
  64582. private _clientHeight;
  64583. /**
  64584. * Gets the horizontal scrollbar
  64585. */
  64586. readonly horizontalBar: ScrollBar;
  64587. /**
  64588. * Gets the vertical scrollbar
  64589. */
  64590. readonly verticalBar: ScrollBar;
  64591. /**
  64592. * Adds a new control to the current container
  64593. * @param control defines the control to add
  64594. * @returns the current container
  64595. */
  64596. addControl(control: BABYLON.Nullable<Control>): Container;
  64597. /**
  64598. * Removes a control from the current container
  64599. * @param control defines the control to remove
  64600. * @returns the current container
  64601. */
  64602. removeControl(control: Control): Container;
  64603. /** Gets the list of children */
  64604. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  64605. /**
  64606. * Creates a new ScrollViewer
  64607. * @param name of ScrollViewer
  64608. */
  64609. constructor(name?: string);
  64610. /** Reset the scroll viewer window to initial size */
  64611. resetWindow(): void;
  64612. protected _getTypeName(): string;
  64613. private _buildClientSizes;
  64614. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64615. protected _postMeasure(): void;
  64616. /**
  64617. * Gets or sets the mouse wheel precision
  64618. * from 0 to 1 with a default value of 0.05
  64619. * */
  64620. wheelPrecision: number;
  64621. /** Gets or sets the bar color */
  64622. barColor: string;
  64623. /** Gets or sets the size of the bar */
  64624. barSize: number;
  64625. /** Gets or sets the bar background */
  64626. barBackground: string;
  64627. /** @hidden */
  64628. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  64629. /** @hidden */
  64630. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64631. /** Releases associated resources */
  64632. dispose(): void;
  64633. }
  64634. }
  64635. declare module BABYLON.GUI {
  64636. /** Class used to render a grid */
  64637. export class DisplayGrid extends Control {
  64638. name?: string | undefined;
  64639. private _cellWidth;
  64640. private _cellHeight;
  64641. private _minorLineTickness;
  64642. private _minorLineColor;
  64643. private _majorLineTickness;
  64644. private _majorLineColor;
  64645. private _majorLineFrequency;
  64646. private _background;
  64647. private _displayMajorLines;
  64648. private _displayMinorLines;
  64649. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64650. displayMinorLines: boolean;
  64651. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64652. displayMajorLines: boolean;
  64653. /** Gets or sets background color (Black by default) */
  64654. background: string;
  64655. /** Gets or sets the width of each cell (20 by default) */
  64656. cellWidth: number;
  64657. /** Gets or sets the height of each cell (20 by default) */
  64658. cellHeight: number;
  64659. /** Gets or sets the tickness of minor lines (1 by default) */
  64660. minorLineTickness: number;
  64661. /** Gets or sets the color of minor lines (DarkGray by default) */
  64662. minorLineColor: string;
  64663. /** Gets or sets the tickness of major lines (2 by default) */
  64664. majorLineTickness: number;
  64665. /** Gets or sets the color of major lines (White by default) */
  64666. majorLineColor: string;
  64667. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64668. majorLineFrequency: number;
  64669. /**
  64670. * Creates a new GridDisplayRectangle
  64671. * @param name defines the control name
  64672. */
  64673. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  64674. protected _getTypeName(): string;
  64675. }
  64676. }
  64677. declare module BABYLON.GUI {
  64678. /**
  64679. * Class used to create slider controls based on images
  64680. */
  64681. export class ImageBasedSlider extends BaseSlider {
  64682. name?: string | undefined;
  64683. private _backgroundImage;
  64684. private _thumbImage;
  64685. private _valueBarImage;
  64686. private _tempMeasure;
  64687. displayThumb: boolean;
  64688. /**
  64689. * Gets or sets the image used to render the background
  64690. */
  64691. backgroundImage: Image;
  64692. /**
  64693. * Gets or sets the image used to render the value bar
  64694. */
  64695. valueBarImage: Image;
  64696. /**
  64697. * Gets or sets the image used to render the thumb
  64698. */
  64699. thumbImage: Image;
  64700. /**
  64701. * Creates a new ImageBasedSlider
  64702. * @param name defines the control name
  64703. */
  64704. constructor(name?: string | undefined);
  64705. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64706. }
  64707. }
  64708. declare module BABYLON.GUI {
  64709. /**
  64710. * Forcing an export so that this code will execute
  64711. * @hidden
  64712. */
  64713. const name = "Statics";
  64714. }
  64715. declare module BABYLON.GUI {
  64716. /**
  64717. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64718. */
  64719. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64720. /**
  64721. * Define the instrumented AdvancedDynamicTexture.
  64722. */
  64723. texture: AdvancedDynamicTexture;
  64724. private _captureRenderTime;
  64725. private _renderTime;
  64726. private _captureLayoutTime;
  64727. private _layoutTime;
  64728. private _onBeginRenderObserver;
  64729. private _onEndRenderObserver;
  64730. private _onBeginLayoutObserver;
  64731. private _onEndLayoutObserver;
  64732. /**
  64733. * Gets the perf counter used to capture render time
  64734. */
  64735. readonly renderTimeCounter: BABYLON.PerfCounter;
  64736. /**
  64737. * Gets the perf counter used to capture layout time
  64738. */
  64739. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64740. /**
  64741. * Enable or disable the render time capture
  64742. */
  64743. captureRenderTime: boolean;
  64744. /**
  64745. * Enable or disable the layout time capture
  64746. */
  64747. captureLayoutTime: boolean;
  64748. /**
  64749. * Instantiates a new advanced dynamic texture instrumentation.
  64750. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64751. * @param texture Defines the AdvancedDynamicTexture to instrument
  64752. */
  64753. constructor(
  64754. /**
  64755. * Define the instrumented AdvancedDynamicTexture.
  64756. */
  64757. texture: AdvancedDynamicTexture);
  64758. /**
  64759. * Dispose and release associated resources.
  64760. */
  64761. dispose(): void;
  64762. }
  64763. }
  64764. declare module BABYLON.GUI {
  64765. /**
  64766. * Class used to create containers for controls
  64767. */
  64768. export class Container3D extends Control3D {
  64769. private _blockLayout;
  64770. /**
  64771. * Gets the list of child controls
  64772. */
  64773. protected _children: Control3D[];
  64774. /**
  64775. * Gets the list of child controls
  64776. */
  64777. readonly children: Array<Control3D>;
  64778. /**
  64779. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64780. * This is helpful to optimize layout operation when adding multiple children in a row
  64781. */
  64782. blockLayout: boolean;
  64783. /**
  64784. * Creates a new container
  64785. * @param name defines the container name
  64786. */
  64787. constructor(name?: string);
  64788. /**
  64789. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64790. * @returns the current container
  64791. */
  64792. updateLayout(): Container3D;
  64793. /**
  64794. * Gets a boolean indicating if the given control is in the children of this control
  64795. * @param control defines the control to check
  64796. * @returns true if the control is in the child list
  64797. */
  64798. containsControl(control: Control3D): boolean;
  64799. /**
  64800. * Adds a control to the children of this control
  64801. * @param control defines the control to add
  64802. * @returns the current container
  64803. */
  64804. addControl(control: Control3D): Container3D;
  64805. /**
  64806. * This function will be called everytime a new control is added
  64807. */
  64808. protected _arrangeChildren(): void;
  64809. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64810. /**
  64811. * Removes a control from the children of this control
  64812. * @param control defines the control to remove
  64813. * @returns the current container
  64814. */
  64815. removeControl(control: Control3D): Container3D;
  64816. protected _getTypeName(): string;
  64817. /**
  64818. * Releases all associated resources
  64819. */
  64820. dispose(): void;
  64821. /** Control rotation will remain unchanged */
  64822. static readonly UNSET_ORIENTATION: number;
  64823. /** Control will rotate to make it look at sphere central axis */
  64824. static readonly FACEORIGIN_ORIENTATION: number;
  64825. /** Control will rotate to make it look back at sphere central axis */
  64826. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64827. /** Control will rotate to look at z axis (0, 0, 1) */
  64828. static readonly FACEFORWARD_ORIENTATION: number;
  64829. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64830. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64831. }
  64832. }
  64833. declare module BABYLON.GUI {
  64834. /**
  64835. * Class used to manage 3D user interface
  64836. * @see http://doc.babylonjs.com/how_to/gui3d
  64837. */
  64838. export class GUI3DManager implements BABYLON.IDisposable {
  64839. private _scene;
  64840. private _sceneDisposeObserver;
  64841. private _utilityLayer;
  64842. private _rootContainer;
  64843. private _pointerObserver;
  64844. private _pointerOutObserver;
  64845. /** @hidden */ private _lastPickedControl: Control3D;
  64846. /** @hidden */ private _lastControlOver: {
  64847. [pointerId: number]: Control3D;
  64848. };
  64849. /** @hidden */ private _lastControlDown: {
  64850. [pointerId: number]: Control3D;
  64851. };
  64852. /**
  64853. * BABYLON.Observable raised when the point picked by the pointer events changed
  64854. */
  64855. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64856. /** @hidden */ private _sharedMaterials: {
  64857. [key: string]: BABYLON.Material;
  64858. };
  64859. /** Gets the hosting scene */
  64860. readonly scene: BABYLON.Scene;
  64861. /** Gets associated utility layer */
  64862. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64863. /**
  64864. * Creates a new GUI3DManager
  64865. * @param scene
  64866. */
  64867. constructor(scene?: BABYLON.Scene);
  64868. private _handlePointerOut;
  64869. private _doPicking;
  64870. /**
  64871. * Gets the root container
  64872. */
  64873. readonly rootContainer: Container3D;
  64874. /**
  64875. * Gets a boolean indicating if the given control is in the root child list
  64876. * @param control defines the control to check
  64877. * @returns true if the control is in the root child list
  64878. */
  64879. containsControl(control: Control3D): boolean;
  64880. /**
  64881. * Adds a control to the root child list
  64882. * @param control defines the control to add
  64883. * @returns the current manager
  64884. */
  64885. addControl(control: Control3D): GUI3DManager;
  64886. /**
  64887. * Removes a control from the root child list
  64888. * @param control defines the control to remove
  64889. * @returns the current container
  64890. */
  64891. removeControl(control: Control3D): GUI3DManager;
  64892. /**
  64893. * Releases all associated resources
  64894. */
  64895. dispose(): void;
  64896. }
  64897. }
  64898. declare module BABYLON.GUI {
  64899. /**
  64900. * Class used to transport BABYLON.Vector3 information for pointer events
  64901. */
  64902. export class Vector3WithInfo extends BABYLON.Vector3 {
  64903. /** defines the current mouse button index */
  64904. buttonIndex: number;
  64905. /**
  64906. * Creates a new Vector3WithInfo
  64907. * @param source defines the vector3 data to transport
  64908. * @param buttonIndex defines the current mouse button index
  64909. */
  64910. constructor(source: BABYLON.Vector3,
  64911. /** defines the current mouse button index */
  64912. buttonIndex?: number);
  64913. }
  64914. }
  64915. declare module BABYLON.GUI {
  64916. /**
  64917. * Class used as base class for controls
  64918. */
  64919. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64920. /** Defines the control name */
  64921. name?: string | undefined;
  64922. /** @hidden */ private _host: GUI3DManager;
  64923. private _node;
  64924. private _downCount;
  64925. private _enterCount;
  64926. private _downPointerIds;
  64927. private _isVisible;
  64928. /** Gets or sets the control position in world space */
  64929. position: BABYLON.Vector3;
  64930. /** Gets or sets the control scaling in world space */
  64931. scaling: BABYLON.Vector3;
  64932. /** Callback used to start pointer enter animation */
  64933. pointerEnterAnimation: () => void;
  64934. /** Callback used to start pointer out animation */
  64935. pointerOutAnimation: () => void;
  64936. /** Callback used to start pointer down animation */
  64937. pointerDownAnimation: () => void;
  64938. /** Callback used to start pointer up animation */
  64939. pointerUpAnimation: () => void;
  64940. /**
  64941. * An event triggered when the pointer move over the control
  64942. */
  64943. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64944. /**
  64945. * An event triggered when the pointer move out of the control
  64946. */
  64947. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64948. /**
  64949. * An event triggered when the pointer taps the control
  64950. */
  64951. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64952. /**
  64953. * An event triggered when pointer is up
  64954. */
  64955. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64956. /**
  64957. * An event triggered when a control is clicked on (with a mouse)
  64958. */
  64959. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64960. /**
  64961. * An event triggered when pointer enters the control
  64962. */
  64963. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64964. /**
  64965. * Gets or sets the parent container
  64966. */
  64967. parent: BABYLON.Nullable<Container3D>;
  64968. private _behaviors;
  64969. /**
  64970. * Gets the list of attached behaviors
  64971. * @see http://doc.babylonjs.com/features/behaviour
  64972. */
  64973. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64974. /**
  64975. * Attach a behavior to the control
  64976. * @see http://doc.babylonjs.com/features/behaviour
  64977. * @param behavior defines the behavior to attach
  64978. * @returns the current control
  64979. */
  64980. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64981. /**
  64982. * Remove an attached behavior
  64983. * @see http://doc.babylonjs.com/features/behaviour
  64984. * @param behavior defines the behavior to attach
  64985. * @returns the current control
  64986. */
  64987. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64988. /**
  64989. * Gets an attached behavior by name
  64990. * @param name defines the name of the behavior to look for
  64991. * @see http://doc.babylonjs.com/features/behaviour
  64992. * @returns null if behavior was not found else the requested behavior
  64993. */
  64994. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64995. /** Gets or sets a boolean indicating if the control is visible */
  64996. isVisible: boolean;
  64997. /**
  64998. * Creates a new control
  64999. * @param name defines the control name
  65000. */
  65001. constructor(
  65002. /** Defines the control name */
  65003. name?: string | undefined);
  65004. /**
  65005. * Gets a string representing the class name
  65006. */
  65007. readonly typeName: string;
  65008. /**
  65009. * Get the current class name of the control.
  65010. * @returns current class name
  65011. */
  65012. getClassName(): string;
  65013. protected _getTypeName(): string;
  65014. /**
  65015. * Gets the transform node used by this control
  65016. */
  65017. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65018. /**
  65019. * Gets the mesh used to render this control
  65020. */
  65021. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65022. /**
  65023. * Link the control as child of the given node
  65024. * @param node defines the node to link to. Use null to unlink the control
  65025. * @returns the current control
  65026. */
  65027. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65028. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  65029. /**
  65030. * Node creation.
  65031. * Can be overriden by children
  65032. * @param scene defines the scene where the node must be attached
  65033. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65034. */
  65035. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65036. /**
  65037. * Affect a material to the given mesh
  65038. * @param mesh defines the mesh which will represent the control
  65039. */
  65040. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65041. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65042. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  65043. /** @hidden */ private _onPointerOut(target: Control3D): void;
  65044. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65045. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65046. /** @hidden */
  65047. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65048. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65049. /** @hidden */ private _disposeNode(): void;
  65050. /**
  65051. * Releases all associated resources
  65052. */
  65053. dispose(): void;
  65054. }
  65055. }
  65056. declare module BABYLON.GUI {
  65057. /**
  65058. * Class used as a root to all buttons
  65059. */
  65060. export class AbstractButton3D extends Control3D {
  65061. /**
  65062. * Creates a new button
  65063. * @param name defines the control name
  65064. */
  65065. constructor(name?: string);
  65066. protected _getTypeName(): string;
  65067. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65068. }
  65069. }
  65070. declare module BABYLON.GUI {
  65071. /**
  65072. * Class used to create a button in 3D
  65073. */
  65074. export class Button3D extends AbstractButton3D {
  65075. /** @hidden */
  65076. protected _currentMaterial: BABYLON.Material;
  65077. private _facadeTexture;
  65078. private _content;
  65079. private _contentResolution;
  65080. private _contentScaleRatio;
  65081. /**
  65082. * Gets or sets the texture resolution used to render content (512 by default)
  65083. */
  65084. contentResolution: BABYLON.int;
  65085. /**
  65086. * Gets or sets the texture scale ratio used to render content (2 by default)
  65087. */
  65088. contentScaleRatio: number;
  65089. protected _disposeFacadeTexture(): void;
  65090. protected _resetContent(): void;
  65091. /**
  65092. * Creates a new button
  65093. * @param name defines the control name
  65094. */
  65095. constructor(name?: string);
  65096. /**
  65097. * Gets or sets the GUI 2D content used to display the button's facade
  65098. */
  65099. content: Control;
  65100. /**
  65101. * Apply the facade texture (created from the content property).
  65102. * This function can be overloaded by child classes
  65103. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65104. */
  65105. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65106. protected _getTypeName(): string;
  65107. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65108. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65109. /**
  65110. * Releases all associated resources
  65111. */
  65112. dispose(): void;
  65113. }
  65114. }
  65115. declare module BABYLON.GUI {
  65116. /**
  65117. * Abstract class used to create a container panel deployed on the surface of a volume
  65118. */
  65119. export abstract class VolumeBasedPanel extends Container3D {
  65120. private _columns;
  65121. private _rows;
  65122. private _rowThenColum;
  65123. private _orientation;
  65124. protected _cellWidth: number;
  65125. protected _cellHeight: number;
  65126. /**
  65127. * Gets or sets the distance between elements
  65128. */
  65129. margin: number;
  65130. /**
  65131. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65132. * | Value | Type | Description |
  65133. * | ----- | ----------------------------------- | ----------- |
  65134. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65135. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65136. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65137. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65138. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65139. */
  65140. orientation: number;
  65141. /**
  65142. * Gets or sets the number of columns requested (10 by default).
  65143. * The panel will automatically compute the number of rows based on number of child controls.
  65144. */
  65145. columns: BABYLON.int;
  65146. /**
  65147. * Gets or sets a the number of rows requested.
  65148. * The panel will automatically compute the number of columns based on number of child controls.
  65149. */
  65150. rows: BABYLON.int;
  65151. /**
  65152. * Creates new VolumeBasedPanel
  65153. */
  65154. constructor();
  65155. protected _arrangeChildren(): void;
  65156. /** Child classes must implement this function to provide correct control positioning */
  65157. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65158. /** Child classes can implement this function to provide additional processing */
  65159. protected _finalProcessing(): void;
  65160. }
  65161. }
  65162. declare module BABYLON.GUI {
  65163. /**
  65164. * Class used to create a container panel deployed on the surface of a cylinder
  65165. */
  65166. export class CylinderPanel extends VolumeBasedPanel {
  65167. private _radius;
  65168. /**
  65169. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65170. */
  65171. radius: BABYLON.float;
  65172. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65173. private _cylindricalMapping;
  65174. }
  65175. }
  65176. declare module BABYLON.GUI {
  65177. /** @hidden */
  65178. export var fluentVertexShader: {
  65179. name: string;
  65180. shader: string;
  65181. };
  65182. }
  65183. declare module BABYLON.GUI {
  65184. /** @hidden */
  65185. export var fluentPixelShader: {
  65186. name: string;
  65187. shader: string;
  65188. };
  65189. }
  65190. declare module BABYLON.GUI {
  65191. /** @hidden */
  65192. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65193. INNERGLOW: boolean;
  65194. BORDER: boolean;
  65195. HOVERLIGHT: boolean;
  65196. TEXTURE: boolean;
  65197. constructor();
  65198. }
  65199. /**
  65200. * Class used to render controls with fluent desgin
  65201. */
  65202. export class FluentMaterial extends BABYLON.PushMaterial {
  65203. /**
  65204. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65205. */
  65206. innerGlowColorIntensity: number;
  65207. /**
  65208. * Gets or sets the inner glow color (white by default)
  65209. */
  65210. innerGlowColor: BABYLON.Color3;
  65211. /**
  65212. * Gets or sets alpha value (default is 1.0)
  65213. */
  65214. alpha: number;
  65215. /**
  65216. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65217. */
  65218. albedoColor: BABYLON.Color3;
  65219. /**
  65220. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65221. */
  65222. renderBorders: boolean;
  65223. /**
  65224. * Gets or sets border width (default is 0.5)
  65225. */
  65226. borderWidth: number;
  65227. /**
  65228. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65229. */
  65230. edgeSmoothingValue: number;
  65231. /**
  65232. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65233. */
  65234. borderMinValue: number;
  65235. /**
  65236. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65237. */
  65238. renderHoverLight: boolean;
  65239. /**
  65240. * Gets or sets the radius used to render the hover light (default is 1.0)
  65241. */
  65242. hoverRadius: number;
  65243. /**
  65244. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65245. */
  65246. hoverColor: BABYLON.Color4;
  65247. /**
  65248. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65249. */
  65250. hoverPosition: BABYLON.Vector3;
  65251. private _albedoTexture;
  65252. /** Gets or sets the texture to use for albedo color */
  65253. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65254. /**
  65255. * Creates a new Fluent material
  65256. * @param name defines the name of the material
  65257. * @param scene defines the hosting scene
  65258. */
  65259. constructor(name: string, scene: BABYLON.Scene);
  65260. needAlphaBlending(): boolean;
  65261. needAlphaTesting(): boolean;
  65262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65263. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65264. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65265. getActiveTextures(): BABYLON.BaseTexture[];
  65266. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65267. dispose(forceDisposeEffect?: boolean): void;
  65268. clone(name: string): FluentMaterial;
  65269. serialize(): any;
  65270. getClassName(): string;
  65271. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65272. }
  65273. }
  65274. declare module BABYLON.GUI {
  65275. /**
  65276. * Class used to create a holographic button in 3D
  65277. */
  65278. export class HolographicButton extends Button3D {
  65279. private _backPlate;
  65280. private _textPlate;
  65281. private _frontPlate;
  65282. private _text;
  65283. private _imageUrl;
  65284. private _shareMaterials;
  65285. private _frontMaterial;
  65286. private _backMaterial;
  65287. private _plateMaterial;
  65288. private _pickedPointObserver;
  65289. private _tooltipFade;
  65290. private _tooltipTextBlock;
  65291. private _tooltipTexture;
  65292. private _tooltipMesh;
  65293. private _tooltipHoverObserver;
  65294. private _tooltipOutObserver;
  65295. private _disposeTooltip;
  65296. /**
  65297. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65298. */
  65299. tooltipText: BABYLON.Nullable<string>;
  65300. /**
  65301. * Gets or sets text for the button
  65302. */
  65303. text: string;
  65304. /**
  65305. * Gets or sets the image url for the button
  65306. */
  65307. imageUrl: string;
  65308. /**
  65309. * Gets the back material used by this button
  65310. */
  65311. readonly backMaterial: FluentMaterial;
  65312. /**
  65313. * Gets the front material used by this button
  65314. */
  65315. readonly frontMaterial: FluentMaterial;
  65316. /**
  65317. * Gets the plate material used by this button
  65318. */
  65319. readonly plateMaterial: BABYLON.StandardMaterial;
  65320. /**
  65321. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65322. */
  65323. readonly shareMaterials: boolean;
  65324. /**
  65325. * Creates a new button
  65326. * @param name defines the control name
  65327. */
  65328. constructor(name?: string, shareMaterials?: boolean);
  65329. protected _getTypeName(): string;
  65330. private _rebuildContent;
  65331. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65332. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65333. private _createBackMaterial;
  65334. private _createFrontMaterial;
  65335. private _createPlateMaterial;
  65336. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65337. /**
  65338. * Releases all associated resources
  65339. */
  65340. dispose(): void;
  65341. }
  65342. }
  65343. declare module BABYLON.GUI {
  65344. /**
  65345. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65346. */
  65347. export class MeshButton3D extends Button3D {
  65348. /** @hidden */
  65349. protected _currentMesh: BABYLON.Mesh;
  65350. /**
  65351. * Creates a new 3D button based on a mesh
  65352. * @param mesh mesh to become a 3D button
  65353. * @param name defines the control name
  65354. */
  65355. constructor(mesh: BABYLON.Mesh, name?: string);
  65356. protected _getTypeName(): string;
  65357. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65358. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65359. }
  65360. }
  65361. declare module BABYLON.GUI {
  65362. /**
  65363. * Class used to create a container panel deployed on the surface of a plane
  65364. */
  65365. export class PlanePanel extends VolumeBasedPanel {
  65366. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65367. }
  65368. }
  65369. declare module BABYLON.GUI {
  65370. /**
  65371. * Class used to create a container panel where items get randomized planar mapping
  65372. */
  65373. export class ScatterPanel extends VolumeBasedPanel {
  65374. private _iteration;
  65375. /**
  65376. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65377. */
  65378. iteration: BABYLON.float;
  65379. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65380. private _scatterMapping;
  65381. protected _finalProcessing(): void;
  65382. }
  65383. }
  65384. declare module BABYLON.GUI {
  65385. /**
  65386. * Class used to create a container panel deployed on the surface of a sphere
  65387. */
  65388. export class SpherePanel extends VolumeBasedPanel {
  65389. private _radius;
  65390. /**
  65391. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65392. */
  65393. radius: BABYLON.float;
  65394. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65395. private _sphericalMapping;
  65396. }
  65397. }
  65398. declare module BABYLON.GUI {
  65399. /**
  65400. * Class used to create a stack panel in 3D on XY plane
  65401. */
  65402. export class StackPanel3D extends Container3D {
  65403. private _isVertical;
  65404. /**
  65405. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65406. */
  65407. isVertical: boolean;
  65408. /**
  65409. * Gets or sets the distance between elements
  65410. */
  65411. margin: number;
  65412. /**
  65413. * Creates new StackPanel
  65414. * @param isVertical
  65415. */
  65416. constructor(isVertical?: boolean);
  65417. protected _arrangeChildren(): void;
  65418. }
  65419. }
  65420. declare module BABYLON {
  65421. /**
  65422. * Mode that determines the coordinate system to use.
  65423. */
  65424. export enum GLTFLoaderCoordinateSystemMode {
  65425. /**
  65426. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65427. */
  65428. AUTO = 0,
  65429. /**
  65430. * Sets the useRightHandedSystem flag on the scene.
  65431. */
  65432. FORCE_RIGHT_HANDED = 1
  65433. }
  65434. /**
  65435. * Mode that determines what animations will start.
  65436. */
  65437. export enum GLTFLoaderAnimationStartMode {
  65438. /**
  65439. * No animation will start.
  65440. */
  65441. NONE = 0,
  65442. /**
  65443. * The first animation will start.
  65444. */
  65445. FIRST = 1,
  65446. /**
  65447. * All animations will start.
  65448. */
  65449. ALL = 2
  65450. }
  65451. /**
  65452. * Interface that contains the data for the glTF asset.
  65453. */
  65454. export interface IGLTFLoaderData {
  65455. /**
  65456. * Object that represents the glTF JSON.
  65457. */
  65458. json: Object;
  65459. /**
  65460. * The BIN chunk of a binary glTF.
  65461. */
  65462. bin: Nullable<ArrayBufferView>;
  65463. }
  65464. /**
  65465. * Interface for extending the loader.
  65466. */
  65467. export interface IGLTFLoaderExtension {
  65468. /**
  65469. * The name of this extension.
  65470. */
  65471. readonly name: string;
  65472. /**
  65473. * Defines whether this extension is enabled.
  65474. */
  65475. enabled: boolean;
  65476. }
  65477. /**
  65478. * Loader state.
  65479. */
  65480. export enum GLTFLoaderState {
  65481. /**
  65482. * The asset is loading.
  65483. */
  65484. LOADING = 0,
  65485. /**
  65486. * The asset is ready for rendering.
  65487. */
  65488. READY = 1,
  65489. /**
  65490. * The asset is completely loaded.
  65491. */
  65492. COMPLETE = 2
  65493. }
  65494. /** @hidden */
  65495. export interface IGLTFLoader extends IDisposable {
  65496. readonly state: Nullable<GLTFLoaderState>;
  65497. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65498. meshes: AbstractMesh[];
  65499. particleSystems: IParticleSystem[];
  65500. skeletons: Skeleton[];
  65501. animationGroups: AnimationGroup[];
  65502. }>;
  65503. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65504. }
  65505. /**
  65506. * File loader for loading glTF files into a scene.
  65507. */
  65508. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65509. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65510. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65511. /**
  65512. * Raised when the asset has been parsed
  65513. */
  65514. onParsedObservable: Observable<IGLTFLoaderData>;
  65515. private _onParsedObserver;
  65516. /**
  65517. * Raised when the asset has been parsed
  65518. */
  65519. onParsed: (loaderData: IGLTFLoaderData) => void;
  65520. /**
  65521. * 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.
  65522. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65523. * Defaults to true.
  65524. * @hidden
  65525. */
  65526. static IncrementalLoading: boolean;
  65527. /**
  65528. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65529. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65530. * @hidden
  65531. */
  65532. static HomogeneousCoordinates: boolean;
  65533. /**
  65534. * The coordinate system mode. Defaults to AUTO.
  65535. */
  65536. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65537. /**
  65538. * The animation start mode. Defaults to FIRST.
  65539. */
  65540. animationStartMode: GLTFLoaderAnimationStartMode;
  65541. /**
  65542. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65543. */
  65544. compileMaterials: boolean;
  65545. /**
  65546. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65547. */
  65548. useClipPlane: boolean;
  65549. /**
  65550. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65551. */
  65552. compileShadowGenerators: boolean;
  65553. /**
  65554. * Defines if the Alpha blended materials are only applied as coverage.
  65555. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65556. * If true, no extra effects are applied to transparent pixels.
  65557. */
  65558. transparencyAsCoverage: boolean;
  65559. /**
  65560. * Function called before loading a url referenced by the asset.
  65561. */
  65562. preprocessUrlAsync: (url: string) => Promise<string>;
  65563. /**
  65564. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65565. */
  65566. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65567. private _onMeshLoadedObserver;
  65568. /**
  65569. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65570. */
  65571. onMeshLoaded: (mesh: AbstractMesh) => void;
  65572. /**
  65573. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65574. */
  65575. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65576. private _onTextureLoadedObserver;
  65577. /**
  65578. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65579. */
  65580. onTextureLoaded: (texture: BaseTexture) => void;
  65581. /**
  65582. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65583. */
  65584. readonly onMaterialLoadedObservable: Observable<Material>;
  65585. private _onMaterialLoadedObserver;
  65586. /**
  65587. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65588. */
  65589. onMaterialLoaded: (material: Material) => void;
  65590. /**
  65591. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65592. */
  65593. readonly onCameraLoadedObservable: Observable<Camera>;
  65594. private _onCameraLoadedObserver;
  65595. /**
  65596. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65597. */
  65598. onCameraLoaded: (camera: Camera) => void;
  65599. /**
  65600. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65601. * For assets with LODs, raised when all of the LODs are complete.
  65602. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65603. */
  65604. readonly onCompleteObservable: Observable<void>;
  65605. private _onCompleteObserver;
  65606. /**
  65607. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65608. * For assets with LODs, raised when all of the LODs are complete.
  65609. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65610. */
  65611. onComplete: () => void;
  65612. /**
  65613. * Observable raised when an error occurs.
  65614. */
  65615. readonly onErrorObservable: Observable<any>;
  65616. private _onErrorObserver;
  65617. /**
  65618. * Callback raised when an error occurs.
  65619. */
  65620. onError: (reason: any) => void;
  65621. /**
  65622. * Observable raised after the loader is disposed.
  65623. */
  65624. readonly onDisposeObservable: Observable<void>;
  65625. private _onDisposeObserver;
  65626. /**
  65627. * Callback raised after the loader is disposed.
  65628. */
  65629. onDispose: () => void;
  65630. /**
  65631. * Observable raised after a loader extension is created.
  65632. * Set additional options for a loader extension in this event.
  65633. */
  65634. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65635. private _onExtensionLoadedObserver;
  65636. /**
  65637. * Callback raised after a loader extension is created.
  65638. */
  65639. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65640. /**
  65641. * Defines if the loader logging is enabled.
  65642. */
  65643. loggingEnabled: boolean;
  65644. /**
  65645. * Defines if the loader should capture performance counters.
  65646. */
  65647. capturePerformanceCounters: boolean;
  65648. /**
  65649. * Defines if the loader should validate the asset.
  65650. */
  65651. validate: boolean;
  65652. /**
  65653. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65654. */
  65655. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65656. private _onValidatedObserver;
  65657. /**
  65658. * Callback raised after a loader extension is created.
  65659. */
  65660. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65661. private _loader;
  65662. /**
  65663. * Name of the loader ("gltf")
  65664. */
  65665. name: string;
  65666. /**
  65667. * Supported file extensions of the loader (.gltf, .glb)
  65668. */
  65669. extensions: ISceneLoaderPluginExtensions;
  65670. /**
  65671. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65672. */
  65673. dispose(): void;
  65674. /** @hidden */ private _clear(): void;
  65675. /**
  65676. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65677. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65678. * @param scene the scene the meshes should be added to
  65679. * @param data the glTF data to load
  65680. * @param rootUrl root url to load from
  65681. * @param onProgress event that fires when loading progress has occured
  65682. * @param fileName Defines the name of the file to load
  65683. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65684. */
  65685. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65686. meshes: AbstractMesh[];
  65687. particleSystems: IParticleSystem[];
  65688. skeletons: Skeleton[];
  65689. animationGroups: AnimationGroup[];
  65690. }>;
  65691. /**
  65692. * Imports all objects from the loaded glTF data and adds them to the scene
  65693. * @param scene the scene the objects should be added to
  65694. * @param data the glTF data to load
  65695. * @param rootUrl root url to load from
  65696. * @param onProgress event that fires when loading progress has occured
  65697. * @param fileName Defines the name of the file to load
  65698. * @returns a promise which completes when objects have been loaded to the scene
  65699. */
  65700. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65701. /**
  65702. * Load into an asset container.
  65703. * @param scene The scene to load into
  65704. * @param data The data to import
  65705. * @param rootUrl The root url for scene and resources
  65706. * @param onProgress The callback when the load progresses
  65707. * @param fileName Defines the name of the file to load
  65708. * @returns The loaded asset container
  65709. */
  65710. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65711. /**
  65712. * If the data string can be loaded directly.
  65713. * @param data string contianing the file data
  65714. * @returns if the data can be loaded directly
  65715. */
  65716. canDirectLoad(data: string): boolean;
  65717. /**
  65718. * Rewrites a url by combining a root url and response url.
  65719. */
  65720. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65721. /**
  65722. * Instantiates a glTF file loader plugin.
  65723. * @returns the created plugin
  65724. */
  65725. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65726. /**
  65727. * The loader state or null if the loader is not active.
  65728. */
  65729. readonly loaderState: Nullable<GLTFLoaderState>;
  65730. /**
  65731. * Returns a promise that resolves when the asset is completely loaded.
  65732. * @returns a promise that resolves when the asset is completely loaded.
  65733. */
  65734. whenCompleteAsync(): Promise<void>;
  65735. private _parseAsync;
  65736. private _validateAsync;
  65737. private _getLoader;
  65738. private _unpackBinary;
  65739. private _unpackBinaryV1;
  65740. private _unpackBinaryV2;
  65741. private static _parseVersion;
  65742. private static _compareVersion;
  65743. private static _decodeBufferToText;
  65744. private static readonly _logSpaces;
  65745. private _logIndentLevel;
  65746. private _loggingEnabled;
  65747. /** @hidden */ private _log: (message: string) => void;
  65748. /** @hidden */ private _logOpen(message: string): void;
  65749. /** @hidden */ private _logClose(): void;
  65750. private _logEnabled;
  65751. private _logDisabled;
  65752. private _capturePerformanceCounters;
  65753. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  65754. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  65755. private _startPerformanceCounterEnabled;
  65756. private _startPerformanceCounterDisabled;
  65757. private _endPerformanceCounterEnabled;
  65758. private _endPerformanceCounterDisabled;
  65759. }
  65760. }
  65761. declare module BABYLON.GLTF1 {
  65762. /**
  65763. * Enums
  65764. * @hidden
  65765. */
  65766. export enum EComponentType {
  65767. BYTE = 5120,
  65768. UNSIGNED_BYTE = 5121,
  65769. SHORT = 5122,
  65770. UNSIGNED_SHORT = 5123,
  65771. FLOAT = 5126
  65772. }
  65773. /** @hidden */
  65774. export enum EShaderType {
  65775. FRAGMENT = 35632,
  65776. VERTEX = 35633
  65777. }
  65778. /** @hidden */
  65779. export enum EParameterType {
  65780. BYTE = 5120,
  65781. UNSIGNED_BYTE = 5121,
  65782. SHORT = 5122,
  65783. UNSIGNED_SHORT = 5123,
  65784. INT = 5124,
  65785. UNSIGNED_INT = 5125,
  65786. FLOAT = 5126,
  65787. FLOAT_VEC2 = 35664,
  65788. FLOAT_VEC3 = 35665,
  65789. FLOAT_VEC4 = 35666,
  65790. INT_VEC2 = 35667,
  65791. INT_VEC3 = 35668,
  65792. INT_VEC4 = 35669,
  65793. BOOL = 35670,
  65794. BOOL_VEC2 = 35671,
  65795. BOOL_VEC3 = 35672,
  65796. BOOL_VEC4 = 35673,
  65797. FLOAT_MAT2 = 35674,
  65798. FLOAT_MAT3 = 35675,
  65799. FLOAT_MAT4 = 35676,
  65800. SAMPLER_2D = 35678
  65801. }
  65802. /** @hidden */
  65803. export enum ETextureWrapMode {
  65804. CLAMP_TO_EDGE = 33071,
  65805. MIRRORED_REPEAT = 33648,
  65806. REPEAT = 10497
  65807. }
  65808. /** @hidden */
  65809. export enum ETextureFilterType {
  65810. NEAREST = 9728,
  65811. LINEAR = 9728,
  65812. NEAREST_MIPMAP_NEAREST = 9984,
  65813. LINEAR_MIPMAP_NEAREST = 9985,
  65814. NEAREST_MIPMAP_LINEAR = 9986,
  65815. LINEAR_MIPMAP_LINEAR = 9987
  65816. }
  65817. /** @hidden */
  65818. export enum ETextureFormat {
  65819. ALPHA = 6406,
  65820. RGB = 6407,
  65821. RGBA = 6408,
  65822. LUMINANCE = 6409,
  65823. LUMINANCE_ALPHA = 6410
  65824. }
  65825. /** @hidden */
  65826. export enum ECullingType {
  65827. FRONT = 1028,
  65828. BACK = 1029,
  65829. FRONT_AND_BACK = 1032
  65830. }
  65831. /** @hidden */
  65832. export enum EBlendingFunction {
  65833. ZERO = 0,
  65834. ONE = 1,
  65835. SRC_COLOR = 768,
  65836. ONE_MINUS_SRC_COLOR = 769,
  65837. DST_COLOR = 774,
  65838. ONE_MINUS_DST_COLOR = 775,
  65839. SRC_ALPHA = 770,
  65840. ONE_MINUS_SRC_ALPHA = 771,
  65841. DST_ALPHA = 772,
  65842. ONE_MINUS_DST_ALPHA = 773,
  65843. CONSTANT_COLOR = 32769,
  65844. ONE_MINUS_CONSTANT_COLOR = 32770,
  65845. CONSTANT_ALPHA = 32771,
  65846. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65847. SRC_ALPHA_SATURATE = 776
  65848. }
  65849. /** @hidden */
  65850. export interface IGLTFProperty {
  65851. extensions?: {
  65852. [key: string]: any;
  65853. };
  65854. extras?: Object;
  65855. }
  65856. /** @hidden */
  65857. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65858. name?: string;
  65859. }
  65860. /** @hidden */
  65861. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65862. bufferView: string;
  65863. byteOffset: number;
  65864. byteStride: number;
  65865. count: number;
  65866. type: string;
  65867. componentType: EComponentType;
  65868. max?: number[];
  65869. min?: number[];
  65870. name?: string;
  65871. }
  65872. /** @hidden */
  65873. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65874. buffer: string;
  65875. byteOffset: number;
  65876. byteLength: number;
  65877. byteStride: number;
  65878. target?: number;
  65879. }
  65880. /** @hidden */
  65881. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65882. uri: string;
  65883. byteLength?: number;
  65884. type?: string;
  65885. }
  65886. /** @hidden */
  65887. export interface IGLTFShader extends IGLTFChildRootProperty {
  65888. uri: string;
  65889. type: EShaderType;
  65890. }
  65891. /** @hidden */
  65892. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65893. attributes: string[];
  65894. fragmentShader: string;
  65895. vertexShader: string;
  65896. }
  65897. /** @hidden */
  65898. export interface IGLTFTechniqueParameter {
  65899. type: number;
  65900. count?: number;
  65901. semantic?: string;
  65902. node?: string;
  65903. value?: number | boolean | string | Array<any>;
  65904. source?: string;
  65905. babylonValue?: any;
  65906. }
  65907. /** @hidden */
  65908. export interface IGLTFTechniqueCommonProfile {
  65909. lightingModel: string;
  65910. texcoordBindings: Object;
  65911. parameters?: Array<any>;
  65912. }
  65913. /** @hidden */
  65914. export interface IGLTFTechniqueStatesFunctions {
  65915. blendColor?: number[];
  65916. blendEquationSeparate?: number[];
  65917. blendFuncSeparate?: number[];
  65918. colorMask: boolean[];
  65919. cullFace: number[];
  65920. }
  65921. /** @hidden */
  65922. export interface IGLTFTechniqueStates {
  65923. enable: number[];
  65924. functions: IGLTFTechniqueStatesFunctions;
  65925. }
  65926. /** @hidden */
  65927. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65928. parameters: {
  65929. [key: string]: IGLTFTechniqueParameter;
  65930. };
  65931. program: string;
  65932. attributes: {
  65933. [key: string]: string;
  65934. };
  65935. uniforms: {
  65936. [key: string]: string;
  65937. };
  65938. states: IGLTFTechniqueStates;
  65939. }
  65940. /** @hidden */
  65941. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65942. technique?: string;
  65943. values: string[];
  65944. }
  65945. /** @hidden */
  65946. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65947. attributes: {
  65948. [key: string]: string;
  65949. };
  65950. indices: string;
  65951. material: string;
  65952. mode?: number;
  65953. }
  65954. /** @hidden */
  65955. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65956. primitives: IGLTFMeshPrimitive[];
  65957. }
  65958. /** @hidden */
  65959. export interface IGLTFImage extends IGLTFChildRootProperty {
  65960. uri: string;
  65961. }
  65962. /** @hidden */
  65963. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65964. magFilter?: number;
  65965. minFilter?: number;
  65966. wrapS?: number;
  65967. wrapT?: number;
  65968. }
  65969. /** @hidden */
  65970. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65971. sampler: string;
  65972. source: string;
  65973. format?: ETextureFormat;
  65974. internalFormat?: ETextureFormat;
  65975. target?: number;
  65976. type?: number;
  65977. babylonTexture?: Texture;
  65978. }
  65979. /** @hidden */
  65980. export interface IGLTFAmbienLight {
  65981. color?: number[];
  65982. }
  65983. /** @hidden */
  65984. export interface IGLTFDirectionalLight {
  65985. color?: number[];
  65986. }
  65987. /** @hidden */
  65988. export interface IGLTFPointLight {
  65989. color?: number[];
  65990. constantAttenuation?: number;
  65991. linearAttenuation?: number;
  65992. quadraticAttenuation?: number;
  65993. }
  65994. /** @hidden */
  65995. export interface IGLTFSpotLight {
  65996. color?: number[];
  65997. constantAttenuation?: number;
  65998. fallOfAngle?: number;
  65999. fallOffExponent?: number;
  66000. linearAttenuation?: number;
  66001. quadraticAttenuation?: number;
  66002. }
  66003. /** @hidden */
  66004. export interface IGLTFLight extends IGLTFChildRootProperty {
  66005. type: string;
  66006. }
  66007. /** @hidden */
  66008. export interface IGLTFCameraOrthographic {
  66009. xmag: number;
  66010. ymag: number;
  66011. zfar: number;
  66012. znear: number;
  66013. }
  66014. /** @hidden */
  66015. export interface IGLTFCameraPerspective {
  66016. aspectRatio: number;
  66017. yfov: number;
  66018. zfar: number;
  66019. znear: number;
  66020. }
  66021. /** @hidden */
  66022. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66023. type: string;
  66024. }
  66025. /** @hidden */
  66026. export interface IGLTFAnimationChannelTarget {
  66027. id: string;
  66028. path: string;
  66029. }
  66030. /** @hidden */
  66031. export interface IGLTFAnimationChannel {
  66032. sampler: string;
  66033. target: IGLTFAnimationChannelTarget;
  66034. }
  66035. /** @hidden */
  66036. export interface IGLTFAnimationSampler {
  66037. input: string;
  66038. output: string;
  66039. interpolation?: string;
  66040. }
  66041. /** @hidden */
  66042. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66043. channels?: IGLTFAnimationChannel[];
  66044. parameters?: {
  66045. [key: string]: string;
  66046. };
  66047. samplers?: {
  66048. [key: string]: IGLTFAnimationSampler;
  66049. };
  66050. }
  66051. /** @hidden */
  66052. export interface IGLTFNodeInstanceSkin {
  66053. skeletons: string[];
  66054. skin: string;
  66055. meshes: string[];
  66056. }
  66057. /** @hidden */
  66058. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66059. bindShapeMatrix: number[];
  66060. inverseBindMatrices: string;
  66061. jointNames: string[];
  66062. babylonSkeleton?: Skeleton;
  66063. }
  66064. /** @hidden */
  66065. export interface IGLTFNode extends IGLTFChildRootProperty {
  66066. camera?: string;
  66067. children: string[];
  66068. skin?: string;
  66069. jointName?: string;
  66070. light?: string;
  66071. matrix: number[];
  66072. mesh?: string;
  66073. meshes?: string[];
  66074. rotation?: number[];
  66075. scale?: number[];
  66076. translation?: number[];
  66077. babylonNode?: Node;
  66078. }
  66079. /** @hidden */
  66080. export interface IGLTFScene extends IGLTFChildRootProperty {
  66081. nodes: string[];
  66082. }
  66083. /** @hidden */
  66084. export interface IGLTFRuntime {
  66085. extensions: {
  66086. [key: string]: any;
  66087. };
  66088. accessors: {
  66089. [key: string]: IGLTFAccessor;
  66090. };
  66091. buffers: {
  66092. [key: string]: IGLTFBuffer;
  66093. };
  66094. bufferViews: {
  66095. [key: string]: IGLTFBufferView;
  66096. };
  66097. meshes: {
  66098. [key: string]: IGLTFMesh;
  66099. };
  66100. lights: {
  66101. [key: string]: IGLTFLight;
  66102. };
  66103. cameras: {
  66104. [key: string]: IGLTFCamera;
  66105. };
  66106. nodes: {
  66107. [key: string]: IGLTFNode;
  66108. };
  66109. images: {
  66110. [key: string]: IGLTFImage;
  66111. };
  66112. textures: {
  66113. [key: string]: IGLTFTexture;
  66114. };
  66115. shaders: {
  66116. [key: string]: IGLTFShader;
  66117. };
  66118. programs: {
  66119. [key: string]: IGLTFProgram;
  66120. };
  66121. samplers: {
  66122. [key: string]: IGLTFSampler;
  66123. };
  66124. techniques: {
  66125. [key: string]: IGLTFTechnique;
  66126. };
  66127. materials: {
  66128. [key: string]: IGLTFMaterial;
  66129. };
  66130. animations: {
  66131. [key: string]: IGLTFAnimation;
  66132. };
  66133. skins: {
  66134. [key: string]: IGLTFSkins;
  66135. };
  66136. currentScene?: Object;
  66137. scenes: {
  66138. [key: string]: IGLTFScene;
  66139. };
  66140. extensionsUsed: string[];
  66141. extensionsRequired?: string[];
  66142. buffersCount: number;
  66143. shaderscount: number;
  66144. scene: Scene;
  66145. rootUrl: string;
  66146. loadedBufferCount: number;
  66147. loadedBufferViews: {
  66148. [name: string]: ArrayBufferView;
  66149. };
  66150. loadedShaderCount: number;
  66151. importOnlyMeshes: boolean;
  66152. importMeshesNames?: string[];
  66153. dummyNodes: Node[];
  66154. }
  66155. /** @hidden */
  66156. export interface INodeToRoot {
  66157. bone: Bone;
  66158. node: IGLTFNode;
  66159. id: string;
  66160. }
  66161. /** @hidden */
  66162. export interface IJointNode {
  66163. node: IGLTFNode;
  66164. id: string;
  66165. }
  66166. }
  66167. declare module BABYLON.GLTF1 {
  66168. /**
  66169. * Utils functions for GLTF
  66170. * @hidden
  66171. */
  66172. export class GLTFUtils {
  66173. /**
  66174. * Sets the given "parameter" matrix
  66175. * @param scene: the Scene object
  66176. * @param source: the source node where to pick the matrix
  66177. * @param parameter: the GLTF technique parameter
  66178. * @param uniformName: the name of the shader's uniform
  66179. * @param shaderMaterial: the shader material
  66180. */
  66181. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66182. /**
  66183. * Sets the given "parameter" matrix
  66184. * @param shaderMaterial: the shader material
  66185. * @param uniform: the name of the shader's uniform
  66186. * @param value: the value of the uniform
  66187. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66188. */
  66189. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66190. /**
  66191. * Returns the wrap mode of the texture
  66192. * @param mode: the mode value
  66193. */
  66194. static GetWrapMode(mode: number): number;
  66195. /**
  66196. * Returns the byte stride giving an accessor
  66197. * @param accessor: the GLTF accessor objet
  66198. */
  66199. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66200. /**
  66201. * Returns the texture filter mode giving a mode value
  66202. * @param mode: the filter mode value
  66203. */
  66204. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66205. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66206. /**
  66207. * Returns a buffer from its accessor
  66208. * @param gltfRuntime: the GLTF runtime
  66209. * @param accessor: the GLTF accessor
  66210. */
  66211. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66212. /**
  66213. * Decodes a buffer view into a string
  66214. * @param view: the buffer view
  66215. */
  66216. static DecodeBufferToText(view: ArrayBufferView): string;
  66217. /**
  66218. * Returns the default material of gltf. Related to
  66219. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66220. * @param scene: the Babylon.js scene
  66221. */
  66222. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66223. private static _DefaultMaterial;
  66224. }
  66225. }
  66226. declare module BABYLON.GLTF1 {
  66227. /**
  66228. * Implementation of the base glTF spec
  66229. * @hidden
  66230. */
  66231. export class GLTFLoaderBase {
  66232. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66233. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66234. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66235. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66236. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66237. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66238. }
  66239. /**
  66240. * glTF V1 Loader
  66241. * @hidden
  66242. */
  66243. export class GLTFLoader implements IGLTFLoader {
  66244. static Extensions: {
  66245. [name: string]: GLTFLoaderExtension;
  66246. };
  66247. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66248. state: Nullable<GLTFLoaderState>;
  66249. dispose(): void;
  66250. private _importMeshAsync;
  66251. /**
  66252. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66253. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66254. * @param scene the scene the meshes should be added to
  66255. * @param data gltf data containing information of the meshes in a loaded file
  66256. * @param rootUrl root url to load from
  66257. * @param onProgress event that fires when loading progress has occured
  66258. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66259. */
  66260. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66261. meshes: AbstractMesh[];
  66262. particleSystems: IParticleSystem[];
  66263. skeletons: Skeleton[];
  66264. animationGroups: AnimationGroup[];
  66265. }>;
  66266. private _loadAsync;
  66267. /**
  66268. * Imports all objects from a loaded gltf file and adds them to the scene
  66269. * @param scene the scene the objects should be added to
  66270. * @param data gltf data containing information of the meshes in a loaded file
  66271. * @param rootUrl root url to load from
  66272. * @param onProgress event that fires when loading progress has occured
  66273. * @returns a promise which completes when objects have been loaded to the scene
  66274. */
  66275. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66276. private _loadShadersAsync;
  66277. private _loadBuffersAsync;
  66278. private _createNodes;
  66279. }
  66280. /** @hidden */
  66281. export abstract class GLTFLoaderExtension {
  66282. private _name;
  66283. constructor(name: string);
  66284. readonly name: string;
  66285. /**
  66286. * Defines an override for loading the runtime
  66287. * Return true to stop further extensions from loading the runtime
  66288. */
  66289. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66290. /**
  66291. * Defines an onverride for creating gltf runtime
  66292. * Return true to stop further extensions from creating the runtime
  66293. */
  66294. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66295. /**
  66296. * Defines an override for loading buffers
  66297. * Return true to stop further extensions from loading this buffer
  66298. */
  66299. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66300. /**
  66301. * Defines an override for loading texture buffers
  66302. * Return true to stop further extensions from loading this texture data
  66303. */
  66304. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66305. /**
  66306. * Defines an override for creating textures
  66307. * Return true to stop further extensions from loading this texture
  66308. */
  66309. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66310. /**
  66311. * Defines an override for loading shader strings
  66312. * Return true to stop further extensions from loading this shader data
  66313. */
  66314. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66315. /**
  66316. * Defines an override for loading materials
  66317. * Return true to stop further extensions from loading this material
  66318. */
  66319. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66320. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66321. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66322. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66323. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66324. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66325. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66326. private static LoadTextureBufferAsync;
  66327. private static CreateTextureAsync;
  66328. private static ApplyExtensions;
  66329. }
  66330. }
  66331. declare module BABYLON.GLTF1 {
  66332. /** @hidden */
  66333. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66334. private _bin;
  66335. constructor();
  66336. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66337. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66338. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66339. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66340. }
  66341. }
  66342. declare module BABYLON.GLTF1 {
  66343. /** @hidden */
  66344. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66345. constructor();
  66346. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66347. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66348. private _loadTexture;
  66349. }
  66350. }
  66351. declare module BABYLON.GLTF2.Loader {
  66352. /**
  66353. * Loader interface with an index field.
  66354. */
  66355. export interface IArrayItem {
  66356. /**
  66357. * The index of this item in the array.
  66358. */
  66359. index: number;
  66360. }
  66361. /**
  66362. * Loader interface with additional members.
  66363. */
  66364. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66365. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66366. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  66367. }
  66368. /**
  66369. * Loader interface with additional members.
  66370. */
  66371. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66372. }
  66373. /** @hidden */
  66374. export interface _IAnimationSamplerData {
  66375. input: Float32Array;
  66376. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66377. output: Float32Array;
  66378. }
  66379. /**
  66380. * Loader interface with additional members.
  66381. */
  66382. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66383. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  66384. }
  66385. /**
  66386. * Loader interface with additional members.
  66387. */
  66388. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66389. channels: IAnimationChannel[];
  66390. samplers: IAnimationSampler[];
  66391. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  66392. }
  66393. /**
  66394. * Loader interface with additional members.
  66395. */
  66396. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66397. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66398. }
  66399. /**
  66400. * Loader interface with additional members.
  66401. */
  66402. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66403. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66404. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  66405. }
  66406. /**
  66407. * Loader interface with additional members.
  66408. */
  66409. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66410. }
  66411. /**
  66412. * Loader interface with additional members.
  66413. */
  66414. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66415. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66416. }
  66417. /**
  66418. * Loader interface with additional members.
  66419. */
  66420. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66421. }
  66422. /**
  66423. * Loader interface with additional members.
  66424. */
  66425. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66426. }
  66427. /**
  66428. * Loader interface with additional members.
  66429. */
  66430. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66431. baseColorTexture?: ITextureInfo;
  66432. metallicRoughnessTexture?: ITextureInfo;
  66433. }
  66434. /**
  66435. * Loader interface with additional members.
  66436. */
  66437. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66438. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66439. normalTexture?: IMaterialNormalTextureInfo;
  66440. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66441. emissiveTexture?: ITextureInfo;
  66442. /** @hidden */ private _data?: {
  66443. [babylonDrawMode: number]: {
  66444. babylonMaterial: Material;
  66445. babylonMeshes: AbstractMesh[];
  66446. promise: Promise<void>;
  66447. };
  66448. };
  66449. }
  66450. /**
  66451. * Loader interface with additional members.
  66452. */
  66453. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66454. primitives: IMeshPrimitive[];
  66455. }
  66456. /**
  66457. * Loader interface with additional members.
  66458. */
  66459. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66460. /** @hidden */ private _instanceData?: {
  66461. babylonSourceMesh: Mesh;
  66462. promise: Promise<any>;
  66463. };
  66464. }
  66465. /**
  66466. * Loader interface with additional members.
  66467. */
  66468. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66469. /**
  66470. * The parent glTF node.
  66471. */
  66472. parent?: INode;
  66473. /** @hidden */ private _babylonTransformNode?: TransformNode;
  66474. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  66475. /** @hidden */ private _babylonBones?: Bone[];
  66476. /** @hidden */ private _numMorphTargets?: number;
  66477. }
  66478. /** @hidden */
  66479. export interface _ISamplerData {
  66480. noMipMaps: boolean;
  66481. samplingMode: number;
  66482. wrapU: number;
  66483. wrapV: number;
  66484. }
  66485. /**
  66486. * Loader interface with additional members.
  66487. */
  66488. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66489. /** @hidden */ private _data?: _ISamplerData;
  66490. }
  66491. /**
  66492. * Loader interface with additional members.
  66493. */
  66494. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66495. }
  66496. /**
  66497. * Loader interface with additional members.
  66498. */
  66499. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66500. /** @hidden */ private _data?: {
  66501. babylonSkeleton: Skeleton;
  66502. promise: Promise<void>;
  66503. };
  66504. }
  66505. /**
  66506. * Loader interface with additional members.
  66507. */
  66508. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66509. }
  66510. /**
  66511. * Loader interface with additional members.
  66512. */
  66513. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66514. }
  66515. /**
  66516. * Loader interface with additional members.
  66517. */
  66518. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66519. accessors?: IAccessor[];
  66520. animations?: IAnimation[];
  66521. buffers?: IBuffer[];
  66522. bufferViews?: IBufferView[];
  66523. cameras?: ICamera[];
  66524. images?: IImage[];
  66525. materials?: IMaterial[];
  66526. meshes?: IMesh[];
  66527. nodes?: INode[];
  66528. samplers?: ISampler[];
  66529. scenes?: IScene[];
  66530. skins?: ISkin[];
  66531. textures?: ITexture[];
  66532. }
  66533. }
  66534. declare module BABYLON.GLTF2 {
  66535. /**
  66536. * Interface for a glTF loader extension.
  66537. */
  66538. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66539. /**
  66540. * Called after the loader state changes to LOADING.
  66541. */
  66542. onLoading?(): void;
  66543. /**
  66544. * Called after the loader state changes to READY.
  66545. */
  66546. onReady?(): void;
  66547. /**
  66548. * Define this method to modify the default behavior when loading scenes.
  66549. * @param context The context when loading the asset
  66550. * @param scene The glTF scene property
  66551. * @returns A promise that resolves when the load is complete or null if not handled
  66552. */
  66553. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66554. /**
  66555. * Define this method to modify the default behavior when loading nodes.
  66556. * @param context The context when loading the asset
  66557. * @param node The glTF node property
  66558. * @param assign A function called synchronously after parsing the glTF properties
  66559. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66560. */
  66561. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66562. /**
  66563. * Define this method to modify the default behavior when loading cameras.
  66564. * @param context The context when loading the asset
  66565. * @param camera The glTF camera property
  66566. * @param assign A function called synchronously after parsing the glTF properties
  66567. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66568. */
  66569. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66570. /**
  66571. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66572. * @param context The context when loading the asset
  66573. * @param primitive The glTF mesh primitive property
  66574. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66575. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66576. /**
  66577. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66578. * @param context The context when loading the asset
  66579. * @param name The mesh name when loading the asset
  66580. * @param node The glTF node when loading the asset
  66581. * @param mesh The glTF mesh when loading the asset
  66582. * @param primitive The glTF mesh primitive property
  66583. * @param assign A function called synchronously after parsing the glTF properties
  66584. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66585. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66586. /**
  66587. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66588. * @param context The context when loading the asset
  66589. * @param material The glTF material property
  66590. * @param assign A function called synchronously after parsing the glTF properties
  66591. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66592. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66593. /**
  66594. * Define this method to modify the default behavior when creating materials.
  66595. * @param context The context when loading the asset
  66596. * @param material The glTF material property
  66597. * @param babylonDrawMode The draw mode for the Babylon material
  66598. * @returns The Babylon material or null if not handled
  66599. */
  66600. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66601. /**
  66602. * Define this method to modify the default behavior when loading material properties.
  66603. * @param context The context when loading the asset
  66604. * @param material The glTF material property
  66605. * @param babylonMaterial The Babylon material
  66606. * @returns A promise that resolves when the load is complete or null if not handled
  66607. */
  66608. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66609. /**
  66610. * Define this method to modify the default behavior when loading texture infos.
  66611. * @param context The context when loading the asset
  66612. * @param textureInfo The glTF texture info property
  66613. * @param assign A function called synchronously after parsing the glTF properties
  66614. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66615. */
  66616. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66617. /**
  66618. * Define this method to modify the default behavior when loading animations.
  66619. * @param context The context when loading the asset
  66620. * @param animation The glTF animation property
  66621. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66622. */
  66623. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66624. /**
  66625. * @hidden Define this method to modify the default behavior when loading skins.
  66626. * @param context The context when loading the asset
  66627. * @param node The glTF node property
  66628. * @param skin The glTF skin property
  66629. * @returns A promise that resolves when the load is complete or null if not handled
  66630. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66631. /**
  66632. * @hidden Define this method to modify the default behavior when loading uris.
  66633. * @param context The context when loading the asset
  66634. * @param property The glTF property associated with the uri
  66635. * @param uri The uri to load
  66636. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66637. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66638. }
  66639. }
  66640. declare module BABYLON.GLTF2 {
  66641. /**
  66642. * Helper class for working with arrays when loading the glTF asset
  66643. */
  66644. export class ArrayItem {
  66645. /**
  66646. * Gets an item from the given array.
  66647. * @param context The context when loading the asset
  66648. * @param array The array to get the item from
  66649. * @param index The index to the array
  66650. * @returns The array item
  66651. */
  66652. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66653. /**
  66654. * Assign an `index` field to each item of the given array.
  66655. * @param array The array of items
  66656. */
  66657. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66658. }
  66659. /**
  66660. * The glTF 2.0 loader
  66661. */
  66662. export class GLTFLoader implements IGLTFLoader {
  66663. /** @hidden */ private _completePromises: Promise<any>[];
  66664. private _disposed;
  66665. private _parent;
  66666. private _state;
  66667. private _extensions;
  66668. private _rootUrl;
  66669. private _fileName;
  66670. private _uniqueRootUrl;
  66671. private _gltf;
  66672. private _babylonScene;
  66673. private _rootBabylonMesh;
  66674. private _defaultBabylonMaterialData;
  66675. private _progressCallback?;
  66676. private _requests;
  66677. private static readonly _DefaultSampler;
  66678. private static _ExtensionNames;
  66679. private static _ExtensionFactories;
  66680. /**
  66681. * Registers a loader extension.
  66682. * @param name The name of the loader extension.
  66683. * @param factory The factory function that creates the loader extension.
  66684. */
  66685. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66686. /**
  66687. * Unregisters a loader extension.
  66688. * @param name The name of the loader extenion.
  66689. * @returns A boolean indicating whether the extension has been unregistered
  66690. */
  66691. static UnregisterExtension(name: string): boolean;
  66692. /**
  66693. * Gets the loader state.
  66694. */
  66695. readonly state: Nullable<GLTFLoaderState>;
  66696. /**
  66697. * The glTF object parsed from the JSON.
  66698. */
  66699. readonly gltf: IGLTF;
  66700. /**
  66701. * The Babylon scene when loading the asset.
  66702. */
  66703. readonly babylonScene: Scene;
  66704. /**
  66705. * The root Babylon mesh when loading the asset.
  66706. */
  66707. readonly rootBabylonMesh: Mesh;
  66708. /** @hidden */
  66709. constructor(parent: GLTFFileLoader);
  66710. /** @hidden */
  66711. dispose(): void;
  66712. /** @hidden */
  66713. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66714. meshes: AbstractMesh[];
  66715. particleSystems: IParticleSystem[];
  66716. skeletons: Skeleton[];
  66717. animationGroups: AnimationGroup[];
  66718. }>;
  66719. /** @hidden */
  66720. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66721. private _loadAsync;
  66722. private _loadData;
  66723. private _setupData;
  66724. private _loadExtensions;
  66725. private _checkExtensions;
  66726. private _setState;
  66727. private _createRootNode;
  66728. /**
  66729. * Loads a glTF scene.
  66730. * @param context The context when loading the asset
  66731. * @param scene The glTF scene property
  66732. * @returns A promise that resolves when the load is complete
  66733. */
  66734. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66735. private _forEachPrimitive;
  66736. private _getMeshes;
  66737. private _getSkeletons;
  66738. private _getAnimationGroups;
  66739. private _startAnimations;
  66740. /**
  66741. * Loads a glTF node.
  66742. * @param context The context when loading the asset
  66743. * @param node The glTF node property
  66744. * @param assign A function called synchronously after parsing the glTF properties
  66745. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66746. */
  66747. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66748. private _loadMeshAsync;
  66749. /**
  66750. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66751. * @param context The context when loading the asset
  66752. * @param name The mesh name when loading the asset
  66753. * @param node The glTF node when loading the asset
  66754. * @param mesh The glTF mesh when loading the asset
  66755. * @param primitive The glTF mesh primitive property
  66756. * @param assign A function called synchronously after parsing the glTF properties
  66757. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66758. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66759. private _loadVertexDataAsync;
  66760. private _createMorphTargets;
  66761. private _loadMorphTargetsAsync;
  66762. private _loadMorphTargetVertexDataAsync;
  66763. private static _LoadTransform;
  66764. private _loadSkinAsync;
  66765. private _loadBones;
  66766. private _loadBone;
  66767. private _loadSkinInverseBindMatricesDataAsync;
  66768. private _updateBoneMatrices;
  66769. private _getNodeMatrix;
  66770. /**
  66771. * Loads a glTF camera.
  66772. * @param context The context when loading the asset
  66773. * @param camera The glTF camera property
  66774. * @param assign A function called synchronously after parsing the glTF properties
  66775. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66776. */
  66777. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66778. private _loadAnimationsAsync;
  66779. /**
  66780. * Loads a glTF animation.
  66781. * @param context The context when loading the asset
  66782. * @param animation The glTF animation property
  66783. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66784. */
  66785. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66786. /**
  66787. * @hidden Loads a glTF animation channel.
  66788. * @param context The context when loading the asset
  66789. * @param animationContext The context of the animation when loading the asset
  66790. * @param animation The glTF animation property
  66791. * @param channel The glTF animation channel property
  66792. * @param babylonAnimationGroup The babylon animation group property
  66793. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66794. * @returns A void promise when the channel load is complete
  66795. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66796. private _loadAnimationSamplerAsync;
  66797. private _loadBufferAsync;
  66798. /**
  66799. * Loads a glTF buffer view.
  66800. * @param context The context when loading the asset
  66801. * @param bufferView The glTF buffer view property
  66802. * @returns A promise that resolves with the loaded data when the load is complete
  66803. */
  66804. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66805. private _loadAccessorAsync;
  66806. private _loadFloatAccessorAsync;
  66807. private _loadIndicesAccessorAsync;
  66808. private _loadVertexBufferViewAsync;
  66809. private _loadVertexAccessorAsync;
  66810. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66811. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66812. private _createDefaultMaterial;
  66813. /**
  66814. * Creates a Babylon material from a glTF material.
  66815. * @param context The context when loading the asset
  66816. * @param material The glTF material property
  66817. * @param babylonDrawMode The draw mode for the Babylon material
  66818. * @returns The Babylon material
  66819. */
  66820. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66821. /**
  66822. * Loads properties from a glTF material into a Babylon material.
  66823. * @param context The context when loading the asset
  66824. * @param material The glTF material property
  66825. * @param babylonMaterial The Babylon material
  66826. * @returns A promise that resolves when the load is complete
  66827. */
  66828. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66829. /**
  66830. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66831. * @param context The context when loading the asset
  66832. * @param material The glTF material property
  66833. * @param babylonMaterial The Babylon material
  66834. * @returns A promise that resolves when the load is complete
  66835. */
  66836. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66837. /**
  66838. * Loads the alpha properties from a glTF material into a Babylon material.
  66839. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66840. * @param context The context when loading the asset
  66841. * @param material The glTF material property
  66842. * @param babylonMaterial The Babylon material
  66843. */
  66844. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66845. /**
  66846. * Loads a glTF texture info.
  66847. * @param context The context when loading the asset
  66848. * @param textureInfo The glTF texture info property
  66849. * @param assign A function called synchronously after parsing the glTF properties
  66850. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66851. */
  66852. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66853. private _loadTextureAsync;
  66854. private _loadSampler;
  66855. /**
  66856. * Loads a glTF image.
  66857. * @param context The context when loading the asset
  66858. * @param image The glTF image property
  66859. * @returns A promise that resolves with the loaded data when the load is complete
  66860. */
  66861. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66862. /**
  66863. * Loads a glTF uri.
  66864. * @param context The context when loading the asset
  66865. * @param property The glTF property associated with the uri
  66866. * @param uri The base64 or relative uri
  66867. * @returns A promise that resolves with the loaded data when the load is complete
  66868. */
  66869. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66870. private _onProgress;
  66871. /**
  66872. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66873. * @param babylonObject the Babylon object with metadata
  66874. * @param pointer the JSON pointer
  66875. */
  66876. static AddPointerMetadata(babylonObject: {
  66877. metadata: any;
  66878. }, pointer: string): void;
  66879. private static _GetTextureWrapMode;
  66880. private static _GetTextureSamplingMode;
  66881. private static _GetTypedArrayConstructor;
  66882. private static _GetTypedArray;
  66883. private static _GetNumComponents;
  66884. private static _ValidateUri;
  66885. private static _GetDrawMode;
  66886. private _compileMaterialsAsync;
  66887. private _compileShadowGeneratorsAsync;
  66888. private _forEachExtensions;
  66889. private _applyExtensions;
  66890. private _extensionsOnLoading;
  66891. private _extensionsOnReady;
  66892. private _extensionsLoadSceneAsync;
  66893. private _extensionsLoadNodeAsync;
  66894. private _extensionsLoadCameraAsync;
  66895. private _extensionsLoadVertexDataAsync;
  66896. private _extensionsLoadMeshPrimitiveAsync;
  66897. private _extensionsLoadMaterialAsync;
  66898. private _extensionsCreateMaterial;
  66899. private _extensionsLoadMaterialPropertiesAsync;
  66900. private _extensionsLoadTextureInfoAsync;
  66901. private _extensionsLoadAnimationAsync;
  66902. private _extensionsLoadSkinAsync;
  66903. private _extensionsLoadUriAsync;
  66904. /**
  66905. * Helper method called by a loader extension to load an glTF extension.
  66906. * @param context The context when loading the asset
  66907. * @param property The glTF property to load the extension from
  66908. * @param extensionName The name of the extension to load
  66909. * @param actionAsync The action to run
  66910. * @returns The promise returned by actionAsync or null if the extension does not exist
  66911. */
  66912. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66913. /**
  66914. * Helper method called by a loader extension to load a glTF extra.
  66915. * @param context The context when loading the asset
  66916. * @param property The glTF property to load the extra from
  66917. * @param extensionName The name of the extension to load
  66918. * @param actionAsync The action to run
  66919. * @returns The promise returned by actionAsync or null if the extra does not exist
  66920. */
  66921. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66922. /**
  66923. * Increments the indentation level and logs a message.
  66924. * @param message The message to log
  66925. */
  66926. logOpen(message: string): void;
  66927. /**
  66928. * Decrements the indentation level.
  66929. */
  66930. logClose(): void;
  66931. /**
  66932. * Logs a message
  66933. * @param message The message to log
  66934. */
  66935. log(message: string): void;
  66936. /**
  66937. * Starts a performance counter.
  66938. * @param counterName The name of the performance counter
  66939. */
  66940. startPerformanceCounter(counterName: string): void;
  66941. /**
  66942. * Ends a performance counter.
  66943. * @param counterName The name of the performance counter
  66944. */
  66945. endPerformanceCounter(counterName: string): void;
  66946. }
  66947. }
  66948. declare module BABYLON.GLTF2.Loader.Extensions {
  66949. /**
  66950. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66951. */
  66952. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66953. /** The name of this extension. */
  66954. readonly name: string;
  66955. /** Defines whether this extension is enabled. */
  66956. enabled: boolean;
  66957. private _loader;
  66958. private _lights?;
  66959. /** @hidden */
  66960. constructor(loader: GLTFLoader);
  66961. /** @hidden */
  66962. dispose(): void;
  66963. /** @hidden */
  66964. onLoading(): void;
  66965. /** @hidden */
  66966. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66967. private _loadLightAsync;
  66968. }
  66969. }
  66970. declare module BABYLON.GLTF2.Loader.Extensions {
  66971. /**
  66972. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  66973. */
  66974. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66975. /** The name of this extension. */
  66976. readonly name: string;
  66977. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66978. dracoCompression?: DracoCompression;
  66979. /** Defines whether this extension is enabled. */
  66980. enabled: boolean;
  66981. private _loader;
  66982. /** @hidden */
  66983. constructor(loader: GLTFLoader);
  66984. /** @hidden */
  66985. dispose(): void;
  66986. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66987. }
  66988. }
  66989. declare module BABYLON.GLTF2.Loader.Extensions {
  66990. /**
  66991. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66992. */
  66993. export class KHR_lights implements IGLTFLoaderExtension {
  66994. /** The name of this extension. */
  66995. readonly name: string;
  66996. /** Defines whether this extension is enabled. */
  66997. enabled: boolean;
  66998. private _loader;
  66999. private _lights?;
  67000. /** @hidden */
  67001. constructor(loader: GLTFLoader);
  67002. /** @hidden */
  67003. dispose(): void;
  67004. /** @hidden */
  67005. onLoading(): void;
  67006. /** @hidden */
  67007. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67008. }
  67009. }
  67010. declare module BABYLON.GLTF2.Loader.Extensions {
  67011. /**
  67012. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67013. */
  67014. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67015. /** The name of this extension. */
  67016. readonly name: string;
  67017. /** Defines whether this extension is enabled. */
  67018. enabled: boolean;
  67019. private _loader;
  67020. /** @hidden */
  67021. constructor(loader: GLTFLoader);
  67022. /** @hidden */
  67023. dispose(): void;
  67024. /** @hidden */
  67025. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67026. private _loadSpecularGlossinessPropertiesAsync;
  67027. }
  67028. }
  67029. declare module BABYLON.GLTF2.Loader.Extensions {
  67030. /**
  67031. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67032. */
  67033. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67034. /** The name of this extension. */
  67035. readonly name: string;
  67036. /** Defines whether this extension is enabled. */
  67037. enabled: boolean;
  67038. private _loader;
  67039. /** @hidden */
  67040. constructor(loader: GLTFLoader);
  67041. /** @hidden */
  67042. dispose(): void;
  67043. /** @hidden */
  67044. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67045. private _loadUnlitPropertiesAsync;
  67046. }
  67047. }
  67048. declare module BABYLON.GLTF2.Loader.Extensions {
  67049. /**
  67050. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67051. */
  67052. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67053. /** The name of this extension. */
  67054. readonly name: string;
  67055. /** Defines whether this extension is enabled. */
  67056. enabled: boolean;
  67057. private _loader;
  67058. /** @hidden */
  67059. constructor(loader: GLTFLoader);
  67060. /** @hidden */
  67061. dispose(): void;
  67062. /** @hidden */
  67063. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67064. }
  67065. }
  67066. declare module BABYLON.GLTF2.Loader.Extensions {
  67067. /**
  67068. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67069. */
  67070. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67071. /** The name of this extension. */
  67072. readonly name: string;
  67073. /** Defines whether this extension is enabled. */
  67074. enabled: boolean;
  67075. private _loader;
  67076. private _clips;
  67077. private _emitters;
  67078. /** @hidden */
  67079. constructor(loader: GLTFLoader);
  67080. /** @hidden */
  67081. dispose(): void;
  67082. /** @hidden */
  67083. onLoading(): void;
  67084. /** @hidden */
  67085. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67086. /** @hidden */
  67087. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67088. /** @hidden */
  67089. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67090. private _loadClipAsync;
  67091. private _loadEmitterAsync;
  67092. private _getEventAction;
  67093. private _loadAnimationEventAsync;
  67094. }
  67095. }
  67096. declare module BABYLON.GLTF2.Loader.Extensions {
  67097. /**
  67098. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67099. */
  67100. export class MSFT_lod implements IGLTFLoaderExtension {
  67101. /** The name of this extension. */
  67102. readonly name: string;
  67103. /** Defines whether this extension is enabled. */
  67104. enabled: boolean;
  67105. /**
  67106. * Maximum number of LODs to load, starting from the lowest LOD.
  67107. */
  67108. maxLODsToLoad: number;
  67109. /**
  67110. * Observable raised when all node LODs of one level are loaded.
  67111. * The event data is the index of the loaded LOD starting from zero.
  67112. * Dispose the loader to cancel the loading of the next level of LODs.
  67113. */
  67114. onNodeLODsLoadedObservable: Observable<number>;
  67115. /**
  67116. * Observable raised when all material LODs of one level are loaded.
  67117. * The event data is the index of the loaded LOD starting from zero.
  67118. * Dispose the loader to cancel the loading of the next level of LODs.
  67119. */
  67120. onMaterialLODsLoadedObservable: Observable<number>;
  67121. private _loader;
  67122. private _nodeIndexLOD;
  67123. private _nodeSignalLODs;
  67124. private _nodePromiseLODs;
  67125. private _materialIndexLOD;
  67126. private _materialSignalLODs;
  67127. private _materialPromiseLODs;
  67128. /** @hidden */
  67129. constructor(loader: GLTFLoader);
  67130. /** @hidden */
  67131. dispose(): void;
  67132. /** @hidden */
  67133. onReady(): void;
  67134. /** @hidden */
  67135. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67136. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67137. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67138. /**
  67139. * Gets an array of LOD properties from lowest to highest.
  67140. */
  67141. private _getLODs;
  67142. private _disposeUnusedMaterials;
  67143. }
  67144. }
  67145. declare module BABYLON.GLTF2.Loader.Extensions {
  67146. /** @hidden */
  67147. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67148. readonly name: string;
  67149. enabled: boolean;
  67150. private _loader;
  67151. constructor(loader: GLTFLoader);
  67152. dispose(): void;
  67153. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67154. }
  67155. }
  67156. declare module BABYLON.GLTF2.Loader.Extensions {
  67157. /** @hidden */
  67158. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67159. readonly name: string;
  67160. enabled: boolean;
  67161. private _loader;
  67162. constructor(loader: GLTFLoader);
  67163. dispose(): void;
  67164. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67165. }
  67166. }
  67167. declare module BABYLON.GLTF2.Loader.Extensions {
  67168. /**
  67169. * Store glTF extras (if present) in BJS objects' metadata
  67170. */
  67171. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67172. /** The name of this extension. */
  67173. readonly name: string;
  67174. /** Defines whether this extension is enabled. */
  67175. enabled: boolean;
  67176. private _loader;
  67177. private _assignExtras;
  67178. /** @hidden */
  67179. constructor(loader: GLTFLoader);
  67180. /** @hidden */
  67181. dispose(): void;
  67182. /** @hidden */
  67183. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67184. /** @hidden */
  67185. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67186. /** @hidden */
  67187. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67188. }
  67189. }
  67190. declare module BABYLON {
  67191. /**
  67192. * Class reading and parsing the MTL file bundled with the obj file.
  67193. */
  67194. export class MTLFileLoader {
  67195. /**
  67196. * All material loaded from the mtl will be set here
  67197. */
  67198. materials: StandardMaterial[];
  67199. /**
  67200. * This function will read the mtl file and create each material described inside
  67201. * This function could be improve by adding :
  67202. * -some component missing (Ni, Tf...)
  67203. * -including the specific options available
  67204. *
  67205. * @param scene defines the scene the material will be created in
  67206. * @param data defines the mtl data to parse
  67207. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67208. */
  67209. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67210. /**
  67211. * Gets the texture for the material.
  67212. *
  67213. * If the material is imported from input file,
  67214. * We sanitize the url to ensure it takes the textre from aside the material.
  67215. *
  67216. * @param rootUrl The root url to load from
  67217. * @param value The value stored in the mtl
  67218. * @return The Texture
  67219. */
  67220. private static _getTexture;
  67221. }
  67222. /**
  67223. * Options for loading OBJ/MTL files
  67224. */
  67225. type MeshLoadOptions = {
  67226. /**
  67227. * Defines if UVs are optimized by default during load.
  67228. */
  67229. OptimizeWithUV: boolean;
  67230. /**
  67231. * Defines custom scaling of UV coordinates of loaded meshes.
  67232. */
  67233. UVScaling: Vector2;
  67234. /**
  67235. * Invert model on y-axis (does a model scaling inversion)
  67236. */
  67237. InvertY: boolean;
  67238. /**
  67239. * Invert Y-Axis of referenced textures on load
  67240. */
  67241. InvertTextureY: boolean;
  67242. /**
  67243. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67244. */
  67245. ImportVertexColors: boolean;
  67246. /**
  67247. * Compute the normals for the model, even if normals are present in the file.
  67248. */
  67249. ComputeNormals: boolean;
  67250. /**
  67251. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67252. */
  67253. SkipMaterials: boolean;
  67254. /**
  67255. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67256. */
  67257. MaterialLoadingFailsSilently: boolean;
  67258. };
  67259. /**
  67260. * OBJ file type loader.
  67261. * This is a babylon scene loader plugin.
  67262. */
  67263. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67264. /**
  67265. * Defines if UVs are optimized by default during load.
  67266. */
  67267. static OPTIMIZE_WITH_UV: boolean;
  67268. /**
  67269. * Invert model on y-axis (does a model scaling inversion)
  67270. */
  67271. static INVERT_Y: boolean;
  67272. /**
  67273. * Invert Y-Axis of referenced textures on load
  67274. */
  67275. static INVERT_TEXTURE_Y: boolean;
  67276. /**
  67277. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67278. */
  67279. static IMPORT_VERTEX_COLORS: boolean;
  67280. /**
  67281. * Compute the normals for the model, even if normals are present in the file.
  67282. */
  67283. static COMPUTE_NORMALS: boolean;
  67284. /**
  67285. * Defines custom scaling of UV coordinates of loaded meshes.
  67286. */
  67287. static UV_SCALING: Vector2;
  67288. /**
  67289. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67290. */
  67291. static SKIP_MATERIALS: boolean;
  67292. /**
  67293. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67294. *
  67295. * Defaults to true for backwards compatibility.
  67296. */
  67297. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67298. /**
  67299. * Defines the name of the plugin.
  67300. */
  67301. name: string;
  67302. /**
  67303. * Defines the extension the plugin is able to load.
  67304. */
  67305. extensions: string;
  67306. /** @hidden */
  67307. obj: RegExp;
  67308. /** @hidden */
  67309. group: RegExp;
  67310. /** @hidden */
  67311. mtllib: RegExp;
  67312. /** @hidden */
  67313. usemtl: RegExp;
  67314. /** @hidden */
  67315. smooth: RegExp;
  67316. /** @hidden */
  67317. vertexPattern: RegExp;
  67318. /** @hidden */
  67319. normalPattern: RegExp;
  67320. /** @hidden */
  67321. uvPattern: RegExp;
  67322. /** @hidden */
  67323. facePattern1: RegExp;
  67324. /** @hidden */
  67325. facePattern2: RegExp;
  67326. /** @hidden */
  67327. facePattern3: RegExp;
  67328. /** @hidden */
  67329. facePattern4: RegExp;
  67330. /** @hidden */
  67331. facePattern5: RegExp;
  67332. private _meshLoadOptions;
  67333. /**
  67334. * Creates loader for .OBJ files
  67335. *
  67336. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67337. */
  67338. constructor(meshLoadOptions?: MeshLoadOptions);
  67339. private static readonly currentMeshLoadOptions;
  67340. /**
  67341. * Calls synchronously the MTL file attached to this obj.
  67342. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67343. * Without this function materials are not displayed in the first frame (but displayed after).
  67344. * In consequence it is impossible to get material information in your HTML file
  67345. *
  67346. * @param url The URL of the MTL file
  67347. * @param rootUrl
  67348. * @param onSuccess Callback function to be called when the MTL file is loaded
  67349. * @private
  67350. */
  67351. private _loadMTL;
  67352. /**
  67353. * Instantiates a OBJ file loader plugin.
  67354. * @returns the created plugin
  67355. */
  67356. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67357. /**
  67358. * If the data string can be loaded directly.
  67359. *
  67360. * @param data string containing the file data
  67361. * @returns if the data can be loaded directly
  67362. */
  67363. canDirectLoad(data: string): boolean;
  67364. /**
  67365. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67366. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67367. * @param scene the scene the meshes should be added to
  67368. * @param data the OBJ data to load
  67369. * @param rootUrl root url to load from
  67370. * @param onProgress event that fires when loading progress has occured
  67371. * @param fileName Defines the name of the file to load
  67372. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67373. */
  67374. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67375. meshes: AbstractMesh[];
  67376. particleSystems: IParticleSystem[];
  67377. skeletons: Skeleton[];
  67378. animationGroups: AnimationGroup[];
  67379. }>;
  67380. /**
  67381. * Imports all objects from the loaded OBJ data and adds them to the scene
  67382. * @param scene the scene the objects should be added to
  67383. * @param data the OBJ data to load
  67384. * @param rootUrl root url to load from
  67385. * @param onProgress event that fires when loading progress has occured
  67386. * @param fileName Defines the name of the file to load
  67387. * @returns a promise which completes when objects have been loaded to the scene
  67388. */
  67389. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67390. /**
  67391. * Load into an asset container.
  67392. * @param scene The scene to load into
  67393. * @param data The data to import
  67394. * @param rootUrl The root url for scene and resources
  67395. * @param onProgress The callback when the load progresses
  67396. * @param fileName Defines the name of the file to load
  67397. * @returns The loaded asset container
  67398. */
  67399. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67400. /**
  67401. * Read the OBJ file and create an Array of meshes.
  67402. * Each mesh contains all information given by the OBJ and the MTL file.
  67403. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67404. *
  67405. * @param meshesNames
  67406. * @param scene Scene The scene where are displayed the data
  67407. * @param data String The content of the obj file
  67408. * @param rootUrl String The path to the folder
  67409. * @returns Array<AbstractMesh>
  67410. * @private
  67411. */
  67412. private _parseSolid;
  67413. }
  67414. }
  67415. declare module BABYLON {
  67416. /**
  67417. * STL file type loader.
  67418. * This is a babylon scene loader plugin.
  67419. */
  67420. export class STLFileLoader implements ISceneLoaderPlugin {
  67421. /** @hidden */
  67422. solidPattern: RegExp;
  67423. /** @hidden */
  67424. facetsPattern: RegExp;
  67425. /** @hidden */
  67426. normalPattern: RegExp;
  67427. /** @hidden */
  67428. vertexPattern: RegExp;
  67429. /**
  67430. * Defines the name of the plugin.
  67431. */
  67432. name: string;
  67433. /**
  67434. * Defines the extensions the stl loader is able to load.
  67435. * force data to come in as an ArrayBuffer
  67436. * we'll convert to string if it looks like it's an ASCII .stl
  67437. */
  67438. extensions: ISceneLoaderPluginExtensions;
  67439. /**
  67440. * Import meshes into a scene.
  67441. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67442. * @param scene The scene to import into
  67443. * @param data The data to import
  67444. * @param rootUrl The root url for scene and resources
  67445. * @param meshes The meshes array to import into
  67446. * @param particleSystems The particle systems array to import into
  67447. * @param skeletons The skeletons array to import into
  67448. * @param onError The callback when import fails
  67449. * @returns True if successful or false otherwise
  67450. */
  67451. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67452. /**
  67453. * Load into a scene.
  67454. * @param scene The scene to load into
  67455. * @param data The data to import
  67456. * @param rootUrl The root url for scene and resources
  67457. * @param onError The callback when import fails
  67458. * @returns true if successful or false otherwise
  67459. */
  67460. load(scene: Scene, data: any, rootUrl: string): boolean;
  67461. /**
  67462. * Load into an asset container.
  67463. * @param scene The scene to load into
  67464. * @param data The data to import
  67465. * @param rootUrl The root url for scene and resources
  67466. * @param onError The callback when import fails
  67467. * @returns The loaded asset container
  67468. */
  67469. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67470. private _isBinary;
  67471. private _parseBinary;
  67472. private _parseASCII;
  67473. }
  67474. }
  67475. declare module BABYLON {
  67476. /**
  67477. * Class for generating OBJ data from a Babylon scene.
  67478. */
  67479. export class OBJExport {
  67480. /**
  67481. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67482. * @param mesh defines the list of meshes to serialize
  67483. * @param materials defines if materials should be exported
  67484. * @param matlibname defines the name of the associated mtl file
  67485. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67486. * @returns the OBJ content
  67487. */
  67488. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67489. /**
  67490. * Exports the material(s) of a mesh in .MTL file format (text)
  67491. * @param mesh defines the mesh to extract the material from
  67492. * @returns the mtl content
  67493. */
  67494. static MTL(mesh: Mesh): string;
  67495. }
  67496. }
  67497. declare module BABYLON {
  67498. /** @hidden */
  67499. export var __IGLTFExporterExtension: number;
  67500. /**
  67501. * Interface for extending the exporter
  67502. * @hidden
  67503. */
  67504. export interface IGLTFExporterExtension {
  67505. /**
  67506. * The name of this extension
  67507. */
  67508. readonly name: string;
  67509. /**
  67510. * Defines whether this extension is enabled
  67511. */
  67512. enabled: boolean;
  67513. /**
  67514. * Defines whether this extension is required
  67515. */
  67516. required: boolean;
  67517. }
  67518. }
  67519. declare module BABYLON.GLTF2.Exporter {
  67520. /** @hidden */
  67521. export var __IGLTFExporterExtensionV2: number;
  67522. /**
  67523. * Interface for a glTF exporter extension
  67524. * @hidden
  67525. */
  67526. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67527. /**
  67528. * Define this method to modify the default behavior before exporting a texture
  67529. * @param context The context when loading the asset
  67530. * @param babylonTexture The glTF texture info property
  67531. * @param mimeType The mime-type of the generated image
  67532. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67533. */
  67534. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67535. /**
  67536. * Define this method to modify the default behavior when exporting texture info
  67537. * @param context The context when loading the asset
  67538. * @param meshPrimitive glTF mesh primitive
  67539. * @param babylonSubMesh Babylon submesh
  67540. * @param binaryWriter glTF serializer binary writer instance
  67541. * @returns nullable IMeshPrimitive promise
  67542. */
  67543. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67544. /**
  67545. * Define this method to modify the default behavior when exporting a node
  67546. * @param context The context when exporting the node
  67547. * @param node glTF node
  67548. * @param babylonNode BabylonJS node
  67549. * @returns nullable INode promise
  67550. */
  67551. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67552. /**
  67553. * Called after the exporter state changes to EXPORTING
  67554. */
  67555. onExporting?(): void;
  67556. }
  67557. }
  67558. declare module BABYLON.GLTF2.Exporter {
  67559. /**
  67560. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67561. * @hidden
  67562. */
  67563. export class _GLTFMaterialExporter {
  67564. /**
  67565. * Represents the dielectric specular values for R, G and B
  67566. */
  67567. private static readonly _DielectricSpecular;
  67568. /**
  67569. * Allows the maximum specular power to be defined for material calculations
  67570. */
  67571. private static readonly _MaxSpecularPower;
  67572. /**
  67573. * Mapping to store textures
  67574. */
  67575. private _textureMap;
  67576. /**
  67577. * Numeric tolerance value
  67578. */
  67579. private static readonly _Epsilon;
  67580. /**
  67581. * Reference to the glTF Exporter
  67582. */
  67583. private _exporter;
  67584. constructor(exporter: _Exporter);
  67585. /**
  67586. * Specifies if two colors are approximately equal in value
  67587. * @param color1 first color to compare to
  67588. * @param color2 second color to compare to
  67589. * @param epsilon threshold value
  67590. */
  67591. private static FuzzyEquals;
  67592. /**
  67593. * Gets the materials from a Babylon scene and converts them to glTF materials
  67594. * @param scene babylonjs scene
  67595. * @param mimeType texture mime type
  67596. * @param images array of images
  67597. * @param textures array of textures
  67598. * @param materials array of materials
  67599. * @param imageData mapping of texture names to base64 textures
  67600. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67601. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67602. /**
  67603. * Makes a copy of the glTF material without the texture parameters
  67604. * @param originalMaterial original glTF material
  67605. * @returns glTF material without texture parameters
  67606. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67607. /**
  67608. * Specifies if the material has any texture parameters present
  67609. * @param material glTF Material
  67610. * @returns boolean specifying if texture parameters are present
  67611. */ private _hasTexturesPresent(material: IMaterial): boolean;
  67612. /**
  67613. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67614. * @param babylonStandardMaterial
  67615. * @returns glTF Metallic Roughness Material representation
  67616. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67617. /**
  67618. * Computes the metallic factor
  67619. * @param diffuse diffused value
  67620. * @param specular specular value
  67621. * @param oneMinusSpecularStrength one minus the specular strength
  67622. * @returns metallic value
  67623. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67624. /**
  67625. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67626. * @param glTFMaterial glTF material
  67627. * @param babylonMaterial Babylon material
  67628. */
  67629. private static _SetAlphaMode;
  67630. /**
  67631. * Converts a Babylon Standard Material to a glTF Material
  67632. * @param babylonStandardMaterial BJS Standard Material
  67633. * @param mimeType mime type to use for the textures
  67634. * @param images array of glTF image interfaces
  67635. * @param textures array of glTF texture interfaces
  67636. * @param materials array of glTF material interfaces
  67637. * @param imageData map of image file name to data
  67638. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67639. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67640. /**
  67641. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67642. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67643. * @param mimeType mime type to use for the textures
  67644. * @param images array of glTF image interfaces
  67645. * @param textures array of glTF texture interfaces
  67646. * @param materials array of glTF material interfaces
  67647. * @param imageData map of image file name to data
  67648. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67649. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67650. /**
  67651. * Converts an image typed array buffer to a base64 image
  67652. * @param buffer typed array buffer
  67653. * @param width width of the image
  67654. * @param height height of the image
  67655. * @param mimeType mimetype of the image
  67656. * @returns base64 image string
  67657. */
  67658. private _createBase64FromCanvasAsync;
  67659. /**
  67660. * Generates a white texture based on the specified width and height
  67661. * @param width width of the texture in pixels
  67662. * @param height height of the texture in pixels
  67663. * @param scene babylonjs scene
  67664. * @returns white texture
  67665. */
  67666. private _createWhiteTexture;
  67667. /**
  67668. * 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
  67669. * @param texture1 first texture to resize
  67670. * @param texture2 second texture to resize
  67671. * @param scene babylonjs scene
  67672. * @returns resized textures or null
  67673. */
  67674. private _resizeTexturesToSameDimensions;
  67675. /**
  67676. * Converts an array of pixels to a Float32Array
  67677. * Throws an error if the pixel format is not supported
  67678. * @param pixels - array buffer containing pixel values
  67679. * @returns Float32 of pixels
  67680. */
  67681. private _convertPixelArrayToFloat32;
  67682. /**
  67683. * Convert Specular Glossiness Textures to Metallic Roughness
  67684. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67685. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67686. * @param diffuseTexture texture used to store diffuse information
  67687. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67688. * @param factors specular glossiness material factors
  67689. * @param mimeType the mime type to use for the texture
  67690. * @returns pbr metallic roughness interface or null
  67691. */
  67692. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67693. /**
  67694. * Converts specular glossiness material properties to metallic roughness
  67695. * @param specularGlossiness interface with specular glossiness material properties
  67696. * @returns interface with metallic roughness material properties
  67697. */
  67698. private _convertSpecularGlossinessToMetallicRoughness;
  67699. /**
  67700. * Calculates the surface reflectance, independent of lighting conditions
  67701. * @param color Color source to calculate brightness from
  67702. * @returns number representing the perceived brightness, or zero if color is undefined
  67703. */
  67704. private _getPerceivedBrightness;
  67705. /**
  67706. * Returns the maximum color component value
  67707. * @param color
  67708. * @returns maximum color component value, or zero if color is null or undefined
  67709. */
  67710. private _getMaxComponent;
  67711. /**
  67712. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67713. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67714. * @param mimeType mime type to use for the textures
  67715. * @param images array of glTF image interfaces
  67716. * @param textures array of glTF texture interfaces
  67717. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67718. * @param imageData map of image file name to data
  67719. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67720. * @returns glTF PBR Metallic Roughness factors
  67721. */
  67722. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67723. private _getGLTFTextureSampler;
  67724. private _getGLTFTextureWrapMode;
  67725. private _getGLTFTextureWrapModesSampler;
  67726. /**
  67727. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67728. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67729. * @param mimeType mime type to use for the textures
  67730. * @param images array of glTF image interfaces
  67731. * @param textures array of glTF texture interfaces
  67732. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67733. * @param imageData map of image file name to data
  67734. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67735. * @returns glTF PBR Metallic Roughness factors
  67736. */
  67737. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67738. /**
  67739. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67740. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67741. * @param mimeType mime type to use for the textures
  67742. * @param images array of glTF image interfaces
  67743. * @param textures array of glTF texture interfaces
  67744. * @param materials array of glTF material interfaces
  67745. * @param imageData map of image file name to data
  67746. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67747. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67748. private setMetallicRoughnessPbrMaterial;
  67749. private getPixelsFromTexture;
  67750. /**
  67751. * Extracts a texture from a Babylon texture into file data and glTF data
  67752. * @param babylonTexture Babylon texture to extract
  67753. * @param mimeType Mime Type of the babylonTexture
  67754. * @return glTF texture info, or null if the texture format is not supported
  67755. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67756. /**
  67757. * Builds a texture from base64 string
  67758. * @param base64Texture base64 texture string
  67759. * @param baseTextureName Name to use for the texture
  67760. * @param mimeType image mime type for the texture
  67761. * @param images array of images
  67762. * @param textures array of textures
  67763. * @param imageData map of image data
  67764. * @returns glTF texture info, or null if the texture format is not supported
  67765. */
  67766. private _getTextureInfoFromBase64;
  67767. }
  67768. }
  67769. declare module BABYLON {
  67770. /**
  67771. * Class for holding and downloading glTF file data
  67772. */
  67773. export class GLTFData {
  67774. /**
  67775. * Object which contains the file name as the key and its data as the value
  67776. */
  67777. glTFFiles: {
  67778. [fileName: string]: string | Blob;
  67779. };
  67780. /**
  67781. * Initializes the glTF file object
  67782. */
  67783. constructor();
  67784. /**
  67785. * Downloads the glTF data as files based on their names and data
  67786. */
  67787. downloadFiles(): void;
  67788. }
  67789. }
  67790. declare module BABYLON {
  67791. /**
  67792. * Holds a collection of exporter options and parameters
  67793. */
  67794. export interface IExportOptions {
  67795. /**
  67796. * Function which indicates whether a babylon node should be exported or not
  67797. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67798. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67799. */
  67800. shouldExportNode?(node: Node): boolean;
  67801. /**
  67802. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67803. * @param metadata source metadata to read from
  67804. * @returns the data to store to glTF node extras
  67805. */
  67806. metadataSelector?(metadata: any): any;
  67807. /**
  67808. * The sample rate to bake animation curves
  67809. */
  67810. animationSampleRate?: number;
  67811. /**
  67812. * Begin serialization without waiting for the scene to be ready
  67813. */
  67814. exportWithoutWaitingForScene?: boolean;
  67815. }
  67816. /**
  67817. * Class for generating glTF data from a Babylon scene.
  67818. */
  67819. export class GLTF2Export {
  67820. /**
  67821. * Exports the geometry of the scene to .gltf file format asynchronously
  67822. * @param scene Babylon scene with scene hierarchy information
  67823. * @param filePrefix File prefix to use when generating the glTF file
  67824. * @param options Exporter options
  67825. * @returns Returns an object with a .gltf file and associates texture names
  67826. * as keys and their data and paths as values
  67827. */
  67828. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67829. private static _PreExportAsync;
  67830. private static _PostExportAsync;
  67831. /**
  67832. * Exports the geometry of the scene to .glb file format asychronously
  67833. * @param scene Babylon scene with scene hierarchy information
  67834. * @param filePrefix File prefix to use when generating glb file
  67835. * @param options Exporter options
  67836. * @returns Returns an object with a .glb filename as key and data as value
  67837. */
  67838. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67839. }
  67840. }
  67841. declare module BABYLON.GLTF2.Exporter {
  67842. /**
  67843. * @hidden
  67844. */
  67845. export class _GLTFUtilities {
  67846. /**
  67847. * Creates a buffer view based on the supplied arguments
  67848. * @param bufferIndex index value of the specified buffer
  67849. * @param byteOffset byte offset value
  67850. * @param byteLength byte length of the bufferView
  67851. * @param byteStride byte distance between conequential elements
  67852. * @param name name of the buffer view
  67853. * @returns bufferView for glTF
  67854. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67855. /**
  67856. * Creates an accessor based on the supplied arguments
  67857. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67858. * @param name The name of the accessor
  67859. * @param type The type of the accessor
  67860. * @param componentType The datatype of components in the attribute
  67861. * @param count The number of attributes referenced by this accessor
  67862. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67863. * @param min Minimum value of each component in this attribute
  67864. * @param max Maximum value of each component in this attribute
  67865. * @returns accessor for glTF
  67866. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67867. /**
  67868. * Calculates the minimum and maximum values of an array of position floats
  67869. * @param positions Positions array of a mesh
  67870. * @param vertexStart Starting vertex offset to calculate min and max values
  67871. * @param vertexCount Number of vertices to check for min and max values
  67872. * @returns min number array and max number array
  67873. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67874. min: number[];
  67875. max: number[];
  67876. };
  67877. /**
  67878. * Converts a new right-handed Vector3
  67879. * @param vector vector3 array
  67880. * @returns right-handed Vector3
  67881. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67882. /**
  67883. * Converts a Vector3 to right-handed
  67884. * @param vector Vector3 to convert to right-handed
  67885. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67886. /**
  67887. * Converts a three element number array to right-handed
  67888. * @param vector number array to convert to right-handed
  67889. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67890. /**
  67891. * Converts a new right-handed Vector3
  67892. * @param vector vector3 array
  67893. * @returns right-handed Vector3
  67894. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67895. /**
  67896. * Converts a Vector3 to right-handed
  67897. * @param vector Vector3 to convert to right-handed
  67898. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67899. /**
  67900. * Converts a three element number array to right-handed
  67901. * @param vector number array to convert to right-handed
  67902. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67903. /**
  67904. * Converts a Vector4 to right-handed
  67905. * @param vector Vector4 to convert to right-handed
  67906. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67907. /**
  67908. * Converts a Vector4 to right-handed
  67909. * @param vector Vector4 to convert to right-handed
  67910. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  67911. /**
  67912. * Converts a Quaternion to right-handed
  67913. * @param quaternion Source quaternion to convert to right-handed
  67914. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67915. /**
  67916. * Converts a Quaternion to right-handed
  67917. * @param quaternion Source quaternion to convert to right-handed
  67918. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  67919. }
  67920. }
  67921. declare module BABYLON.GLTF2.Exporter {
  67922. /**
  67923. * Converts Babylon Scene into glTF 2.0.
  67924. * @hidden
  67925. */
  67926. export class _Exporter {
  67927. /**
  67928. * Stores the glTF to export
  67929. */ private _glTF: IGLTF;
  67930. /**
  67931. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67932. */ private _bufferViews: IBufferView[];
  67933. /**
  67934. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67935. */ private _accessors: IAccessor[];
  67936. /**
  67937. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67938. */
  67939. private _nodes;
  67940. /**
  67941. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67942. */
  67943. private _scenes;
  67944. /**
  67945. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67946. */
  67947. private _meshes;
  67948. /**
  67949. * Stores all the generated material information, which represents the appearance of each primitive
  67950. */ private _materials: IMaterial[]; private _materialMap: {
  67951. [materialID: number]: number;
  67952. };
  67953. /**
  67954. * Stores all the generated texture information, which is referenced by glTF materials
  67955. */ private _textures: ITexture[];
  67956. /**
  67957. * Stores all the generated image information, which is referenced by glTF textures
  67958. */ private _images: IImage[];
  67959. /**
  67960. * Stores all the texture samplers
  67961. */ private _samplers: ISampler[];
  67962. /**
  67963. * Stores all the generated animation samplers, which is referenced by glTF animations
  67964. */
  67965. /**
  67966. * Stores the animations for glTF models
  67967. */
  67968. private _animations;
  67969. /**
  67970. * Stores the total amount of bytes stored in the glTF buffer
  67971. */
  67972. private _totalByteLength;
  67973. /**
  67974. * Stores a reference to the Babylon scene containing the source geometry and material information
  67975. */ private _babylonScene: Scene;
  67976. /**
  67977. * Stores a map of the image data, where the key is the file name and the value
  67978. * is the image data
  67979. */ private _imageData: {
  67980. [fileName: string]: {
  67981. data: Uint8Array;
  67982. mimeType: ImageMimeType;
  67983. };
  67984. };
  67985. /**
  67986. * Stores a map of the unique id of a node to its index in the node array
  67987. */
  67988. private _nodeMap;
  67989. /**
  67990. * Specifies if the Babylon scene should be converted to right-handed on export
  67991. */ private _convertToRightHandedSystem: boolean;
  67992. /**
  67993. * Baked animation sample rate
  67994. */
  67995. private _animationSampleRate;
  67996. private _options;
  67997. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  67998. private _extensions;
  67999. private static _ExtensionNames;
  68000. private static _ExtensionFactories;
  68001. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68002. private _forEachExtensions;
  68003. private _extensionsOnExporting;
  68004. /**
  68005. * Load glTF serializer extensions
  68006. */
  68007. private _loadExtensions;
  68008. /**
  68009. * Creates a glTF Exporter instance, which can accept optional exporter options
  68010. * @param babylonScene Babylon scene object
  68011. * @param options Options to modify the behavior of the exporter
  68012. */
  68013. constructor(babylonScene: Scene, options?: IExportOptions);
  68014. /**
  68015. * Registers a glTF exporter extension
  68016. * @param name Name of the extension to export
  68017. * @param factory The factory function that creates the exporter extension
  68018. */
  68019. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68020. /**
  68021. * Un-registers an exporter extension
  68022. * @param name The name fo the exporter extension
  68023. * @returns A boolean indicating whether the extension has been un-registered
  68024. */
  68025. static UnregisterExtension(name: string): boolean;
  68026. /**
  68027. * Lazy load a local engine with premultiplied alpha set to false
  68028. */ private _getLocalEngine(): Engine;
  68029. private reorderIndicesBasedOnPrimitiveMode;
  68030. /**
  68031. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68032. * clock-wise during export to glTF
  68033. * @param submesh BabylonJS submesh
  68034. * @param primitiveMode Primitive mode of the mesh
  68035. * @param sideOrientation the winding order of the submesh
  68036. * @param vertexBufferKind The type of vertex attribute
  68037. * @param meshAttributeArray The vertex attribute data
  68038. * @param byteOffset The offset to the binary data
  68039. * @param binaryWriter The binary data for the glTF file
  68040. */
  68041. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68042. /**
  68043. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68044. * clock-wise during export to glTF
  68045. * @param submesh BabylonJS submesh
  68046. * @param primitiveMode Primitive mode of the mesh
  68047. * @param sideOrientation the winding order of the submesh
  68048. * @param vertexBufferKind The type of vertex attribute
  68049. * @param meshAttributeArray The vertex attribute data
  68050. * @param byteOffset The offset to the binary data
  68051. * @param binaryWriter The binary data for the glTF file
  68052. */
  68053. private reorderTriangleFillMode;
  68054. /**
  68055. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68056. * clock-wise during export to glTF
  68057. * @param submesh BabylonJS submesh
  68058. * @param primitiveMode Primitive mode of the mesh
  68059. * @param sideOrientation the winding order of the submesh
  68060. * @param vertexBufferKind The type of vertex attribute
  68061. * @param meshAttributeArray The vertex attribute data
  68062. * @param byteOffset The offset to the binary data
  68063. * @param binaryWriter The binary data for the glTF file
  68064. */
  68065. private reorderTriangleStripDrawMode;
  68066. /**
  68067. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68068. * clock-wise during export to glTF
  68069. * @param submesh BabylonJS submesh
  68070. * @param primitiveMode Primitive mode of the mesh
  68071. * @param sideOrientation the winding order of the submesh
  68072. * @param vertexBufferKind The type of vertex attribute
  68073. * @param meshAttributeArray The vertex attribute data
  68074. * @param byteOffset The offset to the binary data
  68075. * @param binaryWriter The binary data for the glTF file
  68076. */
  68077. private reorderTriangleFanMode;
  68078. /**
  68079. * Writes the vertex attribute data to binary
  68080. * @param vertices The vertices to write to the binary writer
  68081. * @param byteOffset The offset into the binary writer to overwrite binary data
  68082. * @param vertexAttributeKind The vertex attribute type
  68083. * @param meshAttributeArray The vertex attribute data
  68084. * @param binaryWriter The writer containing the binary data
  68085. */
  68086. private writeVertexAttributeData;
  68087. /**
  68088. * Writes mesh attribute data to a data buffer
  68089. * Returns the bytelength of the data
  68090. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68091. * @param meshAttributeArray Array containing the attribute data
  68092. * @param binaryWriter The buffer to write the binary data to
  68093. * @param indices Used to specify the order of the vertex data
  68094. */
  68095. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68096. /**
  68097. * Generates glTF json data
  68098. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68099. * @param glTFPrefix Text to use when prefixing a glTF file
  68100. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68101. * @returns json data as string
  68102. */
  68103. private generateJSON;
  68104. /**
  68105. * Generates data for .gltf and .bin files based on the glTF prefix string
  68106. * @param glTFPrefix Text to use when prefixing a glTF file
  68107. * @returns GLTFData with glTF file data
  68108. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68109. /**
  68110. * Creates a binary buffer for glTF
  68111. * @returns array buffer for binary data
  68112. */
  68113. private _generateBinaryAsync;
  68114. /**
  68115. * Pads the number to a multiple of 4
  68116. * @param num number to pad
  68117. * @returns padded number
  68118. */
  68119. private _getPadding;
  68120. /**
  68121. * Generates a glb file from the json and binary data
  68122. * Returns an object with the glb file name as the key and data as the value
  68123. * @param glTFPrefix
  68124. * @returns object with glb filename as key and data as value
  68125. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68126. /**
  68127. * Sets the TRS for each node
  68128. * @param node glTF Node for storing the transformation data
  68129. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68130. */
  68131. private setNodeTransformation;
  68132. private getVertexBufferFromMesh;
  68133. /**
  68134. * Creates a bufferview based on the vertices type for the Babylon mesh
  68135. * @param kind Indicates the type of vertices data
  68136. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68137. * @param binaryWriter The buffer to write the bufferview data to
  68138. */
  68139. private createBufferViewKind;
  68140. /**
  68141. * The primitive mode of the Babylon mesh
  68142. * @param babylonMesh The BabylonJS mesh
  68143. */
  68144. private getMeshPrimitiveMode;
  68145. /**
  68146. * Sets the primitive mode of the glTF mesh primitive
  68147. * @param meshPrimitive glTF mesh primitive
  68148. * @param primitiveMode The primitive mode
  68149. */
  68150. private setPrimitiveMode;
  68151. /**
  68152. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68153. * @param meshPrimitive glTF mesh primitive
  68154. * @param attributeKind vertex attribute
  68155. * @returns boolean specifying if uv coordinates are present
  68156. */
  68157. private setAttributeKind;
  68158. /**
  68159. * Sets data for the primitive attributes of each submesh
  68160. * @param mesh glTF Mesh object to store the primitive attribute information
  68161. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68162. * @param binaryWriter Buffer to write the attribute data to
  68163. */
  68164. private setPrimitiveAttributesAsync;
  68165. /**
  68166. * Creates a glTF scene based on the array of meshes
  68167. * Returns the the total byte offset
  68168. * @param babylonScene Babylon scene to get the mesh data from
  68169. * @param binaryWriter Buffer to write binary data to
  68170. */
  68171. private createSceneAsync;
  68172. /**
  68173. * Creates a mapping of Node unique id to node index and handles animations
  68174. * @param babylonScene Babylon Scene
  68175. * @param nodes Babylon transform nodes
  68176. * @param binaryWriter Buffer to write binary data to
  68177. * @returns Node mapping of unique id to index
  68178. */
  68179. private createNodeMapAndAnimationsAsync;
  68180. /**
  68181. * Creates a glTF node from a Babylon mesh
  68182. * @param babylonMesh Source Babylon mesh
  68183. * @param binaryWriter Buffer for storing geometry data
  68184. * @returns glTF node
  68185. */
  68186. private createNodeAsync;
  68187. }
  68188. /**
  68189. * @hidden
  68190. *
  68191. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68192. */
  68193. export class _BinaryWriter {
  68194. /**
  68195. * Array buffer which stores all binary data
  68196. */
  68197. private _arrayBuffer;
  68198. /**
  68199. * View of the array buffer
  68200. */
  68201. private _dataView;
  68202. /**
  68203. * byte offset of data in array buffer
  68204. */
  68205. private _byteOffset;
  68206. /**
  68207. * Initialize binary writer with an initial byte length
  68208. * @param byteLength Initial byte length of the array buffer
  68209. */
  68210. constructor(byteLength: number);
  68211. /**
  68212. * Resize the array buffer to the specified byte length
  68213. * @param byteLength
  68214. */
  68215. private resizeBuffer;
  68216. /**
  68217. * Get an array buffer with the length of the byte offset
  68218. * @returns ArrayBuffer resized to the byte offset
  68219. */
  68220. getArrayBuffer(): ArrayBuffer;
  68221. /**
  68222. * Get the byte offset of the array buffer
  68223. * @returns byte offset
  68224. */
  68225. getByteOffset(): number;
  68226. /**
  68227. * Stores an UInt8 in the array buffer
  68228. * @param entry
  68229. * @param byteOffset If defined, specifies where to set the value as an offset.
  68230. */
  68231. setUInt8(entry: number, byteOffset?: number): void;
  68232. /**
  68233. * Gets an UInt32 in the array buffer
  68234. * @param entry
  68235. * @param byteOffset If defined, specifies where to set the value as an offset.
  68236. */
  68237. getUInt32(byteOffset: number): number;
  68238. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68239. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68240. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68241. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68242. /**
  68243. * Stores a Float32 in the array buffer
  68244. * @param entry
  68245. */
  68246. setFloat32(entry: number, byteOffset?: number): void;
  68247. /**
  68248. * Stores an UInt32 in the array buffer
  68249. * @param entry
  68250. * @param byteOffset If defined, specifies where to set the value as an offset.
  68251. */
  68252. setUInt32(entry: number, byteOffset?: number): void;
  68253. }
  68254. }
  68255. declare module BABYLON.GLTF2.Exporter {
  68256. /**
  68257. * @hidden
  68258. * Interface to store animation data.
  68259. */
  68260. export interface _IAnimationData {
  68261. /**
  68262. * Keyframe data.
  68263. */
  68264. inputs: number[];
  68265. /**
  68266. * Value data.
  68267. */
  68268. outputs: number[][];
  68269. /**
  68270. * Animation interpolation data.
  68271. */
  68272. samplerInterpolation: AnimationSamplerInterpolation;
  68273. /**
  68274. * Minimum keyframe value.
  68275. */
  68276. inputsMin: number;
  68277. /**
  68278. * Maximum keyframe value.
  68279. */
  68280. inputsMax: number;
  68281. }
  68282. /**
  68283. * @hidden
  68284. */
  68285. export interface _IAnimationInfo {
  68286. /**
  68287. * The target channel for the animation
  68288. */
  68289. animationChannelTargetPath: AnimationChannelTargetPath;
  68290. /**
  68291. * The glTF accessor type for the data.
  68292. */
  68293. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68294. /**
  68295. * Specifies if quaternions should be used.
  68296. */
  68297. useQuaternion: boolean;
  68298. }
  68299. /**
  68300. * @hidden
  68301. * Utility class for generating glTF animation data from BabylonJS.
  68302. */
  68303. export class _GLTFAnimation {
  68304. /**
  68305. * @ignore
  68306. *
  68307. * Creates glTF channel animation from BabylonJS animation.
  68308. * @param babylonTransformNode - BabylonJS mesh.
  68309. * @param animation - animation.
  68310. * @param animationChannelTargetPath - The target animation channel.
  68311. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68312. * @param useQuaternion - Specifies if quaternions are used.
  68313. * @returns nullable IAnimationData
  68314. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68315. private static _DeduceAnimationInfo;
  68316. /**
  68317. * @ignore
  68318. * Create node animations from the transform node animations
  68319. * @param babylonNode
  68320. * @param runtimeGLTFAnimation
  68321. * @param idleGLTFAnimations
  68322. * @param nodeMap
  68323. * @param nodes
  68324. * @param binaryWriter
  68325. * @param bufferViews
  68326. * @param accessors
  68327. * @param convertToRightHandedSystem
  68328. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68329. [key: number]: number;
  68330. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68331. /**
  68332. * @ignore
  68333. * Create node animations from the animation groups
  68334. * @param babylonScene
  68335. * @param glTFAnimations
  68336. * @param nodeMap
  68337. * @param nodes
  68338. * @param binaryWriter
  68339. * @param bufferViews
  68340. * @param accessors
  68341. * @param convertToRightHandedSystem
  68342. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68343. [key: number]: number;
  68344. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68345. private static AddAnimation;
  68346. /**
  68347. * Create a baked animation
  68348. * @param babylonTransformNode BabylonJS mesh
  68349. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68350. * @param animationChannelTargetPath animation target channel
  68351. * @param minFrame minimum animation frame
  68352. * @param maxFrame maximum animation frame
  68353. * @param fps frames per second of the animation
  68354. * @param inputs input key frames of the animation
  68355. * @param outputs output key frame data of the animation
  68356. * @param convertToRightHandedSystem converts the values to right-handed
  68357. * @param useQuaternion specifies if quaternions should be used
  68358. */
  68359. private static _CreateBakedAnimation;
  68360. private static _ConvertFactorToVector3OrQuaternion;
  68361. private static _SetInterpolatedValue;
  68362. /**
  68363. * Creates linear animation from the animation key frames
  68364. * @param babylonTransformNode BabylonJS mesh
  68365. * @param animation BabylonJS animation
  68366. * @param animationChannelTargetPath The target animation channel
  68367. * @param frameDelta The difference between the last and first frame of the animation
  68368. * @param inputs Array to store the key frame times
  68369. * @param outputs Array to store the key frame data
  68370. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68371. * @param useQuaternion Specifies if quaternions are used in the animation
  68372. */
  68373. private static _CreateLinearOrStepAnimation;
  68374. /**
  68375. * Creates cubic spline animation from the animation key frames
  68376. * @param babylonTransformNode BabylonJS mesh
  68377. * @param animation BabylonJS animation
  68378. * @param animationChannelTargetPath The target animation channel
  68379. * @param frameDelta The difference between the last and first frame of the animation
  68380. * @param inputs Array to store the key frame times
  68381. * @param outputs Array to store the key frame data
  68382. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68383. * @param useQuaternion Specifies if quaternions are used in the animation
  68384. */
  68385. private static _CreateCubicSplineAnimation;
  68386. private static _GetBasePositionRotationOrScale;
  68387. /**
  68388. * Adds a key frame value
  68389. * @param keyFrame
  68390. * @param animation
  68391. * @param outputs
  68392. * @param animationChannelTargetPath
  68393. * @param basePositionRotationOrScale
  68394. * @param convertToRightHandedSystem
  68395. * @param useQuaternion
  68396. */
  68397. private static _AddKeyframeValue;
  68398. /**
  68399. * Determine the interpolation based on the key frames
  68400. * @param keyFrames
  68401. * @param animationChannelTargetPath
  68402. * @param useQuaternion
  68403. */
  68404. private static _DeduceInterpolation;
  68405. /**
  68406. * Adds an input tangent or output tangent to the output data
  68407. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68408. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68409. * @param outputs The animation data by keyframe
  68410. * @param animationChannelTargetPath The target animation channel
  68411. * @param interpolation The interpolation type
  68412. * @param keyFrame The key frame with the animation data
  68413. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68414. * @param useQuaternion Specifies if quaternions are used
  68415. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68416. */
  68417. private static AddSplineTangent;
  68418. /**
  68419. * Get the minimum and maximum key frames' frame values
  68420. * @param keyFrames animation key frames
  68421. * @returns the minimum and maximum key frame value
  68422. */
  68423. private static calculateMinMaxKeyFrames;
  68424. }
  68425. }
  68426. declare module BABYLON.GLTF2.Exporter {
  68427. /** @hidden */
  68428. export var textureTransformPixelShader: {
  68429. name: string;
  68430. shader: string;
  68431. };
  68432. }
  68433. declare module BABYLON.GLTF2.Exporter.Extensions {
  68434. /**
  68435. * @hidden
  68436. */
  68437. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68438. /** Name of this extension */
  68439. readonly name: string;
  68440. /** Defines whether this extension is enabled */
  68441. enabled: boolean;
  68442. /** Defines whether this extension is required */
  68443. required: boolean;
  68444. /** Reference to the glTF exporter */
  68445. private _exporter;
  68446. constructor(exporter: _Exporter);
  68447. dispose(): void;
  68448. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68449. /**
  68450. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68451. * @param babylonTexture
  68452. * @param offset
  68453. * @param rotation
  68454. * @param scale
  68455. * @param scene
  68456. */
  68457. private _textureTransformTextureAsync;
  68458. }
  68459. }
  68460. declare module BABYLON.GLTF2.Exporter.Extensions {
  68461. /**
  68462. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68463. */
  68464. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68465. /** The name of this extension. */
  68466. readonly name: string;
  68467. /** Defines whether this extension is enabled. */
  68468. enabled: boolean;
  68469. /** Defines whether this extension is required */
  68470. required: boolean;
  68471. /** Reference to the glTF exporter */
  68472. private _exporter;
  68473. private _lights;
  68474. /** @hidden */
  68475. constructor(exporter: _Exporter);
  68476. /** @hidden */
  68477. dispose(): void;
  68478. /** @hidden */
  68479. onExporting(): void;
  68480. /**
  68481. * Define this method to modify the default behavior when exporting a node
  68482. * @param context The context when exporting the node
  68483. * @param node glTF node
  68484. * @param babylonNode BabylonJS node
  68485. * @returns nullable INode promise
  68486. */
  68487. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68488. }
  68489. }
  68490. declare module BABYLON {
  68491. /**
  68492. * Class for generating STL data from a Babylon scene.
  68493. */
  68494. export class STLExport {
  68495. /**
  68496. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68497. * @param meshes list defines the mesh to serialize
  68498. * @param download triggers the automatic download of the file.
  68499. * @param fileName changes the downloads fileName.
  68500. * @param binary changes the STL to a binary type.
  68501. * @param isLittleEndian toggle for binary type exporter.
  68502. * @returns the STL as UTF8 string
  68503. */
  68504. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68505. }
  68506. }
  68507. /**
  68508. * @ignoreChildren
  68509. * @ignore
  68510. */
  68511. declare module "babylonjs-gltf2interface" {
  68512. export = BABYLON.GLTF2;
  68513. }
  68514. /**
  68515. * Module for glTF 2.0 Interface
  68516. * @ignoreChildren
  68517. * @ignore
  68518. */
  68519. declare module BABYLON.GLTF2 {
  68520. /**
  68521. * The datatype of the components in the attribute
  68522. */
  68523. const enum AccessorComponentType {
  68524. /**
  68525. * Byte
  68526. */
  68527. BYTE = 5120,
  68528. /**
  68529. * Unsigned Byte
  68530. */
  68531. UNSIGNED_BYTE = 5121,
  68532. /**
  68533. * Short
  68534. */
  68535. SHORT = 5122,
  68536. /**
  68537. * Unsigned Short
  68538. */
  68539. UNSIGNED_SHORT = 5123,
  68540. /**
  68541. * Unsigned Int
  68542. */
  68543. UNSIGNED_INT = 5125,
  68544. /**
  68545. * Float
  68546. */
  68547. FLOAT = 5126,
  68548. }
  68549. /**
  68550. * Specifies if the attirbute is a scalar, vector, or matrix
  68551. */
  68552. const enum AccessorType {
  68553. /**
  68554. * Scalar
  68555. */
  68556. SCALAR = "SCALAR",
  68557. /**
  68558. * Vector2
  68559. */
  68560. VEC2 = "VEC2",
  68561. /**
  68562. * Vector3
  68563. */
  68564. VEC3 = "VEC3",
  68565. /**
  68566. * Vector4
  68567. */
  68568. VEC4 = "VEC4",
  68569. /**
  68570. * Matrix2x2
  68571. */
  68572. MAT2 = "MAT2",
  68573. /**
  68574. * Matrix3x3
  68575. */
  68576. MAT3 = "MAT3",
  68577. /**
  68578. * Matrix4x4
  68579. */
  68580. MAT4 = "MAT4",
  68581. }
  68582. /**
  68583. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68584. */
  68585. const enum AnimationChannelTargetPath {
  68586. /**
  68587. * Translation
  68588. */
  68589. TRANSLATION = "translation",
  68590. /**
  68591. * Rotation
  68592. */
  68593. ROTATION = "rotation",
  68594. /**
  68595. * Scale
  68596. */
  68597. SCALE = "scale",
  68598. /**
  68599. * Weights
  68600. */
  68601. WEIGHTS = "weights",
  68602. }
  68603. /**
  68604. * Interpolation algorithm
  68605. */
  68606. const enum AnimationSamplerInterpolation {
  68607. /**
  68608. * The animated values are linearly interpolated between keyframes
  68609. */
  68610. LINEAR = "LINEAR",
  68611. /**
  68612. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68613. */
  68614. STEP = "STEP",
  68615. /**
  68616. * The animation's interpolation is computed using a cubic spline with specified tangents
  68617. */
  68618. CUBICSPLINE = "CUBICSPLINE",
  68619. }
  68620. /**
  68621. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68622. */
  68623. const enum CameraType {
  68624. /**
  68625. * A perspective camera containing properties to create a perspective projection matrix
  68626. */
  68627. PERSPECTIVE = "perspective",
  68628. /**
  68629. * An orthographic camera containing properties to create an orthographic projection matrix
  68630. */
  68631. ORTHOGRAPHIC = "orthographic",
  68632. }
  68633. /**
  68634. * The mime-type of the image
  68635. */
  68636. const enum ImageMimeType {
  68637. /**
  68638. * JPEG Mime-type
  68639. */
  68640. JPEG = "image/jpeg",
  68641. /**
  68642. * PNG Mime-type
  68643. */
  68644. PNG = "image/png",
  68645. }
  68646. /**
  68647. * The alpha rendering mode of the material
  68648. */
  68649. const enum MaterialAlphaMode {
  68650. /**
  68651. * The alpha value is ignored and the rendered output is fully opaque
  68652. */
  68653. OPAQUE = "OPAQUE",
  68654. /**
  68655. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68656. */
  68657. MASK = "MASK",
  68658. /**
  68659. * 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)
  68660. */
  68661. BLEND = "BLEND",
  68662. }
  68663. /**
  68664. * The type of the primitives to render
  68665. */
  68666. const enum MeshPrimitiveMode {
  68667. /**
  68668. * Points
  68669. */
  68670. POINTS = 0,
  68671. /**
  68672. * Lines
  68673. */
  68674. LINES = 1,
  68675. /**
  68676. * Line Loop
  68677. */
  68678. LINE_LOOP = 2,
  68679. /**
  68680. * Line Strip
  68681. */
  68682. LINE_STRIP = 3,
  68683. /**
  68684. * Triangles
  68685. */
  68686. TRIANGLES = 4,
  68687. /**
  68688. * Triangle Strip
  68689. */
  68690. TRIANGLE_STRIP = 5,
  68691. /**
  68692. * Triangle Fan
  68693. */
  68694. TRIANGLE_FAN = 6,
  68695. }
  68696. /**
  68697. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68698. */
  68699. const enum TextureMagFilter {
  68700. /**
  68701. * Nearest
  68702. */
  68703. NEAREST = 9728,
  68704. /**
  68705. * Linear
  68706. */
  68707. LINEAR = 9729,
  68708. }
  68709. /**
  68710. * Minification filter. All valid values correspond to WebGL enums
  68711. */
  68712. const enum TextureMinFilter {
  68713. /**
  68714. * Nearest
  68715. */
  68716. NEAREST = 9728,
  68717. /**
  68718. * Linear
  68719. */
  68720. LINEAR = 9729,
  68721. /**
  68722. * Nearest Mip-Map Nearest
  68723. */
  68724. NEAREST_MIPMAP_NEAREST = 9984,
  68725. /**
  68726. * Linear Mipmap Nearest
  68727. */
  68728. LINEAR_MIPMAP_NEAREST = 9985,
  68729. /**
  68730. * Nearest Mipmap Linear
  68731. */
  68732. NEAREST_MIPMAP_LINEAR = 9986,
  68733. /**
  68734. * Linear Mipmap Linear
  68735. */
  68736. LINEAR_MIPMAP_LINEAR = 9987,
  68737. }
  68738. /**
  68739. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68740. */
  68741. const enum TextureWrapMode {
  68742. /**
  68743. * Clamp to Edge
  68744. */
  68745. CLAMP_TO_EDGE = 33071,
  68746. /**
  68747. * Mirrored Repeat
  68748. */
  68749. MIRRORED_REPEAT = 33648,
  68750. /**
  68751. * Repeat
  68752. */
  68753. REPEAT = 10497,
  68754. }
  68755. /**
  68756. * glTF Property
  68757. */
  68758. interface IProperty {
  68759. /**
  68760. * Dictionary object with extension-specific objects
  68761. */
  68762. extensions?: {
  68763. [key: string]: any;
  68764. };
  68765. /**
  68766. * Application-Specific data
  68767. */
  68768. extras?: any;
  68769. }
  68770. /**
  68771. * glTF Child of Root Property
  68772. */
  68773. interface IChildRootProperty extends IProperty {
  68774. /**
  68775. * The user-defined name of this object
  68776. */
  68777. name?: string;
  68778. }
  68779. /**
  68780. * Indices of those attributes that deviate from their initialization value
  68781. */
  68782. interface IAccessorSparseIndices extends IProperty {
  68783. /**
  68784. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68785. */
  68786. bufferView: number;
  68787. /**
  68788. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68789. */
  68790. byteOffset?: number;
  68791. /**
  68792. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68793. */
  68794. componentType: AccessorComponentType;
  68795. }
  68796. /**
  68797. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68798. */
  68799. interface IAccessorSparseValues extends IProperty {
  68800. /**
  68801. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68802. */
  68803. bufferView: number;
  68804. /**
  68805. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68806. */
  68807. byteOffset?: number;
  68808. }
  68809. /**
  68810. * Sparse storage of attributes that deviate from their initialization value
  68811. */
  68812. interface IAccessorSparse extends IProperty {
  68813. /**
  68814. * The number of attributes encoded in this sparse accessor
  68815. */
  68816. count: number;
  68817. /**
  68818. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68819. */
  68820. indices: IAccessorSparseIndices;
  68821. /**
  68822. * 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
  68823. */
  68824. values: IAccessorSparseValues;
  68825. }
  68826. /**
  68827. * 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
  68828. */
  68829. interface IAccessor extends IChildRootProperty {
  68830. /**
  68831. * The index of the bufferview
  68832. */
  68833. bufferView?: number;
  68834. /**
  68835. * The offset relative to the start of the bufferView in bytes
  68836. */
  68837. byteOffset?: number;
  68838. /**
  68839. * The datatype of components in the attribute
  68840. */
  68841. componentType: AccessorComponentType;
  68842. /**
  68843. * Specifies whether integer data values should be normalized
  68844. */
  68845. normalized?: boolean;
  68846. /**
  68847. * The number of attributes referenced by this accessor
  68848. */
  68849. count: number;
  68850. /**
  68851. * Specifies if the attribute is a scalar, vector, or matrix
  68852. */
  68853. type: AccessorType;
  68854. /**
  68855. * Maximum value of each component in this attribute
  68856. */
  68857. max?: number[];
  68858. /**
  68859. * Minimum value of each component in this attribute
  68860. */
  68861. min?: number[];
  68862. /**
  68863. * Sparse storage of attributes that deviate from their initialization value
  68864. */
  68865. sparse?: IAccessorSparse;
  68866. }
  68867. /**
  68868. * Targets an animation's sampler at a node's property
  68869. */
  68870. interface IAnimationChannel extends IProperty {
  68871. /**
  68872. * The index of a sampler in this animation used to compute the value for the target
  68873. */
  68874. sampler: number;
  68875. /**
  68876. * The index of the node and TRS property to target
  68877. */
  68878. target: IAnimationChannelTarget;
  68879. }
  68880. /**
  68881. * The index of the node and TRS property that an animation channel targets
  68882. */
  68883. interface IAnimationChannelTarget extends IProperty {
  68884. /**
  68885. * The index of the node to target
  68886. */
  68887. node: number;
  68888. /**
  68889. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68890. */
  68891. path: AnimationChannelTargetPath;
  68892. }
  68893. /**
  68894. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68895. */
  68896. interface IAnimationSampler extends IProperty {
  68897. /**
  68898. * The index of an accessor containing keyframe input values, e.g., time
  68899. */
  68900. input: number;
  68901. /**
  68902. * Interpolation algorithm
  68903. */
  68904. interpolation?: AnimationSamplerInterpolation;
  68905. /**
  68906. * The index of an accessor, containing keyframe output values
  68907. */
  68908. output: number;
  68909. }
  68910. /**
  68911. * A keyframe animation
  68912. */
  68913. interface IAnimation extends IChildRootProperty {
  68914. /**
  68915. * An array of channels, each of which targets an animation's sampler at a node's property
  68916. */
  68917. channels: IAnimationChannel[];
  68918. /**
  68919. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68920. */
  68921. samplers: IAnimationSampler[];
  68922. }
  68923. /**
  68924. * Metadata about the glTF asset
  68925. */
  68926. interface IAsset extends IChildRootProperty {
  68927. /**
  68928. * A copyright message suitable for display to credit the content creator
  68929. */
  68930. copyright?: string;
  68931. /**
  68932. * Tool that generated this glTF model. Useful for debugging
  68933. */
  68934. generator?: string;
  68935. /**
  68936. * The glTF version that this asset targets
  68937. */
  68938. version: string;
  68939. /**
  68940. * The minimum glTF version that this asset targets
  68941. */
  68942. minVersion?: string;
  68943. }
  68944. /**
  68945. * A buffer points to binary geometry, animation, or skins
  68946. */
  68947. interface IBuffer extends IChildRootProperty {
  68948. /**
  68949. * 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
  68950. */
  68951. uri?: string;
  68952. /**
  68953. * The length of the buffer in bytes
  68954. */
  68955. byteLength: number;
  68956. }
  68957. /**
  68958. * A view into a buffer generally representing a subset of the buffer
  68959. */
  68960. interface IBufferView extends IChildRootProperty {
  68961. /**
  68962. * The index of the buffer
  68963. */
  68964. buffer: number;
  68965. /**
  68966. * The offset into the buffer in bytes
  68967. */
  68968. byteOffset?: number;
  68969. /**
  68970. * The lenth of the bufferView in bytes
  68971. */
  68972. byteLength: number;
  68973. /**
  68974. * The stride, in bytes
  68975. */
  68976. byteStride?: number;
  68977. }
  68978. /**
  68979. * An orthographic camera containing properties to create an orthographic projection matrix
  68980. */
  68981. interface ICameraOrthographic extends IProperty {
  68982. /**
  68983. * The floating-point horizontal magnification of the view. Must not be zero
  68984. */
  68985. xmag: number;
  68986. /**
  68987. * The floating-point vertical magnification of the view. Must not be zero
  68988. */
  68989. ymag: number;
  68990. /**
  68991. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68992. */
  68993. zfar: number;
  68994. /**
  68995. * The floating-point distance to the near clipping plane
  68996. */
  68997. znear: number;
  68998. }
  68999. /**
  69000. * A perspective camera containing properties to create a perspective projection matrix
  69001. */
  69002. interface ICameraPerspective extends IProperty {
  69003. /**
  69004. * The floating-point aspect ratio of the field of view
  69005. */
  69006. aspectRatio?: number;
  69007. /**
  69008. * The floating-point vertical field of view in radians
  69009. */
  69010. yfov: number;
  69011. /**
  69012. * The floating-point distance to the far clipping plane
  69013. */
  69014. zfar?: number;
  69015. /**
  69016. * The floating-point distance to the near clipping plane
  69017. */
  69018. znear: number;
  69019. }
  69020. /**
  69021. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69022. */
  69023. interface ICamera extends IChildRootProperty {
  69024. /**
  69025. * An orthographic camera containing properties to create an orthographic projection matrix
  69026. */
  69027. orthographic?: ICameraOrthographic;
  69028. /**
  69029. * A perspective camera containing properties to create a perspective projection matrix
  69030. */
  69031. perspective?: ICameraPerspective;
  69032. /**
  69033. * Specifies if the camera uses a perspective or orthographic projection
  69034. */
  69035. type: CameraType;
  69036. }
  69037. /**
  69038. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69039. */
  69040. interface IImage extends IChildRootProperty {
  69041. /**
  69042. * 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
  69043. */
  69044. uri?: string;
  69045. /**
  69046. * The image's MIME type
  69047. */
  69048. mimeType?: ImageMimeType;
  69049. /**
  69050. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69051. */
  69052. bufferView?: number;
  69053. }
  69054. /**
  69055. * Material Normal Texture Info
  69056. */
  69057. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69058. /**
  69059. * The scalar multiplier applied to each normal vector of the normal texture
  69060. */
  69061. scale?: number;
  69062. }
  69063. /**
  69064. * Material Occlusion Texture Info
  69065. */
  69066. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69067. /**
  69068. * A scalar multiplier controlling the amount of occlusion applied
  69069. */
  69070. strength?: number;
  69071. }
  69072. /**
  69073. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69074. */
  69075. interface IMaterialPbrMetallicRoughness {
  69076. /**
  69077. * The material's base color factor
  69078. */
  69079. baseColorFactor?: number[];
  69080. /**
  69081. * The base color texture
  69082. */
  69083. baseColorTexture?: ITextureInfo;
  69084. /**
  69085. * The metalness of the material
  69086. */
  69087. metallicFactor?: number;
  69088. /**
  69089. * The roughness of the material
  69090. */
  69091. roughnessFactor?: number;
  69092. /**
  69093. * The metallic-roughness texture
  69094. */
  69095. metallicRoughnessTexture?: ITextureInfo;
  69096. }
  69097. /**
  69098. * The material appearance of a primitive
  69099. */
  69100. interface IMaterial extends IChildRootProperty {
  69101. /**
  69102. * 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
  69103. */
  69104. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69105. /**
  69106. * The normal map texture
  69107. */
  69108. normalTexture?: IMaterialNormalTextureInfo;
  69109. /**
  69110. * The occlusion map texture
  69111. */
  69112. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69113. /**
  69114. * The emissive map texture
  69115. */
  69116. emissiveTexture?: ITextureInfo;
  69117. /**
  69118. * 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
  69119. */
  69120. emissiveFactor?: number[];
  69121. /**
  69122. * The alpha rendering mode of the material
  69123. */
  69124. alphaMode?: MaterialAlphaMode;
  69125. /**
  69126. * The alpha cutoff value of the material
  69127. */
  69128. alphaCutoff?: number;
  69129. /**
  69130. * Specifies whether the material is double sided
  69131. */
  69132. doubleSided?: boolean;
  69133. }
  69134. /**
  69135. * Geometry to be rendered with the given material
  69136. */
  69137. interface IMeshPrimitive extends IProperty {
  69138. /**
  69139. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69140. */
  69141. attributes: {
  69142. [name: string]: number;
  69143. };
  69144. /**
  69145. * The index of the accessor that contains the indices
  69146. */
  69147. indices?: number;
  69148. /**
  69149. * The index of the material to apply to this primitive when rendering
  69150. */
  69151. material?: number;
  69152. /**
  69153. * The type of primitives to render. All valid values correspond to WebGL enums
  69154. */
  69155. mode?: MeshPrimitiveMode;
  69156. /**
  69157. * 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
  69158. */
  69159. targets?: {
  69160. [name: string]: number;
  69161. }[];
  69162. }
  69163. /**
  69164. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69165. */
  69166. interface IMesh extends IChildRootProperty {
  69167. /**
  69168. * An array of primitives, each defining geometry to be rendered with a material
  69169. */
  69170. primitives: IMeshPrimitive[];
  69171. /**
  69172. * Array of weights to be applied to the Morph Targets
  69173. */
  69174. weights?: number[];
  69175. }
  69176. /**
  69177. * A node in the node hierarchy
  69178. */
  69179. interface INode extends IChildRootProperty {
  69180. /**
  69181. * The index of the camera referenced by this node
  69182. */
  69183. camera?: number;
  69184. /**
  69185. * The indices of this node's children
  69186. */
  69187. children?: number[];
  69188. /**
  69189. * The index of the skin referenced by this node
  69190. */
  69191. skin?: number;
  69192. /**
  69193. * A floating-point 4x4 transformation matrix stored in column-major order
  69194. */
  69195. matrix?: number[];
  69196. /**
  69197. * The index of the mesh in this node
  69198. */
  69199. mesh?: number;
  69200. /**
  69201. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69202. */
  69203. rotation?: number[];
  69204. /**
  69205. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69206. */
  69207. scale?: number[];
  69208. /**
  69209. * The node's translation along the x, y, and z axes
  69210. */
  69211. translation?: number[];
  69212. /**
  69213. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69214. */
  69215. weights?: number[];
  69216. }
  69217. /**
  69218. * Texture sampler properties for filtering and wrapping modes
  69219. */
  69220. interface ISampler extends IChildRootProperty {
  69221. /**
  69222. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69223. */
  69224. magFilter?: TextureMagFilter;
  69225. /**
  69226. * Minification filter. All valid values correspond to WebGL enums
  69227. */
  69228. minFilter?: TextureMinFilter;
  69229. /**
  69230. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69231. */
  69232. wrapS?: TextureWrapMode;
  69233. /**
  69234. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69235. */
  69236. wrapT?: TextureWrapMode;
  69237. }
  69238. /**
  69239. * The root nodes of a scene
  69240. */
  69241. interface IScene extends IChildRootProperty {
  69242. /**
  69243. * The indices of each root node
  69244. */
  69245. nodes: number[];
  69246. }
  69247. /**
  69248. * Joints and matrices defining a skin
  69249. */
  69250. interface ISkin extends IChildRootProperty {
  69251. /**
  69252. * 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
  69253. */
  69254. inverseBindMatrices?: number;
  69255. /**
  69256. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69257. */
  69258. skeleton?: number;
  69259. /**
  69260. * 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)
  69261. */
  69262. joints: number[];
  69263. }
  69264. /**
  69265. * A texture and its sampler
  69266. */
  69267. interface ITexture extends IChildRootProperty {
  69268. /**
  69269. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69270. */
  69271. sampler?: number;
  69272. /**
  69273. * The index of the image used by this texture
  69274. */
  69275. source: number;
  69276. }
  69277. /**
  69278. * Reference to a texture
  69279. */
  69280. interface ITextureInfo extends IProperty {
  69281. /**
  69282. * The index of the texture
  69283. */
  69284. index: number;
  69285. /**
  69286. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69287. */
  69288. texCoord?: number;
  69289. }
  69290. /**
  69291. * The root object for a glTF asset
  69292. */
  69293. interface IGLTF extends IProperty {
  69294. /**
  69295. * An array of accessors. An accessor is a typed view into a bufferView
  69296. */
  69297. accessors?: IAccessor[];
  69298. /**
  69299. * An array of keyframe animations
  69300. */
  69301. animations?: IAnimation[];
  69302. /**
  69303. * Metadata about the glTF asset
  69304. */
  69305. asset: IAsset;
  69306. /**
  69307. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69308. */
  69309. buffers?: IBuffer[];
  69310. /**
  69311. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69312. */
  69313. bufferViews?: IBufferView[];
  69314. /**
  69315. * An array of cameras
  69316. */
  69317. cameras?: ICamera[];
  69318. /**
  69319. * Names of glTF extensions used somewhere in this asset
  69320. */
  69321. extensionsUsed?: string[];
  69322. /**
  69323. * Names of glTF extensions required to properly load this asset
  69324. */
  69325. extensionsRequired?: string[];
  69326. /**
  69327. * An array of images. An image defines data used to create a texture
  69328. */
  69329. images?: IImage[];
  69330. /**
  69331. * An array of materials. A material defines the appearance of a primitive
  69332. */
  69333. materials?: IMaterial[];
  69334. /**
  69335. * An array of meshes. A mesh is a set of primitives to be rendered
  69336. */
  69337. meshes?: IMesh[];
  69338. /**
  69339. * An array of nodes
  69340. */
  69341. nodes?: INode[];
  69342. /**
  69343. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69344. */
  69345. samplers?: ISampler[];
  69346. /**
  69347. * The index of the default scene
  69348. */
  69349. scene?: number;
  69350. /**
  69351. * An array of scenes
  69352. */
  69353. scenes?: IScene[];
  69354. /**
  69355. * An array of skins. A skin is defined by joints and matrices
  69356. */
  69357. skins?: ISkin[];
  69358. /**
  69359. * An array of textures
  69360. */
  69361. textures?: ITexture[];
  69362. }
  69363. /**
  69364. * The glTF validation results
  69365. */
  69366. interface IGLTFValidationResults {
  69367. info: {
  69368. generator: string;
  69369. hasAnimations: boolean;
  69370. hasDefaultScene: boolean;
  69371. hasMaterials: boolean;
  69372. hasMorphTargets: boolean;
  69373. hasSkins: boolean;
  69374. hasTextures: boolean;
  69375. maxAttributesUsed: number;
  69376. primitivesCount: number
  69377. };
  69378. issues: {
  69379. messages: Array<string>;
  69380. numErrors: number;
  69381. numHints: number;
  69382. numInfos: number;
  69383. numWarnings: number;
  69384. truncated: boolean
  69385. };
  69386. mimeType: string;
  69387. uri: string;
  69388. validatedAt: string;
  69389. validatorVersion: string;
  69390. }
  69391. /**
  69392. * The glTF validation options
  69393. */
  69394. interface IGLTFValidationOptions {
  69395. uri?: string;
  69396. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69397. validateAccessorData?: boolean;
  69398. maxIssues?: number;
  69399. ignoredIssues?: Array<string>;
  69400. severityOverrides?: Object;
  69401. }
  69402. /**
  69403. * The glTF validator object
  69404. */
  69405. interface IGLTFValidator {
  69406. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69407. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69408. }
  69409. }
  69410. declare module BABYLON {
  69411. /** @hidden */
  69412. export var cellPixelShader: {
  69413. name: string;
  69414. shader: string;
  69415. };
  69416. }
  69417. declare module BABYLON {
  69418. /** @hidden */
  69419. export var cellVertexShader: {
  69420. name: string;
  69421. shader: string;
  69422. };
  69423. }
  69424. declare module BABYLON {
  69425. export class CellMaterial extends BABYLON.PushMaterial {
  69426. private _diffuseTexture;
  69427. diffuseTexture: BABYLON.BaseTexture;
  69428. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  69429. computeHighLevel: boolean;
  69430. private _disableLighting;
  69431. disableLighting: boolean;
  69432. private _maxSimultaneousLights;
  69433. maxSimultaneousLights: number;
  69434. private _renderId;
  69435. constructor(name: string, scene: BABYLON.Scene);
  69436. needAlphaBlending(): boolean;
  69437. needAlphaTesting(): boolean;
  69438. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69439. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69440. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69441. getAnimatables(): BABYLON.IAnimatable[];
  69442. getActiveTextures(): BABYLON.BaseTexture[];
  69443. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69444. dispose(forceDisposeEffect?: boolean): void;
  69445. getClassName(): string;
  69446. clone(name: string): CellMaterial;
  69447. serialize(): any;
  69448. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69449. }
  69450. }
  69451. declare module BABYLON {
  69452. export class CustomShaderStructure {
  69453. FragmentStore: string;
  69454. VertexStore: string;
  69455. constructor();
  69456. }
  69457. export class ShaderSpecialParts {
  69458. constructor();
  69459. Fragment_Begin: string;
  69460. Fragment_Definitions: string;
  69461. Fragment_MainBegin: string;
  69462. Fragment_Custom_Diffuse: string;
  69463. Fragment_Before_Lights: string;
  69464. Fragment_Before_Fog: string;
  69465. Fragment_Custom_Alpha: string;
  69466. Fragment_Before_FragColor: string;
  69467. Vertex_Begin: string;
  69468. Vertex_Definitions: string;
  69469. Vertex_MainBegin: string;
  69470. Vertex_Before_PositionUpdated: string;
  69471. Vertex_Before_NormalUpdated: string;
  69472. Vertex_MainEnd: string;
  69473. }
  69474. export class CustomMaterial extends BABYLON.StandardMaterial {
  69475. static ShaderIndexer: number;
  69476. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69477. FragmentShader: string;
  69478. VertexShader: string;
  69479. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69480. ReviewUniform(name: string, arr: string[]): string[];
  69481. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69482. constructor(name: string, scene: BABYLON.Scene);
  69483. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69484. Fragment_Begin(shaderPart: string): CustomMaterial;
  69485. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69486. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69487. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69488. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69489. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69490. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69491. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69492. Vertex_Begin(shaderPart: string): CustomMaterial;
  69493. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69494. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69495. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69496. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69497. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69498. }
  69499. }
  69500. declare module BABYLON {
  69501. export class ShaderAlebdoParts {
  69502. constructor();
  69503. Fragment_Begin: string;
  69504. Fragment_Definitions: string;
  69505. Fragment_MainBegin: string;
  69506. Fragment_Custom_Albedo: string;
  69507. Fragment_Before_Lights: string;
  69508. Fragment_Custom_MetallicRoughness: string;
  69509. Fragment_Custom_MicroSurface: string;
  69510. Fragment_Before_Fog: string;
  69511. Fragment_Custom_Alpha: string;
  69512. Fragment_Before_FragColor: string;
  69513. Vertex_Begin: string;
  69514. Vertex_Definitions: string;
  69515. Vertex_MainBegin: string;
  69516. Vertex_Before_PositionUpdated: string;
  69517. Vertex_Before_NormalUpdated: string;
  69518. Vertex_MainEnd: string;
  69519. }
  69520. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69521. static ShaderIndexer: number;
  69522. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69523. FragmentShader: string;
  69524. VertexShader: string;
  69525. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69526. ReviewUniform(name: string, arr: string[]): string[];
  69527. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69528. constructor(name: string, scene: BABYLON.Scene);
  69529. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69530. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69531. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69532. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69533. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69534. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69535. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69536. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69537. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69538. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69539. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69540. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69541. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69542. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69543. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69544. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69545. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69546. }
  69547. }
  69548. declare module BABYLON {
  69549. /** @hidden */
  69550. export var firePixelShader: {
  69551. name: string;
  69552. shader: string;
  69553. };
  69554. }
  69555. declare module BABYLON {
  69556. /** @hidden */
  69557. export var fireVertexShader: {
  69558. name: string;
  69559. shader: string;
  69560. };
  69561. }
  69562. declare module BABYLON {
  69563. export class FireMaterial extends BABYLON.PushMaterial {
  69564. private _diffuseTexture;
  69565. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69566. private _distortionTexture;
  69567. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69568. private _opacityTexture;
  69569. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69570. diffuseColor: BABYLON.Color3;
  69571. speed: number;
  69572. private _scaledDiffuse;
  69573. private _renderId;
  69574. private _lastTime;
  69575. constructor(name: string, scene: BABYLON.Scene);
  69576. needAlphaBlending(): boolean;
  69577. needAlphaTesting(): boolean;
  69578. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69579. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69580. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69581. getAnimatables(): BABYLON.IAnimatable[];
  69582. getActiveTextures(): BABYLON.BaseTexture[];
  69583. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69584. getClassName(): string;
  69585. dispose(forceDisposeEffect?: boolean): void;
  69586. clone(name: string): FireMaterial;
  69587. serialize(): any;
  69588. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69589. }
  69590. }
  69591. declare module BABYLON {
  69592. /** @hidden */
  69593. export var furPixelShader: {
  69594. name: string;
  69595. shader: string;
  69596. };
  69597. }
  69598. declare module BABYLON {
  69599. /** @hidden */
  69600. export var furVertexShader: {
  69601. name: string;
  69602. shader: string;
  69603. };
  69604. }
  69605. declare module BABYLON {
  69606. export class FurMaterial extends BABYLON.PushMaterial {
  69607. private _diffuseTexture;
  69608. diffuseTexture: BABYLON.BaseTexture;
  69609. private _heightTexture;
  69610. heightTexture: BABYLON.BaseTexture;
  69611. diffuseColor: BABYLON.Color3;
  69612. furLength: number;
  69613. furAngle: number;
  69614. furColor: BABYLON.Color3;
  69615. furOffset: number;
  69616. furSpacing: number;
  69617. furGravity: BABYLON.Vector3;
  69618. furSpeed: number;
  69619. furDensity: number;
  69620. furOcclusion: number;
  69621. furTexture: BABYLON.DynamicTexture;
  69622. private _disableLighting;
  69623. disableLighting: boolean;
  69624. private _maxSimultaneousLights;
  69625. maxSimultaneousLights: number;
  69626. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  69627. private _renderId;
  69628. private _furTime;
  69629. constructor(name: string, scene: BABYLON.Scene);
  69630. furTime: number;
  69631. needAlphaBlending(): boolean;
  69632. needAlphaTesting(): boolean;
  69633. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69634. updateFur(): void;
  69635. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69636. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69637. getAnimatables(): BABYLON.IAnimatable[];
  69638. getActiveTextures(): BABYLON.BaseTexture[];
  69639. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69640. dispose(forceDisposeEffect?: boolean): void;
  69641. clone(name: string): FurMaterial;
  69642. serialize(): any;
  69643. getClassName(): string;
  69644. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69645. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69646. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69647. }
  69648. }
  69649. declare module BABYLON {
  69650. /** @hidden */
  69651. export var gradientPixelShader: {
  69652. name: string;
  69653. shader: string;
  69654. };
  69655. }
  69656. declare module BABYLON {
  69657. /** @hidden */
  69658. export var gradientVertexShader: {
  69659. name: string;
  69660. shader: string;
  69661. };
  69662. }
  69663. declare module BABYLON {
  69664. export class GradientMaterial extends BABYLON.PushMaterial {
  69665. private _maxSimultaneousLights;
  69666. maxSimultaneousLights: number;
  69667. topColor: BABYLON.Color3;
  69668. topColorAlpha: number;
  69669. bottomColor: BABYLON.Color3;
  69670. bottomColorAlpha: number;
  69671. offset: number;
  69672. scale: number;
  69673. smoothness: number;
  69674. private _disableLighting;
  69675. disableLighting: boolean;
  69676. private _renderId;
  69677. constructor(name: string, scene: BABYLON.Scene);
  69678. needAlphaBlending(): boolean;
  69679. needAlphaTesting(): boolean;
  69680. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69681. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69682. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69683. getAnimatables(): BABYLON.IAnimatable[];
  69684. dispose(forceDisposeEffect?: boolean): void;
  69685. clone(name: string): GradientMaterial;
  69686. serialize(): any;
  69687. getClassName(): string;
  69688. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69689. }
  69690. }
  69691. declare module BABYLON {
  69692. /** @hidden */
  69693. export var gridPixelShader: {
  69694. name: string;
  69695. shader: string;
  69696. };
  69697. }
  69698. declare module BABYLON {
  69699. /** @hidden */
  69700. export var gridVertexShader: {
  69701. name: string;
  69702. shader: string;
  69703. };
  69704. }
  69705. declare module BABYLON {
  69706. /**
  69707. * The grid materials allows you to wrap any shape with a grid.
  69708. * Colors are customizable.
  69709. */
  69710. export class GridMaterial extends BABYLON.PushMaterial {
  69711. /**
  69712. * Main color of the grid (e.g. between lines)
  69713. */
  69714. mainColor: BABYLON.Color3;
  69715. /**
  69716. * Color of the grid lines.
  69717. */
  69718. lineColor: BABYLON.Color3;
  69719. /**
  69720. * The scale of the grid compared to unit.
  69721. */
  69722. gridRatio: number;
  69723. /**
  69724. * Allows setting an offset for the grid lines.
  69725. */
  69726. gridOffset: BABYLON.Vector3;
  69727. /**
  69728. * The frequency of thicker lines.
  69729. */
  69730. majorUnitFrequency: number;
  69731. /**
  69732. * The visibility of minor units in the grid.
  69733. */
  69734. minorUnitVisibility: number;
  69735. /**
  69736. * The grid opacity outside of the lines.
  69737. */
  69738. opacity: number;
  69739. /**
  69740. * Determine RBG output is premultiplied by alpha value.
  69741. */
  69742. preMultiplyAlpha: boolean;
  69743. private _opacityTexture;
  69744. opacityTexture: BABYLON.BaseTexture;
  69745. private _gridControl;
  69746. private _renderId;
  69747. /**
  69748. * constructor
  69749. * @param name The name given to the material in order to identify it afterwards.
  69750. * @param scene The scene the material is used in.
  69751. */
  69752. constructor(name: string, scene: BABYLON.Scene);
  69753. /**
  69754. * Returns wehter or not the grid requires alpha blending.
  69755. */
  69756. needAlphaBlending(): boolean;
  69757. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69758. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69759. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69760. /**
  69761. * Dispose the material and its associated resources.
  69762. * @param forceDisposeEffect will also dispose the used effect when true
  69763. */
  69764. dispose(forceDisposeEffect?: boolean): void;
  69765. clone(name: string): GridMaterial;
  69766. serialize(): any;
  69767. getClassName(): string;
  69768. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69769. }
  69770. }
  69771. declare module BABYLON {
  69772. /** @hidden */
  69773. export var lavaPixelShader: {
  69774. name: string;
  69775. shader: string;
  69776. };
  69777. }
  69778. declare module BABYLON {
  69779. /** @hidden */
  69780. export var lavaVertexShader: {
  69781. name: string;
  69782. shader: string;
  69783. };
  69784. }
  69785. declare module BABYLON {
  69786. export class LavaMaterial extends BABYLON.PushMaterial {
  69787. private _diffuseTexture;
  69788. diffuseTexture: BABYLON.BaseTexture;
  69789. noiseTexture: BABYLON.BaseTexture;
  69790. fogColor: BABYLON.Color3;
  69791. speed: number;
  69792. movingSpeed: number;
  69793. lowFrequencySpeed: number;
  69794. fogDensity: number;
  69795. private _lastTime;
  69796. diffuseColor: BABYLON.Color3;
  69797. private _disableLighting;
  69798. disableLighting: boolean;
  69799. private _unlit;
  69800. unlit: boolean;
  69801. private _maxSimultaneousLights;
  69802. maxSimultaneousLights: number;
  69803. private _scaledDiffuse;
  69804. private _renderId;
  69805. constructor(name: string, scene: BABYLON.Scene);
  69806. needAlphaBlending(): boolean;
  69807. needAlphaTesting(): boolean;
  69808. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69809. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69810. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69811. getAnimatables(): BABYLON.IAnimatable[];
  69812. getActiveTextures(): BABYLON.BaseTexture[];
  69813. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69814. dispose(forceDisposeEffect?: boolean): void;
  69815. clone(name: string): LavaMaterial;
  69816. serialize(): any;
  69817. getClassName(): string;
  69818. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69819. }
  69820. }
  69821. declare module BABYLON {
  69822. /** @hidden */
  69823. export var mixPixelShader: {
  69824. name: string;
  69825. shader: string;
  69826. };
  69827. }
  69828. declare module BABYLON {
  69829. /** @hidden */
  69830. export var mixVertexShader: {
  69831. name: string;
  69832. shader: string;
  69833. };
  69834. }
  69835. declare module BABYLON {
  69836. export class MixMaterial extends BABYLON.PushMaterial {
  69837. /**
  69838. * Mix textures
  69839. */
  69840. private _mixTexture1;
  69841. mixTexture1: BABYLON.BaseTexture;
  69842. private _mixTexture2;
  69843. mixTexture2: BABYLON.BaseTexture;
  69844. /**
  69845. * Diffuse textures
  69846. */
  69847. private _diffuseTexture1;
  69848. diffuseTexture1: BABYLON.Texture;
  69849. private _diffuseTexture2;
  69850. diffuseTexture2: BABYLON.Texture;
  69851. private _diffuseTexture3;
  69852. diffuseTexture3: BABYLON.Texture;
  69853. private _diffuseTexture4;
  69854. diffuseTexture4: BABYLON.Texture;
  69855. private _diffuseTexture5;
  69856. diffuseTexture5: BABYLON.Texture;
  69857. private _diffuseTexture6;
  69858. diffuseTexture6: BABYLON.Texture;
  69859. private _diffuseTexture7;
  69860. diffuseTexture7: BABYLON.Texture;
  69861. private _diffuseTexture8;
  69862. diffuseTexture8: BABYLON.Texture;
  69863. /**
  69864. * Uniforms
  69865. */
  69866. diffuseColor: BABYLON.Color3;
  69867. specularColor: BABYLON.Color3;
  69868. specularPower: number;
  69869. private _disableLighting;
  69870. disableLighting: boolean;
  69871. private _maxSimultaneousLights;
  69872. maxSimultaneousLights: number;
  69873. private _renderId;
  69874. constructor(name: string, scene: BABYLON.Scene);
  69875. needAlphaBlending(): boolean;
  69876. needAlphaTesting(): boolean;
  69877. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69878. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69879. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69880. getAnimatables(): BABYLON.IAnimatable[];
  69881. getActiveTextures(): BABYLON.BaseTexture[];
  69882. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69883. dispose(forceDisposeEffect?: boolean): void;
  69884. clone(name: string): MixMaterial;
  69885. serialize(): any;
  69886. getClassName(): string;
  69887. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69888. }
  69889. }
  69890. declare module BABYLON {
  69891. /** @hidden */
  69892. export var normalPixelShader: {
  69893. name: string;
  69894. shader: string;
  69895. };
  69896. }
  69897. declare module BABYLON {
  69898. /** @hidden */
  69899. export var normalVertexShader: {
  69900. name: string;
  69901. shader: string;
  69902. };
  69903. }
  69904. declare module BABYLON {
  69905. export class NormalMaterial extends BABYLON.PushMaterial {
  69906. private _diffuseTexture;
  69907. diffuseTexture: BABYLON.BaseTexture;
  69908. diffuseColor: BABYLON.Color3;
  69909. private _disableLighting;
  69910. disableLighting: boolean;
  69911. private _maxSimultaneousLights;
  69912. maxSimultaneousLights: number;
  69913. private _renderId;
  69914. constructor(name: string, scene: BABYLON.Scene);
  69915. needAlphaBlending(): boolean;
  69916. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69917. needAlphaTesting(): boolean;
  69918. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69919. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69920. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69921. getAnimatables(): BABYLON.IAnimatable[];
  69922. getActiveTextures(): BABYLON.BaseTexture[];
  69923. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69924. dispose(forceDisposeEffect?: boolean): void;
  69925. clone(name: string): NormalMaterial;
  69926. serialize(): any;
  69927. getClassName(): string;
  69928. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69929. }
  69930. }
  69931. declare module BABYLON {
  69932. /** @hidden */
  69933. export var shadowOnlyPixelShader: {
  69934. name: string;
  69935. shader: string;
  69936. };
  69937. }
  69938. declare module BABYLON {
  69939. /** @hidden */
  69940. export var shadowOnlyVertexShader: {
  69941. name: string;
  69942. shader: string;
  69943. };
  69944. }
  69945. declare module BABYLON {
  69946. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69947. private _renderId;
  69948. private _activeLight;
  69949. constructor(name: string, scene: BABYLON.Scene);
  69950. shadowColor: BABYLON.Color3;
  69951. needAlphaBlending(): boolean;
  69952. needAlphaTesting(): boolean;
  69953. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69954. activeLight: BABYLON.IShadowLight;
  69955. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69956. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69957. clone(name: string): ShadowOnlyMaterial;
  69958. serialize(): any;
  69959. getClassName(): string;
  69960. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69961. }
  69962. }
  69963. declare module BABYLON {
  69964. /** @hidden */
  69965. export var simplePixelShader: {
  69966. name: string;
  69967. shader: string;
  69968. };
  69969. }
  69970. declare module BABYLON {
  69971. /** @hidden */
  69972. export var simpleVertexShader: {
  69973. name: string;
  69974. shader: string;
  69975. };
  69976. }
  69977. declare module BABYLON {
  69978. export class SimpleMaterial extends BABYLON.PushMaterial {
  69979. private _diffuseTexture;
  69980. diffuseTexture: BABYLON.BaseTexture;
  69981. diffuseColor: BABYLON.Color3;
  69982. private _disableLighting;
  69983. disableLighting: boolean;
  69984. private _maxSimultaneousLights;
  69985. maxSimultaneousLights: number;
  69986. private _renderId;
  69987. constructor(name: string, scene: BABYLON.Scene);
  69988. needAlphaBlending(): boolean;
  69989. needAlphaTesting(): boolean;
  69990. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69993. getAnimatables(): BABYLON.IAnimatable[];
  69994. getActiveTextures(): BABYLON.BaseTexture[];
  69995. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69996. dispose(forceDisposeEffect?: boolean): void;
  69997. clone(name: string): SimpleMaterial;
  69998. serialize(): any;
  69999. getClassName(): string;
  70000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70001. }
  70002. }
  70003. declare module BABYLON {
  70004. /** @hidden */
  70005. export var skyPixelShader: {
  70006. name: string;
  70007. shader: string;
  70008. };
  70009. }
  70010. declare module BABYLON {
  70011. /** @hidden */
  70012. export var skyVertexShader: {
  70013. name: string;
  70014. shader: string;
  70015. };
  70016. }
  70017. declare module BABYLON {
  70018. /**
  70019. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70020. * @see https://doc.babylonjs.com/extensions/sky
  70021. */
  70022. export class SkyMaterial extends BABYLON.PushMaterial {
  70023. /**
  70024. * Defines the overall luminance of sky in interval ]0, 1[.
  70025. */
  70026. luminance: number;
  70027. /**
  70028. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70029. */
  70030. turbidity: number;
  70031. /**
  70032. * Defines the sky appearance (light intensity).
  70033. */
  70034. rayleigh: number;
  70035. /**
  70036. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70037. */
  70038. mieCoefficient: number;
  70039. /**
  70040. * Defines the amount of haze particles following the Mie scattering theory.
  70041. */
  70042. mieDirectionalG: number;
  70043. /**
  70044. * Defines the distance of the sun according to the active scene camera.
  70045. */
  70046. distance: number;
  70047. /**
  70048. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70049. * "inclined".
  70050. */
  70051. inclination: number;
  70052. /**
  70053. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70054. * an object direction and a reference direction.
  70055. */
  70056. azimuth: number;
  70057. /**
  70058. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70059. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70060. */
  70061. sunPosition: BABYLON.Vector3;
  70062. /**
  70063. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70064. * .sunPosition property.
  70065. */
  70066. useSunPosition: boolean;
  70067. /**
  70068. * Defines an offset vector used to get a horizon offset.
  70069. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70070. */
  70071. cameraOffset: BABYLON.Vector3;
  70072. private _cameraPosition;
  70073. private _renderId;
  70074. /**
  70075. * Instantiates a new sky material.
  70076. * This material allows to create dynamic and texture free
  70077. * effects for skyboxes by taking care of the atmosphere state.
  70078. * @see https://doc.babylonjs.com/extensions/sky
  70079. * @param name Define the name of the material in the scene
  70080. * @param scene Define the scene the material belong to
  70081. */
  70082. constructor(name: string, scene: BABYLON.Scene);
  70083. /**
  70084. * Specifies if the material will require alpha blending
  70085. * @returns a boolean specifying if alpha blending is needed
  70086. */
  70087. needAlphaBlending(): boolean;
  70088. /**
  70089. * Specifies if this material should be rendered in alpha test mode
  70090. * @returns false as the sky material doesn't need alpha testing.
  70091. */
  70092. needAlphaTesting(): boolean;
  70093. /**
  70094. * Get the texture used for alpha test purpose.
  70095. * @returns null as the sky material has no texture.
  70096. */
  70097. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70098. /**
  70099. * Get if the submesh is ready to be used and all its information available.
  70100. * Child classes can use it to update shaders
  70101. * @param mesh defines the mesh to check
  70102. * @param subMesh defines which submesh to check
  70103. * @param useInstances specifies that instances should be used
  70104. * @returns a boolean indicating that the submesh is ready or not
  70105. */
  70106. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70107. /**
  70108. * Binds the submesh to this material by preparing the effect and shader to draw
  70109. * @param world defines the world transformation matrix
  70110. * @param mesh defines the mesh containing the submesh
  70111. * @param subMesh defines the submesh to bind the material to
  70112. */
  70113. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70114. /**
  70115. * Get the list of animatables in the material.
  70116. * @returns the list of animatables object used in the material
  70117. */
  70118. getAnimatables(): BABYLON.IAnimatable[];
  70119. /**
  70120. * Disposes the material
  70121. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70122. */
  70123. dispose(forceDisposeEffect?: boolean): void;
  70124. /**
  70125. * Makes a duplicate of the material, and gives it a new name
  70126. * @param name defines the new name for the duplicated material
  70127. * @returns the cloned material
  70128. */
  70129. clone(name: string): SkyMaterial;
  70130. /**
  70131. * Serializes this material in a JSON representation
  70132. * @returns the serialized material object
  70133. */
  70134. serialize(): any;
  70135. /**
  70136. * Gets the current class name of the material e.g. "SkyMaterial"
  70137. * Mainly use in serialization.
  70138. * @returns the class name
  70139. */
  70140. getClassName(): string;
  70141. /**
  70142. * Creates a sky material from parsed material data
  70143. * @param source defines the JSON representation of the material
  70144. * @param scene defines the hosting scene
  70145. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70146. * @returns a new sky material
  70147. */
  70148. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70149. }
  70150. }
  70151. declare module BABYLON {
  70152. /** @hidden */
  70153. export var terrainPixelShader: {
  70154. name: string;
  70155. shader: string;
  70156. };
  70157. }
  70158. declare module BABYLON {
  70159. /** @hidden */
  70160. export var terrainVertexShader: {
  70161. name: string;
  70162. shader: string;
  70163. };
  70164. }
  70165. declare module BABYLON {
  70166. export class TerrainMaterial extends BABYLON.PushMaterial {
  70167. private _mixTexture;
  70168. mixTexture: BABYLON.BaseTexture;
  70169. private _diffuseTexture1;
  70170. diffuseTexture1: BABYLON.Texture;
  70171. private _diffuseTexture2;
  70172. diffuseTexture2: BABYLON.Texture;
  70173. private _diffuseTexture3;
  70174. diffuseTexture3: BABYLON.Texture;
  70175. private _bumpTexture1;
  70176. bumpTexture1: BABYLON.Texture;
  70177. private _bumpTexture2;
  70178. bumpTexture2: BABYLON.Texture;
  70179. private _bumpTexture3;
  70180. bumpTexture3: BABYLON.Texture;
  70181. diffuseColor: BABYLON.Color3;
  70182. specularColor: BABYLON.Color3;
  70183. specularPower: number;
  70184. private _disableLighting;
  70185. disableLighting: boolean;
  70186. private _maxSimultaneousLights;
  70187. maxSimultaneousLights: number;
  70188. private _renderId;
  70189. constructor(name: string, scene: BABYLON.Scene);
  70190. needAlphaBlending(): boolean;
  70191. needAlphaTesting(): boolean;
  70192. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70193. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70194. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70195. getAnimatables(): BABYLON.IAnimatable[];
  70196. getActiveTextures(): BABYLON.BaseTexture[];
  70197. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70198. dispose(forceDisposeEffect?: boolean): void;
  70199. clone(name: string): TerrainMaterial;
  70200. serialize(): any;
  70201. getClassName(): string;
  70202. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70203. }
  70204. }
  70205. declare module BABYLON {
  70206. /** @hidden */
  70207. export var triplanarPixelShader: {
  70208. name: string;
  70209. shader: string;
  70210. };
  70211. }
  70212. declare module BABYLON {
  70213. /** @hidden */
  70214. export var triplanarVertexShader: {
  70215. name: string;
  70216. shader: string;
  70217. };
  70218. }
  70219. declare module BABYLON {
  70220. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70221. mixTexture: BABYLON.BaseTexture;
  70222. private _diffuseTextureX;
  70223. diffuseTextureX: BABYLON.BaseTexture;
  70224. private _diffuseTextureY;
  70225. diffuseTextureY: BABYLON.BaseTexture;
  70226. private _diffuseTextureZ;
  70227. diffuseTextureZ: BABYLON.BaseTexture;
  70228. private _normalTextureX;
  70229. normalTextureX: BABYLON.BaseTexture;
  70230. private _normalTextureY;
  70231. normalTextureY: BABYLON.BaseTexture;
  70232. private _normalTextureZ;
  70233. normalTextureZ: BABYLON.BaseTexture;
  70234. tileSize: number;
  70235. diffuseColor: BABYLON.Color3;
  70236. specularColor: BABYLON.Color3;
  70237. specularPower: number;
  70238. private _disableLighting;
  70239. disableLighting: boolean;
  70240. private _maxSimultaneousLights;
  70241. maxSimultaneousLights: number;
  70242. private _renderId;
  70243. constructor(name: string, scene: BABYLON.Scene);
  70244. needAlphaBlending(): boolean;
  70245. needAlphaTesting(): boolean;
  70246. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70247. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70248. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70249. getAnimatables(): BABYLON.IAnimatable[];
  70250. getActiveTextures(): BABYLON.BaseTexture[];
  70251. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70252. dispose(forceDisposeEffect?: boolean): void;
  70253. clone(name: string): TriPlanarMaterial;
  70254. serialize(): any;
  70255. getClassName(): string;
  70256. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70257. }
  70258. }
  70259. declare module BABYLON {
  70260. /** @hidden */
  70261. export var waterPixelShader: {
  70262. name: string;
  70263. shader: string;
  70264. };
  70265. }
  70266. declare module BABYLON {
  70267. /** @hidden */
  70268. export var waterVertexShader: {
  70269. name: string;
  70270. shader: string;
  70271. };
  70272. }
  70273. declare module BABYLON {
  70274. export class WaterMaterial extends BABYLON.PushMaterial {
  70275. renderTargetSize: BABYLON.Vector2;
  70276. private _bumpTexture;
  70277. bumpTexture: BABYLON.BaseTexture;
  70278. diffuseColor: BABYLON.Color3;
  70279. specularColor: BABYLON.Color3;
  70280. specularPower: number;
  70281. private _disableLighting;
  70282. disableLighting: boolean;
  70283. private _maxSimultaneousLights;
  70284. maxSimultaneousLights: number;
  70285. /**
  70286. * @param {number}: Represents the wind force
  70287. */
  70288. windForce: number;
  70289. /**
  70290. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70291. */
  70292. windDirection: BABYLON.Vector2;
  70293. /**
  70294. * @param {number}: Wave height, represents the height of the waves
  70295. */
  70296. waveHeight: number;
  70297. /**
  70298. * @param {number}: Bump height, represents the bump height related to the bump map
  70299. */
  70300. bumpHeight: number;
  70301. /**
  70302. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70303. */
  70304. private _bumpSuperimpose;
  70305. bumpSuperimpose: boolean;
  70306. /**
  70307. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70308. */
  70309. private _fresnelSeparate;
  70310. fresnelSeparate: boolean;
  70311. /**
  70312. * @param {boolean}: bump Waves modify the reflection.
  70313. */
  70314. private _bumpAffectsReflection;
  70315. bumpAffectsReflection: boolean;
  70316. /**
  70317. * @param {number}: The water color blended with the refraction (near)
  70318. */
  70319. waterColor: BABYLON.Color3;
  70320. /**
  70321. * @param {number}: The blend factor related to the water color
  70322. */
  70323. colorBlendFactor: number;
  70324. /**
  70325. * @param {number}: The water color blended with the reflection (far)
  70326. */
  70327. waterColor2: BABYLON.Color3;
  70328. /**
  70329. * @param {number}: The blend factor related to the water color (reflection, far)
  70330. */
  70331. colorBlendFactor2: number;
  70332. /**
  70333. * @param {number}: Represents the maximum length of a wave
  70334. */
  70335. waveLength: number;
  70336. /**
  70337. * @param {number}: Defines the waves speed
  70338. */
  70339. waveSpeed: number;
  70340. /**
  70341. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70342. * will avoid calculating useless pixels in the pixel shader of the water material.
  70343. */
  70344. disableClipPlane: boolean;
  70345. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70346. private _mesh;
  70347. private _refractionRTT;
  70348. private _reflectionRTT;
  70349. private _reflectionTransform;
  70350. private _lastTime;
  70351. private _lastDeltaTime;
  70352. private _renderId;
  70353. private _useLogarithmicDepth;
  70354. private _waitingRenderList;
  70355. private _imageProcessingConfiguration;
  70356. private _imageProcessingObserver;
  70357. /**
  70358. * Gets a boolean indicating that current material needs to register RTT
  70359. */
  70360. readonly hasRenderTargetTextures: boolean;
  70361. /**
  70362. * Constructor
  70363. */
  70364. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70365. useLogarithmicDepth: boolean;
  70366. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70367. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70368. addToRenderList(node: any): void;
  70369. enableRenderTargets(enable: boolean): void;
  70370. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70371. readonly renderTargetsEnabled: boolean;
  70372. needAlphaBlending(): boolean;
  70373. needAlphaTesting(): boolean;
  70374. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70377. private _createRenderTargets;
  70378. getAnimatables(): BABYLON.IAnimatable[];
  70379. getActiveTextures(): BABYLON.BaseTexture[];
  70380. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70381. dispose(forceDisposeEffect?: boolean): void;
  70382. clone(name: string): WaterMaterial;
  70383. serialize(): any;
  70384. getClassName(): string;
  70385. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70386. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70387. }
  70388. }
  70389. declare module BABYLON {
  70390. /** @hidden */
  70391. export var asciiartPixelShader: {
  70392. name: string;
  70393. shader: string;
  70394. };
  70395. }
  70396. declare module BABYLON {
  70397. /**
  70398. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70399. *
  70400. * It basically takes care rendering the font front the given font size to a texture.
  70401. * This is used later on in the postprocess.
  70402. */
  70403. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70404. private _font;
  70405. private _text;
  70406. private _charSize;
  70407. /**
  70408. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70409. */
  70410. readonly charSize: number;
  70411. /**
  70412. * Create a new instance of the Ascii Art FontTexture class
  70413. * @param name the name of the texture
  70414. * @param font the font to use, use the W3C CSS notation
  70415. * @param text the caracter set to use in the rendering.
  70416. * @param scene the scene that owns the texture
  70417. */
  70418. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70419. /**
  70420. * Gets the max char width of a font.
  70421. * @param font the font to use, use the W3C CSS notation
  70422. * @return the max char width
  70423. */
  70424. private getFontWidth;
  70425. /**
  70426. * Gets the max char height of a font.
  70427. * @param font the font to use, use the W3C CSS notation
  70428. * @return the max char height
  70429. */
  70430. private getFontHeight;
  70431. /**
  70432. * Clones the current AsciiArtTexture.
  70433. * @return the clone of the texture.
  70434. */
  70435. clone(): AsciiArtFontTexture;
  70436. /**
  70437. * Parses a json object representing the texture and returns an instance of it.
  70438. * @param source the source JSON representation
  70439. * @param scene the scene to create the texture for
  70440. * @return the parsed texture
  70441. */
  70442. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70443. }
  70444. /**
  70445. * Option available in the Ascii Art Post Process.
  70446. */
  70447. export interface IAsciiArtPostProcessOptions {
  70448. /**
  70449. * The font to use following the w3c font definition.
  70450. */
  70451. font?: string;
  70452. /**
  70453. * The character set to use in the postprocess.
  70454. */
  70455. characterSet?: string;
  70456. /**
  70457. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70458. * This number is defined between 0 and 1;
  70459. */
  70460. mixToTile?: number;
  70461. /**
  70462. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70463. * This number is defined between 0 and 1;
  70464. */
  70465. mixToNormal?: number;
  70466. }
  70467. /**
  70468. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70469. *
  70470. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70471. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70472. */
  70473. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70474. /**
  70475. * The font texture used to render the char in the post process.
  70476. */
  70477. private _asciiArtFontTexture;
  70478. /**
  70479. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70480. * This number is defined between 0 and 1;
  70481. */
  70482. mixToTile: number;
  70483. /**
  70484. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70485. * This number is defined between 0 and 1;
  70486. */
  70487. mixToNormal: number;
  70488. /**
  70489. * Instantiates a new Ascii Art Post Process.
  70490. * @param name the name to give to the postprocess
  70491. * @camera the camera to apply the post process to.
  70492. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70493. */
  70494. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70495. }
  70496. }
  70497. declare module BABYLON {
  70498. /** @hidden */
  70499. export var digitalrainPixelShader: {
  70500. name: string;
  70501. shader: string;
  70502. };
  70503. }
  70504. declare module BABYLON {
  70505. /**
  70506. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70507. *
  70508. * It basically takes care rendering the font front the given font size to a texture.
  70509. * This is used later on in the postprocess.
  70510. */
  70511. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70512. private _font;
  70513. private _text;
  70514. private _charSize;
  70515. /**
  70516. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70517. */
  70518. readonly charSize: number;
  70519. /**
  70520. * Create a new instance of the Digital Rain FontTexture class
  70521. * @param name the name of the texture
  70522. * @param font the font to use, use the W3C CSS notation
  70523. * @param text the caracter set to use in the rendering.
  70524. * @param scene the scene that owns the texture
  70525. */
  70526. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70527. /**
  70528. * Gets the max char width of a font.
  70529. * @param font the font to use, use the W3C CSS notation
  70530. * @return the max char width
  70531. */
  70532. private getFontWidth;
  70533. /**
  70534. * Gets the max char height of a font.
  70535. * @param font the font to use, use the W3C CSS notation
  70536. * @return the max char height
  70537. */
  70538. private getFontHeight;
  70539. /**
  70540. * Clones the current DigitalRainFontTexture.
  70541. * @return the clone of the texture.
  70542. */
  70543. clone(): DigitalRainFontTexture;
  70544. /**
  70545. * Parses a json object representing the texture and returns an instance of it.
  70546. * @param source the source JSON representation
  70547. * @param scene the scene to create the texture for
  70548. * @return the parsed texture
  70549. */
  70550. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70551. }
  70552. /**
  70553. * Option available in the Digital Rain Post Process.
  70554. */
  70555. export interface IDigitalRainPostProcessOptions {
  70556. /**
  70557. * The font to use following the w3c font definition.
  70558. */
  70559. font?: string;
  70560. /**
  70561. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70562. * This number is defined between 0 and 1;
  70563. */
  70564. mixToTile?: number;
  70565. /**
  70566. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70567. * This number is defined between 0 and 1;
  70568. */
  70569. mixToNormal?: number;
  70570. }
  70571. /**
  70572. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70573. *
  70574. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70575. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70576. */
  70577. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70578. /**
  70579. * The font texture used to render the char in the post process.
  70580. */
  70581. private _digitalRainFontTexture;
  70582. /**
  70583. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70584. * This number is defined between 0 and 1;
  70585. */
  70586. mixToTile: number;
  70587. /**
  70588. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70589. * This number is defined between 0 and 1;
  70590. */
  70591. mixToNormal: number;
  70592. /**
  70593. * Instantiates a new Digital Rain Post Process.
  70594. * @param name the name to give to the postprocess
  70595. * @camera the camera to apply the post process to.
  70596. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70597. */
  70598. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70599. }
  70600. }
  70601. declare module BABYLON {
  70602. /** @hidden */
  70603. export var oceanPostProcessPixelShader: {
  70604. name: string;
  70605. shader: string;
  70606. };
  70607. }
  70608. declare module BABYLON {
  70609. /**
  70610. * Option available in the Ocean Post Process.
  70611. */
  70612. export interface IOceanPostProcessOptions {
  70613. /**
  70614. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70615. */
  70616. reflectionSize?: number | {
  70617. width: number;
  70618. height: number;
  70619. } | {
  70620. ratio: number;
  70621. };
  70622. /**
  70623. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70624. */
  70625. refractionSize?: number | {
  70626. width: number;
  70627. height: number;
  70628. } | {
  70629. ratio: number;
  70630. };
  70631. }
  70632. /**
  70633. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70634. *
  70635. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70636. * Example usage:
  70637. * var pp = new OceanPostProcess("myOcean", camera);
  70638. * pp.reflectionEnabled = true;
  70639. * pp.refractionEnabled = true;
  70640. */
  70641. export class OceanPostProcess extends BABYLON.PostProcess {
  70642. /**
  70643. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70644. */
  70645. /**
  70646. * Sets weither or not the real-time reflection is enabled on the ocean.
  70647. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70648. */
  70649. reflectionEnabled: boolean;
  70650. /**
  70651. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70652. */
  70653. /**
  70654. * Sets weither or not the real-time refraction is enabled on the ocean.
  70655. * Is set to true, the refraction render target texture will be used as refraction texture.
  70656. */
  70657. refractionEnabled: boolean;
  70658. /**
  70659. * Gets wether or not the post-processes is supported by the running hardware.
  70660. * This requires draw buffer supports.
  70661. */
  70662. readonly isSupported: boolean;
  70663. /**
  70664. * This is the reflection mirror texture used to display reflections on the ocean.
  70665. * By default, render list is empty.
  70666. */
  70667. reflectionTexture: BABYLON.MirrorTexture;
  70668. /**
  70669. * This is the refraction render target texture used to display refraction on the ocean.
  70670. * By default, render list is empty.
  70671. */
  70672. refractionTexture: BABYLON.RenderTargetTexture;
  70673. private _time;
  70674. private _cameraRotation;
  70675. private _cameraViewMatrix;
  70676. private _reflectionEnabled;
  70677. private _refractionEnabled;
  70678. private _geometryRenderer;
  70679. /**
  70680. * Instantiates a new Ocean Post Process.
  70681. * @param name the name to give to the postprocess.
  70682. * @camera the camera to apply the post process to.
  70683. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70684. */
  70685. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70686. /**
  70687. * Returns the appropriate defines according to the current configuration.
  70688. */
  70689. private _getDefines;
  70690. /**
  70691. * Computes the current camera rotation as the shader requires a camera rotation.
  70692. */
  70693. private _computeCameraRotation;
  70694. }
  70695. }
  70696. declare module BABYLON {
  70697. /** @hidden */
  70698. export var brickProceduralTexturePixelShader: {
  70699. name: string;
  70700. shader: string;
  70701. };
  70702. }
  70703. declare module BABYLON {
  70704. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70705. private _numberOfBricksHeight;
  70706. private _numberOfBricksWidth;
  70707. private _jointColor;
  70708. private _brickColor;
  70709. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70710. updateShaderUniforms(): void;
  70711. numberOfBricksHeight: number;
  70712. numberOfBricksWidth: number;
  70713. jointColor: BABYLON.Color3;
  70714. brickColor: BABYLON.Color3;
  70715. /**
  70716. * Serializes this brick procedural texture
  70717. * @returns a serialized brick procedural texture object
  70718. */
  70719. serialize(): any;
  70720. /**
  70721. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70722. * @param parsedTexture defines parsed texture data
  70723. * @param scene defines the current scene
  70724. * @param rootUrl defines the root URL containing brick procedural texture information
  70725. * @returns a parsed Brick Procedural BABYLON.Texture
  70726. */
  70727. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70728. }
  70729. }
  70730. declare module BABYLON {
  70731. /** @hidden */
  70732. export var cloudProceduralTexturePixelShader: {
  70733. name: string;
  70734. shader: string;
  70735. };
  70736. }
  70737. declare module BABYLON {
  70738. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70739. private _skyColor;
  70740. private _cloudColor;
  70741. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70742. updateShaderUniforms(): void;
  70743. skyColor: BABYLON.Color4;
  70744. cloudColor: BABYLON.Color4;
  70745. /**
  70746. * Serializes this cloud procedural texture
  70747. * @returns a serialized cloud procedural texture object
  70748. */
  70749. serialize(): any;
  70750. /**
  70751. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70752. * @param parsedTexture defines parsed texture data
  70753. * @param scene defines the current scene
  70754. * @param rootUrl defines the root URL containing cloud procedural texture information
  70755. * @returns a parsed Cloud Procedural BABYLON.Texture
  70756. */
  70757. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70758. }
  70759. }
  70760. declare module BABYLON {
  70761. /** @hidden */
  70762. export var fireProceduralTexturePixelShader: {
  70763. name: string;
  70764. shader: string;
  70765. };
  70766. }
  70767. declare module BABYLON {
  70768. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70769. private _time;
  70770. private _speed;
  70771. private _autoGenerateTime;
  70772. private _fireColors;
  70773. private _alphaThreshold;
  70774. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70775. updateShaderUniforms(): void;
  70776. render(useCameraPostProcess?: boolean): void;
  70777. static readonly PurpleFireColors: BABYLON.Color3[];
  70778. static readonly GreenFireColors: BABYLON.Color3[];
  70779. static readonly RedFireColors: BABYLON.Color3[];
  70780. static readonly BlueFireColors: BABYLON.Color3[];
  70781. autoGenerateTime: boolean;
  70782. fireColors: BABYLON.Color3[];
  70783. time: number;
  70784. speed: BABYLON.Vector2;
  70785. alphaThreshold: number;
  70786. /**
  70787. * Serializes this fire procedural texture
  70788. * @returns a serialized fire procedural texture object
  70789. */
  70790. serialize(): any;
  70791. /**
  70792. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70793. * @param parsedTexture defines parsed texture data
  70794. * @param scene defines the current scene
  70795. * @param rootUrl defines the root URL containing fire procedural texture information
  70796. * @returns a parsed Fire Procedural BABYLON.Texture
  70797. */
  70798. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70799. }
  70800. }
  70801. declare module BABYLON {
  70802. /** @hidden */
  70803. export var grassProceduralTexturePixelShader: {
  70804. name: string;
  70805. shader: string;
  70806. };
  70807. }
  70808. declare module BABYLON {
  70809. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70810. private _grassColors;
  70811. private _groundColor;
  70812. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70813. updateShaderUniforms(): void;
  70814. grassColors: BABYLON.Color3[];
  70815. groundColor: BABYLON.Color3;
  70816. /**
  70817. * Serializes this grass procedural texture
  70818. * @returns a serialized grass procedural texture object
  70819. */
  70820. serialize(): any;
  70821. /**
  70822. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70823. * @param parsedTexture defines parsed texture data
  70824. * @param scene defines the current scene
  70825. * @param rootUrl defines the root URL containing grass procedural texture information
  70826. * @returns a parsed Grass Procedural BABYLON.Texture
  70827. */
  70828. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70829. }
  70830. }
  70831. declare module BABYLON {
  70832. /** @hidden */
  70833. export var marbleProceduralTexturePixelShader: {
  70834. name: string;
  70835. shader: string;
  70836. };
  70837. }
  70838. declare module BABYLON {
  70839. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70840. private _numberOfTilesHeight;
  70841. private _numberOfTilesWidth;
  70842. private _amplitude;
  70843. private _jointColor;
  70844. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70845. updateShaderUniforms(): void;
  70846. numberOfTilesHeight: number;
  70847. amplitude: number;
  70848. numberOfTilesWidth: number;
  70849. jointColor: BABYLON.Color3;
  70850. /**
  70851. * Serializes this marble procedural texture
  70852. * @returns a serialized marble procedural texture object
  70853. */
  70854. serialize(): any;
  70855. /**
  70856. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70857. * @param parsedTexture defines parsed texture data
  70858. * @param scene defines the current scene
  70859. * @param rootUrl defines the root URL containing marble procedural texture information
  70860. * @returns a parsed Marble Procedural BABYLON.Texture
  70861. */
  70862. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70863. }
  70864. }
  70865. declare module BABYLON {
  70866. /** @hidden */
  70867. export var normalMapProceduralTexturePixelShader: {
  70868. name: string;
  70869. shader: string;
  70870. };
  70871. }
  70872. declare module BABYLON {
  70873. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70874. private _baseTexture;
  70875. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70876. updateShaderUniforms(): void;
  70877. render(useCameraPostProcess?: boolean): void;
  70878. resize(size: any, generateMipMaps: any): void;
  70879. baseTexture: BABYLON.Texture;
  70880. /**
  70881. * Serializes this normal map procedural texture
  70882. * @returns a serialized normal map procedural texture object
  70883. */
  70884. serialize(): any;
  70885. /**
  70886. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70887. * @param parsedTexture defines parsed texture data
  70888. * @param scene defines the current scene
  70889. * @param rootUrl defines the root URL containing normal map procedural texture information
  70890. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70891. */
  70892. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70893. }
  70894. }
  70895. declare module BABYLON {
  70896. /** @hidden */
  70897. export var perlinNoiseProceduralTexturePixelShader: {
  70898. name: string;
  70899. shader: string;
  70900. };
  70901. }
  70902. declare module BABYLON {
  70903. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70904. time: number;
  70905. timeScale: number;
  70906. translationSpeed: number;
  70907. private _currentTranslation;
  70908. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70909. updateShaderUniforms(): void;
  70910. render(useCameraPostProcess?: boolean): void;
  70911. resize(size: any, generateMipMaps: any): void;
  70912. /**
  70913. * Serializes this perlin noise procedural texture
  70914. * @returns a serialized perlin noise procedural texture object
  70915. */
  70916. serialize(): any;
  70917. /**
  70918. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70919. * @param parsedTexture defines parsed texture data
  70920. * @param scene defines the current scene
  70921. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70922. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70923. */
  70924. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70925. }
  70926. }
  70927. declare module BABYLON {
  70928. /** @hidden */
  70929. export var roadProceduralTexturePixelShader: {
  70930. name: string;
  70931. shader: string;
  70932. };
  70933. }
  70934. declare module BABYLON {
  70935. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70936. private _roadColor;
  70937. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70938. updateShaderUniforms(): void;
  70939. roadColor: BABYLON.Color3;
  70940. /**
  70941. * Serializes this road procedural texture
  70942. * @returns a serialized road procedural texture object
  70943. */
  70944. serialize(): any;
  70945. /**
  70946. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70947. * @param parsedTexture defines parsed texture data
  70948. * @param scene defines the current scene
  70949. * @param rootUrl defines the root URL containing road procedural texture information
  70950. * @returns a parsed Road Procedural BABYLON.Texture
  70951. */
  70952. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70953. }
  70954. }
  70955. declare module BABYLON {
  70956. /** @hidden */
  70957. export var starfieldProceduralTexturePixelShader: {
  70958. name: string;
  70959. shader: string;
  70960. };
  70961. }
  70962. declare module BABYLON {
  70963. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  70964. private _time;
  70965. private _alpha;
  70966. private _beta;
  70967. private _zoom;
  70968. private _formuparam;
  70969. private _stepsize;
  70970. private _tile;
  70971. private _brightness;
  70972. private _darkmatter;
  70973. private _distfading;
  70974. private _saturation;
  70975. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70976. updateShaderUniforms(): void;
  70977. time: number;
  70978. alpha: number;
  70979. beta: number;
  70980. formuparam: number;
  70981. stepsize: number;
  70982. zoom: number;
  70983. tile: number;
  70984. brightness: number;
  70985. darkmatter: number;
  70986. distfading: number;
  70987. saturation: number;
  70988. /**
  70989. * Serializes this starfield procedural texture
  70990. * @returns a serialized starfield procedural texture object
  70991. */
  70992. serialize(): any;
  70993. /**
  70994. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70995. * @param parsedTexture defines parsed texture data
  70996. * @param scene defines the current scene
  70997. * @param rootUrl defines the root URL containing startfield procedural texture information
  70998. * @returns a parsed Starfield Procedural BABYLON.Texture
  70999. */
  71000. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71001. }
  71002. }
  71003. declare module BABYLON {
  71004. /** @hidden */
  71005. export var woodProceduralTexturePixelShader: {
  71006. name: string;
  71007. shader: string;
  71008. };
  71009. }
  71010. declare module BABYLON {
  71011. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71012. private _ampScale;
  71013. private _woodColor;
  71014. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71015. updateShaderUniforms(): void;
  71016. ampScale: number;
  71017. woodColor: BABYLON.Color3;
  71018. /**
  71019. * Serializes this wood procedural texture
  71020. * @returns a serialized wood procedural texture object
  71021. */
  71022. serialize(): any;
  71023. /**
  71024. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71025. * @param parsedTexture defines parsed texture data
  71026. * @param scene defines the current scene
  71027. * @param rootUrl defines the root URL containing wood procedural texture information
  71028. * @returns a parsed Wood Procedural BABYLON.Texture
  71029. */
  71030. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71031. }
  71032. }