babylon.d.txt 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */ private _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Helper to manipulate strings
  378. */
  379. export class StringTools {
  380. /**
  381. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  382. * @param str Source string
  383. * @param suffix Suffix to search for in the source string
  384. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  385. */
  386. static EndsWith(str: string, suffix: string): boolean;
  387. /**
  388. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static StartsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Decodes a buffer into a string
  396. * @param buffer The buffer to decode
  397. * @returns The decoded string
  398. */
  399. static Decode(buffer: Uint8Array | Uint16Array): string;
  400. /**
  401. * Encode a buffer to a base64 string
  402. * @param buffer defines the buffer to encode
  403. * @returns the encoded string
  404. */
  405. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Class containing a set of static utilities functions for deep copy.
  411. */
  412. export class DeepCopier {
  413. /**
  414. * Tries to copy an object by duplicating every property
  415. * @param source defines the source object
  416. * @param destination defines the target object
  417. * @param doNotCopyList defines a list of properties to avoid
  418. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  419. */
  420. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  421. }
  422. }
  423. declare module BABYLON {
  424. /**
  425. * Class containing a set of static utilities functions for precision date
  426. */
  427. export class PrecisionDate {
  428. /**
  429. * Gets either window.performance.now() if supported or Date.now() else
  430. */
  431. static readonly Now: number;
  432. }
  433. }
  434. declare module BABYLON {
  435. /** @hidden */
  436. export class _DevTools {
  437. static WarnImport(name: string): string;
  438. }
  439. }
  440. declare module BABYLON {
  441. /**
  442. * Interface used to define the mechanism to get data from the network
  443. */
  444. export interface IWebRequest {
  445. /**
  446. * Returns client's response url
  447. */
  448. responseURL: string;
  449. /**
  450. * Returns client's status
  451. */
  452. status: number;
  453. /**
  454. * Returns client's status as a text
  455. */
  456. statusText: string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  462. */
  463. export class WebRequest implements IWebRequest {
  464. private _xhr;
  465. /**
  466. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  467. * i.e. when loading files, where the server/service expects an Authorization header
  468. */
  469. static CustomRequestHeaders: {
  470. [key: string]: string;
  471. };
  472. /**
  473. * Add callback functions in this array to update all the requests before they get sent to the network
  474. */
  475. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  476. private _injectCustomRequestHeaders;
  477. /**
  478. * Gets or sets a function to be called when loading progress changes
  479. */
  480. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  481. /**
  482. * Returns client's state
  483. */
  484. readonly readyState: number;
  485. /**
  486. * Returns client's status
  487. */
  488. readonly status: number;
  489. /**
  490. * Returns client's status as a text
  491. */
  492. readonly statusText: string;
  493. /**
  494. * Returns client's response
  495. */
  496. readonly response: any;
  497. /**
  498. * Returns client's response url
  499. */
  500. readonly responseURL: string;
  501. /**
  502. * Returns client's response as text
  503. */
  504. readonly responseText: string;
  505. /**
  506. * Gets or sets the expected response type
  507. */
  508. responseType: XMLHttpRequestResponseType;
  509. /** @hidden */
  510. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  511. /** @hidden */
  512. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  513. /**
  514. * Cancels any network activity
  515. */
  516. abort(): void;
  517. /**
  518. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  519. * @param body defines an optional request body
  520. */
  521. send(body?: Document | BodyInit | null): void;
  522. /**
  523. * Sets the request method, request URL
  524. * @param method defines the method to use (GET, POST, etc..)
  525. * @param url defines the url to connect with
  526. */
  527. open(method: string, url: string): void;
  528. /**
  529. * Sets the value of a request header.
  530. * @param name The name of the header whose value is to be set
  531. * @param value The value to set as the body of the header
  532. */
  533. setRequestHeader(name: string, value: string): void;
  534. /**
  535. * Get the string containing the text of a particular header's value.
  536. * @param name The name of the header
  537. * @returns The string containing the text of the given header name
  538. */
  539. getResponseHeader(name: string): Nullable<string>;
  540. }
  541. }
  542. declare module BABYLON {
  543. /**
  544. * File request interface
  545. */
  546. export interface IFileRequest {
  547. /**
  548. * Raised when the request is complete (success or error).
  549. */
  550. onCompleteObservable: Observable<IFileRequest>;
  551. /**
  552. * Aborts the request for a file.
  553. */
  554. abort: () => void;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * Define options used to create a render target texture
  560. */
  561. export class RenderTargetCreationOptions {
  562. /**
  563. * Specifies is mipmaps must be generated
  564. */
  565. generateMipMaps?: boolean;
  566. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  567. generateDepthBuffer?: boolean;
  568. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  569. generateStencilBuffer?: boolean;
  570. /** Defines texture type (int by default) */
  571. type?: number;
  572. /** Defines sampling mode (trilinear by default) */
  573. samplingMode?: number;
  574. /** Defines format (RGBA by default) */
  575. format?: number;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * @hidden
  581. **/
  582. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  583. }
  584. }
  585. declare module BABYLON {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending to DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending to SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending to SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending to SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending to SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /** Defines that alpha blending equation a SUM */
  641. static readonly ALPHA_EQUATION_ADD: number;
  642. /** Defines that alpha blending equation a SUBSTRACTION */
  643. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  644. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  645. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  646. /** Defines that alpha blending equation a MAX operation */
  647. static readonly ALPHA_EQUATION_MAX: number;
  648. /** Defines that alpha blending equation a MIN operation */
  649. static readonly ALPHA_EQUATION_MIN: number;
  650. /**
  651. * Defines that alpha blending equation a DARKEN operation:
  652. * It takes the min of the src and sums the alpha channels.
  653. */
  654. static readonly ALPHA_EQUATION_DARKEN: number;
  655. /** Defines that the ressource is not delayed*/
  656. static readonly DELAYLOADSTATE_NONE: number;
  657. /** Defines that the ressource was successfully delay loaded */
  658. static readonly DELAYLOADSTATE_LOADED: number;
  659. /** Defines that the ressource is currently delay loading */
  660. static readonly DELAYLOADSTATE_LOADING: number;
  661. /** Defines that the ressource is delayed and has not started loading */
  662. static readonly DELAYLOADSTATE_NOTLOADED: number;
  663. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  664. static readonly NEVER: number;
  665. /** 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 */
  666. static readonly ALWAYS: number;
  667. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  668. static readonly LESS: number;
  669. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  670. static readonly EQUAL: number;
  671. /** 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 */
  672. static readonly LEQUAL: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  674. static readonly GREATER: number;
  675. /** 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 */
  676. static readonly GEQUAL: number;
  677. /** 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 */
  678. static readonly NOTEQUAL: number;
  679. /** Passed to stencilOperation to specify that stencil value must be kept */
  680. static readonly KEEP: number;
  681. /** Passed to stencilOperation to specify that stencil value must be replaced */
  682. static readonly REPLACE: number;
  683. /** Passed to stencilOperation to specify that stencil value must be incremented */
  684. static readonly INCR: number;
  685. /** Passed to stencilOperation to specify that stencil value must be decremented */
  686. static readonly DECR: number;
  687. /** Passed to stencilOperation to specify that stencil value must be inverted */
  688. static readonly INVERT: number;
  689. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  690. static readonly INCR_WRAP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  692. static readonly DECR_WRAP: number;
  693. /** Texture is not repeating outside of 0..1 UVs */
  694. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  695. /** Texture is repeating outside of 0..1 UVs */
  696. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  697. /** Texture is repeating and mirrored */
  698. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  699. /** ALPHA */
  700. static readonly TEXTUREFORMAT_ALPHA: number;
  701. /** LUMINANCE */
  702. static readonly TEXTUREFORMAT_LUMINANCE: number;
  703. /** LUMINANCE_ALPHA */
  704. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  705. /** RGB */
  706. static readonly TEXTUREFORMAT_RGB: number;
  707. /** RGBA */
  708. static readonly TEXTUREFORMAT_RGBA: number;
  709. /** RED */
  710. static readonly TEXTUREFORMAT_RED: number;
  711. /** RED (2nd reference) */
  712. static readonly TEXTUREFORMAT_R: number;
  713. /** RG */
  714. static readonly TEXTUREFORMAT_RG: number;
  715. /** RED_INTEGER */
  716. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  717. /** RED_INTEGER (2nd reference) */
  718. static readonly TEXTUREFORMAT_R_INTEGER: number;
  719. /** RG_INTEGER */
  720. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  721. /** RGB_INTEGER */
  722. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  723. /** RGBA_INTEGER */
  724. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  725. /** UNSIGNED_BYTE */
  726. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  727. /** UNSIGNED_BYTE (2nd reference) */
  728. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  729. /** FLOAT */
  730. static readonly TEXTURETYPE_FLOAT: number;
  731. /** HALF_FLOAT */
  732. static readonly TEXTURETYPE_HALF_FLOAT: number;
  733. /** BYTE */
  734. static readonly TEXTURETYPE_BYTE: number;
  735. /** SHORT */
  736. static readonly TEXTURETYPE_SHORT: number;
  737. /** UNSIGNED_SHORT */
  738. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  739. /** INT */
  740. static readonly TEXTURETYPE_INT: number;
  741. /** UNSIGNED_INT */
  742. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  743. /** UNSIGNED_SHORT_4_4_4_4 */
  744. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  745. /** UNSIGNED_SHORT_5_5_5_1 */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  747. /** UNSIGNED_SHORT_5_6_5 */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  749. /** UNSIGNED_INT_2_10_10_10_REV */
  750. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  751. /** UNSIGNED_INT_24_8 */
  752. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  753. /** UNSIGNED_INT_10F_11F_11F_REV */
  754. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  755. /** UNSIGNED_INT_5_9_9_9_REV */
  756. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  757. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  758. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  759. /** nearest is mag = nearest and min = nearest and mip = linear */
  760. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  761. /** Bilinear is mag = linear and min = linear and mip = nearest */
  762. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  763. /** Trilinear is mag = linear and min = linear and mip = linear */
  764. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  765. /** nearest is mag = nearest and min = nearest and mip = linear */
  766. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  768. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  769. /** Trilinear is mag = linear and min = linear and mip = linear */
  770. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  771. /** mag = nearest and min = nearest and mip = nearest */
  772. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  773. /** mag = nearest and min = linear and mip = nearest */
  774. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  775. /** mag = nearest and min = linear and mip = linear */
  776. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  777. /** mag = nearest and min = linear and mip = none */
  778. static readonly TEXTURE_NEAREST_LINEAR: number;
  779. /** mag = nearest and min = nearest and mip = none */
  780. static readonly TEXTURE_NEAREST_NEAREST: number;
  781. /** mag = linear and min = nearest and mip = nearest */
  782. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  783. /** mag = linear and min = nearest and mip = linear */
  784. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  785. /** mag = linear and min = linear and mip = none */
  786. static readonly TEXTURE_LINEAR_LINEAR: number;
  787. /** mag = linear and min = nearest and mip = none */
  788. static readonly TEXTURE_LINEAR_NEAREST: number;
  789. /** Explicit coordinates mode */
  790. static readonly TEXTURE_EXPLICIT_MODE: number;
  791. /** Spherical coordinates mode */
  792. static readonly TEXTURE_SPHERICAL_MODE: number;
  793. /** Planar coordinates mode */
  794. static readonly TEXTURE_PLANAR_MODE: number;
  795. /** Cubic coordinates mode */
  796. static readonly TEXTURE_CUBIC_MODE: number;
  797. /** Projection coordinates mode */
  798. static readonly TEXTURE_PROJECTION_MODE: number;
  799. /** Skybox coordinates mode */
  800. static readonly TEXTURE_SKYBOX_MODE: number;
  801. /** Inverse Cubic coordinates mode */
  802. static readonly TEXTURE_INVCUBIC_MODE: number;
  803. /** Equirectangular coordinates mode */
  804. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  805. /** Equirectangular Fixed coordinates mode */
  806. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  807. /** Equirectangular Fixed Mirrored coordinates mode */
  808. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  809. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  810. static readonly SCALEMODE_FLOOR: number;
  811. /** Defines that texture rescaling will look for the nearest power of 2 size */
  812. static readonly SCALEMODE_NEAREST: number;
  813. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  814. static readonly SCALEMODE_CEILING: number;
  815. /**
  816. * The dirty texture flag value
  817. */
  818. static readonly MATERIAL_TextureDirtyFlag: number;
  819. /**
  820. * The dirty light flag value
  821. */
  822. static readonly MATERIAL_LightDirtyFlag: number;
  823. /**
  824. * The dirty fresnel flag value
  825. */
  826. static readonly MATERIAL_FresnelDirtyFlag: number;
  827. /**
  828. * The dirty attribute flag value
  829. */
  830. static readonly MATERIAL_AttributesDirtyFlag: number;
  831. /**
  832. * The dirty misc flag value
  833. */
  834. static readonly MATERIAL_MiscDirtyFlag: number;
  835. /**
  836. * The all dirty flag value
  837. */
  838. static readonly MATERIAL_AllDirtyFlag: number;
  839. /**
  840. * Returns the triangle fill mode
  841. */
  842. static readonly MATERIAL_TriangleFillMode: number;
  843. /**
  844. * Returns the wireframe mode
  845. */
  846. static readonly MATERIAL_WireFrameFillMode: number;
  847. /**
  848. * Returns the point fill mode
  849. */
  850. static readonly MATERIAL_PointFillMode: number;
  851. /**
  852. * Returns the point list draw mode
  853. */
  854. static readonly MATERIAL_PointListDrawMode: number;
  855. /**
  856. * Returns the line list draw mode
  857. */
  858. static readonly MATERIAL_LineListDrawMode: number;
  859. /**
  860. * Returns the line loop draw mode
  861. */
  862. static readonly MATERIAL_LineLoopDrawMode: number;
  863. /**
  864. * Returns the line strip draw mode
  865. */
  866. static readonly MATERIAL_LineStripDrawMode: number;
  867. /**
  868. * Returns the triangle strip draw mode
  869. */
  870. static readonly MATERIAL_TriangleStripDrawMode: number;
  871. /**
  872. * Returns the triangle fan draw mode
  873. */
  874. static readonly MATERIAL_TriangleFanDrawMode: number;
  875. /**
  876. * Stores the clock-wise side orientation
  877. */
  878. static readonly MATERIAL_ClockWiseSideOrientation: number;
  879. /**
  880. * Stores the counter clock-wise side orientation
  881. */
  882. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  883. /**
  884. * Nothing
  885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  886. */
  887. static readonly ACTION_NothingTrigger: number;
  888. /**
  889. * On pick
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickTrigger: number;
  893. /**
  894. * On left pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLeftPickTrigger: number;
  898. /**
  899. * On right pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnRightPickTrigger: number;
  903. /**
  904. * On center pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnCenterPickTrigger: number;
  908. /**
  909. * On pick down
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnPickDownTrigger: number;
  913. /**
  914. * On double pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnDoublePickTrigger: number;
  918. /**
  919. * On pick up
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickUpTrigger: number;
  923. /**
  924. * On pick out.
  925. * This trigger will only be raised if you also declared a OnPickDown
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnPickOutTrigger: number;
  929. /**
  930. * On long press
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnLongPressTrigger: number;
  934. /**
  935. * On pointer over
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPointerOverTrigger: number;
  939. /**
  940. * On pointer out
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOutTrigger: number;
  944. /**
  945. * On every frame
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnEveryFrameTrigger: number;
  949. /**
  950. * On intersection enter
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnIntersectionEnterTrigger: number;
  954. /**
  955. * On intersection exit
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionExitTrigger: number;
  959. /**
  960. * On key down
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnKeyDownTrigger: number;
  964. /**
  965. * On key up
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyUpTrigger: number;
  969. /**
  970. * Billboard mode will only apply to Y axis
  971. */
  972. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  973. /**
  974. * Billboard mode will apply to all axes
  975. */
  976. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  977. /**
  978. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  981. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  982. * Test order :
  983. * Is the bounding sphere outside the frustum ?
  984. * If not, are the bounding box vertices outside the frustum ?
  985. * It not, then the cullable object is in the frustum.
  986. */
  987. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  988. /** Culling strategy : Bounding Sphere Only.
  989. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  990. * It's also less accurate than the standard because some not visible objects can still be selected.
  991. * Test : is the bounding sphere outside the frustum ?
  992. * If not, then the cullable object is in the frustum.
  993. */
  994. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  995. /** Culling strategy : Optimistic Inclusion.
  996. * This in an inclusion test first, then the standard exclusion test.
  997. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  998. * 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.
  999. * Anyway, it's as accurate as the standard strategy.
  1000. * Test :
  1001. * Is the cullable object bounding sphere center in the frustum ?
  1002. * If not, apply the default culling strategy.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1005. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1006. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1007. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1015. /**
  1016. * No logging while loading
  1017. */
  1018. static readonly SCENELOADER_NO_LOGGING: number;
  1019. /**
  1020. * Minimal logging while loading
  1021. */
  1022. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1023. /**
  1024. * Summary logging while loading
  1025. */
  1026. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1027. /**
  1028. * Detailled logging while loading
  1029. */
  1030. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1031. }
  1032. }
  1033. declare module BABYLON {
  1034. /**
  1035. * This represents the required contract to create a new type of texture loader.
  1036. */
  1037. export interface IInternalTextureLoader {
  1038. /**
  1039. * Defines wether the loader supports cascade loading the different faces.
  1040. */
  1041. supportCascades: boolean;
  1042. /**
  1043. * This returns if the loader support the current file information.
  1044. * @param extension defines the file extension of the file being loaded
  1045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1046. * @param fallback defines the fallback internal texture if any
  1047. * @param isBase64 defines whether the texture is encoded as a base64
  1048. * @param isBuffer defines whether the texture data are stored as a buffer
  1049. * @returns true if the loader can load the specified file
  1050. */
  1051. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1052. /**
  1053. * Transform the url before loading if required.
  1054. * @param rootUrl the url of the texture
  1055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1056. * @returns the transformed texture
  1057. */
  1058. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1059. /**
  1060. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1061. * @param rootUrl the url of the texture
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @returns the fallback texture
  1064. */
  1065. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1066. /**
  1067. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1068. * @param data contains the texture data
  1069. * @param texture defines the BabylonJS internal texture
  1070. * @param createPolynomials will be true if polynomials have been requested
  1071. * @param onLoad defines the callback to trigger once the texture is ready
  1072. * @param onError defines the callback to trigger in case of error
  1073. */
  1074. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1075. /**
  1076. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1077. * @param data contains the texture data
  1078. * @param texture defines the BabylonJS internal texture
  1079. * @param callback defines the method to call once ready to upload
  1080. */
  1081. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1082. }
  1083. }
  1084. declare module BABYLON {
  1085. /**
  1086. * Class used to store and describe the pipeline context associated with an effect
  1087. */
  1088. export interface IPipelineContext {
  1089. /**
  1090. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1091. */
  1092. isAsync: boolean;
  1093. /**
  1094. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1095. */
  1096. isReady: boolean;
  1097. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. readonly underlyingResource: any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. readonly currentLine: string;
  1173. readonly canRead: boolean;
  1174. lines: string[];
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderCodeTestNode extends ShaderCodeNode {
  1196. testExpression: ShaderDefineExpression;
  1197. isValid(preprocessors: {
  1198. [key: string]: string;
  1199. }): boolean;
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1205. define: string;
  1206. not: boolean;
  1207. constructor(define: string, not?: boolean);
  1208. isTrue(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module BABYLON {
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1226. leftOperand: ShaderDefineExpression;
  1227. rightOperand: ShaderDefineExpression;
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module BABYLON {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module BABYLON {
  1297. /**
  1298. * Class used to define a retry strategy when error happens while loading assets
  1299. */
  1300. export class RetryStrategy {
  1301. /**
  1302. * Function used to defines an exponential back off strategy
  1303. * @param maxRetries defines the maximum number of retries (3 by default)
  1304. * @param baseInterval defines the interval between retries
  1305. * @returns the strategy function to use
  1306. */
  1307. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1308. }
  1309. }
  1310. declare module BABYLON {
  1311. /**
  1312. * @ignore
  1313. * Application error to support additional information when loading a file
  1314. */
  1315. export abstract class BaseError extends Error {
  1316. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1317. }
  1318. }
  1319. declare module BABYLON {
  1320. /** @ignore */
  1321. export class LoadFileError extends BaseError {
  1322. request?: WebRequest;
  1323. file?: File;
  1324. /**
  1325. * Creates a new LoadFileError
  1326. * @param message defines the message of the error
  1327. * @param request defines the optional web request
  1328. * @param file defines the optional file
  1329. */
  1330. constructor(message: string, object?: WebRequest | File);
  1331. }
  1332. /** @ignore */
  1333. export class RequestFileError extends BaseError {
  1334. request: WebRequest;
  1335. /**
  1336. * Creates a new LoadFileError
  1337. * @param message defines the message of the error
  1338. * @param request defines the optional web request
  1339. */
  1340. constructor(message: string, request: WebRequest);
  1341. }
  1342. /** @ignore */
  1343. export class ReadFileError extends BaseError {
  1344. file: File;
  1345. /**
  1346. * Creates a new ReadFileError
  1347. * @param message defines the message of the error
  1348. * @param file defines the optional file
  1349. */
  1350. constructor(message: string, file: File);
  1351. }
  1352. /**
  1353. * @hidden
  1354. */
  1355. export class FileTools {
  1356. /**
  1357. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1358. */
  1359. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1360. /**
  1361. * Gets or sets the base URL to use to load assets
  1362. */
  1363. static BaseUrl: string;
  1364. /**
  1365. * Default behaviour for cors in the application.
  1366. * It can be a string if the expected behavior is identical in the entire app.
  1367. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1368. */
  1369. static CorsBehavior: string | ((url: string | string[]) => string);
  1370. /**
  1371. * Gets or sets a function used to pre-process url before using them to load assets
  1372. */
  1373. static PreprocessUrl: (url: string) => string;
  1374. /**
  1375. * Removes unwanted characters from an url
  1376. * @param url defines the url to clean
  1377. * @returns the cleaned url
  1378. */
  1379. private static _CleanUrl;
  1380. /**
  1381. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1382. * @param url define the url we are trying
  1383. * @param element define the dom element where to configure the cors policy
  1384. */
  1385. static SetCorsBehavior(url: string | string[], element: {
  1386. crossOrigin: string | null;
  1387. }): void;
  1388. /**
  1389. * Loads an image as an HTMLImageElement.
  1390. * @param input url string, ArrayBuffer, or Blob to load
  1391. * @param onLoad callback called when the image successfully loads
  1392. * @param onError callback called when the image fails to load
  1393. * @param offlineProvider offline provider for caching
  1394. * @param mimeType optional mime type
  1395. * @returns the HTMLImageElement of the loaded image
  1396. */
  1397. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1398. /**
  1399. * Reads a file from a File object
  1400. * @param file defines the file to load
  1401. * @param onSuccess defines the callback to call when data is loaded
  1402. * @param onProgress defines the callback to call during loading process
  1403. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1404. * @param onError defines the callback to call when an error occurs
  1405. * @returns a file request object
  1406. */
  1407. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1408. /**
  1409. * Loads a file from a url
  1410. * @param url url to load
  1411. * @param onSuccess callback called when the file successfully loads
  1412. * @param onProgress callback called while file is loading (if the server supports this mode)
  1413. * @param offlineProvider defines the offline provider for caching
  1414. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1415. * @param onError callback called when the file fails to load
  1416. * @returns a file request object
  1417. */
  1418. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1419. /**
  1420. * Loads a file
  1421. * @param url url to load
  1422. * @param onSuccess callback called when the file successfully loads
  1423. * @param onProgress callback called while file is loading (if the server supports this mode)
  1424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1425. * @param onError callback called when the file fails to load
  1426. * @param onOpened callback called when the web request is opened
  1427. * @returns a file request object
  1428. */
  1429. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1430. /**
  1431. * Checks if the loaded document was accessed via `file:`-Protocol.
  1432. * @returns boolean
  1433. */
  1434. static IsFileURL(): boolean;
  1435. }
  1436. }
  1437. declare module BABYLON {
  1438. /** @hidden */
  1439. export class ShaderProcessor {
  1440. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1441. private static _ProcessPrecision;
  1442. private static _ExtractOperation;
  1443. private static _BuildSubExpression;
  1444. private static _BuildExpression;
  1445. private static _MoveCursorWithinIf;
  1446. private static _MoveCursor;
  1447. private static _EvaluatePreProcessors;
  1448. private static _PreparePreProcessors;
  1449. private static _ProcessShaderConversion;
  1450. private static _ProcessIncludes;
  1451. }
  1452. }
  1453. declare module BABYLON {
  1454. /**
  1455. * @hidden
  1456. */
  1457. export interface IColor4Like {
  1458. r: float;
  1459. g: float;
  1460. b: float;
  1461. a: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IColor3Like {
  1467. r: float;
  1468. g: float;
  1469. b: float;
  1470. }
  1471. /**
  1472. * @hidden
  1473. */
  1474. export interface IVector4Like {
  1475. x: float;
  1476. y: float;
  1477. z: float;
  1478. w: float;
  1479. }
  1480. /**
  1481. * @hidden
  1482. */
  1483. export interface IVector3Like {
  1484. x: float;
  1485. y: float;
  1486. z: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IVector2Like {
  1492. x: float;
  1493. y: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IMatrixLike {
  1499. toArray(): DeepImmutable<Float32Array>;
  1500. updateFlag: int;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IViewportLike {
  1506. x: float;
  1507. y: float;
  1508. width: float;
  1509. height: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IPlaneLike {
  1515. normal: IVector3Like;
  1516. d: float;
  1517. normalize(): void;
  1518. }
  1519. }
  1520. declare module BABYLON {
  1521. /**
  1522. * Interface used to define common properties for effect fallbacks
  1523. */
  1524. export interface IEffectFallbacks {
  1525. /**
  1526. * Removes the defines that should be removed when falling back.
  1527. * @param currentDefines defines the current define statements for the shader.
  1528. * @param effect defines the current effect we try to compile
  1529. * @returns The resulting defines with defines of the current rank removed.
  1530. */
  1531. reduce(currentDefines: string, effect: Effect): string;
  1532. /**
  1533. * Removes the fallback from the bound mesh.
  1534. */
  1535. unBindMesh(): void;
  1536. /**
  1537. * Checks to see if more fallbacks are still availible.
  1538. */
  1539. hasMoreFallbacks: boolean;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /**
  1544. * Class used to evalaute queries containing `and` and `or` operators
  1545. */
  1546. export class AndOrNotEvaluator {
  1547. /**
  1548. * Evaluate a query
  1549. * @param query defines the query to evaluate
  1550. * @param evaluateCallback defines the callback used to filter result
  1551. * @returns true if the query matches
  1552. */
  1553. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1554. private static _HandleParenthesisContent;
  1555. private static _SimplifyNegation;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to store custom tags
  1561. */
  1562. export class Tags {
  1563. /**
  1564. * Adds support for tags on the given object
  1565. * @param obj defines the object to use
  1566. */
  1567. static EnableFor(obj: any): void;
  1568. /**
  1569. * Removes tags support
  1570. * @param obj defines the object to use
  1571. */
  1572. static DisableFor(obj: any): void;
  1573. /**
  1574. * Gets a boolean indicating if the given object has tags
  1575. * @param obj defines the object to use
  1576. * @returns a boolean
  1577. */
  1578. static HasTags(obj: any): boolean;
  1579. /**
  1580. * Gets the tags available on a given object
  1581. * @param obj defines the object to use
  1582. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1583. * @returns the tags
  1584. */
  1585. static GetTags(obj: any, asString?: boolean): any;
  1586. /**
  1587. * Adds tags to an object
  1588. * @param obj defines the object to use
  1589. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1590. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1591. */
  1592. static AddTagsTo(obj: any, tagsString: string): void;
  1593. /**
  1594. * @hidden
  1595. */ private static _AddTagTo(obj: any, tag: string): void;
  1596. /**
  1597. * Removes specific tags from a specific object
  1598. * @param obj defines the object to use
  1599. * @param tagsString defines the tags to remove
  1600. */
  1601. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1602. /**
  1603. * @hidden
  1604. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  1605. /**
  1606. * Defines if tags hosted on an object match a given query
  1607. * @param obj defines the object to use
  1608. * @param tagsQuery defines the tag query
  1609. * @returns a boolean
  1610. */
  1611. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Scalar computation library
  1617. */
  1618. export class Scalar {
  1619. /**
  1620. * Two pi constants convenient for computation.
  1621. */
  1622. static TwoPi: number;
  1623. /**
  1624. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1625. * @param a number
  1626. * @param b number
  1627. * @param epsilon (default = 1.401298E-45)
  1628. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1629. */
  1630. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1631. /**
  1632. * Returns a string : the upper case translation of the number i to hexadecimal.
  1633. * @param i number
  1634. * @returns the upper case translation of the number i to hexadecimal.
  1635. */
  1636. static ToHex(i: number): string;
  1637. /**
  1638. * Returns -1 if value is negative and +1 is value is positive.
  1639. * @param value the value
  1640. * @returns the value itself if it's equal to zero.
  1641. */
  1642. static Sign(value: number): number;
  1643. /**
  1644. * Returns the value itself if it's between min and max.
  1645. * Returns min if the value is lower than min.
  1646. * Returns max if the value is greater than max.
  1647. * @param value the value to clmap
  1648. * @param min the min value to clamp to (default: 0)
  1649. * @param max the max value to clamp to (default: 1)
  1650. * @returns the clamped value
  1651. */
  1652. static Clamp(value: number, min?: number, max?: number): number;
  1653. /**
  1654. * the log2 of value.
  1655. * @param value the value to compute log2 of
  1656. * @returns the log2 of value.
  1657. */
  1658. static Log2(value: number): number;
  1659. /**
  1660. * Loops the value, so that it is never larger than length and never smaller than 0.
  1661. *
  1662. * This is similar to the modulo operator but it works with floating point numbers.
  1663. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1664. * With t = 5 and length = 2.5, the result would be 0.0.
  1665. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1666. * @param value the value
  1667. * @param length the length
  1668. * @returns the looped value
  1669. */
  1670. static Repeat(value: number, length: number): number;
  1671. /**
  1672. * Normalize the value between 0.0 and 1.0 using min and max values
  1673. * @param value value to normalize
  1674. * @param min max to normalize between
  1675. * @param max min to normalize between
  1676. * @returns the normalized value
  1677. */
  1678. static Normalize(value: number, min: number, max: number): number;
  1679. /**
  1680. * Denormalize the value from 0.0 and 1.0 using min and max values
  1681. * @param normalized value to denormalize
  1682. * @param min max to denormalize between
  1683. * @param max min to denormalize between
  1684. * @returns the denormalized value
  1685. */
  1686. static Denormalize(normalized: number, min: number, max: number): number;
  1687. /**
  1688. * Calculates the shortest difference between two given angles given in degrees.
  1689. * @param current current angle in degrees
  1690. * @param target target angle in degrees
  1691. * @returns the delta
  1692. */
  1693. static DeltaAngle(current: number, target: number): number;
  1694. /**
  1695. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1696. * @param tx value
  1697. * @param length length
  1698. * @returns The returned value will move back and forth between 0 and length
  1699. */
  1700. static PingPong(tx: number, length: number): number;
  1701. /**
  1702. * Interpolates between min and max with smoothing at the limits.
  1703. *
  1704. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1705. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1706. * @param from from
  1707. * @param to to
  1708. * @param tx value
  1709. * @returns the smooth stepped value
  1710. */
  1711. static SmoothStep(from: number, to: number, tx: number): number;
  1712. /**
  1713. * Moves a value current towards target.
  1714. *
  1715. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1716. * Negative values of maxDelta pushes the value away from target.
  1717. * @param current current value
  1718. * @param target target value
  1719. * @param maxDelta max distance to move
  1720. * @returns resulting value
  1721. */
  1722. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1723. /**
  1724. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1725. *
  1726. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1727. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1728. * @param current current value
  1729. * @param target target value
  1730. * @param maxDelta max distance to move
  1731. * @returns resulting angle
  1732. */
  1733. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1734. /**
  1735. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1736. * @param start start value
  1737. * @param end target value
  1738. * @param amount amount to lerp between
  1739. * @returns the lerped value
  1740. */
  1741. static Lerp(start: number, end: number, amount: number): number;
  1742. /**
  1743. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1744. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static LerpAngle(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1753. * @param a start value
  1754. * @param b target value
  1755. * @param value value between a and b
  1756. * @returns the inverseLerp value
  1757. */
  1758. static InverseLerp(a: number, b: number, value: number): number;
  1759. /**
  1760. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1761. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1762. * @param value1 spline value
  1763. * @param tangent1 spline value
  1764. * @param value2 spline value
  1765. * @param tangent2 spline value
  1766. * @param amount input value
  1767. * @returns hermite result
  1768. */
  1769. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1770. /**
  1771. * Returns a random float number between and min and max values
  1772. * @param min min value of random
  1773. * @param max max value of random
  1774. * @returns random value
  1775. */
  1776. static RandomRange(min: number, max: number): number;
  1777. /**
  1778. * This function returns percentage of a number in a given range.
  1779. *
  1780. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1781. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1782. * @param number to convert to percentage
  1783. * @param min min range
  1784. * @param max max range
  1785. * @returns the percentage
  1786. */
  1787. static RangeToPercent(number: number, min: number, max: number): number;
  1788. /**
  1789. * This function returns number that corresponds to the percentage in a given range.
  1790. *
  1791. * PercentToRange(0.34,0,100) will return 34.
  1792. * @param percent to convert to number
  1793. * @param min min range
  1794. * @param max max range
  1795. * @returns the number
  1796. */
  1797. static PercentToRange(percent: number, min: number, max: number): number;
  1798. /**
  1799. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1800. * @param angle The angle to normalize in radian.
  1801. * @return The converted angle.
  1802. */
  1803. static NormalizeRadians(angle: number): number;
  1804. }
  1805. }
  1806. declare module BABYLON {
  1807. /**
  1808. * Constant used to convert a value to gamma space
  1809. * @ignorenaming
  1810. */
  1811. export const ToGammaSpace: number;
  1812. /**
  1813. * Constant used to convert a value to linear space
  1814. * @ignorenaming
  1815. */
  1816. export const ToLinearSpace = 2.2;
  1817. /**
  1818. * Constant used to define the minimal number value in Babylon.js
  1819. * @ignorenaming
  1820. */
  1821. let Epsilon: number;
  1822. }
  1823. declare module BABYLON {
  1824. /**
  1825. * Class used to represent a viewport on screen
  1826. */
  1827. export class Viewport {
  1828. /** viewport left coordinate */
  1829. x: number;
  1830. /** viewport top coordinate */
  1831. y: number;
  1832. /**viewport width */
  1833. width: number;
  1834. /** viewport height */
  1835. height: number;
  1836. /**
  1837. * Creates a Viewport object located at (x, y) and sized (width, height)
  1838. * @param x defines viewport left coordinate
  1839. * @param y defines viewport top coordinate
  1840. * @param width defines the viewport width
  1841. * @param height defines the viewport height
  1842. */
  1843. constructor(
  1844. /** viewport left coordinate */
  1845. x: number,
  1846. /** viewport top coordinate */
  1847. y: number,
  1848. /**viewport width */
  1849. width: number,
  1850. /** viewport height */
  1851. height: number);
  1852. /**
  1853. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1854. * @param renderWidth defines the rendering width
  1855. * @param renderHeight defines the rendering height
  1856. * @returns a new Viewport
  1857. */
  1858. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1859. /**
  1860. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1861. * @param renderWidth defines the rendering width
  1862. * @param renderHeight defines the rendering height
  1863. * @param ref defines the target viewport
  1864. * @returns the current viewport
  1865. */
  1866. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1867. /**
  1868. * Returns a new Viewport copied from the current one
  1869. * @returns a new Viewport
  1870. */
  1871. clone(): Viewport;
  1872. }
  1873. }
  1874. declare module BABYLON {
  1875. /**
  1876. * Class containing a set of static utilities functions for arrays.
  1877. */
  1878. export class ArrayTools {
  1879. /**
  1880. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1881. * @param size the number of element to construct and put in the array
  1882. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1883. * @returns a new array filled with new objects
  1884. */
  1885. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1886. }
  1887. }
  1888. declare module BABYLON {
  1889. /**
  1890. * Class representing a vector containing 2 coordinates
  1891. */
  1892. export class Vector2 {
  1893. /** defines the first coordinate */
  1894. x: number;
  1895. /** defines the second coordinate */
  1896. y: number;
  1897. /**
  1898. * Creates a new Vector2 from the given x and y coordinates
  1899. * @param x defines the first coordinate
  1900. * @param y defines the second coordinate
  1901. */
  1902. constructor(
  1903. /** defines the first coordinate */
  1904. x?: number,
  1905. /** defines the second coordinate */
  1906. y?: number);
  1907. /**
  1908. * Gets a string with the Vector2 coordinates
  1909. * @returns a string with the Vector2 coordinates
  1910. */
  1911. toString(): string;
  1912. /**
  1913. * Gets class name
  1914. * @returns the string "Vector2"
  1915. */
  1916. getClassName(): string;
  1917. /**
  1918. * Gets current vector hash code
  1919. * @returns the Vector2 hash code as a number
  1920. */
  1921. getHashCode(): number;
  1922. /**
  1923. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1924. * @param array defines the source array
  1925. * @param index defines the offset in source array
  1926. * @returns the current Vector2
  1927. */
  1928. toArray(array: FloatArray, index?: number): Vector2;
  1929. /**
  1930. * Copy the current vector to an array
  1931. * @returns a new array with 2 elements: the Vector2 coordinates.
  1932. */
  1933. asArray(): number[];
  1934. /**
  1935. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1936. * @param source defines the source Vector2
  1937. * @returns the current updated Vector2
  1938. */
  1939. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1940. /**
  1941. * Sets the Vector2 coordinates with the given floats
  1942. * @param x defines the first coordinate
  1943. * @param y defines the second coordinate
  1944. * @returns the current updated Vector2
  1945. */
  1946. copyFromFloats(x: number, y: number): Vector2;
  1947. /**
  1948. * Sets the Vector2 coordinates with the given floats
  1949. * @param x defines the first coordinate
  1950. * @param y defines the second coordinate
  1951. * @returns the current updated Vector2
  1952. */
  1953. set(x: number, y: number): Vector2;
  1954. /**
  1955. * Add another vector with the current one
  1956. * @param otherVector defines the other vector
  1957. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1958. */
  1959. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1960. /**
  1961. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1962. * @param otherVector defines the other vector
  1963. * @param result defines the target vector
  1964. * @returns the unmodified current Vector2
  1965. */
  1966. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1967. /**
  1968. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1969. * @param otherVector defines the other vector
  1970. * @returns the current updated Vector2
  1971. */
  1972. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1975. * @param otherVector defines the other vector
  1976. * @returns a new Vector2
  1977. */
  1978. addVector3(otherVector: Vector3): Vector2;
  1979. /**
  1980. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1981. * @param otherVector defines the other vector
  1982. * @returns a new Vector2
  1983. */
  1984. subtract(otherVector: Vector2): Vector2;
  1985. /**
  1986. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1987. * @param otherVector defines the other vector
  1988. * @param result defines the target vector
  1989. * @returns the unmodified current Vector2
  1990. */
  1991. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1992. /**
  1993. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1994. * @param otherVector defines the other vector
  1995. * @returns the current updated Vector2
  1996. */
  1997. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Multiplies in place the current Vector2 coordinates by the given ones
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2010. /**
  2011. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @param result defines the target vector
  2014. * @returns the unmodified current Vector2
  2015. */
  2016. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2019. * @param x defines the first coordinate
  2020. * @param y defines the second coordinate
  2021. * @returns a new Vector2
  2022. */
  2023. multiplyByFloats(x: number, y: number): Vector2;
  2024. /**
  2025. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. divide(otherVector: Vector2): Vector2;
  2030. /**
  2031. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @param result defines the target vector
  2034. * @returns the unmodified current Vector2
  2035. */
  2036. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2037. /**
  2038. * Divides the current Vector2 coordinates by the given ones
  2039. * @param otherVector defines the other vector
  2040. * @returns the current updated Vector2
  2041. */
  2042. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2043. /**
  2044. * Gets a new Vector2 with current Vector2 negated coordinates
  2045. * @returns a new Vector2
  2046. */
  2047. negate(): Vector2;
  2048. /**
  2049. * Multiply the Vector2 coordinates by scale
  2050. * @param scale defines the scaling factor
  2051. * @returns the current updated Vector2
  2052. */
  2053. scaleInPlace(scale: number): Vector2;
  2054. /**
  2055. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2056. * @param scale defines the scaling factor
  2057. * @returns a new Vector2
  2058. */
  2059. scale(scale: number): Vector2;
  2060. /**
  2061. * Scale the current Vector2 values by a factor to a given Vector2
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector2 object where to store the result
  2064. * @returns the unmodified current Vector2
  2065. */
  2066. scaleToRef(scale: number, result: Vector2): Vector2;
  2067. /**
  2068. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2069. * @param scale defines the scale factor
  2070. * @param result defines the Vector2 object where to store the result
  2071. * @returns the unmodified current Vector2
  2072. */
  2073. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2074. /**
  2075. * Gets a boolean if two vectors are equals
  2076. * @param otherVector defines the other vector
  2077. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2078. */
  2079. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2080. /**
  2081. * Gets a boolean if two vectors are equals (using an epsilon value)
  2082. * @param otherVector defines the other vector
  2083. * @param epsilon defines the minimal distance to consider equality
  2084. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2085. */
  2086. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2087. /**
  2088. * Gets a new Vector2 from current Vector2 floored values
  2089. * @returns a new Vector2
  2090. */
  2091. floor(): Vector2;
  2092. /**
  2093. * Gets a new Vector2 from current Vector2 floored values
  2094. * @returns a new Vector2
  2095. */
  2096. fract(): Vector2;
  2097. /**
  2098. * Gets the length of the vector
  2099. * @returns the vector length (float)
  2100. */
  2101. length(): number;
  2102. /**
  2103. * Gets the vector squared length
  2104. * @returns the vector squared length (float)
  2105. */
  2106. lengthSquared(): number;
  2107. /**
  2108. * Normalize the vector
  2109. * @returns the current updated Vector2
  2110. */
  2111. normalize(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 copied from the Vector2
  2114. * @returns a new Vector2
  2115. */
  2116. clone(): Vector2;
  2117. /**
  2118. * Gets a new Vector2(0, 0)
  2119. * @returns a new Vector2
  2120. */
  2121. static Zero(): Vector2;
  2122. /**
  2123. * Gets a new Vector2(1, 1)
  2124. * @returns a new Vector2
  2125. */
  2126. static One(): Vector2;
  2127. /**
  2128. * Gets a new Vector2 set from the given index element of the given array
  2129. * @param array defines the data source
  2130. * @param offset defines the offset in the data source
  2131. * @returns a new Vector2
  2132. */
  2133. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2134. /**
  2135. * Sets "result" from the given index element of the given array
  2136. * @param array defines the data source
  2137. * @param offset defines the offset in the data source
  2138. * @param result defines the target vector
  2139. */
  2140. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2141. /**
  2142. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2143. * @param value1 defines 1st point of control
  2144. * @param value2 defines 2nd point of control
  2145. * @param value3 defines 3rd point of control
  2146. * @param value4 defines 4th point of control
  2147. * @param amount defines the interpolation factor
  2148. * @returns a new Vector2
  2149. */
  2150. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2151. /**
  2152. * 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".
  2153. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2154. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2155. * @param value defines the value to clamp
  2156. * @param min defines the lower limit
  2157. * @param max defines the upper limit
  2158. * @returns a new Vector2
  2159. */
  2160. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2161. /**
  2162. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2163. * @param value1 defines the 1st control point
  2164. * @param tangent1 defines the outgoing tangent
  2165. * @param value2 defines the 2nd control point
  2166. * @param tangent2 defines the incoming tangent
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2173. * @param start defines the start vector
  2174. * @param end defines the end vector
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Gets the dot product of the vector "left" and the vector "right"
  2181. * @param left defines first vector
  2182. * @param right defines second vector
  2183. * @returns the dot product (float)
  2184. */
  2185. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2186. /**
  2187. * Returns a new Vector2 equal to the normalized given vector
  2188. * @param vector defines the vector to normalize
  2189. * @returns a new Vector2
  2190. */
  2191. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2192. /**
  2193. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2194. * @param left defines 1st vector
  2195. * @param right defines 2nd vector
  2196. * @returns a new Vector2
  2197. */
  2198. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2201. * @param left defines 1st vector
  2202. * @param right defines 2nd vector
  2203. * @returns a new Vector2
  2204. */
  2205. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2208. * @param vector defines the vector to transform
  2209. * @param transformation defines the matrix to apply
  2210. * @returns a new Vector2
  2211. */
  2212. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2213. /**
  2214. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2215. * @param vector defines the vector to transform
  2216. * @param transformation defines the matrix to apply
  2217. * @param result defines the target vector
  2218. */
  2219. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2220. /**
  2221. * Determines if a given vector is included in a triangle
  2222. * @param p defines the vector to test
  2223. * @param p0 defines 1st triangle point
  2224. * @param p1 defines 2nd triangle point
  2225. * @param p2 defines 3rd triangle point
  2226. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2227. */
  2228. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2229. /**
  2230. * Gets the distance between the vectors "value1" and "value2"
  2231. * @param value1 defines first vector
  2232. * @param value2 defines second vector
  2233. * @returns the distance between vectors
  2234. */
  2235. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2236. /**
  2237. * Returns the squared distance between the vectors "value1" and "value2"
  2238. * @param value1 defines first vector
  2239. * @param value2 defines second vector
  2240. * @returns the squared distance between vectors
  2241. */
  2242. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2243. /**
  2244. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2245. * @param value1 defines first vector
  2246. * @param value2 defines second vector
  2247. * @returns a new Vector2
  2248. */
  2249. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2250. /**
  2251. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2252. * @param p defines the middle point
  2253. * @param segA defines one point of the segment
  2254. * @param segB defines the other point of the segment
  2255. * @returns the shortest distance
  2256. */
  2257. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2258. }
  2259. /**
  2260. * Classed used to store (x,y,z) vector representation
  2261. * A Vector3 is the main object used in 3D geometry
  2262. * It can represent etiher the coordinates of a point the space, either a direction
  2263. * Reminder: js uses a left handed forward facing system
  2264. */
  2265. export class Vector3 {
  2266. /**
  2267. * Defines the first coordinates (on X axis)
  2268. */
  2269. x: number;
  2270. /**
  2271. * Defines the second coordinates (on Y axis)
  2272. */
  2273. y: number;
  2274. /**
  2275. * Defines the third coordinates (on Z axis)
  2276. */
  2277. z: number;
  2278. private static _UpReadOnly;
  2279. private static _ZeroReadOnly;
  2280. /**
  2281. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2282. * @param x defines the first coordinates (on X axis)
  2283. * @param y defines the second coordinates (on Y axis)
  2284. * @param z defines the third coordinates (on Z axis)
  2285. */
  2286. constructor(
  2287. /**
  2288. * Defines the first coordinates (on X axis)
  2289. */
  2290. x?: number,
  2291. /**
  2292. * Defines the second coordinates (on Y axis)
  2293. */
  2294. y?: number,
  2295. /**
  2296. * Defines the third coordinates (on Z axis)
  2297. */
  2298. z?: number);
  2299. /**
  2300. * Creates a string representation of the Vector3
  2301. * @returns a string with the Vector3 coordinates.
  2302. */
  2303. toString(): string;
  2304. /**
  2305. * Gets the class name
  2306. * @returns the string "Vector3"
  2307. */
  2308. getClassName(): string;
  2309. /**
  2310. * Creates the Vector3 hash code
  2311. * @returns a number which tends to be unique between Vector3 instances
  2312. */
  2313. getHashCode(): number;
  2314. /**
  2315. * Creates an array containing three elements : the coordinates of the Vector3
  2316. * @returns a new array of numbers
  2317. */
  2318. asArray(): number[];
  2319. /**
  2320. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2321. * @param array defines the destination array
  2322. * @param index defines the offset in the destination array
  2323. * @returns the current Vector3
  2324. */
  2325. toArray(array: FloatArray, index?: number): Vector3;
  2326. /**
  2327. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2328. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2329. */
  2330. toQuaternion(): Quaternion;
  2331. /**
  2332. * Adds the given vector to the current Vector3
  2333. * @param otherVector defines the second operand
  2334. * @returns the current updated Vector3
  2335. */
  2336. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2337. /**
  2338. * Adds the given coordinates to the current Vector3
  2339. * @param x defines the x coordinate of the operand
  2340. * @param y defines the y coordinate of the operand
  2341. * @param z defines the z coordinate of the operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2345. /**
  2346. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2347. * @param otherVector defines the second operand
  2348. * @returns the resulting Vector3
  2349. */
  2350. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2351. /**
  2352. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2353. * @param otherVector defines the second operand
  2354. * @param result defines the Vector3 object where to store the result
  2355. * @returns the current Vector3
  2356. */
  2357. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2358. /**
  2359. * Subtract the given vector from the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2366. * @param otherVector defines the second operand
  2367. * @returns the resulting Vector3
  2368. */
  2369. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2370. /**
  2371. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2372. * @param otherVector defines the second operand
  2373. * @param result defines the Vector3 object where to store the result
  2374. * @returns the current Vector3
  2375. */
  2376. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2377. /**
  2378. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2379. * @param x defines the x coordinate of the operand
  2380. * @param y defines the y coordinate of the operand
  2381. * @param z defines the z coordinate of the operand
  2382. * @returns the resulting Vector3
  2383. */
  2384. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2385. /**
  2386. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @param result defines the Vector3 object where to store the result
  2391. * @returns the current Vector3
  2392. */
  2393. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2394. /**
  2395. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2396. * @returns a new Vector3
  2397. */
  2398. negate(): Vector3;
  2399. /**
  2400. * Multiplies the Vector3 coordinates by the float "scale"
  2401. * @param scale defines the multiplier factor
  2402. * @returns the current updated Vector3
  2403. */
  2404. scaleInPlace(scale: number): Vector3;
  2405. /**
  2406. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2407. * @param scale defines the multiplier factor
  2408. * @returns a new Vector3
  2409. */
  2410. scale(scale: number): Vector3;
  2411. /**
  2412. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2413. * @param scale defines the multiplier factor
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. scaleToRef(scale: number, result: Vector3): Vector3;
  2418. /**
  2419. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2420. * @param scale defines the scale factor
  2421. * @param result defines the Vector3 object where to store the result
  2422. * @returns the unmodified current Vector3
  2423. */
  2424. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2425. /**
  2426. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2427. * @param otherVector defines the second operand
  2428. * @returns true if both vectors are equals
  2429. */
  2430. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2431. /**
  2432. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2433. * @param otherVector defines the second operand
  2434. * @param epsilon defines the minimal distance to define values as equals
  2435. * @returns true if both vectors are distant less than epsilon
  2436. */
  2437. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2438. /**
  2439. * Returns true if the current Vector3 coordinates equals the given floats
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns true if both vectors are equals
  2444. */
  2445. equalsToFloats(x: number, y: number, z: number): boolean;
  2446. /**
  2447. * Multiplies the current Vector3 coordinates by the given ones
  2448. * @param otherVector defines the second operand
  2449. * @returns the current updated Vector3
  2450. */
  2451. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2452. /**
  2453. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2454. * @param otherVector defines the second operand
  2455. * @returns the new Vector3
  2456. */
  2457. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2458. /**
  2459. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2460. * @param otherVector defines the second operand
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the current Vector3
  2463. */
  2464. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2465. /**
  2466. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2467. * @param x defines the x coordinate of the operand
  2468. * @param y defines the y coordinate of the operand
  2469. * @param z defines the z coordinate of the operand
  2470. * @returns the new Vector3
  2471. */
  2472. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2475. * @param otherVector defines the second operand
  2476. * @returns the new Vector3
  2477. */
  2478. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2479. /**
  2480. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2481. * @param otherVector defines the second operand
  2482. * @param result defines the Vector3 object where to store the result
  2483. * @returns the current Vector3
  2484. */
  2485. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2486. /**
  2487. * Divides the current Vector3 coordinates by the given ones.
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. divideInPlace(otherVector: Vector3): Vector3;
  2492. /**
  2493. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2494. * @param other defines the second operand
  2495. * @returns the current updated Vector3
  2496. */
  2497. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2500. * @param other defines the second operand
  2501. * @returns the current updated Vector3
  2502. */
  2503. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2504. /**
  2505. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2522. * Check if is non uniform within a certain amount of decimal places to account for this
  2523. * @param epsilon the amount the values can differ
  2524. * @returns if the the vector is non uniform to a certain number of decimal places
  2525. */
  2526. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2527. /**
  2528. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2529. */
  2530. readonly isNonUniform: boolean;
  2531. /**
  2532. * Gets a new Vector3 from current Vector3 floored values
  2533. * @returns a new Vector3
  2534. */
  2535. floor(): Vector3;
  2536. /**
  2537. * Gets a new Vector3 from current Vector3 floored values
  2538. * @returns a new Vector3
  2539. */
  2540. fract(): Vector3;
  2541. /**
  2542. * Gets the length of the Vector3
  2543. * @returns the length of the Vector3
  2544. */
  2545. length(): number;
  2546. /**
  2547. * Gets the squared length of the Vector3
  2548. * @returns squared length of the Vector3
  2549. */
  2550. lengthSquared(): number;
  2551. /**
  2552. * Normalize the current Vector3.
  2553. * Please note that this is an in place operation.
  2554. * @returns the current updated Vector3
  2555. */
  2556. normalize(): Vector3;
  2557. /**
  2558. * Reorders the x y z properties of the vector in place
  2559. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2560. * @returns the current updated vector
  2561. */
  2562. reorderInPlace(order: string): this;
  2563. /**
  2564. * Rotates the vector around 0,0,0 by a quaternion
  2565. * @param quaternion the rotation quaternion
  2566. * @param result vector to store the result
  2567. * @returns the resulting vector
  2568. */
  2569. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2570. /**
  2571. * Rotates a vector around a given point
  2572. * @param quaternion the rotation quaternion
  2573. * @param point the point to rotate around
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2578. /**
  2579. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2580. * The cross product is then orthogonal to both current and "other"
  2581. * @param other defines the right operand
  2582. * @returns the cross product
  2583. */
  2584. cross(other: Vector3): Vector3;
  2585. /**
  2586. * Normalize the current Vector3 with the given input length.
  2587. * Please note that this is an in place operation.
  2588. * @param len the length of the vector
  2589. * @returns the current updated Vector3
  2590. */
  2591. normalizeFromLength(len: number): Vector3;
  2592. /**
  2593. * Normalize the current Vector3 to a new vector
  2594. * @returns the new Vector3
  2595. */
  2596. normalizeToNew(): Vector3;
  2597. /**
  2598. * Normalize the current Vector3 to the reference
  2599. * @param reference define the Vector3 to update
  2600. * @returns the updated Vector3
  2601. */
  2602. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Creates a new Vector3 copied from the current Vector3
  2605. * @returns the new Vector3
  2606. */
  2607. clone(): Vector3;
  2608. /**
  2609. * Copies the given vector coordinates to the current Vector3 ones
  2610. * @param source defines the source Vector3
  2611. * @returns the current updated Vector3
  2612. */
  2613. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Copies the given floats to the current Vector3 coordinates
  2616. * @param x defines the x coordinate of the operand
  2617. * @param y defines the y coordinate of the operand
  2618. * @param z defines the z coordinate of the operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFromFloats(x: number, y: number, z: number): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. set(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given float to the current Vector3 coordinates
  2632. * @param v defines the x, y and z coordinates of the operand
  2633. * @returns the current updated Vector3
  2634. */
  2635. setAll(v: number): Vector3;
  2636. /**
  2637. * Get the clip factor between two vectors
  2638. * @param vector0 defines the first operand
  2639. * @param vector1 defines the second operand
  2640. * @param axis defines the axis to use
  2641. * @param size defines the size along the axis
  2642. * @returns the clip factor
  2643. */
  2644. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2645. /**
  2646. * Get angle between two vectors
  2647. * @param vector0 angle between vector0 and vector1
  2648. * @param vector1 angle between vector0 and vector1
  2649. * @param normal direction of the normal
  2650. * @return the angle between vector0 and vector1
  2651. */
  2652. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2653. /**
  2654. * Returns a new Vector3 set from the index "offset" of the given array
  2655. * @param array defines the source array
  2656. * @param offset defines the offset in the source array
  2657. * @returns the new Vector3
  2658. */
  2659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2660. /**
  2661. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2662. * This function is deprecated. Use FromArray instead
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2668. /**
  2669. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @param result defines the Vector3 where to store the result
  2673. */
  2674. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2675. /**
  2676. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2677. * This function is deprecated. Use FromArrayToRef instead.
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the given floats.
  2685. * @param x defines the x coordinate of the source
  2686. * @param y defines the y coordinate of the source
  2687. * @param z defines the z coordinate of the source
  2688. * @param result defines the Vector3 where to store the result
  2689. */
  2690. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2691. /**
  2692. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2693. * @returns a new empty Vector3
  2694. */
  2695. static Zero(): Vector3;
  2696. /**
  2697. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2698. * @returns a new unit Vector3
  2699. */
  2700. static One(): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2703. * @returns a new up Vector3
  2704. */
  2705. static Up(): Vector3;
  2706. /**
  2707. * Gets a up Vector3 that must not be updated
  2708. */
  2709. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2710. /**
  2711. * Gets a zero Vector3 that must not be updated
  2712. */
  2713. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2714. /**
  2715. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2716. * @returns a new down Vector3
  2717. */
  2718. static Down(): Vector3;
  2719. /**
  2720. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2721. * @returns a new forward Vector3
  2722. */
  2723. static Forward(): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2726. * @returns a new forward Vector3
  2727. */
  2728. static Backward(): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2731. * @returns a new right Vector3
  2732. */
  2733. static Right(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2736. * @returns a new left Vector3
  2737. */
  2738. static Left(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2741. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2742. * @param vector defines the Vector3 to transform
  2743. * @param transformation defines the transformation matrix
  2744. * @returns the transformed Vector3
  2745. */
  2746. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2747. /**
  2748. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2757. * This method computes tranformed coordinates only, not transformed direction vectors
  2758. * @param x define the x coordinate of the source vector
  2759. * @param y define the y coordinate of the source vector
  2760. * @param z define the z coordinate of the source vector
  2761. * @param transformation defines the transformation matrix
  2762. * @param result defines the Vector3 where to store the result
  2763. */
  2764. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2765. /**
  2766. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2767. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2768. * @param vector defines the Vector3 to transform
  2769. * @param transformation defines the transformation matrix
  2770. * @returns the new Vector3
  2771. */
  2772. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2773. /**
  2774. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @param result defines the Vector3 where to store the result
  2779. */
  2780. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param x define the x coordinate of the source vector
  2785. * @param y define the y coordinate of the source vector
  2786. * @param z define the z coordinate of the source vector
  2787. * @param transformation defines the transformation matrix
  2788. * @param result defines the Vector3 where to store the result
  2789. */
  2790. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2791. /**
  2792. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2793. * @param value1 defines the first control point
  2794. * @param value2 defines the second control point
  2795. * @param value3 defines the third control point
  2796. * @param value4 defines the fourth control point
  2797. * @param amount defines the amount on the spline to use
  2798. * @returns the new Vector3
  2799. */
  2800. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2801. /**
  2802. * 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"
  2803. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2804. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2805. * @param value defines the current value
  2806. * @param min defines the lower range value
  2807. * @param max defines the upper range value
  2808. * @returns the new Vector3
  2809. */
  2810. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2811. /**
  2812. * 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"
  2813. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2814. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2815. * @param value defines the current value
  2816. * @param min defines the lower range value
  2817. * @param max defines the upper range value
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2821. /**
  2822. * Checks if a given vector is inside a specific range
  2823. * @param v defines the vector to test
  2824. * @param min defines the minimum range
  2825. * @param max defines the maximum range
  2826. */
  2827. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2828. /**
  2829. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2830. * @param value1 defines the first control point
  2831. * @param tangent1 defines the first tangent vector
  2832. * @param value2 defines the second control point
  2833. * @param tangent2 defines the second tangent vector
  2834. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2835. * @returns the new Vector3
  2836. */
  2837. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2838. /**
  2839. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2840. * @param start defines the start value
  2841. * @param end defines the end value
  2842. * @param amount max defines amount between both (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2854. /**
  2855. * Returns the dot product (float) between the vectors "left" and "right"
  2856. * @param left defines the left operand
  2857. * @param right defines the right operand
  2858. * @returns the dot product
  2859. */
  2860. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2861. /**
  2862. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2863. * The cross product is then orthogonal to both "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the cross product
  2867. */
  2868. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2869. /**
  2870. * Sets the given vector "result" with the cross product of "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @param result defines the Vector3 where to store the result
  2875. */
  2876. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2877. /**
  2878. * Returns a new Vector3 as the normalization of the given vector
  2879. * @param vector defines the Vector3 to normalize
  2880. * @returns the new Vector3
  2881. */
  2882. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2883. /**
  2884. * Sets the given vector "result" with the normalization of the given first vector
  2885. * @param vector defines the Vector3 to normalize
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2889. /**
  2890. * Project a Vector3 onto screen space
  2891. * @param vector defines the Vector3 to project
  2892. * @param world defines the world matrix to use
  2893. * @param transform defines the transform (view x projection) matrix to use
  2894. * @param viewport defines the screen viewport to use
  2895. * @returns the new Vector3
  2896. */
  2897. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2898. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2899. /**
  2900. * Unproject from screen space to object space
  2901. * @param source defines the screen space Vector3 to use
  2902. * @param viewportWidth defines the current width of the viewport
  2903. * @param viewportHeight defines the current height of the viewport
  2904. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2905. * @param transform defines the transform (view x projection) matrix to use
  2906. * @returns the new Vector3
  2907. */
  2908. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2909. /**
  2910. * Unproject from screen space to object space
  2911. * @param source defines the screen space Vector3 to use
  2912. * @param viewportWidth defines the current width of the viewport
  2913. * @param viewportHeight defines the current height of the viewport
  2914. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2915. * @param view defines the view matrix to use
  2916. * @param projection defines the projection matrix to use
  2917. * @returns the new Vector3
  2918. */
  2919. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2920. /**
  2921. * Unproject from screen space to object space
  2922. * @param source defines the screen space Vector3 to use
  2923. * @param viewportWidth defines the current width of the viewport
  2924. * @param viewportHeight defines the current height of the viewport
  2925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2926. * @param view defines the view matrix to use
  2927. * @param projection defines the projection matrix to use
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param sourceX defines the screen space x coordinate to use
  2934. * @param sourceY defines the screen space y coordinate to use
  2935. * @param sourceZ defines the screen space z coordinate to use
  2936. * @param viewportWidth defines the current width of the viewport
  2937. * @param viewportHeight defines the current height of the viewport
  2938. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2939. * @param view defines the view matrix to use
  2940. * @param projection defines the projection matrix to use
  2941. * @param result defines the Vector3 where to store the result
  2942. */
  2943. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2944. /**
  2945. * Gets the minimal coordinate values between two Vector3
  2946. * @param left defines the first operand
  2947. * @param right defines the second operand
  2948. * @returns the new Vector3
  2949. */
  2950. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2951. /**
  2952. * Gets the maximal coordinate values between two Vector3
  2953. * @param left defines the first operand
  2954. * @param right defines the second operand
  2955. * @returns the new Vector3
  2956. */
  2957. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2958. /**
  2959. * Returns the distance between the vectors "value1" and "value2"
  2960. * @param value1 defines the first operand
  2961. * @param value2 defines the second operand
  2962. * @returns the distance
  2963. */
  2964. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2965. /**
  2966. * Returns the squared distance between the vectors "value1" and "value2"
  2967. * @param value1 defines the first operand
  2968. * @param value2 defines the second operand
  2969. * @returns the squared distance
  2970. */
  2971. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2972. /**
  2973. * Returns a new Vector3 located at the center between "value1" and "value2"
  2974. * @param value1 defines the first operand
  2975. * @param value2 defines the second operand
  2976. * @returns the new Vector3
  2977. */
  2978. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2979. /**
  2980. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2981. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2982. * to something in order to rotate it from its local system to the given target system
  2983. * Note: axis1, axis2 and axis3 are normalized during this operation
  2984. * @param axis1 defines the first axis
  2985. * @param axis2 defines the second axis
  2986. * @param axis3 defines the third axis
  2987. * @returns a new Vector3
  2988. */
  2989. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2992. * @param axis1 defines the first axis
  2993. * @param axis2 defines the second axis
  2994. * @param axis3 defines the third axis
  2995. * @param ref defines the Vector3 where to store the result
  2996. */
  2997. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2998. }
  2999. /**
  3000. * Vector4 class created for EulerAngle class conversion to Quaternion
  3001. */
  3002. export class Vector4 {
  3003. /** x value of the vector */
  3004. x: number;
  3005. /** y value of the vector */
  3006. y: number;
  3007. /** z value of the vector */
  3008. z: number;
  3009. /** w value of the vector */
  3010. w: number;
  3011. /**
  3012. * Creates a Vector4 object from the given floats.
  3013. * @param x x value of the vector
  3014. * @param y y value of the vector
  3015. * @param z z value of the vector
  3016. * @param w w value of the vector
  3017. */
  3018. constructor(
  3019. /** x value of the vector */
  3020. x: number,
  3021. /** y value of the vector */
  3022. y: number,
  3023. /** z value of the vector */
  3024. z: number,
  3025. /** w value of the vector */
  3026. w: number);
  3027. /**
  3028. * Returns the string with the Vector4 coordinates.
  3029. * @returns a string containing all the vector values
  3030. */
  3031. toString(): string;
  3032. /**
  3033. * Returns the string "Vector4".
  3034. * @returns "Vector4"
  3035. */
  3036. getClassName(): string;
  3037. /**
  3038. * Returns the Vector4 hash code.
  3039. * @returns a unique hash code
  3040. */
  3041. getHashCode(): number;
  3042. /**
  3043. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3044. * @returns the resulting array
  3045. */
  3046. asArray(): number[];
  3047. /**
  3048. * Populates the given array from the given index with the Vector4 coordinates.
  3049. * @param array array to populate
  3050. * @param index index of the array to start at (default: 0)
  3051. * @returns the Vector4.
  3052. */
  3053. toArray(array: FloatArray, index?: number): Vector4;
  3054. /**
  3055. * Adds the given vector to the current Vector4.
  3056. * @param otherVector the vector to add
  3057. * @returns the updated Vector4.
  3058. */
  3059. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3060. /**
  3061. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3062. * @param otherVector the vector to add
  3063. * @returns the resulting vector
  3064. */
  3065. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3066. /**
  3067. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3068. * @param otherVector the vector to add
  3069. * @param result the vector to store the result
  3070. * @returns the current Vector4.
  3071. */
  3072. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3073. /**
  3074. * Subtract in place the given vector from the current Vector4.
  3075. * @param otherVector the vector to subtract
  3076. * @returns the updated Vector4.
  3077. */
  3078. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3079. /**
  3080. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3081. * @param otherVector the vector to add
  3082. * @returns the new vector with the result
  3083. */
  3084. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3085. /**
  3086. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3087. * @param otherVector the vector to subtract
  3088. * @param result the vector to store the result
  3089. * @returns the current Vector4.
  3090. */
  3091. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3092. /**
  3093. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3094. */
  3095. /**
  3096. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3097. * @param x value to subtract
  3098. * @param y value to subtract
  3099. * @param z value to subtract
  3100. * @param w value to subtract
  3101. * @returns new vector containing the result
  3102. */
  3103. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3104. /**
  3105. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @param result the vector to store the result in
  3111. * @returns the current Vector4.
  3112. */
  3113. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3114. /**
  3115. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3116. * @returns a new vector with the negated values
  3117. */
  3118. negate(): Vector4;
  3119. /**
  3120. * Multiplies the current Vector4 coordinates by scale (float).
  3121. * @param scale the number to scale with
  3122. * @returns the updated Vector4.
  3123. */
  3124. scaleInPlace(scale: number): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3127. * @param scale the number to scale with
  3128. * @returns a new vector with the result
  3129. */
  3130. scale(scale: number): Vector4;
  3131. /**
  3132. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3133. * @param scale the number to scale with
  3134. * @param result a vector to store the result in
  3135. * @returns the current Vector4.
  3136. */
  3137. scaleToRef(scale: number, result: Vector4): Vector4;
  3138. /**
  3139. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3140. * @param scale defines the scale factor
  3141. * @param result defines the Vector4 object where to store the result
  3142. * @returns the unmodified current Vector4
  3143. */
  3144. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3145. /**
  3146. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3147. * @param otherVector the vector to compare against
  3148. * @returns true if they are equal
  3149. */
  3150. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3151. /**
  3152. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3153. * @param otherVector vector to compare against
  3154. * @param epsilon (Default: very small number)
  3155. * @returns true if they are equal
  3156. */
  3157. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3158. /**
  3159. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3160. * @param x x value to compare against
  3161. * @param y y value to compare against
  3162. * @param z z value to compare against
  3163. * @param w w value to compare against
  3164. * @returns true if equal
  3165. */
  3166. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3167. /**
  3168. * Multiplies in place the current Vector4 by the given one.
  3169. * @param otherVector vector to multiple with
  3170. * @returns the updated Vector4.
  3171. */
  3172. multiplyInPlace(otherVector: Vector4): Vector4;
  3173. /**
  3174. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3175. * @param otherVector vector to multiple with
  3176. * @returns resulting new vector
  3177. */
  3178. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3179. /**
  3180. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3181. * @param otherVector vector to multiple with
  3182. * @param result vector to store the result
  3183. * @returns the current Vector4.
  3184. */
  3185. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3188. * @param x x value multiply with
  3189. * @param y y value multiply with
  3190. * @param z z value multiply with
  3191. * @param w w value multiply with
  3192. * @returns resulting new vector
  3193. */
  3194. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3197. * @param otherVector vector to devide with
  3198. * @returns resulting new vector
  3199. */
  3200. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3201. /**
  3202. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3203. * @param otherVector vector to devide with
  3204. * @param result vector to store the result
  3205. * @returns the current Vector4.
  3206. */
  3207. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3208. /**
  3209. * Divides the current Vector3 coordinates by the given ones.
  3210. * @param otherVector vector to devide with
  3211. * @returns the updated Vector3.
  3212. */
  3213. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3214. /**
  3215. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3216. * @param other defines the second operand
  3217. * @returns the current updated Vector4
  3218. */
  3219. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3220. /**
  3221. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3222. * @param other defines the second operand
  3223. * @returns the current updated Vector4
  3224. */
  3225. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Gets a new Vector4 from current Vector4 floored values
  3228. * @returns a new Vector4
  3229. */
  3230. floor(): Vector4;
  3231. /**
  3232. * Gets a new Vector4 from current Vector3 floored values
  3233. * @returns a new Vector4
  3234. */
  3235. fract(): Vector4;
  3236. /**
  3237. * Returns the Vector4 length (float).
  3238. * @returns the length
  3239. */
  3240. length(): number;
  3241. /**
  3242. * Returns the Vector4 squared length (float).
  3243. * @returns the length squared
  3244. */
  3245. lengthSquared(): number;
  3246. /**
  3247. * Normalizes in place the Vector4.
  3248. * @returns the updated Vector4.
  3249. */
  3250. normalize(): Vector4;
  3251. /**
  3252. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3253. * @returns this converted to a new vector3
  3254. */
  3255. toVector3(): Vector3;
  3256. /**
  3257. * Returns a new Vector4 copied from the current one.
  3258. * @returns the new cloned vector
  3259. */
  3260. clone(): Vector4;
  3261. /**
  3262. * Updates the current Vector4 with the given one coordinates.
  3263. * @param source the source vector to copy from
  3264. * @returns the updated Vector4.
  3265. */
  3266. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the current Vector4 coordinates with the given floats.
  3269. * @param x float to copy from
  3270. * @param y float to copy from
  3271. * @param z float to copy from
  3272. * @param w float to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to set from
  3279. * @param y float to set from
  3280. * @param z float to set from
  3281. * @param w float to set from
  3282. * @returns the updated Vector4.
  3283. */
  3284. set(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Copies the given float to the current Vector3 coordinates
  3287. * @param v defines the x, y, z and w coordinates of the operand
  3288. * @returns the current updated Vector3
  3289. */
  3290. setAll(v: number): Vector4;
  3291. /**
  3292. * Returns a new Vector4 set from the starting index of the given array.
  3293. * @param array the array to pull values from
  3294. * @param offset the offset into the array to start at
  3295. * @returns the new vector
  3296. */
  3297. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3298. /**
  3299. * Updates the given vector "result" from the starting index of the given array.
  3300. * @param array the array to pull values from
  3301. * @param offset the offset into the array to start at
  3302. * @param result the vector to store the result in
  3303. */
  3304. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3305. /**
  3306. * Updates the given vector "result" from the starting index of the given Float32Array.
  3307. * @param array the array to pull values from
  3308. * @param offset the offset into the array to start at
  3309. * @param result the vector to store the result in
  3310. */
  3311. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3312. /**
  3313. * Updates the given vector "result" coordinates from the given floats.
  3314. * @param x float to set from
  3315. * @param y float to set from
  3316. * @param z float to set from
  3317. * @param w float to set from
  3318. * @param result the vector to the floats in
  3319. */
  3320. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3321. /**
  3322. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3323. * @returns the new vector
  3324. */
  3325. static Zero(): Vector4;
  3326. /**
  3327. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3328. * @returns the new vector
  3329. */
  3330. static One(): Vector4;
  3331. /**
  3332. * Returns a new normalized Vector4 from the given one.
  3333. * @param vector the vector to normalize
  3334. * @returns the vector
  3335. */
  3336. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the normalization of the given one.
  3339. * @param vector the vector to normalize
  3340. * @param result the vector to store the result in
  3341. */
  3342. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3343. /**
  3344. * Returns a vector with the minimum values from the left and right vectors
  3345. * @param left left vector to minimize
  3346. * @param right right vector to minimize
  3347. * @returns a new vector with the minimum of the left and right vector values
  3348. */
  3349. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Returns a vector with the maximum values from the left and right vectors
  3352. * @param left left vector to maximize
  3353. * @param right right vector to maximize
  3354. * @returns a new vector with the maximum of the left and right vector values
  3355. */
  3356. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Returns the distance (float) between the vectors "value1" and "value2".
  3359. * @param value1 value to calulate the distance between
  3360. * @param value2 value to calulate the distance between
  3361. * @return the distance between the two vectors
  3362. */
  3363. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3364. /**
  3365. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3366. * @param value1 value to calulate the distance between
  3367. * @param value2 value to calulate the distance between
  3368. * @return the distance between the two vectors squared
  3369. */
  3370. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3371. /**
  3372. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3373. * @param value1 value to calulate the center between
  3374. * @param value2 value to calulate the center between
  3375. * @return the center between the two vectors
  3376. */
  3377. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3380. * This methods computes transformed normalized direction vectors only.
  3381. * @param vector the vector to transform
  3382. * @param transformation the transformation matrix to apply
  3383. * @returns the new vector
  3384. */
  3385. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3386. /**
  3387. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3388. * This methods computes transformed normalized direction vectors only.
  3389. * @param vector the vector to transform
  3390. * @param transformation the transformation matrix to apply
  3391. * @param result the vector to store the result in
  3392. */
  3393. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3394. /**
  3395. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3396. * This methods computes transformed normalized direction vectors only.
  3397. * @param x value to transform
  3398. * @param y value to transform
  3399. * @param z value to transform
  3400. * @param w value to transform
  3401. * @param transformation the transformation matrix to apply
  3402. * @param result the vector to store the results in
  3403. */
  3404. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3405. /**
  3406. * Creates a new Vector4 from a Vector3
  3407. * @param source defines the source data
  3408. * @param w defines the 4th component (default is 0)
  3409. * @returns a new Vector4
  3410. */
  3411. static FromVector3(source: Vector3, w?: number): Vector4;
  3412. }
  3413. /**
  3414. * Class used to store quaternion data
  3415. * @see https://en.wikipedia.org/wiki/Quaternion
  3416. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3417. */
  3418. export class Quaternion {
  3419. /** defines the first component (0 by default) */
  3420. x: number;
  3421. /** defines the second component (0 by default) */
  3422. y: number;
  3423. /** defines the third component (0 by default) */
  3424. z: number;
  3425. /** defines the fourth component (1.0 by default) */
  3426. w: number;
  3427. /**
  3428. * Creates a new Quaternion from the given floats
  3429. * @param x defines the first component (0 by default)
  3430. * @param y defines the second component (0 by default)
  3431. * @param z defines the third component (0 by default)
  3432. * @param w defines the fourth component (1.0 by default)
  3433. */
  3434. constructor(
  3435. /** defines the first component (0 by default) */
  3436. x?: number,
  3437. /** defines the second component (0 by default) */
  3438. y?: number,
  3439. /** defines the third component (0 by default) */
  3440. z?: number,
  3441. /** defines the fourth component (1.0 by default) */
  3442. w?: number);
  3443. /**
  3444. * Gets a string representation for the current quaternion
  3445. * @returns a string with the Quaternion coordinates
  3446. */
  3447. toString(): string;
  3448. /**
  3449. * Gets the class name of the quaternion
  3450. * @returns the string "Quaternion"
  3451. */
  3452. getClassName(): string;
  3453. /**
  3454. * Gets a hash code for this quaternion
  3455. * @returns the quaternion hash code
  3456. */
  3457. getHashCode(): number;
  3458. /**
  3459. * Copy the quaternion to an array
  3460. * @returns a new array populated with 4 elements from the quaternion coordinates
  3461. */
  3462. asArray(): number[];
  3463. /**
  3464. * Check if two quaternions are equals
  3465. * @param otherQuaternion defines the second operand
  3466. * @return true if the current quaternion and the given one coordinates are strictly equals
  3467. */
  3468. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3469. /**
  3470. * Clone the current quaternion
  3471. * @returns a new quaternion copied from the current one
  3472. */
  3473. clone(): Quaternion;
  3474. /**
  3475. * Copy a quaternion to the current one
  3476. * @param other defines the other quaternion
  3477. * @returns the updated current quaternion
  3478. */
  3479. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3480. /**
  3481. * Updates the current quaternion with the given float coordinates
  3482. * @param x defines the x coordinate
  3483. * @param y defines the y coordinate
  3484. * @param z defines the z coordinate
  3485. * @param w defines the w coordinate
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3489. /**
  3490. * Updates the current quaternion from the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. set(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Adds two quaternions
  3500. * @param other defines the second operand
  3501. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3502. */
  3503. add(other: DeepImmutable<Quaternion>): Quaternion;
  3504. /**
  3505. * Add a quaternion to the current one
  3506. * @param other defines the quaternion to add
  3507. * @returns the current quaternion
  3508. */
  3509. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3510. /**
  3511. * Subtract two quaternions
  3512. * @param other defines the second operand
  3513. * @returns a new quaternion as the subtraction result of the given one from the current one
  3514. */
  3515. subtract(other: Quaternion): Quaternion;
  3516. /**
  3517. * Multiplies the current quaternion by a scale factor
  3518. * @param value defines the scale factor
  3519. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3520. */
  3521. scale(value: number): Quaternion;
  3522. /**
  3523. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3524. * @param scale defines the scale factor
  3525. * @param result defines the Quaternion object where to store the result
  3526. * @returns the unmodified current quaternion
  3527. */
  3528. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3529. /**
  3530. * Multiplies in place the current quaternion by a scale factor
  3531. * @param value defines the scale factor
  3532. * @returns the current modified quaternion
  3533. */
  3534. scaleInPlace(value: number): Quaternion;
  3535. /**
  3536. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3537. * @param scale defines the scale factor
  3538. * @param result defines the Quaternion object where to store the result
  3539. * @returns the unmodified current quaternion
  3540. */
  3541. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3542. /**
  3543. * Multiplies two quaternions
  3544. * @param q1 defines the second operand
  3545. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3546. */
  3547. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3550. * @param q1 defines the second operand
  3551. * @param result defines the target quaternion
  3552. * @returns the current quaternion
  3553. */
  3554. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3555. /**
  3556. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3557. * @param q1 defines the second operand
  3558. * @returns the currentupdated quaternion
  3559. */
  3560. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3561. /**
  3562. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3563. * @param ref defines the target quaternion
  3564. * @returns the current quaternion
  3565. */
  3566. conjugateToRef(ref: Quaternion): Quaternion;
  3567. /**
  3568. * Conjugates in place (1-q) the current quaternion
  3569. * @returns the current updated quaternion
  3570. */
  3571. conjugateInPlace(): Quaternion;
  3572. /**
  3573. * Conjugates in place (1-q) the current quaternion
  3574. * @returns a new quaternion
  3575. */
  3576. conjugate(): Quaternion;
  3577. /**
  3578. * Gets length of current quaternion
  3579. * @returns the quaternion length (float)
  3580. */
  3581. length(): number;
  3582. /**
  3583. * Normalize in place the current quaternion
  3584. * @returns the current updated quaternion
  3585. */
  3586. normalize(): Quaternion;
  3587. /**
  3588. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3589. * @param order is a reserved parameter and is ignore for now
  3590. * @returns a new Vector3 containing the Euler angles
  3591. */
  3592. toEulerAngles(order?: string): Vector3;
  3593. /**
  3594. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3595. * @param result defines the vector which will be filled with the Euler angles
  3596. * @param order is a reserved parameter and is ignore for now
  3597. * @returns the current unchanged quaternion
  3598. */
  3599. toEulerAnglesToRef(result: Vector3): Quaternion;
  3600. /**
  3601. * Updates the given rotation matrix with the current quaternion values
  3602. * @param result defines the target matrix
  3603. * @returns the current unchanged quaternion
  3604. */
  3605. toRotationMatrix(result: Matrix): Quaternion;
  3606. /**
  3607. * Updates the current quaternion from the given rotation matrix values
  3608. * @param matrix defines the source matrix
  3609. * @returns the current updated quaternion
  3610. */
  3611. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3612. /**
  3613. * Creates a new quaternion from a rotation matrix
  3614. * @param matrix defines the source matrix
  3615. * @returns a new quaternion created from the given rotation matrix values
  3616. */
  3617. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3618. /**
  3619. * Updates the given quaternion with the given rotation matrix values
  3620. * @param matrix defines the source matrix
  3621. * @param result defines the target quaternion
  3622. */
  3623. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3624. /**
  3625. * Returns the dot product (float) between the quaternions "left" and "right"
  3626. * @param left defines the left operand
  3627. * @param right defines the right operand
  3628. * @returns the dot product
  3629. */
  3630. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3631. /**
  3632. * Checks if the two quaternions are close to each other
  3633. * @param quat0 defines the first quaternion to check
  3634. * @param quat1 defines the second quaternion to check
  3635. * @returns true if the two quaternions are close to each other
  3636. */
  3637. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3638. /**
  3639. * Creates an empty quaternion
  3640. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3641. */
  3642. static Zero(): Quaternion;
  3643. /**
  3644. * Inverse a given quaternion
  3645. * @param q defines the source quaternion
  3646. * @returns a new quaternion as the inverted current quaternion
  3647. */
  3648. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3649. /**
  3650. * Inverse a given quaternion
  3651. * @param q defines the source quaternion
  3652. * @param result the quaternion the result will be stored in
  3653. * @returns the result quaternion
  3654. */
  3655. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3656. /**
  3657. * Creates an identity quaternion
  3658. * @returns the identity quaternion
  3659. */
  3660. static Identity(): Quaternion;
  3661. /**
  3662. * Gets a boolean indicating if the given quaternion is identity
  3663. * @param quaternion defines the quaternion to check
  3664. * @returns true if the quaternion is identity
  3665. */
  3666. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3667. /**
  3668. * Creates a quaternion from a rotation around an axis
  3669. * @param axis defines the axis to use
  3670. * @param angle defines the angle to use
  3671. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3672. */
  3673. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3674. /**
  3675. * Creates a rotation around an axis and stores it into the given quaternion
  3676. * @param axis defines the axis to use
  3677. * @param angle defines the angle to use
  3678. * @param result defines the target quaternion
  3679. * @returns the target quaternion
  3680. */
  3681. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3682. /**
  3683. * Creates a new quaternion from data stored into an array
  3684. * @param array defines the data source
  3685. * @param offset defines the offset in the source array where the data starts
  3686. * @returns a new quaternion
  3687. */
  3688. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3689. /**
  3690. * Create a quaternion from Euler rotation angles
  3691. * @param x Pitch
  3692. * @param y Yaw
  3693. * @param z Roll
  3694. * @returns the new Quaternion
  3695. */
  3696. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3697. /**
  3698. * Updates a quaternion from Euler rotation angles
  3699. * @param x Pitch
  3700. * @param y Yaw
  3701. * @param z Roll
  3702. * @param result the quaternion to store the result
  3703. * @returns the updated quaternion
  3704. */
  3705. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3706. /**
  3707. * Create a quaternion from Euler rotation vector
  3708. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3709. * @returns the new Quaternion
  3710. */
  3711. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3712. /**
  3713. * Updates a quaternion from Euler rotation vector
  3714. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3715. * @param result the quaternion to store the result
  3716. * @returns the updated quaternion
  3717. */
  3718. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3719. /**
  3720. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3721. * @param yaw defines the rotation around Y axis
  3722. * @param pitch defines the rotation around X axis
  3723. * @param roll defines the rotation around Z axis
  3724. * @returns the new quaternion
  3725. */
  3726. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3727. /**
  3728. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3729. * @param yaw defines the rotation around Y axis
  3730. * @param pitch defines the rotation around X axis
  3731. * @param roll defines the rotation around Z axis
  3732. * @param result defines the target quaternion
  3733. */
  3734. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3735. /**
  3736. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3737. * @param alpha defines the rotation around first axis
  3738. * @param beta defines the rotation around second axis
  3739. * @param gamma defines the rotation around third axis
  3740. * @returns the new quaternion
  3741. */
  3742. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3743. /**
  3744. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3745. * @param alpha defines the rotation around first axis
  3746. * @param beta defines the rotation around second axis
  3747. * @param gamma defines the rotation around third axis
  3748. * @param result defines the target quaternion
  3749. */
  3750. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3751. /**
  3752. * 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)
  3753. * @param axis1 defines the first axis
  3754. * @param axis2 defines the second axis
  3755. * @param axis3 defines the third axis
  3756. * @returns the new quaternion
  3757. */
  3758. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3759. /**
  3760. * 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
  3761. * @param axis1 defines the first axis
  3762. * @param axis2 defines the second axis
  3763. * @param axis3 defines the third axis
  3764. * @param ref defines the target quaternion
  3765. */
  3766. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3767. /**
  3768. * Interpolates between two quaternions
  3769. * @param left defines first quaternion
  3770. * @param right defines second quaternion
  3771. * @param amount defines the gradient to use
  3772. * @returns the new interpolated quaternion
  3773. */
  3774. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3775. /**
  3776. * Interpolates between two quaternions and stores it into a target quaternion
  3777. * @param left defines first quaternion
  3778. * @param right defines second quaternion
  3779. * @param amount defines the gradient to use
  3780. * @param result defines the target quaternion
  3781. */
  3782. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3783. /**
  3784. * Interpolate between two quaternions using Hermite interpolation
  3785. * @param value1 defines first quaternion
  3786. * @param tangent1 defines the incoming tangent
  3787. * @param value2 defines second quaternion
  3788. * @param tangent2 defines the outgoing tangent
  3789. * @param amount defines the target quaternion
  3790. * @returns the new interpolated quaternion
  3791. */
  3792. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3793. }
  3794. /**
  3795. * Class used to store matrix data (4x4)
  3796. */
  3797. export class Matrix {
  3798. private static _updateFlagSeed;
  3799. private static _identityReadOnly;
  3800. private _isIdentity;
  3801. private _isIdentityDirty;
  3802. private _isIdentity3x2;
  3803. private _isIdentity3x2Dirty;
  3804. /**
  3805. * Gets the update flag of the matrix which is an unique number for the matrix.
  3806. * It will be incremented every time the matrix data change.
  3807. * You can use it to speed the comparison between two versions of the same matrix.
  3808. */
  3809. updateFlag: number;
  3810. private readonly _m;
  3811. /**
  3812. * Gets the internal data of the matrix
  3813. */
  3814. readonly m: DeepImmutable<Float32Array>;
  3815. /** @hidden */ private _markAsUpdated(): void;
  3816. /** @hidden */
  3817. private _updateIdentityStatus;
  3818. /**
  3819. * Creates an empty matrix (filled with zeros)
  3820. */
  3821. constructor();
  3822. /**
  3823. * Check if the current matrix is identity
  3824. * @returns true is the matrix is the identity matrix
  3825. */
  3826. isIdentity(): boolean;
  3827. /**
  3828. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3829. * @returns true is the matrix is the identity matrix
  3830. */
  3831. isIdentityAs3x2(): boolean;
  3832. /**
  3833. * Gets the determinant of the matrix
  3834. * @returns the matrix determinant
  3835. */
  3836. determinant(): number;
  3837. /**
  3838. * Returns the matrix as a Float32Array
  3839. * @returns the matrix underlying array
  3840. */
  3841. toArray(): DeepImmutable<Float32Array>;
  3842. /**
  3843. * Returns the matrix as a Float32Array
  3844. * @returns the matrix underlying array.
  3845. */
  3846. asArray(): DeepImmutable<Float32Array>;
  3847. /**
  3848. * Inverts the current matrix in place
  3849. * @returns the current inverted matrix
  3850. */
  3851. invert(): Matrix;
  3852. /**
  3853. * Sets all the matrix elements to zero
  3854. * @returns the current matrix
  3855. */
  3856. reset(): Matrix;
  3857. /**
  3858. * Adds the current matrix with a second one
  3859. * @param other defines the matrix to add
  3860. * @returns a new matrix as the addition of the current matrix and the given one
  3861. */
  3862. add(other: DeepImmutable<Matrix>): Matrix;
  3863. /**
  3864. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3865. * @param other defines the matrix to add
  3866. * @param result defines the target matrix
  3867. * @returns the current matrix
  3868. */
  3869. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3870. /**
  3871. * Adds in place the given matrix to the current matrix
  3872. * @param other defines the second operand
  3873. * @returns the current updated matrix
  3874. */
  3875. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3876. /**
  3877. * Sets the given matrix to the current inverted Matrix
  3878. * @param other defines the target matrix
  3879. * @returns the unmodified current matrix
  3880. */
  3881. invertToRef(other: Matrix): Matrix;
  3882. /**
  3883. * add a value at the specified position in the current Matrix
  3884. * @param index the index of the value within the matrix. between 0 and 15.
  3885. * @param value the value to be added
  3886. * @returns the current updated matrix
  3887. */
  3888. addAtIndex(index: number, value: number): Matrix;
  3889. /**
  3890. * mutiply the specified position in the current Matrix by a value
  3891. * @param index the index of the value within the matrix. between 0 and 15.
  3892. * @param value the value to be added
  3893. * @returns the current updated matrix
  3894. */
  3895. multiplyAtIndex(index: number, value: number): Matrix;
  3896. /**
  3897. * Inserts the translation vector (using 3 floats) in the current matrix
  3898. * @param x defines the 1st component of the translation
  3899. * @param y defines the 2nd component of the translation
  3900. * @param z defines the 3rd component of the translation
  3901. * @returns the current updated matrix
  3902. */
  3903. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3904. /**
  3905. * Adds the translation vector (using 3 floats) in the current matrix
  3906. * @param x defines the 1st component of the translation
  3907. * @param y defines the 2nd component of the translation
  3908. * @param z defines the 3rd component of the translation
  3909. * @returns the current updated matrix
  3910. */
  3911. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3912. /**
  3913. * Inserts the translation vector in the current matrix
  3914. * @param vector3 defines the translation to insert
  3915. * @returns the current updated matrix
  3916. */
  3917. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3918. /**
  3919. * Gets the translation value of the current matrix
  3920. * @returns a new Vector3 as the extracted translation from the matrix
  3921. */
  3922. getTranslation(): Vector3;
  3923. /**
  3924. * Fill a Vector3 with the extracted translation from the matrix
  3925. * @param result defines the Vector3 where to store the translation
  3926. * @returns the current matrix
  3927. */
  3928. getTranslationToRef(result: Vector3): Matrix;
  3929. /**
  3930. * Remove rotation and scaling part from the matrix
  3931. * @returns the updated matrix
  3932. */
  3933. removeRotationAndScaling(): Matrix;
  3934. /**
  3935. * Multiply two matrices
  3936. * @param other defines the second operand
  3937. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3938. */
  3939. multiply(other: DeepImmutable<Matrix>): Matrix;
  3940. /**
  3941. * Copy the current matrix from the given one
  3942. * @param other defines the source matrix
  3943. * @returns the current updated matrix
  3944. */
  3945. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3946. /**
  3947. * Populates the given array from the starting index with the current matrix values
  3948. * @param array defines the target array
  3949. * @param offset defines the offset in the target array where to start storing values
  3950. * @returns the current matrix
  3951. */
  3952. copyToArray(array: Float32Array, offset?: number): Matrix;
  3953. /**
  3954. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3955. * @param other defines the second operand
  3956. * @param result defines the matrix where to store the multiplication
  3957. * @returns the current matrix
  3958. */
  3959. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3960. /**
  3961. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3962. * @param other defines the second operand
  3963. * @param result defines the array where to store the multiplication
  3964. * @param offset defines the offset in the target array where to start storing values
  3965. * @returns the current matrix
  3966. */
  3967. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3968. /**
  3969. * Check equality between this matrix and a second one
  3970. * @param value defines the second matrix to compare
  3971. * @returns true is the current matrix and the given one values are strictly equal
  3972. */
  3973. equals(value: DeepImmutable<Matrix>): boolean;
  3974. /**
  3975. * Clone the current matrix
  3976. * @returns a new matrix from the current matrix
  3977. */
  3978. clone(): Matrix;
  3979. /**
  3980. * Returns the name of the current matrix class
  3981. * @returns the string "Matrix"
  3982. */
  3983. getClassName(): string;
  3984. /**
  3985. * Gets the hash code of the current matrix
  3986. * @returns the hash code
  3987. */
  3988. getHashCode(): number;
  3989. /**
  3990. * Decomposes the current Matrix into a translation, rotation and scaling components
  3991. * @param scale defines the scale vector3 given as a reference to update
  3992. * @param rotation defines the rotation quaternion given as a reference to update
  3993. * @param translation defines the translation vector3 given as a reference to update
  3994. * @returns true if operation was successful
  3995. */
  3996. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3997. /**
  3998. * Gets specific row of the matrix
  3999. * @param index defines the number of the row to get
  4000. * @returns the index-th row of the current matrix as a new Vector4
  4001. */
  4002. getRow(index: number): Nullable<Vector4>;
  4003. /**
  4004. * Sets the index-th row of the current matrix to the vector4 values
  4005. * @param index defines the number of the row to set
  4006. * @param row defines the target vector4
  4007. * @returns the updated current matrix
  4008. */
  4009. setRow(index: number, row: Vector4): Matrix;
  4010. /**
  4011. * Compute the transpose of the matrix
  4012. * @returns the new transposed matrix
  4013. */
  4014. transpose(): Matrix;
  4015. /**
  4016. * Compute the transpose of the matrix and store it in a given matrix
  4017. * @param result defines the target matrix
  4018. * @returns the current matrix
  4019. */
  4020. transposeToRef(result: Matrix): Matrix;
  4021. /**
  4022. * Sets the index-th row of the current matrix with the given 4 x float values
  4023. * @param index defines the row index
  4024. * @param x defines the x component to set
  4025. * @param y defines the y component to set
  4026. * @param z defines the z component to set
  4027. * @param w defines the w component to set
  4028. * @returns the updated current matrix
  4029. */
  4030. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4031. /**
  4032. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4033. * @param scale defines the scale factor
  4034. * @returns a new matrix
  4035. */
  4036. scale(scale: number): Matrix;
  4037. /**
  4038. * Scale the current matrix values by a factor to a given result matrix
  4039. * @param scale defines the scale factor
  4040. * @param result defines the matrix to store the result
  4041. * @returns the current matrix
  4042. */
  4043. scaleToRef(scale: number, result: Matrix): Matrix;
  4044. /**
  4045. * Scale the current matrix values by a factor and add the result to a given matrix
  4046. * @param scale defines the scale factor
  4047. * @param result defines the Matrix to store the result
  4048. * @returns the current matrix
  4049. */
  4050. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4051. /**
  4052. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4053. * @param ref matrix to store the result
  4054. */
  4055. toNormalMatrix(ref: Matrix): void;
  4056. /**
  4057. * Gets only rotation part of the current matrix
  4058. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4059. */
  4060. getRotationMatrix(): Matrix;
  4061. /**
  4062. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4063. * @param result defines the target matrix to store data to
  4064. * @returns the current matrix
  4065. */
  4066. getRotationMatrixToRef(result: Matrix): Matrix;
  4067. /**
  4068. * Toggles model matrix from being right handed to left handed in place and vice versa
  4069. */
  4070. toggleModelMatrixHandInPlace(): void;
  4071. /**
  4072. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4073. */
  4074. toggleProjectionMatrixHandInPlace(): void;
  4075. /**
  4076. * Creates a matrix from an array
  4077. * @param array defines the source array
  4078. * @param offset defines an offset in the source array
  4079. * @returns a new Matrix set from the starting index of the given array
  4080. */
  4081. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4082. /**
  4083. * Copy the content of an array into a given matrix
  4084. * @param array defines the source array
  4085. * @param offset defines an offset in the source array
  4086. * @param result defines the target matrix
  4087. */
  4088. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4089. /**
  4090. * Stores an array into a matrix after having multiplied each component by a given factor
  4091. * @param array defines the source array
  4092. * @param offset defines the offset in the source array
  4093. * @param scale defines the scaling factor
  4094. * @param result defines the target matrix
  4095. */
  4096. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4097. /**
  4098. * Gets an identity matrix that must not be updated
  4099. */
  4100. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4101. /**
  4102. * Stores a list of values (16) inside a given matrix
  4103. * @param initialM11 defines 1st value of 1st row
  4104. * @param initialM12 defines 2nd value of 1st row
  4105. * @param initialM13 defines 3rd value of 1st row
  4106. * @param initialM14 defines 4th value of 1st row
  4107. * @param initialM21 defines 1st value of 2nd row
  4108. * @param initialM22 defines 2nd value of 2nd row
  4109. * @param initialM23 defines 3rd value of 2nd row
  4110. * @param initialM24 defines 4th value of 2nd row
  4111. * @param initialM31 defines 1st value of 3rd row
  4112. * @param initialM32 defines 2nd value of 3rd row
  4113. * @param initialM33 defines 3rd value of 3rd row
  4114. * @param initialM34 defines 4th value of 3rd row
  4115. * @param initialM41 defines 1st value of 4th row
  4116. * @param initialM42 defines 2nd value of 4th row
  4117. * @param initialM43 defines 3rd value of 4th row
  4118. * @param initialM44 defines 4th value of 4th row
  4119. * @param result defines the target matrix
  4120. */
  4121. 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;
  4122. /**
  4123. * Creates new matrix from a list of values (16)
  4124. * @param initialM11 defines 1st value of 1st row
  4125. * @param initialM12 defines 2nd value of 1st row
  4126. * @param initialM13 defines 3rd value of 1st row
  4127. * @param initialM14 defines 4th value of 1st row
  4128. * @param initialM21 defines 1st value of 2nd row
  4129. * @param initialM22 defines 2nd value of 2nd row
  4130. * @param initialM23 defines 3rd value of 2nd row
  4131. * @param initialM24 defines 4th value of 2nd row
  4132. * @param initialM31 defines 1st value of 3rd row
  4133. * @param initialM32 defines 2nd value of 3rd row
  4134. * @param initialM33 defines 3rd value of 3rd row
  4135. * @param initialM34 defines 4th value of 3rd row
  4136. * @param initialM41 defines 1st value of 4th row
  4137. * @param initialM42 defines 2nd value of 4th row
  4138. * @param initialM43 defines 3rd value of 4th row
  4139. * @param initialM44 defines 4th value of 4th row
  4140. * @returns the new matrix
  4141. */
  4142. 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;
  4143. /**
  4144. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4145. * @param scale defines the scale vector3
  4146. * @param rotation defines the rotation quaternion
  4147. * @param translation defines the translation vector3
  4148. * @returns a new matrix
  4149. */
  4150. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4151. /**
  4152. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4153. * @param scale defines the scale vector3
  4154. * @param rotation defines the rotation quaternion
  4155. * @param translation defines the translation vector3
  4156. * @param result defines the target matrix
  4157. */
  4158. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4159. /**
  4160. * Creates a new identity matrix
  4161. * @returns a new identity matrix
  4162. */
  4163. static Identity(): Matrix;
  4164. /**
  4165. * Creates a new identity matrix and stores the result in a given matrix
  4166. * @param result defines the target matrix
  4167. */
  4168. static IdentityToRef(result: Matrix): void;
  4169. /**
  4170. * Creates a new zero matrix
  4171. * @returns a new zero matrix
  4172. */
  4173. static Zero(): Matrix;
  4174. /**
  4175. * Creates a new rotation matrix for "angle" radians around the X axis
  4176. * @param angle defines the angle (in radians) to use
  4177. * @return the new matrix
  4178. */
  4179. static RotationX(angle: number): Matrix;
  4180. /**
  4181. * Creates a new matrix as the invert of a given matrix
  4182. * @param source defines the source matrix
  4183. * @returns the new matrix
  4184. */
  4185. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4186. /**
  4187. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4188. * @param angle defines the angle (in radians) to use
  4189. * @param result defines the target matrix
  4190. */
  4191. static RotationXToRef(angle: number, result: Matrix): void;
  4192. /**
  4193. * Creates a new rotation matrix for "angle" radians around the Y axis
  4194. * @param angle defines the angle (in radians) to use
  4195. * @return the new matrix
  4196. */
  4197. static RotationY(angle: number): Matrix;
  4198. /**
  4199. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4200. * @param angle defines the angle (in radians) to use
  4201. * @param result defines the target matrix
  4202. */
  4203. static RotationYToRef(angle: number, result: Matrix): void;
  4204. /**
  4205. * Creates a new rotation matrix for "angle" radians around the Z axis
  4206. * @param angle defines the angle (in radians) to use
  4207. * @return the new matrix
  4208. */
  4209. static RotationZ(angle: number): Matrix;
  4210. /**
  4211. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4212. * @param angle defines the angle (in radians) to use
  4213. * @param result defines the target matrix
  4214. */
  4215. static RotationZToRef(angle: number, result: Matrix): void;
  4216. /**
  4217. * Creates a new rotation matrix for "angle" radians around the given axis
  4218. * @param axis defines the axis to use
  4219. * @param angle defines the angle (in radians) to use
  4220. * @return the new matrix
  4221. */
  4222. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4223. /**
  4224. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4225. * @param axis defines the axis to use
  4226. * @param angle defines the angle (in radians) to use
  4227. * @param result defines the target matrix
  4228. */
  4229. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4230. /**
  4231. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4232. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4233. * @param from defines the vector to align
  4234. * @param to defines the vector to align to
  4235. * @param result defines the target matrix
  4236. */
  4237. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4238. /**
  4239. * Creates a rotation matrix
  4240. * @param yaw defines the yaw angle in radians (Y axis)
  4241. * @param pitch defines the pitch angle in radians (X axis)
  4242. * @param roll defines the roll angle in radians (X axis)
  4243. * @returns the new rotation matrix
  4244. */
  4245. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4246. /**
  4247. * Creates a rotation matrix and stores it in a given matrix
  4248. * @param yaw defines the yaw angle in radians (Y axis)
  4249. * @param pitch defines the pitch angle in radians (X axis)
  4250. * @param roll defines the roll angle in radians (X axis)
  4251. * @param result defines the target matrix
  4252. */
  4253. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4254. /**
  4255. * Creates a scaling matrix
  4256. * @param x defines the scale factor on X axis
  4257. * @param y defines the scale factor on Y axis
  4258. * @param z defines the scale factor on Z axis
  4259. * @returns the new matrix
  4260. */
  4261. static Scaling(x: number, y: number, z: number): Matrix;
  4262. /**
  4263. * Creates a scaling matrix and stores it in a given matrix
  4264. * @param x defines the scale factor on X axis
  4265. * @param y defines the scale factor on Y axis
  4266. * @param z defines the scale factor on Z axis
  4267. * @param result defines the target matrix
  4268. */
  4269. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4270. /**
  4271. * Creates a translation matrix
  4272. * @param x defines the translation on X axis
  4273. * @param y defines the translation on Y axis
  4274. * @param z defines the translationon Z axis
  4275. * @returns the new matrix
  4276. */
  4277. static Translation(x: number, y: number, z: number): Matrix;
  4278. /**
  4279. * Creates a translation matrix and stores it in a given matrix
  4280. * @param x defines the translation on X axis
  4281. * @param y defines the translation on Y axis
  4282. * @param z defines the translationon Z axis
  4283. * @param result defines the target matrix
  4284. */
  4285. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4286. /**
  4287. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4288. * @param startValue defines the start value
  4289. * @param endValue defines the end value
  4290. * @param gradient defines the gradient factor
  4291. * @returns the new matrix
  4292. */
  4293. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4294. /**
  4295. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4296. * @param startValue defines the start value
  4297. * @param endValue defines the end value
  4298. * @param gradient defines the gradient factor
  4299. * @param result defines the Matrix object where to store data
  4300. */
  4301. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4302. /**
  4303. * Builds a new matrix whose values are computed by:
  4304. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4305. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4306. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4307. * @param startValue defines the first matrix
  4308. * @param endValue defines the second matrix
  4309. * @param gradient defines the gradient between the two matrices
  4310. * @returns the new matrix
  4311. */
  4312. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4313. /**
  4314. * Update a matrix to values which are computed by:
  4315. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4316. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4317. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4318. * @param startValue defines the first matrix
  4319. * @param endValue defines the second matrix
  4320. * @param gradient defines the gradient between the two matrices
  4321. * @param result defines the target matrix
  4322. */
  4323. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4324. /**
  4325. * 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"
  4326. * This function works in left handed mode
  4327. * @param eye defines the final position of the entity
  4328. * @param target defines where the entity should look at
  4329. * @param up defines the up vector for the entity
  4330. * @returns the new matrix
  4331. */
  4332. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4333. /**
  4334. * 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".
  4335. * This function works in left handed mode
  4336. * @param eye defines the final position of the entity
  4337. * @param target defines where the entity should look at
  4338. * @param up defines the up vector for the entity
  4339. * @param result defines the target matrix
  4340. */
  4341. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4342. /**
  4343. * 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"
  4344. * This function works in right handed mode
  4345. * @param eye defines the final position of the entity
  4346. * @param target defines where the entity should look at
  4347. * @param up defines the up vector for the entity
  4348. * @returns the new matrix
  4349. */
  4350. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4351. /**
  4352. * 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".
  4353. * This function works in right handed mode
  4354. * @param eye defines the final position of the entity
  4355. * @param target defines where the entity should look at
  4356. * @param up defines the up vector for the entity
  4357. * @param result defines the target matrix
  4358. */
  4359. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4360. /**
  4361. * Create a left-handed orthographic projection matrix
  4362. * @param width defines the viewport width
  4363. * @param height defines the viewport height
  4364. * @param znear defines the near clip plane
  4365. * @param zfar defines the far clip plane
  4366. * @returns a new matrix as a left-handed orthographic projection matrix
  4367. */
  4368. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4369. /**
  4370. * Store a left-handed orthographic projection to a given matrix
  4371. * @param width defines the viewport width
  4372. * @param height defines the viewport height
  4373. * @param znear defines the near clip plane
  4374. * @param zfar defines the far clip plane
  4375. * @param result defines the target matrix
  4376. */
  4377. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4378. /**
  4379. * Create a left-handed orthographic projection matrix
  4380. * @param left defines the viewport left coordinate
  4381. * @param right defines the viewport right coordinate
  4382. * @param bottom defines the viewport bottom coordinate
  4383. * @param top defines the viewport top coordinate
  4384. * @param znear defines the near clip plane
  4385. * @param zfar defines the far clip plane
  4386. * @returns a new matrix as a left-handed orthographic projection matrix
  4387. */
  4388. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4389. /**
  4390. * Stores a left-handed orthographic projection into a given matrix
  4391. * @param left defines the viewport left coordinate
  4392. * @param right defines the viewport right coordinate
  4393. * @param bottom defines the viewport bottom coordinate
  4394. * @param top defines the viewport top coordinate
  4395. * @param znear defines the near clip plane
  4396. * @param zfar defines the far clip plane
  4397. * @param result defines the target matrix
  4398. */
  4399. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4400. /**
  4401. * Creates a right-handed orthographic projection matrix
  4402. * @param left defines the viewport left coordinate
  4403. * @param right defines the viewport right coordinate
  4404. * @param bottom defines the viewport bottom coordinate
  4405. * @param top defines the viewport top coordinate
  4406. * @param znear defines the near clip plane
  4407. * @param zfar defines the far clip plane
  4408. * @returns a new matrix as a right-handed orthographic projection matrix
  4409. */
  4410. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4411. /**
  4412. * Stores a right-handed orthographic projection into a given matrix
  4413. * @param left defines the viewport left coordinate
  4414. * @param right defines the viewport right coordinate
  4415. * @param bottom defines the viewport bottom coordinate
  4416. * @param top defines the viewport top coordinate
  4417. * @param znear defines the near clip plane
  4418. * @param zfar defines the far clip plane
  4419. * @param result defines the target matrix
  4420. */
  4421. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4422. /**
  4423. * Creates a left-handed perspective projection matrix
  4424. * @param width defines the viewport width
  4425. * @param height defines the viewport height
  4426. * @param znear defines the near clip plane
  4427. * @param zfar defines the far clip plane
  4428. * @returns a new matrix as a left-handed perspective projection matrix
  4429. */
  4430. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4431. /**
  4432. * Creates a left-handed perspective projection matrix
  4433. * @param fov defines the horizontal field of view
  4434. * @param aspect defines the aspect ratio
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @returns a new matrix as a left-handed perspective projection matrix
  4438. */
  4439. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4440. /**
  4441. * Stores a left-handed perspective projection into a given matrix
  4442. * @param fov defines the horizontal field of view
  4443. * @param aspect defines the aspect ratio
  4444. * @param znear defines the near clip plane
  4445. * @param zfar defines the far clip plane
  4446. * @param result defines the target matrix
  4447. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4448. */
  4449. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4450. /**
  4451. * Creates a right-handed perspective projection matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @returns a new matrix as a right-handed perspective projection matrix
  4457. */
  4458. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4459. /**
  4460. * Stores a right-handed perspective projection into a given matrix
  4461. * @param fov defines the horizontal field of view
  4462. * @param aspect defines the aspect ratio
  4463. * @param znear defines the near clip plane
  4464. * @param zfar defines the far clip plane
  4465. * @param result defines the target matrix
  4466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4467. */
  4468. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4469. /**
  4470. * Stores a perspective projection for WebVR info a given matrix
  4471. * @param fov defines the field of view
  4472. * @param znear defines the near clip plane
  4473. * @param zfar defines the far clip plane
  4474. * @param result defines the target matrix
  4475. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4476. */
  4477. static PerspectiveFovWebVRToRef(fov: {
  4478. upDegrees: number;
  4479. downDegrees: number;
  4480. leftDegrees: number;
  4481. rightDegrees: number;
  4482. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4483. /**
  4484. * Computes a complete transformation matrix
  4485. * @param viewport defines the viewport to use
  4486. * @param world defines the world matrix
  4487. * @param view defines the view matrix
  4488. * @param projection defines the projection matrix
  4489. * @param zmin defines the near clip plane
  4490. * @param zmax defines the far clip plane
  4491. * @returns the transformation matrix
  4492. */
  4493. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4494. /**
  4495. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4496. * @param matrix defines the matrix to use
  4497. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4498. */
  4499. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4500. /**
  4501. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4502. * @param matrix defines the matrix to use
  4503. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4504. */
  4505. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4506. /**
  4507. * Compute the transpose of a given matrix
  4508. * @param matrix defines the matrix to transpose
  4509. * @returns the new matrix
  4510. */
  4511. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4512. /**
  4513. * Compute the transpose of a matrix and store it in a target matrix
  4514. * @param matrix defines the matrix to transpose
  4515. * @param result defines the target matrix
  4516. */
  4517. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4518. /**
  4519. * Computes a reflection matrix from a plane
  4520. * @param plane defines the reflection plane
  4521. * @returns a new matrix
  4522. */
  4523. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4524. /**
  4525. * Computes a reflection matrix from a plane
  4526. * @param plane defines the reflection plane
  4527. * @param result defines the target matrix
  4528. */
  4529. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4530. /**
  4531. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4532. * @param xaxis defines the value of the 1st axis
  4533. * @param yaxis defines the value of the 2nd axis
  4534. * @param zaxis defines the value of the 3rd axis
  4535. * @param result defines the target matrix
  4536. */
  4537. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4538. /**
  4539. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4540. * @param quat defines the quaternion to use
  4541. * @param result defines the target matrix
  4542. */
  4543. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4544. }
  4545. /**
  4546. * @hidden
  4547. */
  4548. export class TmpVectors {
  4549. static Vector2: Vector2[];
  4550. static Vector3: Vector3[];
  4551. static Vector4: Vector4[];
  4552. static Quaternion: Quaternion[];
  4553. static Matrix: Matrix[];
  4554. }
  4555. }
  4556. declare module BABYLON {
  4557. /**
  4558. * Defines potential orientation for back face culling
  4559. */
  4560. export enum Orientation {
  4561. /**
  4562. * Clockwise
  4563. */
  4564. CW = 0,
  4565. /** Counter clockwise */
  4566. CCW = 1
  4567. }
  4568. /** Class used to represent a Bezier curve */
  4569. export class BezierCurve {
  4570. /**
  4571. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4572. * @param t defines the time
  4573. * @param x1 defines the left coordinate on X axis
  4574. * @param y1 defines the left coordinate on Y axis
  4575. * @param x2 defines the right coordinate on X axis
  4576. * @param y2 defines the right coordinate on Y axis
  4577. * @returns the interpolated value
  4578. */
  4579. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4580. }
  4581. /**
  4582. * Defines angle representation
  4583. */
  4584. export class Angle {
  4585. private _radians;
  4586. /**
  4587. * Creates an Angle object of "radians" radians (float).
  4588. * @param radians the angle in radians
  4589. */
  4590. constructor(radians: number);
  4591. /**
  4592. * Get value in degrees
  4593. * @returns the Angle value in degrees (float)
  4594. */
  4595. degrees(): number;
  4596. /**
  4597. * Get value in radians
  4598. * @returns the Angle value in radians (float)
  4599. */
  4600. radians(): number;
  4601. /**
  4602. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4603. * @param a defines first vector
  4604. * @param b defines second vector
  4605. * @returns a new Angle
  4606. */
  4607. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4608. /**
  4609. * Gets a new Angle object from the given float in radians
  4610. * @param radians defines the angle value in radians
  4611. * @returns a new Angle
  4612. */
  4613. static FromRadians(radians: number): Angle;
  4614. /**
  4615. * Gets a new Angle object from the given float in degrees
  4616. * @param degrees defines the angle value in degrees
  4617. * @returns a new Angle
  4618. */
  4619. static FromDegrees(degrees: number): Angle;
  4620. }
  4621. /**
  4622. * This represents an arc in a 2d space.
  4623. */
  4624. export class Arc2 {
  4625. /** Defines the start point of the arc */
  4626. startPoint: Vector2;
  4627. /** Defines the mid point of the arc */
  4628. midPoint: Vector2;
  4629. /** Defines the end point of the arc */
  4630. endPoint: Vector2;
  4631. /**
  4632. * Defines the center point of the arc.
  4633. */
  4634. centerPoint: Vector2;
  4635. /**
  4636. * Defines the radius of the arc.
  4637. */
  4638. radius: number;
  4639. /**
  4640. * Defines the angle of the arc (from mid point to end point).
  4641. */
  4642. angle: Angle;
  4643. /**
  4644. * Defines the start angle of the arc (from start point to middle point).
  4645. */
  4646. startAngle: Angle;
  4647. /**
  4648. * Defines the orientation of the arc (clock wise/counter clock wise).
  4649. */
  4650. orientation: Orientation;
  4651. /**
  4652. * Creates an Arc object from the three given points : start, middle and end.
  4653. * @param startPoint Defines the start point of the arc
  4654. * @param midPoint Defines the midlle point of the arc
  4655. * @param endPoint Defines the end point of the arc
  4656. */
  4657. constructor(
  4658. /** Defines the start point of the arc */
  4659. startPoint: Vector2,
  4660. /** Defines the mid point of the arc */
  4661. midPoint: Vector2,
  4662. /** Defines the end point of the arc */
  4663. endPoint: Vector2);
  4664. }
  4665. /**
  4666. * Represents a 2D path made up of multiple 2D points
  4667. */
  4668. export class Path2 {
  4669. private _points;
  4670. private _length;
  4671. /**
  4672. * If the path start and end point are the same
  4673. */
  4674. closed: boolean;
  4675. /**
  4676. * Creates a Path2 object from the starting 2D coordinates x and y.
  4677. * @param x the starting points x value
  4678. * @param y the starting points y value
  4679. */
  4680. constructor(x: number, y: number);
  4681. /**
  4682. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4683. * @param x the added points x value
  4684. * @param y the added points y value
  4685. * @returns the updated Path2.
  4686. */
  4687. addLineTo(x: number, y: number): Path2;
  4688. /**
  4689. * 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.
  4690. * @param midX middle point x value
  4691. * @param midY middle point y value
  4692. * @param endX end point x value
  4693. * @param endY end point y value
  4694. * @param numberOfSegments (default: 36)
  4695. * @returns the updated Path2.
  4696. */
  4697. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4698. /**
  4699. * Closes the Path2.
  4700. * @returns the Path2.
  4701. */
  4702. close(): Path2;
  4703. /**
  4704. * Gets the sum of the distance between each sequential point in the path
  4705. * @returns the Path2 total length (float).
  4706. */
  4707. length(): number;
  4708. /**
  4709. * Gets the points which construct the path
  4710. * @returns the Path2 internal array of points.
  4711. */
  4712. getPoints(): Vector2[];
  4713. /**
  4714. * Retreives the point at the distance aways from the starting point
  4715. * @param normalizedLengthPosition the length along the path to retreive the point from
  4716. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4717. */
  4718. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4719. /**
  4720. * Creates a new path starting from an x and y position
  4721. * @param x starting x value
  4722. * @param y starting y value
  4723. * @returns a new Path2 starting at the coordinates (x, y).
  4724. */
  4725. static StartingAt(x: number, y: number): Path2;
  4726. }
  4727. /**
  4728. * Represents a 3D path made up of multiple 3D points
  4729. */
  4730. export class Path3D {
  4731. /**
  4732. * an array of Vector3, the curve axis of the Path3D
  4733. */
  4734. path: Vector3[];
  4735. private _curve;
  4736. private _distances;
  4737. private _tangents;
  4738. private _normals;
  4739. private _binormals;
  4740. private _raw;
  4741. /**
  4742. * new Path3D(path, normal, raw)
  4743. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4744. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4745. * @param path an array of Vector3, the curve axis of the Path3D
  4746. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4747. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4748. */
  4749. constructor(
  4750. /**
  4751. * an array of Vector3, the curve axis of the Path3D
  4752. */
  4753. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4754. /**
  4755. * Returns the Path3D array of successive Vector3 designing its curve.
  4756. * @returns the Path3D array of successive Vector3 designing its curve.
  4757. */
  4758. getCurve(): Vector3[];
  4759. /**
  4760. * Returns an array populated with tangent vectors on each Path3D curve point.
  4761. * @returns an array populated with tangent vectors on each Path3D curve point.
  4762. */
  4763. getTangents(): Vector3[];
  4764. /**
  4765. * Returns an array populated with normal vectors on each Path3D curve point.
  4766. * @returns an array populated with normal vectors on each Path3D curve point.
  4767. */
  4768. getNormals(): Vector3[];
  4769. /**
  4770. * Returns an array populated with binormal vectors on each Path3D curve point.
  4771. * @returns an array populated with binormal vectors on each Path3D curve point.
  4772. */
  4773. getBinormals(): Vector3[];
  4774. /**
  4775. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4776. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4777. */
  4778. getDistances(): number[];
  4779. /**
  4780. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4781. * @param path path which all values are copied into the curves points
  4782. * @param firstNormal which should be projected onto the curve
  4783. * @returns the same object updated.
  4784. */
  4785. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4786. private _compute;
  4787. private _getFirstNonNullVector;
  4788. private _getLastNonNullVector;
  4789. private _normalVector;
  4790. }
  4791. /**
  4792. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4793. * A Curve3 is designed from a series of successive Vector3.
  4794. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4795. */
  4796. export class Curve3 {
  4797. private _points;
  4798. private _length;
  4799. /**
  4800. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4801. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4802. * @param v1 (Vector3) the control point
  4803. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4804. * @param nbPoints (integer) the wanted number of points in the curve
  4805. * @returns the created Curve3
  4806. */
  4807. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4808. /**
  4809. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4810. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4811. * @param v1 (Vector3) the first control point
  4812. * @param v2 (Vector3) the second control point
  4813. * @param v3 (Vector3) the end point of the Cubic Bezier
  4814. * @param nbPoints (integer) the wanted number of points in the curve
  4815. * @returns the created Curve3
  4816. */
  4817. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4818. /**
  4819. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4820. * @param p1 (Vector3) the origin point of the Hermite Spline
  4821. * @param t1 (Vector3) the tangent vector at the origin point
  4822. * @param p2 (Vector3) the end point of the Hermite Spline
  4823. * @param t2 (Vector3) the tangent vector at the end point
  4824. * @param nbPoints (integer) the wanted number of points in the curve
  4825. * @returns the created Curve3
  4826. */
  4827. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4828. /**
  4829. * Returns a Curve3 object along a CatmullRom Spline curve :
  4830. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4831. * @param nbPoints (integer) the wanted number of points between each curve control points
  4832. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4833. * @returns the created Curve3
  4834. */
  4835. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4836. /**
  4837. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4838. * A Curve3 is designed from a series of successive Vector3.
  4839. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4840. * @param points points which make up the curve
  4841. */
  4842. constructor(points: Vector3[]);
  4843. /**
  4844. * @returns the Curve3 stored array of successive Vector3
  4845. */
  4846. getPoints(): Vector3[];
  4847. /**
  4848. * @returns the computed length (float) of the curve.
  4849. */
  4850. length(): number;
  4851. /**
  4852. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4853. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4854. * curveA and curveB keep unchanged.
  4855. * @param curve the curve to continue from this curve
  4856. * @returns the newly constructed curve
  4857. */
  4858. continue(curve: DeepImmutable<Curve3>): Curve3;
  4859. private _computeLength;
  4860. }
  4861. }
  4862. declare module BABYLON {
  4863. /**
  4864. * This represents the main contract an easing function should follow.
  4865. * Easing functions are used throughout the animation system.
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. export interface IEasingFunction {
  4869. /**
  4870. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4871. * of the easing function.
  4872. * The link below provides some of the most common examples of easing functions.
  4873. * @see https://easings.net/
  4874. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4875. * @returns the corresponding value on the curve defined by the easing function
  4876. */
  4877. ease(gradient: number): number;
  4878. }
  4879. /**
  4880. * Base class used for every default easing function.
  4881. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4882. */
  4883. export class EasingFunction implements IEasingFunction {
  4884. /**
  4885. * Interpolation follows the mathematical formula associated with the easing function.
  4886. */
  4887. static readonly EASINGMODE_EASEIN: number;
  4888. /**
  4889. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4890. */
  4891. static readonly EASINGMODE_EASEOUT: number;
  4892. /**
  4893. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4894. */
  4895. static readonly EASINGMODE_EASEINOUT: number;
  4896. private _easingMode;
  4897. /**
  4898. * Sets the easing mode of the current function.
  4899. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4900. */
  4901. setEasingMode(easingMode: number): void;
  4902. /**
  4903. * Gets the current easing mode.
  4904. * @returns the easing mode
  4905. */
  4906. getEasingMode(): number;
  4907. /**
  4908. * @hidden
  4909. */
  4910. easeInCore(gradient: number): number;
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corresponding value
  4913. * of the easing function.
  4914. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4915. * @returns the corresponding value on the curve defined by the easing function
  4916. */
  4917. ease(gradient: number): number;
  4918. }
  4919. /**
  4920. * Easing function with a circle shape (see link below).
  4921. * @see https://easings.net/#easeInCirc
  4922. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4923. */
  4924. export class CircleEase extends EasingFunction implements IEasingFunction {
  4925. /** @hidden */
  4926. easeInCore(gradient: number): number;
  4927. }
  4928. /**
  4929. * Easing function with a ease back shape (see link below).
  4930. * @see https://easings.net/#easeInBack
  4931. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4932. */
  4933. export class BackEase extends EasingFunction implements IEasingFunction {
  4934. /** Defines the amplitude of the function */
  4935. amplitude: number;
  4936. /**
  4937. * Instantiates a back ease easing
  4938. * @see https://easings.net/#easeInBack
  4939. * @param amplitude Defines the amplitude of the function
  4940. */
  4941. constructor(
  4942. /** Defines the amplitude of the function */
  4943. amplitude?: number);
  4944. /** @hidden */
  4945. easeInCore(gradient: number): number;
  4946. }
  4947. /**
  4948. * Easing function with a bouncing shape (see link below).
  4949. * @see https://easings.net/#easeInBounce
  4950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4951. */
  4952. export class BounceEase extends EasingFunction implements IEasingFunction {
  4953. /** Defines the number of bounces */
  4954. bounces: number;
  4955. /** Defines the amplitude of the bounce */
  4956. bounciness: number;
  4957. /**
  4958. * Instantiates a bounce easing
  4959. * @see https://easings.net/#easeInBounce
  4960. * @param bounces Defines the number of bounces
  4961. * @param bounciness Defines the amplitude of the bounce
  4962. */
  4963. constructor(
  4964. /** Defines the number of bounces */
  4965. bounces?: number,
  4966. /** Defines the amplitude of the bounce */
  4967. bounciness?: number);
  4968. /** @hidden */
  4969. easeInCore(gradient: number): number;
  4970. }
  4971. /**
  4972. * Easing function with a power of 3 shape (see link below).
  4973. * @see https://easings.net/#easeInCubic
  4974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4975. */
  4976. export class CubicEase extends EasingFunction implements IEasingFunction {
  4977. /** @hidden */
  4978. easeInCore(gradient: number): number;
  4979. }
  4980. /**
  4981. * Easing function with an elastic shape (see link below).
  4982. * @see https://easings.net/#easeInElastic
  4983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4984. */
  4985. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4986. /** Defines the number of oscillations*/
  4987. oscillations: number;
  4988. /** Defines the amplitude of the oscillations*/
  4989. springiness: number;
  4990. /**
  4991. * Instantiates an elastic easing function
  4992. * @see https://easings.net/#easeInElastic
  4993. * @param oscillations Defines the number of oscillations
  4994. * @param springiness Defines the amplitude of the oscillations
  4995. */
  4996. constructor(
  4997. /** Defines the number of oscillations*/
  4998. oscillations?: number,
  4999. /** Defines the amplitude of the oscillations*/
  5000. springiness?: number);
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. /**
  5005. * Easing function with an exponential shape (see link below).
  5006. * @see https://easings.net/#easeInExpo
  5007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5008. */
  5009. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5010. /** Defines the exponent of the function */
  5011. exponent: number;
  5012. /**
  5013. * Instantiates an exponential easing function
  5014. * @see https://easings.net/#easeInExpo
  5015. * @param exponent Defines the exponent of the function
  5016. */
  5017. constructor(
  5018. /** Defines the exponent of the function */
  5019. exponent?: number);
  5020. /** @hidden */
  5021. easeInCore(gradient: number): number;
  5022. }
  5023. /**
  5024. * Easing function with a power shape (see link below).
  5025. * @see https://easings.net/#easeInQuad
  5026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5027. */
  5028. export class PowerEase extends EasingFunction implements IEasingFunction {
  5029. /** Defines the power of the function */
  5030. power: number;
  5031. /**
  5032. * Instantiates an power base easing function
  5033. * @see https://easings.net/#easeInQuad
  5034. * @param power Defines the power of the function
  5035. */
  5036. constructor(
  5037. /** Defines the power of the function */
  5038. power?: number);
  5039. /** @hidden */
  5040. easeInCore(gradient: number): number;
  5041. }
  5042. /**
  5043. * Easing function with a power of 2 shape (see link below).
  5044. * @see https://easings.net/#easeInQuad
  5045. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5046. */
  5047. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5048. /** @hidden */
  5049. easeInCore(gradient: number): number;
  5050. }
  5051. /**
  5052. * Easing function with a power of 4 shape (see link below).
  5053. * @see https://easings.net/#easeInQuart
  5054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5055. */
  5056. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5057. /** @hidden */
  5058. easeInCore(gradient: number): number;
  5059. }
  5060. /**
  5061. * Easing function with a power of 5 shape (see link below).
  5062. * @see https://easings.net/#easeInQuint
  5063. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5064. */
  5065. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5066. /** @hidden */
  5067. easeInCore(gradient: number): number;
  5068. }
  5069. /**
  5070. * Easing function with a sin shape (see link below).
  5071. * @see https://easings.net/#easeInSine
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export class SineEase extends EasingFunction implements IEasingFunction {
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a bezier shape (see link below).
  5080. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the x component of the start tangent in the bezier curve */
  5085. x1: number;
  5086. /** Defines the y component of the start tangent in the bezier curve */
  5087. y1: number;
  5088. /** Defines the x component of the end tangent in the bezier curve */
  5089. x2: number;
  5090. /** Defines the y component of the end tangent in the bezier curve */
  5091. y2: number;
  5092. /**
  5093. * Instantiates a bezier function
  5094. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5095. * @param x1 Defines the x component of the start tangent in the bezier curve
  5096. * @param y1 Defines the y component of the start tangent in the bezier curve
  5097. * @param x2 Defines the x component of the end tangent in the bezier curve
  5098. * @param y2 Defines the y component of the end tangent in the bezier curve
  5099. */
  5100. constructor(
  5101. /** Defines the x component of the start tangent in the bezier curve */
  5102. x1?: number,
  5103. /** Defines the y component of the start tangent in the bezier curve */
  5104. y1?: number,
  5105. /** Defines the x component of the end tangent in the bezier curve */
  5106. x2?: number,
  5107. /** Defines the y component of the end tangent in the bezier curve */
  5108. y2?: number);
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. }
  5113. declare module BABYLON {
  5114. /**
  5115. * Class used to hold a RBG color
  5116. */
  5117. export class Color3 {
  5118. /**
  5119. * Defines the red component (between 0 and 1, default is 0)
  5120. */
  5121. r: number;
  5122. /**
  5123. * Defines the green component (between 0 and 1, default is 0)
  5124. */
  5125. g: number;
  5126. /**
  5127. * Defines the blue component (between 0 and 1, default is 0)
  5128. */
  5129. b: number;
  5130. /**
  5131. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5132. * @param r defines the red component (between 0 and 1, default is 0)
  5133. * @param g defines the green component (between 0 and 1, default is 0)
  5134. * @param b defines the blue component (between 0 and 1, default is 0)
  5135. */
  5136. constructor(
  5137. /**
  5138. * Defines the red component (between 0 and 1, default is 0)
  5139. */
  5140. r?: number,
  5141. /**
  5142. * Defines the green component (between 0 and 1, default is 0)
  5143. */
  5144. g?: number,
  5145. /**
  5146. * Defines the blue component (between 0 and 1, default is 0)
  5147. */
  5148. b?: number);
  5149. /**
  5150. * Creates a string with the Color3 current values
  5151. * @returns the string representation of the Color3 object
  5152. */
  5153. toString(): string;
  5154. /**
  5155. * Returns the string "Color3"
  5156. * @returns "Color3"
  5157. */
  5158. getClassName(): string;
  5159. /**
  5160. * Compute the Color3 hash code
  5161. * @returns an unique number that can be used to hash Color3 objects
  5162. */
  5163. getHashCode(): number;
  5164. /**
  5165. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5166. * @param array defines the array where to store the r,g,b components
  5167. * @param index defines an optional index in the target array to define where to start storing values
  5168. * @returns the current Color3 object
  5169. */
  5170. toArray(array: FloatArray, index?: number): Color3;
  5171. /**
  5172. * Returns a new Color4 object from the current Color3 and the given alpha
  5173. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5174. * @returns a new Color4 object
  5175. */
  5176. toColor4(alpha?: number): Color4;
  5177. /**
  5178. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5179. * @returns the new array
  5180. */
  5181. asArray(): number[];
  5182. /**
  5183. * Returns the luminance value
  5184. * @returns a float value
  5185. */
  5186. toLuminance(): number;
  5187. /**
  5188. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5189. * @param otherColor defines the second operand
  5190. * @returns the new Color3 object
  5191. */
  5192. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5193. /**
  5194. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5195. * @param otherColor defines the second operand
  5196. * @param result defines the Color3 object where to store the result
  5197. * @returns the current Color3
  5198. */
  5199. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5200. /**
  5201. * Determines equality between Color3 objects
  5202. * @param otherColor defines the second operand
  5203. * @returns true if the rgb values are equal to the given ones
  5204. */
  5205. equals(otherColor: DeepImmutable<Color3>): boolean;
  5206. /**
  5207. * Determines equality between the current Color3 object and a set of r,b,g values
  5208. * @param r defines the red component to check
  5209. * @param g defines the green component to check
  5210. * @param b defines the blue component to check
  5211. * @returns true if the rgb values are equal to the given ones
  5212. */
  5213. equalsFloats(r: number, g: number, b: number): boolean;
  5214. /**
  5215. * Multiplies in place each rgb value by scale
  5216. * @param scale defines the scaling factor
  5217. * @returns the updated Color3
  5218. */
  5219. scale(scale: number): Color3;
  5220. /**
  5221. * Multiplies the rgb values by scale and stores the result into "result"
  5222. * @param scale defines the scaling factor
  5223. * @param result defines the Color3 object where to store the result
  5224. * @returns the unmodified current Color3
  5225. */
  5226. scaleToRef(scale: number, result: Color3): Color3;
  5227. /**
  5228. * Scale the current Color3 values by a factor and add the result to a given Color3
  5229. * @param scale defines the scale factor
  5230. * @param result defines color to store the result into
  5231. * @returns the unmodified current Color3
  5232. */
  5233. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5234. /**
  5235. * Clamps the rgb values by the min and max values and stores the result into "result"
  5236. * @param min defines minimum clamping value (default is 0)
  5237. * @param max defines maximum clamping value (default is 1)
  5238. * @param result defines color to store the result into
  5239. * @returns the original Color3
  5240. */
  5241. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5242. /**
  5243. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5244. * @param otherColor defines the second operand
  5245. * @returns the new Color3
  5246. */
  5247. add(otherColor: DeepImmutable<Color3>): Color3;
  5248. /**
  5249. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5250. * @param otherColor defines the second operand
  5251. * @param result defines Color3 object to store the result into
  5252. * @returns the unmodified current Color3
  5253. */
  5254. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5255. /**
  5256. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5257. * @param otherColor defines the second operand
  5258. * @returns the new Color3
  5259. */
  5260. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5261. /**
  5262. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5263. * @param otherColor defines the second operand
  5264. * @param result defines Color3 object to store the result into
  5265. * @returns the unmodified current Color3
  5266. */
  5267. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5268. /**
  5269. * Copy the current object
  5270. * @returns a new Color3 copied the current one
  5271. */
  5272. clone(): Color3;
  5273. /**
  5274. * Copies the rgb values from the source in the current Color3
  5275. * @param source defines the source Color3 object
  5276. * @returns the updated Color3 object
  5277. */
  5278. copyFrom(source: DeepImmutable<Color3>): Color3;
  5279. /**
  5280. * Updates the Color3 rgb values from the given floats
  5281. * @param r defines the red component to read from
  5282. * @param g defines the green component to read from
  5283. * @param b defines the blue component to read from
  5284. * @returns the current Color3 object
  5285. */
  5286. copyFromFloats(r: number, g: number, b: number): Color3;
  5287. /**
  5288. * Updates the Color3 rgb values from the given floats
  5289. * @param r defines the red component to read from
  5290. * @param g defines the green component to read from
  5291. * @param b defines the blue component to read from
  5292. * @returns the current Color3 object
  5293. */
  5294. set(r: number, g: number, b: number): Color3;
  5295. /**
  5296. * Compute the Color3 hexadecimal code as a string
  5297. * @returns a string containing the hexadecimal representation of the Color3 object
  5298. */
  5299. toHexString(): string;
  5300. /**
  5301. * Computes a new Color3 converted from the current one to linear space
  5302. * @returns a new Color3 object
  5303. */
  5304. toLinearSpace(): Color3;
  5305. /**
  5306. * Converts current color in rgb space to HSV values
  5307. * @returns a new color3 representing the HSV values
  5308. */
  5309. toHSV(): Color3;
  5310. /**
  5311. * Converts current color in rgb space to HSV values
  5312. * @param result defines the Color3 where to store the HSV values
  5313. */
  5314. toHSVToRef(result: Color3): void;
  5315. /**
  5316. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5317. * @param convertedColor defines the Color3 object where to store the linear space version
  5318. * @returns the unmodified Color3
  5319. */
  5320. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5321. /**
  5322. * Computes a new Color3 converted from the current one to gamma space
  5323. * @returns a new Color3 object
  5324. */
  5325. toGammaSpace(): Color3;
  5326. /**
  5327. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5328. * @param convertedColor defines the Color3 object where to store the gamma space version
  5329. * @returns the unmodified Color3
  5330. */
  5331. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5332. private static _BlackReadOnly;
  5333. /**
  5334. * Convert Hue, saturation and value to a Color3 (RGB)
  5335. * @param hue defines the hue
  5336. * @param saturation defines the saturation
  5337. * @param value defines the value
  5338. * @param result defines the Color3 where to store the RGB values
  5339. */
  5340. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5341. /**
  5342. * Creates a new Color3 from the string containing valid hexadecimal values
  5343. * @param hex defines a string containing valid hexadecimal values
  5344. * @returns a new Color3 object
  5345. */
  5346. static FromHexString(hex: string): Color3;
  5347. /**
  5348. * Creates a new Color3 from the starting index of the given array
  5349. * @param array defines the source array
  5350. * @param offset defines an offset in the source array
  5351. * @returns a new Color3 object
  5352. */
  5353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5354. /**
  5355. * Creates a new Color3 from integer values (< 256)
  5356. * @param r defines the red component to read from (value between 0 and 255)
  5357. * @param g defines the green component to read from (value between 0 and 255)
  5358. * @param b defines the blue component to read from (value between 0 and 255)
  5359. * @returns a new Color3 object
  5360. */
  5361. static FromInts(r: number, g: number, b: number): Color3;
  5362. /**
  5363. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5364. * @param start defines the start Color3 value
  5365. * @param end defines the end Color3 value
  5366. * @param amount defines the gradient value between start and end
  5367. * @returns a new Color3 object
  5368. */
  5369. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5370. /**
  5371. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5372. * @param left defines the start value
  5373. * @param right defines the end value
  5374. * @param amount defines the gradient factor
  5375. * @param result defines the Color3 object where to store the result
  5376. */
  5377. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5378. /**
  5379. * Returns a Color3 value containing a red color
  5380. * @returns a new Color3 object
  5381. */
  5382. static Red(): Color3;
  5383. /**
  5384. * Returns a Color3 value containing a green color
  5385. * @returns a new Color3 object
  5386. */
  5387. static Green(): Color3;
  5388. /**
  5389. * Returns a Color3 value containing a blue color
  5390. * @returns a new Color3 object
  5391. */
  5392. static Blue(): Color3;
  5393. /**
  5394. * Returns a Color3 value containing a black color
  5395. * @returns a new Color3 object
  5396. */
  5397. static Black(): Color3;
  5398. /**
  5399. * Gets a Color3 value containing a black color that must not be updated
  5400. */
  5401. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5402. /**
  5403. * Returns a Color3 value containing a white color
  5404. * @returns a new Color3 object
  5405. */
  5406. static White(): Color3;
  5407. /**
  5408. * Returns a Color3 value containing a purple color
  5409. * @returns a new Color3 object
  5410. */
  5411. static Purple(): Color3;
  5412. /**
  5413. * Returns a Color3 value containing a magenta color
  5414. * @returns a new Color3 object
  5415. */
  5416. static Magenta(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a yellow color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Yellow(): Color3;
  5422. /**
  5423. * Returns a Color3 value containing a gray color
  5424. * @returns a new Color3 object
  5425. */
  5426. static Gray(): Color3;
  5427. /**
  5428. * Returns a Color3 value containing a teal color
  5429. * @returns a new Color3 object
  5430. */
  5431. static Teal(): Color3;
  5432. /**
  5433. * Returns a Color3 value containing a random color
  5434. * @returns a new Color3 object
  5435. */
  5436. static Random(): Color3;
  5437. }
  5438. /**
  5439. * Class used to hold a RBGA color
  5440. */
  5441. export class Color4 {
  5442. /**
  5443. * Defines the red component (between 0 and 1, default is 0)
  5444. */
  5445. r: number;
  5446. /**
  5447. * Defines the green component (between 0 and 1, default is 0)
  5448. */
  5449. g: number;
  5450. /**
  5451. * Defines the blue component (between 0 and 1, default is 0)
  5452. */
  5453. b: number;
  5454. /**
  5455. * Defines the alpha component (between 0 and 1, default is 1)
  5456. */
  5457. a: number;
  5458. /**
  5459. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5460. * @param r defines the red component (between 0 and 1, default is 0)
  5461. * @param g defines the green component (between 0 and 1, default is 0)
  5462. * @param b defines the blue component (between 0 and 1, default is 0)
  5463. * @param a defines the alpha component (between 0 and 1, default is 1)
  5464. */
  5465. constructor(
  5466. /**
  5467. * Defines the red component (between 0 and 1, default is 0)
  5468. */
  5469. r?: number,
  5470. /**
  5471. * Defines the green component (between 0 and 1, default is 0)
  5472. */
  5473. g?: number,
  5474. /**
  5475. * Defines the blue component (between 0 and 1, default is 0)
  5476. */
  5477. b?: number,
  5478. /**
  5479. * Defines the alpha component (between 0 and 1, default is 1)
  5480. */
  5481. a?: number);
  5482. /**
  5483. * Adds in place the given Color4 values to the current Color4 object
  5484. * @param right defines the second operand
  5485. * @returns the current updated Color4 object
  5486. */
  5487. addInPlace(right: DeepImmutable<Color4>): Color4;
  5488. /**
  5489. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5490. * @returns the new array
  5491. */
  5492. asArray(): number[];
  5493. /**
  5494. * Stores from the starting index in the given array the Color4 successive values
  5495. * @param array defines the array where to store the r,g,b components
  5496. * @param index defines an optional index in the target array to define where to start storing values
  5497. * @returns the current Color4 object
  5498. */
  5499. toArray(array: number[], index?: number): Color4;
  5500. /**
  5501. * Determines equality between Color4 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgba values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color4>): boolean;
  5506. /**
  5507. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5508. * @param right defines the second operand
  5509. * @returns a new Color4 object
  5510. */
  5511. add(right: DeepImmutable<Color4>): Color4;
  5512. /**
  5513. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5514. * @param right defines the second operand
  5515. * @returns a new Color4 object
  5516. */
  5517. subtract(right: DeepImmutable<Color4>): Color4;
  5518. /**
  5519. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5520. * @param right defines the second operand
  5521. * @param result defines the Color4 object where to store the result
  5522. * @returns the current Color4 object
  5523. */
  5524. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5525. /**
  5526. * Creates a new Color4 with the current Color4 values multiplied by scale
  5527. * @param scale defines the scaling factor to apply
  5528. * @returns a new Color4 object
  5529. */
  5530. scale(scale: number): Color4;
  5531. /**
  5532. * Multiplies the current Color4 values by scale and stores the result in "result"
  5533. * @param scale defines the scaling factor to apply
  5534. * @param result defines the Color4 object where to store the result
  5535. * @returns the current unmodified Color4
  5536. */
  5537. scaleToRef(scale: number, result: Color4): Color4;
  5538. /**
  5539. * Scale the current Color4 values by a factor and add the result to a given Color4
  5540. * @param scale defines the scale factor
  5541. * @param result defines the Color4 object where to store the result
  5542. * @returns the unmodified current Color4
  5543. */
  5544. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5545. /**
  5546. * Clamps the rgb values by the min and max values and stores the result into "result"
  5547. * @param min defines minimum clamping value (default is 0)
  5548. * @param max defines maximum clamping value (default is 1)
  5549. * @param result defines color to store the result into.
  5550. * @returns the cuurent Color4
  5551. */
  5552. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5553. /**
  5554. * Multipy an Color4 value by another and return a new Color4 object
  5555. * @param color defines the Color4 value to multiply by
  5556. * @returns a new Color4 object
  5557. */
  5558. multiply(color: Color4): Color4;
  5559. /**
  5560. * Multipy a Color4 value by another and push the result in a reference value
  5561. * @param color defines the Color4 value to multiply by
  5562. * @param result defines the Color4 to fill the result in
  5563. * @returns the result Color4
  5564. */
  5565. multiplyToRef(color: Color4, result: Color4): Color4;
  5566. /**
  5567. * Creates a string with the Color4 current values
  5568. * @returns the string representation of the Color4 object
  5569. */
  5570. toString(): string;
  5571. /**
  5572. * Returns the string "Color4"
  5573. * @returns "Color4"
  5574. */
  5575. getClassName(): string;
  5576. /**
  5577. * Compute the Color4 hash code
  5578. * @returns an unique number that can be used to hash Color4 objects
  5579. */
  5580. getHashCode(): number;
  5581. /**
  5582. * Creates a new Color4 copied from the current one
  5583. * @returns a new Color4 object
  5584. */
  5585. clone(): Color4;
  5586. /**
  5587. * Copies the given Color4 values into the current one
  5588. * @param source defines the source Color4 object
  5589. * @returns the current updated Color4 object
  5590. */
  5591. copyFrom(source: Color4): Color4;
  5592. /**
  5593. * Copies the given float values into the current one
  5594. * @param r defines the red component to read from
  5595. * @param g defines the green component to read from
  5596. * @param b defines the blue component to read from
  5597. * @param a defines the alpha component to read from
  5598. * @returns the current updated Color4 object
  5599. */
  5600. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5601. /**
  5602. * Copies the given float values into the current one
  5603. * @param r defines the red component to read from
  5604. * @param g defines the green component to read from
  5605. * @param b defines the blue component to read from
  5606. * @param a defines the alpha component to read from
  5607. * @returns the current updated Color4 object
  5608. */
  5609. set(r: number, g: number, b: number, a: number): Color4;
  5610. /**
  5611. * Compute the Color4 hexadecimal code as a string
  5612. * @returns a string containing the hexadecimal representation of the Color4 object
  5613. */
  5614. toHexString(): string;
  5615. /**
  5616. * Computes a new Color4 converted from the current one to linear space
  5617. * @returns a new Color4 object
  5618. */
  5619. toLinearSpace(): Color4;
  5620. /**
  5621. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5622. * @param convertedColor defines the Color4 object where to store the linear space version
  5623. * @returns the unmodified Color4
  5624. */
  5625. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5626. /**
  5627. * Computes a new Color4 converted from the current one to gamma space
  5628. * @returns a new Color4 object
  5629. */
  5630. toGammaSpace(): Color4;
  5631. /**
  5632. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5633. * @param convertedColor defines the Color4 object where to store the gamma space version
  5634. * @returns the unmodified Color4
  5635. */
  5636. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5637. /**
  5638. * Creates a new Color4 from the string containing valid hexadecimal values
  5639. * @param hex defines a string containing valid hexadecimal values
  5640. * @returns a new Color4 object
  5641. */
  5642. static FromHexString(hex: string): Color4;
  5643. /**
  5644. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5645. * @param left defines the start value
  5646. * @param right defines the end value
  5647. * @param amount defines the gradient factor
  5648. * @returns a new Color4 object
  5649. */
  5650. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5651. /**
  5652. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5653. * @param left defines the start value
  5654. * @param right defines the end value
  5655. * @param amount defines the gradient factor
  5656. * @param result defines the Color4 object where to store data
  5657. */
  5658. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5659. /**
  5660. * Creates a new Color4 from a Color3 and an alpha value
  5661. * @param color3 defines the source Color3 to read from
  5662. * @param alpha defines the alpha component (1.0 by default)
  5663. * @returns a new Color4 object
  5664. */
  5665. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5666. /**
  5667. * Creates a new Color4 from the starting index element of the given array
  5668. * @param array defines the source array to read from
  5669. * @param offset defines the offset in the source array
  5670. * @returns a new Color4 object
  5671. */
  5672. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5673. /**
  5674. * Creates a new Color3 from integer values (< 256)
  5675. * @param r defines the red component to read from (value between 0 and 255)
  5676. * @param g defines the green component to read from (value between 0 and 255)
  5677. * @param b defines the blue component to read from (value between 0 and 255)
  5678. * @param a defines the alpha component to read from (value between 0 and 255)
  5679. * @returns a new Color3 object
  5680. */
  5681. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5682. /**
  5683. * Check the content of a given array and convert it to an array containing RGBA data
  5684. * If the original array was already containing count * 4 values then it is returned directly
  5685. * @param colors defines the array to check
  5686. * @param count defines the number of RGBA data to expect
  5687. * @returns an array containing count * 4 values (RGBA)
  5688. */
  5689. static CheckColors4(colors: number[], count: number): number[];
  5690. }
  5691. /**
  5692. * @hidden
  5693. */
  5694. export class TmpColors {
  5695. static Color3: Color3[];
  5696. static Color4: Color4[];
  5697. }
  5698. }
  5699. declare module BABYLON {
  5700. /**
  5701. * Defines an interface which represents an animation key frame
  5702. */
  5703. export interface IAnimationKey {
  5704. /**
  5705. * Frame of the key frame
  5706. */
  5707. frame: number;
  5708. /**
  5709. * Value at the specifies key frame
  5710. */
  5711. value: any;
  5712. /**
  5713. * The input tangent for the cubic hermite spline
  5714. */
  5715. inTangent?: any;
  5716. /**
  5717. * The output tangent for the cubic hermite spline
  5718. */
  5719. outTangent?: any;
  5720. /**
  5721. * The animation interpolation type
  5722. */
  5723. interpolation?: AnimationKeyInterpolation;
  5724. }
  5725. /**
  5726. * Enum for the animation key frame interpolation type
  5727. */
  5728. export enum AnimationKeyInterpolation {
  5729. /**
  5730. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5731. */
  5732. STEP = 1
  5733. }
  5734. }
  5735. declare module BABYLON {
  5736. /**
  5737. * Represents the range of an animation
  5738. */
  5739. export class AnimationRange {
  5740. /**The name of the animation range**/
  5741. name: string;
  5742. /**The starting frame of the animation */
  5743. from: number;
  5744. /**The ending frame of the animation*/
  5745. to: number;
  5746. /**
  5747. * Initializes the range of an animation
  5748. * @param name The name of the animation range
  5749. * @param from The starting frame of the animation
  5750. * @param to The ending frame of the animation
  5751. */
  5752. constructor(
  5753. /**The name of the animation range**/
  5754. name: string,
  5755. /**The starting frame of the animation */
  5756. from: number,
  5757. /**The ending frame of the animation*/
  5758. to: number);
  5759. /**
  5760. * Makes a copy of the animation range
  5761. * @returns A copy of the animation range
  5762. */
  5763. clone(): AnimationRange;
  5764. }
  5765. }
  5766. declare module BABYLON {
  5767. /**
  5768. * Composed of a frame, and an action function
  5769. */
  5770. export class AnimationEvent {
  5771. /** The frame for which the event is triggered **/
  5772. frame: number;
  5773. /** The event to perform when triggered **/
  5774. action: (currentFrame: number) => void;
  5775. /** Specifies if the event should be triggered only once**/
  5776. onlyOnce?: boolean | undefined;
  5777. /**
  5778. * Specifies if the animation event is done
  5779. */
  5780. isDone: boolean;
  5781. /**
  5782. * Initializes the animation event
  5783. * @param frame The frame for which the event is triggered
  5784. * @param action The event to perform when triggered
  5785. * @param onlyOnce Specifies if the event should be triggered only once
  5786. */
  5787. constructor(
  5788. /** The frame for which the event is triggered **/
  5789. frame: number,
  5790. /** The event to perform when triggered **/
  5791. action: (currentFrame: number) => void,
  5792. /** Specifies if the event should be triggered only once**/
  5793. onlyOnce?: boolean | undefined);
  5794. /** @hidden */ private _clone(): AnimationEvent;
  5795. }
  5796. }
  5797. declare module BABYLON {
  5798. /**
  5799. * Interface used to define a behavior
  5800. */
  5801. export interface Behavior<T> {
  5802. /** gets or sets behavior's name */
  5803. name: string;
  5804. /**
  5805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5806. */
  5807. init(): void;
  5808. /**
  5809. * Called when the behavior is attached to a target
  5810. * @param target defines the target where the behavior is attached to
  5811. */
  5812. attach(target: T): void;
  5813. /**
  5814. * Called when the behavior is detached from its target
  5815. */
  5816. detach(): void;
  5817. }
  5818. /**
  5819. * Interface implemented by classes supporting behaviors
  5820. */
  5821. export interface IBehaviorAware<T> {
  5822. /**
  5823. * Attach a behavior
  5824. * @param behavior defines the behavior to attach
  5825. * @returns the current host
  5826. */
  5827. addBehavior(behavior: Behavior<T>): T;
  5828. /**
  5829. * Remove a behavior from the current object
  5830. * @param behavior defines the behavior to detach
  5831. * @returns the current host
  5832. */
  5833. removeBehavior(behavior: Behavior<T>): T;
  5834. /**
  5835. * Gets a behavior using its name to search
  5836. * @param name defines the name to search
  5837. * @returns the behavior or null if not found
  5838. */
  5839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5840. }
  5841. }
  5842. declare module BABYLON {
  5843. /**
  5844. * Defines an array and its length.
  5845. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5846. */
  5847. export interface ISmartArrayLike<T> {
  5848. /**
  5849. * The data of the array.
  5850. */
  5851. data: Array<T>;
  5852. /**
  5853. * The active length of the array.
  5854. */
  5855. length: number;
  5856. }
  5857. /**
  5858. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5859. */
  5860. export class SmartArray<T> implements ISmartArrayLike<T> {
  5861. /**
  5862. * The full set of data from the array.
  5863. */
  5864. data: Array<T>;
  5865. /**
  5866. * The active length of the array.
  5867. */
  5868. length: number;
  5869. protected _id: number;
  5870. /**
  5871. * Instantiates a Smart Array.
  5872. * @param capacity defines the default capacity of the array.
  5873. */
  5874. constructor(capacity: number);
  5875. /**
  5876. * Pushes a value at the end of the active data.
  5877. * @param value defines the object to push in the array.
  5878. */
  5879. push(value: T): void;
  5880. /**
  5881. * Iterates over the active data and apply the lambda to them.
  5882. * @param func defines the action to apply on each value.
  5883. */
  5884. forEach(func: (content: T) => void): void;
  5885. /**
  5886. * Sorts the full sets of data.
  5887. * @param compareFn defines the comparison function to apply.
  5888. */
  5889. sort(compareFn: (a: T, b: T) => number): void;
  5890. /**
  5891. * Resets the active data to an empty array.
  5892. */
  5893. reset(): void;
  5894. /**
  5895. * Releases all the data from the array as well as the array.
  5896. */
  5897. dispose(): void;
  5898. /**
  5899. * Concats the active data with a given array.
  5900. * @param array defines the data to concatenate with.
  5901. */
  5902. concat(array: any): void;
  5903. /**
  5904. * Returns the position of a value in the active data.
  5905. * @param value defines the value to find the index for
  5906. * @returns the index if found in the active data otherwise -1
  5907. */
  5908. indexOf(value: T): number;
  5909. /**
  5910. * Returns whether an element is part of the active data.
  5911. * @param value defines the value to look for
  5912. * @returns true if found in the active data otherwise false
  5913. */
  5914. contains(value: T): boolean;
  5915. private static _GlobalId;
  5916. }
  5917. /**
  5918. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5919. * The data in this array can only be present once
  5920. */
  5921. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5922. private _duplicateId;
  5923. /**
  5924. * Pushes a value at the end of the active data.
  5925. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5926. * @param value defines the object to push in the array.
  5927. */
  5928. push(value: T): void;
  5929. /**
  5930. * Pushes a value at the end of the active data.
  5931. * If the data is already present, it won t be added again
  5932. * @param value defines the object to push in the array.
  5933. * @returns true if added false if it was already present
  5934. */
  5935. pushNoDuplicate(value: T): boolean;
  5936. /**
  5937. * Resets the active data to an empty array.
  5938. */
  5939. reset(): void;
  5940. /**
  5941. * Concats the active data with a given array.
  5942. * This ensures no dupplicate will be present in the result.
  5943. * @param array defines the data to concatenate with.
  5944. */
  5945. concatWithNoDuplicate(array: any): void;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * @ignore
  5951. * This is a list of all the different input types that are available in the application.
  5952. * Fo instance: ArcRotateCameraGamepadInput...
  5953. */
  5954. export var CameraInputTypes: {};
  5955. /**
  5956. * This is the contract to implement in order to create a new input class.
  5957. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5958. */
  5959. export interface ICameraInput<TCamera extends Camera> {
  5960. /**
  5961. * Defines the camera the input is attached to.
  5962. */
  5963. camera: Nullable<TCamera>;
  5964. /**
  5965. * Gets the class name of the current intput.
  5966. * @returns the class name
  5967. */
  5968. getClassName(): string;
  5969. /**
  5970. * Get the friendly name associated with the input class.
  5971. * @returns the input friendly name
  5972. */
  5973. getSimpleName(): string;
  5974. /**
  5975. * Attach the input controls to a specific dom element to get the input from.
  5976. * @param element Defines the element the controls should be listened from
  5977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5978. */
  5979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5980. /**
  5981. * Detach the current controls from the specified dom element.
  5982. * @param element Defines the element to stop listening the inputs from
  5983. */
  5984. detachControl(element: Nullable<HTMLElement>): void;
  5985. /**
  5986. * Update the current camera state depending on the inputs that have been used this frame.
  5987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5988. */
  5989. checkInputs?: () => void;
  5990. }
  5991. /**
  5992. * Represents a map of input types to input instance or input index to input instance.
  5993. */
  5994. export interface CameraInputsMap<TCamera extends Camera> {
  5995. /**
  5996. * Accessor to the input by input type.
  5997. */
  5998. [name: string]: ICameraInput<TCamera>;
  5999. /**
  6000. * Accessor to the input by input index.
  6001. */
  6002. [idx: number]: ICameraInput<TCamera>;
  6003. }
  6004. /**
  6005. * This represents the input manager used within a camera.
  6006. * It helps dealing with all the different kind of input attached to a camera.
  6007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6008. */
  6009. export class CameraInputsManager<TCamera extends Camera> {
  6010. /**
  6011. * Defines the list of inputs attahed to the camera.
  6012. */
  6013. attached: CameraInputsMap<TCamera>;
  6014. /**
  6015. * Defines the dom element the camera is collecting inputs from.
  6016. * This is null if the controls have not been attached.
  6017. */
  6018. attachedElement: Nullable<HTMLElement>;
  6019. /**
  6020. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6021. */
  6022. noPreventDefault: boolean;
  6023. /**
  6024. * Defined the camera the input manager belongs to.
  6025. */
  6026. camera: TCamera;
  6027. /**
  6028. * Update the current camera state depending on the inputs that have been used this frame.
  6029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6030. */
  6031. checkInputs: () => void;
  6032. /**
  6033. * Instantiate a new Camera Input Manager.
  6034. * @param camera Defines the camera the input manager blongs to
  6035. */
  6036. constructor(camera: TCamera);
  6037. /**
  6038. * Add an input method to a camera
  6039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6040. * @param input camera input method
  6041. */
  6042. add(input: ICameraInput<TCamera>): void;
  6043. /**
  6044. * Remove a specific input method from a camera
  6045. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6046. * @param inputToRemove camera input method
  6047. */
  6048. remove(inputToRemove: ICameraInput<TCamera>): void;
  6049. /**
  6050. * Remove a specific input type from a camera
  6051. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6052. * @param inputType the type of the input to remove
  6053. */
  6054. removeByType(inputType: string): void;
  6055. private _addCheckInputs;
  6056. /**
  6057. * Attach the input controls to the currently attached dom element to listen the events from.
  6058. * @param input Defines the input to attach
  6059. */
  6060. attachInput(input: ICameraInput<TCamera>): void;
  6061. /**
  6062. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6063. * @param element Defines the dom element to collect the events from
  6064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6065. */
  6066. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6067. /**
  6068. * Detach the current manager inputs controls from a specific dom element.
  6069. * @param element Defines the dom element to collect the events from
  6070. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6071. */
  6072. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6073. /**
  6074. * Rebuild the dynamic inputCheck function from the current list of
  6075. * defined inputs in the manager.
  6076. */
  6077. rebuildInputCheck(): void;
  6078. /**
  6079. * Remove all attached input methods from a camera
  6080. */
  6081. clear(): void;
  6082. /**
  6083. * Serialize the current input manager attached to a camera.
  6084. * This ensures than once parsed,
  6085. * the input associated to the camera will be identical to the current ones
  6086. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6087. */
  6088. serialize(serializedCamera: any): void;
  6089. /**
  6090. * Parses an input manager serialized JSON to restore the previous list of inputs
  6091. * and states associated to a camera.
  6092. * @param parsedCamera Defines the JSON to parse
  6093. */
  6094. parse(parsedCamera: any): void;
  6095. }
  6096. }
  6097. declare module BABYLON {
  6098. /**
  6099. * Class used to store data that will be store in GPU memory
  6100. */
  6101. export class Buffer {
  6102. private _engine;
  6103. private _buffer;
  6104. /** @hidden */ private _data: Nullable<DataArray>;
  6105. private _updatable;
  6106. private _instanced;
  6107. private _divisor;
  6108. /**
  6109. * Gets the byte stride.
  6110. */
  6111. readonly byteStride: number;
  6112. /**
  6113. * Constructor
  6114. * @param engine the engine
  6115. * @param data the data to use for this buffer
  6116. * @param updatable whether the data is updatable
  6117. * @param stride the stride (optional)
  6118. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6119. * @param instanced whether the buffer is instanced (optional)
  6120. * @param useBytes set to true if the stride in in bytes (optional)
  6121. * @param divisor sets an optional divisor for instances (1 by default)
  6122. */
  6123. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6124. /**
  6125. * Create a new VertexBuffer based on the current buffer
  6126. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6127. * @param offset defines offset in the buffer (0 by default)
  6128. * @param size defines the size in floats of attributes (position is 3 for instance)
  6129. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6130. * @param instanced defines if the vertex buffer contains indexed data
  6131. * @param useBytes defines if the offset and stride are in bytes *
  6132. * @param divisor sets an optional divisor for instances (1 by default)
  6133. * @returns the new vertex buffer
  6134. */
  6135. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6136. /**
  6137. * Gets a boolean indicating if the Buffer is updatable?
  6138. * @returns true if the buffer is updatable
  6139. */
  6140. isUpdatable(): boolean;
  6141. /**
  6142. * Gets current buffer's data
  6143. * @returns a DataArray or null
  6144. */
  6145. getData(): Nullable<DataArray>;
  6146. /**
  6147. * Gets underlying native buffer
  6148. * @returns underlying native buffer
  6149. */
  6150. getBuffer(): Nullable<DataBuffer>;
  6151. /**
  6152. * Gets the stride in float32 units (i.e. byte stride / 4).
  6153. * May not be an integer if the byte stride is not divisible by 4.
  6154. * DEPRECATED. Use byteStride instead.
  6155. * @returns the stride in float32 units
  6156. */
  6157. getStrideSize(): number;
  6158. /**
  6159. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6160. * @param data defines the data to store
  6161. */
  6162. create(data?: Nullable<DataArray>): void;
  6163. /** @hidden */ private _rebuild(): void;
  6164. /**
  6165. * Update current buffer data
  6166. * @param data defines the data to store
  6167. */
  6168. update(data: DataArray): void;
  6169. /**
  6170. * Updates the data directly.
  6171. * @param data the new data
  6172. * @param offset the new offset
  6173. * @param vertexCount the vertex count (optional)
  6174. * @param useBytes set to true if the offset is in bytes
  6175. */
  6176. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6177. /**
  6178. * Release all resources
  6179. */
  6180. dispose(): void;
  6181. }
  6182. /**
  6183. * Specialized buffer used to store vertex data
  6184. */
  6185. export class VertexBuffer {
  6186. /** @hidden */ private _buffer: Buffer;
  6187. private _kind;
  6188. private _size;
  6189. private _ownsBuffer;
  6190. private _instanced;
  6191. private _instanceDivisor;
  6192. /**
  6193. * The byte type.
  6194. */
  6195. static readonly BYTE: number;
  6196. /**
  6197. * The unsigned byte type.
  6198. */
  6199. static readonly UNSIGNED_BYTE: number;
  6200. /**
  6201. * The short type.
  6202. */
  6203. static readonly SHORT: number;
  6204. /**
  6205. * The unsigned short type.
  6206. */
  6207. static readonly UNSIGNED_SHORT: number;
  6208. /**
  6209. * The integer type.
  6210. */
  6211. static readonly INT: number;
  6212. /**
  6213. * The unsigned integer type.
  6214. */
  6215. static readonly UNSIGNED_INT: number;
  6216. /**
  6217. * The float type.
  6218. */
  6219. static readonly FLOAT: number;
  6220. /**
  6221. * Gets or sets the instance divisor when in instanced mode
  6222. */
  6223. instanceDivisor: number;
  6224. /**
  6225. * Gets the byte stride.
  6226. */
  6227. readonly byteStride: number;
  6228. /**
  6229. * Gets the byte offset.
  6230. */
  6231. readonly byteOffset: number;
  6232. /**
  6233. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6234. */
  6235. readonly normalized: boolean;
  6236. /**
  6237. * Gets the data type of each component in the array.
  6238. */
  6239. readonly type: number;
  6240. /**
  6241. * Constructor
  6242. * @param engine the engine
  6243. * @param data the data to use for this vertex buffer
  6244. * @param kind the vertex buffer kind
  6245. * @param updatable whether the data is updatable
  6246. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6247. * @param stride the stride (optional)
  6248. * @param instanced whether the buffer is instanced (optional)
  6249. * @param offset the offset of the data (optional)
  6250. * @param size the number of components (optional)
  6251. * @param type the type of the component (optional)
  6252. * @param normalized whether the data contains normalized data (optional)
  6253. * @param useBytes set to true if stride and offset are in bytes (optional)
  6254. * @param divisor defines the instance divisor to use (1 by default)
  6255. */
  6256. 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, divisor?: number);
  6257. /** @hidden */ private _rebuild(): void;
  6258. /**
  6259. * Returns the kind of the VertexBuffer (string)
  6260. * @returns a string
  6261. */
  6262. getKind(): string;
  6263. /**
  6264. * Gets a boolean indicating if the VertexBuffer is updatable?
  6265. * @returns true if the buffer is updatable
  6266. */
  6267. isUpdatable(): boolean;
  6268. /**
  6269. * Gets current buffer's data
  6270. * @returns a DataArray or null
  6271. */
  6272. getData(): Nullable<DataArray>;
  6273. /**
  6274. * Gets underlying native buffer
  6275. * @returns underlying native buffer
  6276. */
  6277. getBuffer(): Nullable<DataBuffer>;
  6278. /**
  6279. * Gets the stride in float32 units (i.e. byte stride / 4).
  6280. * May not be an integer if the byte stride is not divisible by 4.
  6281. * DEPRECATED. Use byteStride instead.
  6282. * @returns the stride in float32 units
  6283. */
  6284. getStrideSize(): number;
  6285. /**
  6286. * Returns the offset as a multiple of the type byte length.
  6287. * DEPRECATED. Use byteOffset instead.
  6288. * @returns the offset in bytes
  6289. */
  6290. getOffset(): number;
  6291. /**
  6292. * Returns the number of components per vertex attribute (integer)
  6293. * @returns the size in float
  6294. */
  6295. getSize(): number;
  6296. /**
  6297. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6298. * @returns true if this buffer is instanced
  6299. */
  6300. getIsInstanced(): boolean;
  6301. /**
  6302. * Returns the instancing divisor, zero for non-instanced (integer).
  6303. * @returns a number
  6304. */
  6305. getInstanceDivisor(): number;
  6306. /**
  6307. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6308. * @param data defines the data to store
  6309. */
  6310. create(data?: DataArray): void;
  6311. /**
  6312. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6313. * This function will create a new buffer if the current one is not updatable
  6314. * @param data defines the data to store
  6315. */
  6316. update(data: DataArray): void;
  6317. /**
  6318. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6319. * Returns the directly updated WebGLBuffer.
  6320. * @param data the new data
  6321. * @param offset the new offset
  6322. * @param useBytes set to true if the offset is in bytes
  6323. */
  6324. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6325. /**
  6326. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6327. */
  6328. dispose(): void;
  6329. /**
  6330. * Enumerates each value of this vertex buffer as numbers.
  6331. * @param count the number of values to enumerate
  6332. * @param callback the callback function called for each value
  6333. */
  6334. forEach(count: number, callback: (value: number, index: number) => void): void;
  6335. /**
  6336. * Positions
  6337. */
  6338. static readonly PositionKind: string;
  6339. /**
  6340. * Normals
  6341. */
  6342. static readonly NormalKind: string;
  6343. /**
  6344. * Tangents
  6345. */
  6346. static readonly TangentKind: string;
  6347. /**
  6348. * Texture coordinates
  6349. */
  6350. static readonly UVKind: string;
  6351. /**
  6352. * Texture coordinates 2
  6353. */
  6354. static readonly UV2Kind: string;
  6355. /**
  6356. * Texture coordinates 3
  6357. */
  6358. static readonly UV3Kind: string;
  6359. /**
  6360. * Texture coordinates 4
  6361. */
  6362. static readonly UV4Kind: string;
  6363. /**
  6364. * Texture coordinates 5
  6365. */
  6366. static readonly UV5Kind: string;
  6367. /**
  6368. * Texture coordinates 6
  6369. */
  6370. static readonly UV6Kind: string;
  6371. /**
  6372. * Colors
  6373. */
  6374. static readonly ColorKind: string;
  6375. /**
  6376. * Matrix indices (for bones)
  6377. */
  6378. static readonly MatricesIndicesKind: string;
  6379. /**
  6380. * Matrix weights (for bones)
  6381. */
  6382. static readonly MatricesWeightsKind: string;
  6383. /**
  6384. * Additional matrix indices (for bones)
  6385. */
  6386. static readonly MatricesIndicesExtraKind: string;
  6387. /**
  6388. * Additional matrix weights (for bones)
  6389. */
  6390. static readonly MatricesWeightsExtraKind: string;
  6391. /**
  6392. * Deduces the stride given a kind.
  6393. * @param kind The kind string to deduce
  6394. * @returns The deduced stride
  6395. */
  6396. static DeduceStride(kind: string): number;
  6397. /**
  6398. * Gets the byte length of the given type.
  6399. * @param type the type
  6400. * @returns the number of bytes
  6401. */
  6402. static GetTypeByteLength(type: number): number;
  6403. /**
  6404. * Enumerates each value of the given parameters as numbers.
  6405. * @param data the data to enumerate
  6406. * @param byteOffset the byte offset of the data
  6407. * @param byteStride the byte stride of the data
  6408. * @param componentCount the number of components per element
  6409. * @param componentType the type of the component
  6410. * @param count the number of values to enumerate
  6411. * @param normalized whether the data is normalized
  6412. * @param callback the callback function called for each value
  6413. */
  6414. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6415. private static _GetFloatValue;
  6416. }
  6417. }
  6418. declare module BABYLON {
  6419. /**
  6420. * @hidden
  6421. */
  6422. export class IntersectionInfo {
  6423. bu: Nullable<number>;
  6424. bv: Nullable<number>;
  6425. distance: number;
  6426. faceId: number;
  6427. subMeshId: number;
  6428. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6429. }
  6430. }
  6431. declare module BABYLON {
  6432. /**
  6433. * Represens a plane by the equation ax + by + cz + d = 0
  6434. */
  6435. export class Plane {
  6436. private static _TmpMatrix;
  6437. /**
  6438. * Normal of the plane (a,b,c)
  6439. */
  6440. normal: Vector3;
  6441. /**
  6442. * d component of the plane
  6443. */
  6444. d: number;
  6445. /**
  6446. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6447. * @param a a component of the plane
  6448. * @param b b component of the plane
  6449. * @param c c component of the plane
  6450. * @param d d component of the plane
  6451. */
  6452. constructor(a: number, b: number, c: number, d: number);
  6453. /**
  6454. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6455. */
  6456. asArray(): number[];
  6457. /**
  6458. * @returns a new plane copied from the current Plane.
  6459. */
  6460. clone(): Plane;
  6461. /**
  6462. * @returns the string "Plane".
  6463. */
  6464. getClassName(): string;
  6465. /**
  6466. * @returns the Plane hash code.
  6467. */
  6468. getHashCode(): number;
  6469. /**
  6470. * Normalize the current Plane in place.
  6471. * @returns the updated Plane.
  6472. */
  6473. normalize(): Plane;
  6474. /**
  6475. * Applies a transformation the plane and returns the result
  6476. * @param transformation the transformation matrix to be applied to the plane
  6477. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6478. */
  6479. transform(transformation: DeepImmutable<Matrix>): Plane;
  6480. /**
  6481. * Calcualtte the dot product between the point and the plane normal
  6482. * @param point point to calculate the dot product with
  6483. * @returns the dot product (float) of the point coordinates and the plane normal.
  6484. */
  6485. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6486. /**
  6487. * Updates the current Plane from the plane defined by the three given points.
  6488. * @param point1 one of the points used to contruct the plane
  6489. * @param point2 one of the points used to contruct the plane
  6490. * @param point3 one of the points used to contruct the plane
  6491. * @returns the updated Plane.
  6492. */
  6493. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6494. /**
  6495. * Checks if the plane is facing a given direction
  6496. * @param direction the direction to check if the plane is facing
  6497. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6498. * @returns True is the vector "direction" is the same side than the plane normal.
  6499. */
  6500. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6501. /**
  6502. * Calculates the distance to a point
  6503. * @param point point to calculate distance to
  6504. * @returns the signed distance (float) from the given point to the Plane.
  6505. */
  6506. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6507. /**
  6508. * Creates a plane from an array
  6509. * @param array the array to create a plane from
  6510. * @returns a new Plane from the given array.
  6511. */
  6512. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6513. /**
  6514. * Creates a plane from three points
  6515. * @param point1 point used to create the plane
  6516. * @param point2 point used to create the plane
  6517. * @param point3 point used to create the plane
  6518. * @returns a new Plane defined by the three given points.
  6519. */
  6520. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6521. /**
  6522. * Creates a plane from an origin point and a normal
  6523. * @param origin origin of the plane to be constructed
  6524. * @param normal normal of the plane to be constructed
  6525. * @returns a new Plane the normal vector to this plane at the given origin point.
  6526. * Note : the vector "normal" is updated because normalized.
  6527. */
  6528. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6529. /**
  6530. * Calculates the distance from a plane and a point
  6531. * @param origin origin of the plane to be constructed
  6532. * @param normal normal of the plane to be constructed
  6533. * @param point point to calculate distance to
  6534. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6535. */
  6536. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6537. }
  6538. }
  6539. declare module BABYLON {
  6540. /**
  6541. * Class used to store bounding sphere information
  6542. */
  6543. export class BoundingSphere {
  6544. /**
  6545. * Gets the center of the bounding sphere in local space
  6546. */
  6547. readonly center: Vector3;
  6548. /**
  6549. * Radius of the bounding sphere in local space
  6550. */
  6551. radius: number;
  6552. /**
  6553. * Gets the center of the bounding sphere in world space
  6554. */
  6555. readonly centerWorld: Vector3;
  6556. /**
  6557. * Radius of the bounding sphere in world space
  6558. */
  6559. radiusWorld: number;
  6560. /**
  6561. * Gets the minimum vector in local space
  6562. */
  6563. readonly minimum: Vector3;
  6564. /**
  6565. * Gets the maximum vector in local space
  6566. */
  6567. readonly maximum: Vector3;
  6568. private _worldMatrix;
  6569. private static readonly TmpVector3;
  6570. /**
  6571. * Creates a new bounding sphere
  6572. * @param min defines the minimum vector (in local space)
  6573. * @param max defines the maximum vector (in local space)
  6574. * @param worldMatrix defines the new world matrix
  6575. */
  6576. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6577. /**
  6578. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6579. * @param min defines the new minimum vector (in local space)
  6580. * @param max defines the new maximum vector (in local space)
  6581. * @param worldMatrix defines the new world matrix
  6582. */
  6583. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6584. /**
  6585. * Scale the current bounding sphere by applying a scale factor
  6586. * @param factor defines the scale factor to apply
  6587. * @returns the current bounding box
  6588. */
  6589. scale(factor: number): BoundingSphere;
  6590. /**
  6591. * Gets the world matrix of the bounding box
  6592. * @returns a matrix
  6593. */
  6594. getWorldMatrix(): DeepImmutable<Matrix>;
  6595. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6596. /**
  6597. * Tests if the bounding sphere is intersecting the frustum planes
  6598. * @param frustumPlanes defines the frustum planes to test
  6599. * @returns true if there is an intersection
  6600. */
  6601. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6602. /**
  6603. * Tests if the bounding sphere center is in between the frustum planes.
  6604. * Used for optimistic fast inclusion.
  6605. * @param frustumPlanes defines the frustum planes to test
  6606. * @returns true if the sphere center is in between the frustum planes
  6607. */
  6608. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6609. /**
  6610. * Tests if a point is inside the bounding sphere
  6611. * @param point defines the point to test
  6612. * @returns true if the point is inside the bounding sphere
  6613. */
  6614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6615. /**
  6616. * Checks if two sphere intersct
  6617. * @param sphere0 sphere 0
  6618. * @param sphere1 sphere 1
  6619. * @returns true if the speres intersect
  6620. */
  6621. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6622. }
  6623. }
  6624. declare module BABYLON {
  6625. /**
  6626. * Class used to store bounding box information
  6627. */
  6628. export class BoundingBox implements ICullable {
  6629. /**
  6630. * Gets the 8 vectors representing the bounding box in local space
  6631. */
  6632. readonly vectors: Vector3[];
  6633. /**
  6634. * Gets the center of the bounding box in local space
  6635. */
  6636. readonly center: Vector3;
  6637. /**
  6638. * Gets the center of the bounding box in world space
  6639. */
  6640. readonly centerWorld: Vector3;
  6641. /**
  6642. * Gets the extend size in local space
  6643. */
  6644. readonly extendSize: Vector3;
  6645. /**
  6646. * Gets the extend size in world space
  6647. */
  6648. readonly extendSizeWorld: Vector3;
  6649. /**
  6650. * Gets the OBB (object bounding box) directions
  6651. */
  6652. readonly directions: Vector3[];
  6653. /**
  6654. * Gets the 8 vectors representing the bounding box in world space
  6655. */
  6656. readonly vectorsWorld: Vector3[];
  6657. /**
  6658. * Gets the minimum vector in world space
  6659. */
  6660. readonly minimumWorld: Vector3;
  6661. /**
  6662. * Gets the maximum vector in world space
  6663. */
  6664. readonly maximumWorld: Vector3;
  6665. /**
  6666. * Gets the minimum vector in local space
  6667. */
  6668. readonly minimum: Vector3;
  6669. /**
  6670. * Gets the maximum vector in local space
  6671. */
  6672. readonly maximum: Vector3;
  6673. private _worldMatrix;
  6674. private static readonly TmpVector3;
  6675. /**
  6676. * @hidden
  6677. */ private _tag: number;
  6678. /**
  6679. * Creates a new bounding box
  6680. * @param min defines the minimum vector (in local space)
  6681. * @param max defines the maximum vector (in local space)
  6682. * @param worldMatrix defines the new world matrix
  6683. */
  6684. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6685. /**
  6686. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6687. * @param min defines the new minimum vector (in local space)
  6688. * @param max defines the new maximum vector (in local space)
  6689. * @param worldMatrix defines the new world matrix
  6690. */
  6691. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6692. /**
  6693. * Scale the current bounding box by applying a scale factor
  6694. * @param factor defines the scale factor to apply
  6695. * @returns the current bounding box
  6696. */
  6697. scale(factor: number): BoundingBox;
  6698. /**
  6699. * Gets the world matrix of the bounding box
  6700. * @returns a matrix
  6701. */
  6702. getWorldMatrix(): DeepImmutable<Matrix>;
  6703. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6704. /**
  6705. * Tests if the bounding box is intersecting the frustum planes
  6706. * @param frustumPlanes defines the frustum planes to test
  6707. * @returns true if there is an intersection
  6708. */
  6709. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6710. /**
  6711. * Tests if the bounding box is entirely inside the frustum planes
  6712. * @param frustumPlanes defines the frustum planes to test
  6713. * @returns true if there is an inclusion
  6714. */
  6715. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6716. /**
  6717. * Tests if a point is inside the bounding box
  6718. * @param point defines the point to test
  6719. * @returns true if the point is inside the bounding box
  6720. */
  6721. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6722. /**
  6723. * Tests if the bounding box intersects with a bounding sphere
  6724. * @param sphere defines the sphere to test
  6725. * @returns true if there is an intersection
  6726. */
  6727. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6728. /**
  6729. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6730. * @param min defines the min vector to use
  6731. * @param max defines the max vector to use
  6732. * @returns true if there is an intersection
  6733. */
  6734. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6735. /**
  6736. * Tests if two bounding boxes are intersections
  6737. * @param box0 defines the first box to test
  6738. * @param box1 defines the second box to test
  6739. * @returns true if there is an intersection
  6740. */
  6741. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6742. /**
  6743. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6744. * @param minPoint defines the minimum vector of the bounding box
  6745. * @param maxPoint defines the maximum vector of the bounding box
  6746. * @param sphereCenter defines the sphere center
  6747. * @param sphereRadius defines the sphere radius
  6748. * @returns true if there is an intersection
  6749. */
  6750. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6751. /**
  6752. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6753. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @return true if there is an inclusion
  6756. */
  6757. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6760. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @return true if there is an intersection
  6763. */
  6764. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. }
  6766. }
  6767. declare module BABYLON {
  6768. /** @hidden */
  6769. export class Collider {
  6770. /** Define if a collision was found */
  6771. collisionFound: boolean;
  6772. /**
  6773. * Define last intersection point in local space
  6774. */
  6775. intersectionPoint: Vector3;
  6776. /**
  6777. * Define last collided mesh
  6778. */
  6779. collidedMesh: Nullable<AbstractMesh>;
  6780. private _collisionPoint;
  6781. private _planeIntersectionPoint;
  6782. private _tempVector;
  6783. private _tempVector2;
  6784. private _tempVector3;
  6785. private _tempVector4;
  6786. private _edge;
  6787. private _baseToVertex;
  6788. private _destinationPoint;
  6789. private _slidePlaneNormal;
  6790. private _displacementVector;
  6791. /** @hidden */ private _radius: Vector3;
  6792. /** @hidden */ private _retry: number;
  6793. private _velocity;
  6794. private _basePoint;
  6795. private _epsilon;
  6796. /** @hidden */ private _velocityWorldLength: number;
  6797. /** @hidden */ private _basePointWorld: Vector3;
  6798. private _velocityWorld;
  6799. private _normalizedVelocity;
  6800. /** @hidden */ private _initialVelocity: Vector3;
  6801. /** @hidden */ private _initialPosition: Vector3;
  6802. private _nearestDistance;
  6803. private _collisionMask;
  6804. collisionMask: number;
  6805. /**
  6806. * Gets the plane normal used to compute the sliding response (in local space)
  6807. */
  6808. readonly slidePlaneNormal: Vector3;
  6809. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  6810. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6811. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6812. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6813. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6814. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * Interface for cullable objects
  6820. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6821. */
  6822. export interface ICullable {
  6823. /**
  6824. * Checks if the object or part of the object is in the frustum
  6825. * @param frustumPlanes Camera near/planes
  6826. * @returns true if the object is in frustum otherwise false
  6827. */
  6828. isInFrustum(frustumPlanes: Plane[]): boolean;
  6829. /**
  6830. * Checks if a cullable object (mesh...) is in the camera frustum
  6831. * Unlike isInFrustum this cheks the full bounding box
  6832. * @param frustumPlanes Camera near/planes
  6833. * @returns true if the object is in frustum otherwise false
  6834. */
  6835. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6836. }
  6837. /**
  6838. * Info for a bounding data of a mesh
  6839. */
  6840. export class BoundingInfo implements ICullable {
  6841. /**
  6842. * Bounding box for the mesh
  6843. */
  6844. readonly boundingBox: BoundingBox;
  6845. /**
  6846. * Bounding sphere for the mesh
  6847. */
  6848. readonly boundingSphere: BoundingSphere;
  6849. private _isLocked;
  6850. private static readonly TmpVector3;
  6851. /**
  6852. * Constructs bounding info
  6853. * @param minimum min vector of the bounding box/sphere
  6854. * @param maximum max vector of the bounding box/sphere
  6855. * @param worldMatrix defines the new world matrix
  6856. */
  6857. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6858. /**
  6859. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6860. * @param min defines the new minimum vector (in local space)
  6861. * @param max defines the new maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6865. /**
  6866. * min vector of the bounding box/sphere
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * max vector of the bounding box/sphere
  6871. */
  6872. readonly maximum: Vector3;
  6873. /**
  6874. * If the info is locked and won't be updated to avoid perf overhead
  6875. */
  6876. isLocked: boolean;
  6877. /**
  6878. * Updates the bounding sphere and box
  6879. * @param world world matrix to be used to update
  6880. */
  6881. update(world: DeepImmutable<Matrix>): void;
  6882. /**
  6883. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6884. * @param center New center of the bounding info
  6885. * @param extend New extend of the bounding info
  6886. * @returns the current bounding info
  6887. */
  6888. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6889. /**
  6890. * Scale the current bounding info by applying a scale factor
  6891. * @param factor defines the scale factor to apply
  6892. * @returns the current bounding info
  6893. */
  6894. scale(factor: number): BoundingInfo;
  6895. /**
  6896. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6897. * @param frustumPlanes defines the frustum to test
  6898. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6899. * @returns true if the bounding info is in the frustum planes
  6900. */
  6901. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6902. /**
  6903. * Gets the world distance between the min and max points of the bounding box
  6904. */
  6905. readonly diagonalLength: number;
  6906. /**
  6907. * Checks if a cullable object (mesh...) is in the camera frustum
  6908. * Unlike isInFrustum this cheks the full bounding box
  6909. * @param frustumPlanes Camera near/planes
  6910. * @returns true if the object is in frustum otherwise false
  6911. */
  6912. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6913. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  6914. /**
  6915. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6916. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6917. * @param point the point to check intersection with
  6918. * @returns if the point intersects
  6919. */
  6920. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6923. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6924. * @param boundingInfo the bounding info to check intersection with
  6925. * @param precise if the intersection should be done using OBB
  6926. * @returns if the bounding info intersects
  6927. */
  6928. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6929. }
  6930. }
  6931. declare module BABYLON {
  6932. /**
  6933. * Extracts minimum and maximum values from a list of indexed positions
  6934. * @param positions defines the positions to use
  6935. * @param indices defines the indices to the positions
  6936. * @param indexStart defines the start index
  6937. * @param indexCount defines the end index
  6938. * @param bias defines bias value to add to the result
  6939. * @return minimum and maximum values
  6940. */
  6941. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6942. minimum: Vector3;
  6943. maximum: Vector3;
  6944. };
  6945. /**
  6946. * Extracts minimum and maximum values from a list of positions
  6947. * @param positions defines the positions to use
  6948. * @param start defines the start index in the positions array
  6949. * @param count defines the number of positions to handle
  6950. * @param bias defines bias value to add to the result
  6951. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6952. * @return minimum and maximum values
  6953. */
  6954. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6955. minimum: Vector3;
  6956. maximum: Vector3;
  6957. };
  6958. }
  6959. declare module BABYLON {
  6960. /** @hidden */
  6961. export class WebGLDataBuffer extends DataBuffer {
  6962. private _buffer;
  6963. constructor(resource: WebGLBuffer);
  6964. readonly underlyingResource: any;
  6965. }
  6966. }
  6967. declare module BABYLON {
  6968. /** @hidden */
  6969. export class WebGLPipelineContext implements IPipelineContext {
  6970. engine: ThinEngine;
  6971. program: Nullable<WebGLProgram>;
  6972. context?: WebGLRenderingContext;
  6973. vertexShader?: WebGLShader;
  6974. fragmentShader?: WebGLShader;
  6975. isParallelCompiled: boolean;
  6976. onCompiled?: () => void;
  6977. transformFeedback?: WebGLTransformFeedback | null;
  6978. readonly isAsync: boolean;
  6979. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6980. }
  6981. }
  6982. declare module BABYLON {
  6983. interface ThinEngine {
  6984. /**
  6985. * Create an uniform buffer
  6986. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6987. * @param elements defines the content of the uniform buffer
  6988. * @returns the webGL uniform buffer
  6989. */
  6990. createUniformBuffer(elements: FloatArray): DataBuffer;
  6991. /**
  6992. * Create a dynamic uniform buffer
  6993. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6994. * @param elements defines the content of the uniform buffer
  6995. * @returns the webGL uniform buffer
  6996. */
  6997. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6998. /**
  6999. * Update an existing uniform buffer
  7000. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7001. * @param uniformBuffer defines the target uniform buffer
  7002. * @param elements defines the content to update
  7003. * @param offset defines the offset in the uniform buffer where update should start
  7004. * @param count defines the size of the data to update
  7005. */
  7006. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7007. /**
  7008. * Bind an uniform buffer to the current webGL context
  7009. * @param buffer defines the buffer to bind
  7010. */
  7011. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7012. /**
  7013. * Bind a buffer to the current webGL context at a given location
  7014. * @param buffer defines the buffer to bind
  7015. * @param location defines the index where to bind the buffer
  7016. */
  7017. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7018. /**
  7019. * Bind a specific block at a given index in a specific shader program
  7020. * @param pipelineContext defines the pipeline context to use
  7021. * @param blockName defines the block name
  7022. * @param index defines the index where to bind the block
  7023. */
  7024. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7025. }
  7026. }
  7027. declare module BABYLON {
  7028. /**
  7029. * Uniform buffer objects.
  7030. *
  7031. * Handles blocks of uniform on the GPU.
  7032. *
  7033. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7034. *
  7035. * For more information, please refer to :
  7036. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7037. */
  7038. export class UniformBuffer {
  7039. private _engine;
  7040. private _buffer;
  7041. private _data;
  7042. private _bufferData;
  7043. private _dynamic?;
  7044. private _uniformLocations;
  7045. private _uniformSizes;
  7046. private _uniformLocationPointer;
  7047. private _needSync;
  7048. private _noUBO;
  7049. private _currentEffect;
  7050. /** @hidden */ private _alreadyBound: boolean;
  7051. private static _MAX_UNIFORM_SIZE;
  7052. private static _tempBuffer;
  7053. /**
  7054. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7055. * This is dynamic to allow compat with webgl 1 and 2.
  7056. * You will need to pass the name of the uniform as well as the value.
  7057. */
  7058. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7059. /**
  7060. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7061. * This is dynamic to allow compat with webgl 1 and 2.
  7062. * You will need to pass the name of the uniform as well as the value.
  7063. */
  7064. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7065. /**
  7066. * Lambda to Update a single float in a uniform buffer.
  7067. * This is dynamic to allow compat with webgl 1 and 2.
  7068. * You will need to pass the name of the uniform as well as the value.
  7069. */
  7070. updateFloat: (name: string, x: number) => void;
  7071. /**
  7072. * Lambda to Update a vec2 of float in a uniform buffer.
  7073. * This is dynamic to allow compat with webgl 1 and 2.
  7074. * You will need to pass the name of the uniform as well as the value.
  7075. */
  7076. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7077. /**
  7078. * Lambda to Update a vec3 of float in a uniform buffer.
  7079. * This is dynamic to allow compat with webgl 1 and 2.
  7080. * You will need to pass the name of the uniform as well as the value.
  7081. */
  7082. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7083. /**
  7084. * Lambda to Update a vec4 of float in a uniform buffer.
  7085. * This is dynamic to allow compat with webgl 1 and 2.
  7086. * You will need to pass the name of the uniform as well as the value.
  7087. */
  7088. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7089. /**
  7090. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7091. * This is dynamic to allow compat with webgl 1 and 2.
  7092. * You will need to pass the name of the uniform as well as the value.
  7093. */
  7094. updateMatrix: (name: string, mat: Matrix) => void;
  7095. /**
  7096. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7097. * This is dynamic to allow compat with webgl 1 and 2.
  7098. * You will need to pass the name of the uniform as well as the value.
  7099. */
  7100. updateVector3: (name: string, vector: Vector3) => void;
  7101. /**
  7102. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7103. * This is dynamic to allow compat with webgl 1 and 2.
  7104. * You will need to pass the name of the uniform as well as the value.
  7105. */
  7106. updateVector4: (name: string, vector: Vector4) => void;
  7107. /**
  7108. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7109. * This is dynamic to allow compat with webgl 1 and 2.
  7110. * You will need to pass the name of the uniform as well as the value.
  7111. */
  7112. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7113. /**
  7114. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7115. * This is dynamic to allow compat with webgl 1 and 2.
  7116. * You will need to pass the name of the uniform as well as the value.
  7117. */
  7118. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7119. /**
  7120. * Instantiates a new Uniform buffer objects.
  7121. *
  7122. * Handles blocks of uniform on the GPU.
  7123. *
  7124. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7125. *
  7126. * For more information, please refer to :
  7127. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7128. * @param engine Define the engine the buffer is associated with
  7129. * @param data Define the data contained in the buffer
  7130. * @param dynamic Define if the buffer is updatable
  7131. */
  7132. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7133. /**
  7134. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7135. * or just falling back on setUniformXXX calls.
  7136. */
  7137. readonly useUbo: boolean;
  7138. /**
  7139. * Indicates if the WebGL underlying uniform buffer is in sync
  7140. * with the javascript cache data.
  7141. */
  7142. readonly isSync: boolean;
  7143. /**
  7144. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7145. * Also, a dynamic UniformBuffer will disable cache verification and always
  7146. * update the underlying WebGL uniform buffer to the GPU.
  7147. * @returns if Dynamic, otherwise false
  7148. */
  7149. isDynamic(): boolean;
  7150. /**
  7151. * The data cache on JS side.
  7152. * @returns the underlying data as a float array
  7153. */
  7154. getData(): Float32Array;
  7155. /**
  7156. * The underlying WebGL Uniform buffer.
  7157. * @returns the webgl buffer
  7158. */
  7159. getBuffer(): Nullable<DataBuffer>;
  7160. /**
  7161. * std140 layout specifies how to align data within an UBO structure.
  7162. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7163. * for specs.
  7164. */
  7165. private _fillAlignment;
  7166. /**
  7167. * Adds an uniform in the buffer.
  7168. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7169. * for the layout to be correct !
  7170. * @param name Name of the uniform, as used in the uniform block in the shader.
  7171. * @param size Data size, or data directly.
  7172. */
  7173. addUniform(name: string, size: number | number[]): void;
  7174. /**
  7175. * Adds a Matrix 4x4 to the uniform buffer.
  7176. * @param name Name of the uniform, as used in the uniform block in the shader.
  7177. * @param mat A 4x4 matrix.
  7178. */
  7179. addMatrix(name: string, mat: Matrix): void;
  7180. /**
  7181. * Adds a vec2 to the uniform buffer.
  7182. * @param name Name of the uniform, as used in the uniform block in the shader.
  7183. * @param x Define the x component value of the vec2
  7184. * @param y Define the y component value of the vec2
  7185. */
  7186. addFloat2(name: string, x: number, y: number): void;
  7187. /**
  7188. * Adds a vec3 to the uniform buffer.
  7189. * @param name Name of the uniform, as used in the uniform block in the shader.
  7190. * @param x Define the x component value of the vec3
  7191. * @param y Define the y component value of the vec3
  7192. * @param z Define the z component value of the vec3
  7193. */
  7194. addFloat3(name: string, x: number, y: number, z: number): void;
  7195. /**
  7196. * Adds a vec3 to the uniform buffer.
  7197. * @param name Name of the uniform, as used in the uniform block in the shader.
  7198. * @param color Define the vec3 from a Color
  7199. */
  7200. addColor3(name: string, color: Color3): void;
  7201. /**
  7202. * Adds a vec4 to the uniform buffer.
  7203. * @param name Name of the uniform, as used in the uniform block in the shader.
  7204. * @param color Define the rgb components from a Color
  7205. * @param alpha Define the a component of the vec4
  7206. */
  7207. addColor4(name: string, color: Color3, alpha: number): void;
  7208. /**
  7209. * Adds a vec3 to the uniform buffer.
  7210. * @param name Name of the uniform, as used in the uniform block in the shader.
  7211. * @param vector Define the vec3 components from a Vector
  7212. */
  7213. addVector3(name: string, vector: Vector3): void;
  7214. /**
  7215. * Adds a Matrix 3x3 to the uniform buffer.
  7216. * @param name Name of the uniform, as used in the uniform block in the shader.
  7217. */
  7218. addMatrix3x3(name: string): void;
  7219. /**
  7220. * Adds a Matrix 2x2 to the uniform buffer.
  7221. * @param name Name of the uniform, as used in the uniform block in the shader.
  7222. */
  7223. addMatrix2x2(name: string): void;
  7224. /**
  7225. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7226. */
  7227. create(): void;
  7228. /** @hidden */ private _rebuild(): void;
  7229. /**
  7230. * Updates the WebGL Uniform Buffer on the GPU.
  7231. * If the `dynamic` flag is set to true, no cache comparison is done.
  7232. * Otherwise, the buffer will be updated only if the cache differs.
  7233. */
  7234. update(): void;
  7235. /**
  7236. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7237. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7238. * @param data Define the flattened data
  7239. * @param size Define the size of the data.
  7240. */
  7241. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7242. private _valueCache;
  7243. private _cacheMatrix;
  7244. private _updateMatrix3x3ForUniform;
  7245. private _updateMatrix3x3ForEffect;
  7246. private _updateMatrix2x2ForEffect;
  7247. private _updateMatrix2x2ForUniform;
  7248. private _updateFloatForEffect;
  7249. private _updateFloatForUniform;
  7250. private _updateFloat2ForEffect;
  7251. private _updateFloat2ForUniform;
  7252. private _updateFloat3ForEffect;
  7253. private _updateFloat3ForUniform;
  7254. private _updateFloat4ForEffect;
  7255. private _updateFloat4ForUniform;
  7256. private _updateMatrixForEffect;
  7257. private _updateMatrixForUniform;
  7258. private _updateVector3ForEffect;
  7259. private _updateVector3ForUniform;
  7260. private _updateVector4ForEffect;
  7261. private _updateVector4ForUniform;
  7262. private _updateColor3ForEffect;
  7263. private _updateColor3ForUniform;
  7264. private _updateColor4ForEffect;
  7265. private _updateColor4ForUniform;
  7266. /**
  7267. * Sets a sampler uniform on the effect.
  7268. * @param name Define the name of the sampler.
  7269. * @param texture Define the texture to set in the sampler
  7270. */
  7271. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7272. /**
  7273. * Directly updates the value of the uniform in the cache AND on the GPU.
  7274. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7275. * @param data Define the flattened data
  7276. */
  7277. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7278. /**
  7279. * Binds this uniform buffer to an effect.
  7280. * @param effect Define the effect to bind the buffer to
  7281. * @param name Name of the uniform block in the shader.
  7282. */
  7283. bindToEffect(effect: Effect, name: string): void;
  7284. /**
  7285. * Disposes the uniform buffer.
  7286. */
  7287. dispose(): void;
  7288. }
  7289. }
  7290. declare module BABYLON {
  7291. /**
  7292. * Enum that determines the text-wrapping mode to use.
  7293. */
  7294. export enum InspectableType {
  7295. /**
  7296. * Checkbox for booleans
  7297. */
  7298. Checkbox = 0,
  7299. /**
  7300. * Sliders for numbers
  7301. */
  7302. Slider = 1,
  7303. /**
  7304. * Vector3
  7305. */
  7306. Vector3 = 2,
  7307. /**
  7308. * Quaternions
  7309. */
  7310. Quaternion = 3,
  7311. /**
  7312. * Color3
  7313. */
  7314. Color3 = 4,
  7315. /**
  7316. * String
  7317. */
  7318. String = 5
  7319. }
  7320. /**
  7321. * Interface used to define custom inspectable properties.
  7322. * This interface is used by the inspector to display custom property grids
  7323. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7324. */
  7325. export interface IInspectable {
  7326. /**
  7327. * Gets the label to display
  7328. */
  7329. label: string;
  7330. /**
  7331. * Gets the name of the property to edit
  7332. */
  7333. propertyName: string;
  7334. /**
  7335. * Gets the type of the editor to use
  7336. */
  7337. type: InspectableType;
  7338. /**
  7339. * Gets the minimum value of the property when using in "slider" mode
  7340. */
  7341. min?: number;
  7342. /**
  7343. * Gets the maximum value of the property when using in "slider" mode
  7344. */
  7345. max?: number;
  7346. /**
  7347. * Gets the setp to use when using in "slider" mode
  7348. */
  7349. step?: number;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * Class used to provide helper for timing
  7355. */
  7356. export class TimingTools {
  7357. /**
  7358. * Polyfill for setImmediate
  7359. * @param action defines the action to execute after the current execution block
  7360. */
  7361. static SetImmediate(action: () => void): void;
  7362. }
  7363. }
  7364. declare module BABYLON {
  7365. /**
  7366. * Class used to enable instatition of objects by class name
  7367. */
  7368. export class InstantiationTools {
  7369. /**
  7370. * Use this object to register external classes like custom textures or material
  7371. * to allow the laoders to instantiate them
  7372. */
  7373. static RegisteredExternalClasses: {
  7374. [key: string]: Object;
  7375. };
  7376. /**
  7377. * Tries to instantiate a new object from a given class name
  7378. * @param className defines the class name to instantiate
  7379. * @returns the new object or null if the system was not able to do the instantiation
  7380. */
  7381. static Instantiate(className: string): any;
  7382. }
  7383. }
  7384. declare module BABYLON {
  7385. /**
  7386. * Define options used to create a depth texture
  7387. */
  7388. export class DepthTextureCreationOptions {
  7389. /** Specifies whether or not a stencil should be allocated in the texture */
  7390. generateStencil?: boolean;
  7391. /** Specifies whether or not bilinear filtering is enable on the texture */
  7392. bilinearFiltering?: boolean;
  7393. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7394. comparisonFunction?: number;
  7395. /** Specifies if the created texture is a cube texture */
  7396. isCube?: boolean;
  7397. }
  7398. }
  7399. declare module BABYLON {
  7400. interface ThinEngine {
  7401. /**
  7402. * Creates a depth stencil cube texture.
  7403. * This is only available in WebGL 2.
  7404. * @param size The size of face edge in the cube texture.
  7405. * @param options The options defining the cube texture.
  7406. * @returns The cube texture
  7407. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7408. /**
  7409. * Creates a cube texture
  7410. * @param rootUrl defines the url where the files to load is located
  7411. * @param scene defines the current scene
  7412. * @param files defines the list of files to load (1 per face)
  7413. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7414. * @param onLoad defines an optional callback raised when the texture is loaded
  7415. * @param onError defines an optional callback raised if there is an issue to load the texture
  7416. * @param format defines the format of the data
  7417. * @param forcedExtension defines the extension to use to pick the right loader
  7418. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7419. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7420. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7421. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7422. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7423. * @returns the cube texture as an InternalTexture
  7424. */
  7425. 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;
  7426. /**
  7427. * Creates a cube texture
  7428. * @param rootUrl defines the url where the files to load is located
  7429. * @param scene defines the current scene
  7430. * @param files defines the list of files to load (1 per face)
  7431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7432. * @param onLoad defines an optional callback raised when the texture is loaded
  7433. * @param onError defines an optional callback raised if there is an issue to load the texture
  7434. * @param format defines the format of the data
  7435. * @param forcedExtension defines the extension to use to pick the right loader
  7436. * @returns the cube texture as an InternalTexture
  7437. */
  7438. 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;
  7439. /**
  7440. * Creates a cube texture
  7441. * @param rootUrl defines the url where the files to load is located
  7442. * @param scene defines the current scene
  7443. * @param files defines the list of files to load (1 per face)
  7444. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7445. * @param onLoad defines an optional callback raised when the texture is loaded
  7446. * @param onError defines an optional callback raised if there is an issue to load the texture
  7447. * @param format defines the format of the data
  7448. * @param forcedExtension defines the extension to use to pick the right loader
  7449. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7450. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7451. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7452. * @returns the cube texture as an InternalTexture
  7453. */
  7454. 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;
  7455. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7456. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7457. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7458. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7459. /**
  7460. * @hidden
  7461. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  7462. }
  7463. }
  7464. declare module BABYLON {
  7465. /**
  7466. * Class for creating a cube texture
  7467. */
  7468. export class CubeTexture extends BaseTexture {
  7469. private _delayedOnLoad;
  7470. /**
  7471. * The url of the texture
  7472. */
  7473. url: string;
  7474. /**
  7475. * Gets or sets the center of the bounding box associated with the cube texture.
  7476. * It must define where the camera used to render the texture was set
  7477. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7478. */
  7479. boundingBoxPosition: Vector3;
  7480. private _boundingBoxSize;
  7481. /**
  7482. * Gets or sets the size of the bounding box associated with the cube texture
  7483. * When defined, the cubemap will switch to local mode
  7484. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7485. * @example https://www.babylonjs-playground.com/#RNASML
  7486. */
  7487. /**
  7488. * Returns the bounding box size
  7489. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7490. */
  7491. boundingBoxSize: Vector3;
  7492. protected _rotationY: number;
  7493. /**
  7494. * Sets texture matrix rotation angle around Y axis in radians.
  7495. */
  7496. /**
  7497. * Gets texture matrix rotation angle around Y axis radians.
  7498. */
  7499. rotationY: number;
  7500. /**
  7501. * Are mip maps generated for this texture or not.
  7502. */
  7503. readonly noMipmap: boolean;
  7504. private _noMipmap;
  7505. private _files;
  7506. protected _forcedExtension: Nullable<string>;
  7507. private _extensions;
  7508. private _textureMatrix;
  7509. private _format;
  7510. private _createPolynomials;
  7511. /** @hidden */ private _prefiltered: boolean;
  7512. /**
  7513. * Creates a cube texture from an array of image urls
  7514. * @param files defines an array of image urls
  7515. * @param scene defines the hosting scene
  7516. * @param noMipmap specifies if mip maps are not used
  7517. * @returns a cube texture
  7518. */
  7519. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7520. /**
  7521. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7522. * @param url defines the url of the prefiltered texture
  7523. * @param scene defines the scene the texture is attached to
  7524. * @param forcedExtension defines the extension of the file if different from the url
  7525. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7526. * @return the prefiltered texture
  7527. */
  7528. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7529. /**
  7530. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7531. * as prefiltered data.
  7532. * @param rootUrl defines the url of the texture or the root name of the six images
  7533. * @param scene defines the scene the texture is attached to
  7534. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7535. * @param noMipmap defines if mipmaps should be created or not
  7536. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7537. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7538. * @param onError defines a callback triggered in case of error during load
  7539. * @param format defines the internal format to use for the texture once loaded
  7540. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7541. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7542. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7545. * @return the cube texture
  7546. */
  7547. 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);
  7548. /**
  7549. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7550. */
  7551. readonly isPrefiltered: boolean;
  7552. /**
  7553. * Get the current class name of the texture useful for serialization or dynamic coding.
  7554. * @returns "CubeTexture"
  7555. */
  7556. getClassName(): string;
  7557. /**
  7558. * Update the url (and optional buffer) of this texture if url was null during construction.
  7559. * @param url the url of the texture
  7560. * @param forcedExtension defines the extension to use
  7561. * @param onLoad callback called when the texture is loaded (defaults to null)
  7562. */
  7563. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7564. /**
  7565. * Delays loading of the cube texture
  7566. * @param forcedExtension defines the extension to use
  7567. */
  7568. delayLoad(forcedExtension?: string): void;
  7569. /**
  7570. * Returns the reflection texture matrix
  7571. * @returns the reflection texture matrix
  7572. */
  7573. getReflectionTextureMatrix(): Matrix;
  7574. /**
  7575. * Sets the reflection texture matrix
  7576. * @param value Reflection texture matrix
  7577. */
  7578. setReflectionTextureMatrix(value: Matrix): void;
  7579. /**
  7580. * Parses text to create a cube texture
  7581. * @param parsedTexture define the serialized text to read from
  7582. * @param scene defines the hosting scene
  7583. * @param rootUrl defines the root url of the cube texture
  7584. * @returns a cube texture
  7585. */
  7586. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7587. /**
  7588. * Makes a clone, or deep copy, of the cube texture
  7589. * @returns a new cube texture
  7590. */
  7591. clone(): CubeTexture;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Manages the defines for the Material
  7597. */
  7598. export class MaterialDefines {
  7599. /** @hidden */
  7600. protected _keys: string[];
  7601. private _isDirty;
  7602. /** @hidden */ private _renderId: number;
  7603. /** @hidden */ private _areLightsDirty: boolean;
  7604. /** @hidden */ private _areLightsDisposed: boolean;
  7605. /** @hidden */ private _areAttributesDirty: boolean;
  7606. /** @hidden */ private _areTexturesDirty: boolean;
  7607. /** @hidden */ private _areFresnelDirty: boolean;
  7608. /** @hidden */ private _areMiscDirty: boolean;
  7609. /** @hidden */ private _areImageProcessingDirty: boolean;
  7610. /** @hidden */ private _normals: boolean;
  7611. /** @hidden */ private _uvs: boolean;
  7612. /** @hidden */ private _needNormals: boolean;
  7613. /** @hidden */ private _needUVs: boolean;
  7614. [id: string]: any;
  7615. /**
  7616. * Specifies if the material needs to be re-calculated
  7617. */
  7618. readonly isDirty: boolean;
  7619. /**
  7620. * Marks the material to indicate that it has been re-calculated
  7621. */
  7622. markAsProcessed(): void;
  7623. /**
  7624. * Marks the material to indicate that it needs to be re-calculated
  7625. */
  7626. markAsUnprocessed(): void;
  7627. /**
  7628. * Marks the material to indicate all of its defines need to be re-calculated
  7629. */
  7630. markAllAsDirty(): void;
  7631. /**
  7632. * Marks the material to indicate that image processing needs to be re-calculated
  7633. */
  7634. markAsImageProcessingDirty(): void;
  7635. /**
  7636. * Marks the material to indicate the lights need to be re-calculated
  7637. * @param disposed Defines whether the light is dirty due to dispose or not
  7638. */
  7639. markAsLightDirty(disposed?: boolean): void;
  7640. /**
  7641. * Marks the attribute state as changed
  7642. */
  7643. markAsAttributesDirty(): void;
  7644. /**
  7645. * Marks the texture state as changed
  7646. */
  7647. markAsTexturesDirty(): void;
  7648. /**
  7649. * Marks the fresnel state as changed
  7650. */
  7651. markAsFresnelDirty(): void;
  7652. /**
  7653. * Marks the misc state as changed
  7654. */
  7655. markAsMiscDirty(): void;
  7656. /**
  7657. * Rebuilds the material defines
  7658. */
  7659. rebuild(): void;
  7660. /**
  7661. * Specifies if two material defines are equal
  7662. * @param other - A material define instance to compare to
  7663. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7664. */
  7665. isEqual(other: MaterialDefines): boolean;
  7666. /**
  7667. * Clones this instance's defines to another instance
  7668. * @param other - material defines to clone values to
  7669. */
  7670. cloneTo(other: MaterialDefines): void;
  7671. /**
  7672. * Resets the material define values
  7673. */
  7674. reset(): void;
  7675. /**
  7676. * Converts the material define values to a string
  7677. * @returns - String of material define information
  7678. */
  7679. toString(): string;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7686. * 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;
  7687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7688. */
  7689. export class ColorCurves {
  7690. private _dirty;
  7691. private _tempColor;
  7692. private _globalCurve;
  7693. private _highlightsCurve;
  7694. private _midtonesCurve;
  7695. private _shadowsCurve;
  7696. private _positiveCurve;
  7697. private _negativeCurve;
  7698. private _globalHue;
  7699. private _globalDensity;
  7700. private _globalSaturation;
  7701. private _globalExposure;
  7702. /**
  7703. * Gets the global Hue value.
  7704. * 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).
  7705. */
  7706. /**
  7707. * Sets the global Hue value.
  7708. * 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).
  7709. */
  7710. globalHue: number;
  7711. /**
  7712. * Gets the global Density value.
  7713. * 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.
  7714. * Values less than zero provide a filter of opposite hue.
  7715. */
  7716. /**
  7717. * Sets the global Density value.
  7718. * 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.
  7719. * Values less than zero provide a filter of opposite hue.
  7720. */
  7721. globalDensity: number;
  7722. /**
  7723. * Gets the global Saturation value.
  7724. * 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.
  7725. */
  7726. /**
  7727. * Sets the global Saturation value.
  7728. * 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.
  7729. */
  7730. globalSaturation: number;
  7731. /**
  7732. * Gets the global Exposure value.
  7733. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7734. */
  7735. /**
  7736. * Sets the global Exposure value.
  7737. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7738. */
  7739. globalExposure: number;
  7740. private _highlightsHue;
  7741. private _highlightsDensity;
  7742. private _highlightsSaturation;
  7743. private _highlightsExposure;
  7744. /**
  7745. * Gets the highlights Hue value.
  7746. * 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).
  7747. */
  7748. /**
  7749. * Sets the highlights Hue value.
  7750. * 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).
  7751. */
  7752. highlightsHue: number;
  7753. /**
  7754. * Gets the highlights Density value.
  7755. * 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.
  7756. * Values less than zero provide a filter of opposite hue.
  7757. */
  7758. /**
  7759. * Sets the highlights Density value.
  7760. * 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.
  7761. * Values less than zero provide a filter of opposite hue.
  7762. */
  7763. highlightsDensity: number;
  7764. /**
  7765. * Gets the highlights Saturation value.
  7766. * 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.
  7767. */
  7768. /**
  7769. * Sets the highlights Saturation value.
  7770. * 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.
  7771. */
  7772. highlightsSaturation: number;
  7773. /**
  7774. * Gets the highlights Exposure value.
  7775. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7776. */
  7777. /**
  7778. * Sets the highlights Exposure value.
  7779. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7780. */
  7781. highlightsExposure: number;
  7782. private _midtonesHue;
  7783. private _midtonesDensity;
  7784. private _midtonesSaturation;
  7785. private _midtonesExposure;
  7786. /**
  7787. * Gets the midtones Hue value.
  7788. * 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).
  7789. */
  7790. /**
  7791. * Sets the midtones Hue value.
  7792. * 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).
  7793. */
  7794. midtonesHue: number;
  7795. /**
  7796. * Gets the midtones Density value.
  7797. * 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.
  7798. * Values less than zero provide a filter of opposite hue.
  7799. */
  7800. /**
  7801. * Sets the midtones Density value.
  7802. * 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.
  7803. * Values less than zero provide a filter of opposite hue.
  7804. */
  7805. midtonesDensity: number;
  7806. /**
  7807. * Gets the midtones Saturation value.
  7808. * 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.
  7809. */
  7810. /**
  7811. * Sets the midtones Saturation value.
  7812. * 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.
  7813. */
  7814. midtonesSaturation: number;
  7815. /**
  7816. * Gets the midtones Exposure value.
  7817. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7818. */
  7819. /**
  7820. * Sets the midtones Exposure value.
  7821. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7822. */
  7823. midtonesExposure: number;
  7824. private _shadowsHue;
  7825. private _shadowsDensity;
  7826. private _shadowsSaturation;
  7827. private _shadowsExposure;
  7828. /**
  7829. * Gets the shadows Hue value.
  7830. * 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).
  7831. */
  7832. /**
  7833. * Sets the shadows Hue value.
  7834. * 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).
  7835. */
  7836. shadowsHue: number;
  7837. /**
  7838. * Gets the shadows Density value.
  7839. * 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.
  7840. * Values less than zero provide a filter of opposite hue.
  7841. */
  7842. /**
  7843. * Sets the shadows Density value.
  7844. * 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.
  7845. * Values less than zero provide a filter of opposite hue.
  7846. */
  7847. shadowsDensity: number;
  7848. /**
  7849. * Gets the shadows Saturation value.
  7850. * 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.
  7851. */
  7852. /**
  7853. * Sets the shadows Saturation value.
  7854. * 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.
  7855. */
  7856. shadowsSaturation: number;
  7857. /**
  7858. * Gets the shadows Exposure value.
  7859. * 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.
  7860. */
  7861. /**
  7862. * Sets the shadows Exposure value.
  7863. * 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.
  7864. */
  7865. shadowsExposure: number;
  7866. /**
  7867. * Returns the class name
  7868. * @returns The class name
  7869. */
  7870. getClassName(): string;
  7871. /**
  7872. * Binds the color curves to the shader.
  7873. * @param colorCurves The color curve to bind
  7874. * @param effect The effect to bind to
  7875. * @param positiveUniform The positive uniform shader parameter
  7876. * @param neutralUniform The neutral uniform shader parameter
  7877. * @param negativeUniform The negative uniform shader parameter
  7878. */
  7879. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7880. /**
  7881. * Prepare the list of uniforms associated with the ColorCurves effects.
  7882. * @param uniformsList The list of uniforms used in the effect
  7883. */
  7884. static PrepareUniforms(uniformsList: string[]): void;
  7885. /**
  7886. * Returns color grading data based on a hue, density, saturation and exposure value.
  7887. * @param filterHue The hue of the color filter.
  7888. * @param filterDensity The density of the color filter.
  7889. * @param saturation The saturation.
  7890. * @param exposure The exposure.
  7891. * @param result The result data container.
  7892. */
  7893. private getColorGradingDataToRef;
  7894. /**
  7895. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7896. * @param value The input slider value in range [-100,100].
  7897. * @returns Adjusted value.
  7898. */
  7899. private static applyColorGradingSliderNonlinear;
  7900. /**
  7901. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7902. * @param hue The hue (H) input.
  7903. * @param saturation The saturation (S) input.
  7904. * @param brightness The brightness (B) input.
  7905. * @result An RGBA color represented as Vector4.
  7906. */
  7907. private static fromHSBToRef;
  7908. /**
  7909. * Returns a value clamped between min and max
  7910. * @param value The value to clamp
  7911. * @param min The minimum of value
  7912. * @param max The maximum of value
  7913. * @returns The clamped value.
  7914. */
  7915. private static clamp;
  7916. /**
  7917. * Clones the current color curve instance.
  7918. * @return The cloned curves
  7919. */
  7920. clone(): ColorCurves;
  7921. /**
  7922. * Serializes the current color curve instance to a json representation.
  7923. * @return a JSON representation
  7924. */
  7925. serialize(): any;
  7926. /**
  7927. * Parses the color curve from a json representation.
  7928. * @param source the JSON source to parse
  7929. * @return The parsed curves
  7930. */
  7931. static Parse(source: any): ColorCurves;
  7932. }
  7933. }
  7934. declare module BABYLON {
  7935. /**
  7936. * Interface to follow in your material defines to integrate easily the
  7937. * Image proccessing functions.
  7938. * @hidden
  7939. */
  7940. export interface IImageProcessingConfigurationDefines {
  7941. IMAGEPROCESSING: boolean;
  7942. VIGNETTE: boolean;
  7943. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7944. VIGNETTEBLENDMODEOPAQUE: boolean;
  7945. TONEMAPPING: boolean;
  7946. TONEMAPPING_ACES: boolean;
  7947. CONTRAST: boolean;
  7948. EXPOSURE: boolean;
  7949. COLORCURVES: boolean;
  7950. COLORGRADING: boolean;
  7951. COLORGRADING3D: boolean;
  7952. SAMPLER3DGREENDEPTH: boolean;
  7953. SAMPLER3DBGRMAP: boolean;
  7954. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7955. }
  7956. /**
  7957. * @hidden
  7958. */
  7959. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7960. IMAGEPROCESSING: boolean;
  7961. VIGNETTE: boolean;
  7962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7963. VIGNETTEBLENDMODEOPAQUE: boolean;
  7964. TONEMAPPING: boolean;
  7965. TONEMAPPING_ACES: boolean;
  7966. CONTRAST: boolean;
  7967. COLORCURVES: boolean;
  7968. COLORGRADING: boolean;
  7969. COLORGRADING3D: boolean;
  7970. SAMPLER3DGREENDEPTH: boolean;
  7971. SAMPLER3DBGRMAP: boolean;
  7972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7973. EXPOSURE: boolean;
  7974. constructor();
  7975. }
  7976. /**
  7977. * This groups together the common properties used for image processing either in direct forward pass
  7978. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7979. * or not.
  7980. */
  7981. export class ImageProcessingConfiguration {
  7982. /**
  7983. * Default tone mapping applied in BabylonJS.
  7984. */
  7985. static readonly TONEMAPPING_STANDARD: number;
  7986. /**
  7987. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7988. * to other engines rendering to increase portability.
  7989. */
  7990. static readonly TONEMAPPING_ACES: number;
  7991. /**
  7992. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7993. */
  7994. colorCurves: Nullable<ColorCurves>;
  7995. private _colorCurvesEnabled;
  7996. /**
  7997. * Gets wether the color curves effect is enabled.
  7998. */
  7999. /**
  8000. * Sets wether the color curves effect is enabled.
  8001. */
  8002. colorCurvesEnabled: boolean;
  8003. private _colorGradingTexture;
  8004. /**
  8005. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8006. */
  8007. /**
  8008. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8009. */
  8010. colorGradingTexture: Nullable<BaseTexture>;
  8011. private _colorGradingEnabled;
  8012. /**
  8013. * Gets wether the color grading effect is enabled.
  8014. */
  8015. /**
  8016. * Sets wether the color grading effect is enabled.
  8017. */
  8018. colorGradingEnabled: boolean;
  8019. private _colorGradingWithGreenDepth;
  8020. /**
  8021. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8022. */
  8023. /**
  8024. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8025. */
  8026. colorGradingWithGreenDepth: boolean;
  8027. private _colorGradingBGR;
  8028. /**
  8029. * Gets wether the color grading texture contains BGR values.
  8030. */
  8031. /**
  8032. * Sets wether the color grading texture contains BGR values.
  8033. */
  8034. colorGradingBGR: boolean;
  8035. /** @hidden */ private _exposure: number;
  8036. /**
  8037. * Gets the Exposure used in the effect.
  8038. */
  8039. /**
  8040. * Sets the Exposure used in the effect.
  8041. */
  8042. exposure: number;
  8043. private _toneMappingEnabled;
  8044. /**
  8045. * Gets wether the tone mapping effect is enabled.
  8046. */
  8047. /**
  8048. * Sets wether the tone mapping effect is enabled.
  8049. */
  8050. toneMappingEnabled: boolean;
  8051. private _toneMappingType;
  8052. /**
  8053. * Gets the type of tone mapping effect.
  8054. */
  8055. /**
  8056. * Sets the type of tone mapping effect used in BabylonJS.
  8057. */
  8058. toneMappingType: number;
  8059. protected _contrast: number;
  8060. /**
  8061. * Gets the contrast used in the effect.
  8062. */
  8063. /**
  8064. * Sets the contrast used in the effect.
  8065. */
  8066. contrast: number;
  8067. /**
  8068. * Vignette stretch size.
  8069. */
  8070. vignetteStretch: number;
  8071. /**
  8072. * Vignette centre X Offset.
  8073. */
  8074. vignetteCentreX: number;
  8075. /**
  8076. * Vignette centre Y Offset.
  8077. */
  8078. vignetteCentreY: number;
  8079. /**
  8080. * Vignette weight or intensity of the vignette effect.
  8081. */
  8082. vignetteWeight: number;
  8083. /**
  8084. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8085. * if vignetteEnabled is set to true.
  8086. */
  8087. vignetteColor: Color4;
  8088. /**
  8089. * Camera field of view used by the Vignette effect.
  8090. */
  8091. vignetteCameraFov: number;
  8092. private _vignetteBlendMode;
  8093. /**
  8094. * Gets the vignette blend mode allowing different kind of effect.
  8095. */
  8096. /**
  8097. * Sets the vignette blend mode allowing different kind of effect.
  8098. */
  8099. vignetteBlendMode: number;
  8100. private _vignetteEnabled;
  8101. /**
  8102. * Gets wether the vignette effect is enabled.
  8103. */
  8104. /**
  8105. * Sets wether the vignette effect is enabled.
  8106. */
  8107. vignetteEnabled: boolean;
  8108. private _applyByPostProcess;
  8109. /**
  8110. * Gets wether the image processing is applied through a post process or not.
  8111. */
  8112. /**
  8113. * Sets wether the image processing is applied through a post process or not.
  8114. */
  8115. applyByPostProcess: boolean;
  8116. private _isEnabled;
  8117. /**
  8118. * Gets wether the image processing is enabled or not.
  8119. */
  8120. /**
  8121. * Sets wether the image processing is enabled or not.
  8122. */
  8123. isEnabled: boolean;
  8124. /**
  8125. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8126. */
  8127. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8128. /**
  8129. * Method called each time the image processing information changes requires to recompile the effect.
  8130. */
  8131. protected _updateParameters(): void;
  8132. /**
  8133. * Gets the current class name.
  8134. * @return "ImageProcessingConfiguration"
  8135. */
  8136. getClassName(): string;
  8137. /**
  8138. * Prepare the list of uniforms associated with the Image Processing effects.
  8139. * @param uniforms The list of uniforms used in the effect
  8140. * @param defines the list of defines currently in use
  8141. */
  8142. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8143. /**
  8144. * Prepare the list of samplers associated with the Image Processing effects.
  8145. * @param samplersList The list of uniforms used in the effect
  8146. * @param defines the list of defines currently in use
  8147. */
  8148. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8149. /**
  8150. * Prepare the list of defines associated to the shader.
  8151. * @param defines the list of defines to complete
  8152. * @param forPostProcess Define if we are currently in post process mode or not
  8153. */
  8154. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8155. /**
  8156. * Returns true if all the image processing information are ready.
  8157. * @returns True if ready, otherwise, false
  8158. */
  8159. isReady(): boolean;
  8160. /**
  8161. * Binds the image processing to the shader.
  8162. * @param effect The effect to bind to
  8163. * @param overrideAspectRatio Override the aspect ratio of the effect
  8164. */
  8165. bind(effect: Effect, overrideAspectRatio?: number): void;
  8166. /**
  8167. * Clones the current image processing instance.
  8168. * @return The cloned image processing
  8169. */
  8170. clone(): ImageProcessingConfiguration;
  8171. /**
  8172. * Serializes the current image processing instance to a json representation.
  8173. * @return a JSON representation
  8174. */
  8175. serialize(): any;
  8176. /**
  8177. * Parses the image processing from a json representation.
  8178. * @param source the JSON source to parse
  8179. * @return The parsed image processing
  8180. */
  8181. static Parse(source: any): ImageProcessingConfiguration;
  8182. private static _VIGNETTEMODE_MULTIPLY;
  8183. private static _VIGNETTEMODE_OPAQUE;
  8184. /**
  8185. * Used to apply the vignette as a mix with the pixel color.
  8186. */
  8187. static readonly VIGNETTEMODE_MULTIPLY: number;
  8188. /**
  8189. * Used to apply the vignette as a replacement of the pixel color.
  8190. */
  8191. static readonly VIGNETTEMODE_OPAQUE: number;
  8192. }
  8193. }
  8194. declare module BABYLON {
  8195. /** @hidden */
  8196. export var postprocessVertexShader: {
  8197. name: string;
  8198. shader: string;
  8199. };
  8200. }
  8201. declare module BABYLON {
  8202. interface ThinEngine {
  8203. /**
  8204. * Creates a new render target texture
  8205. * @param size defines the size of the texture
  8206. * @param options defines the options used to create the texture
  8207. * @returns a new render target texture stored in an InternalTexture
  8208. */
  8209. createRenderTargetTexture(size: number | {
  8210. width: number;
  8211. height: number;
  8212. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8213. /**
  8214. * Creates a depth stencil texture.
  8215. * This is only available in WebGL 2 or with the depth texture extension available.
  8216. * @param size The size of face edge in the texture.
  8217. * @param options The options defining the texture.
  8218. * @returns The texture
  8219. */
  8220. createDepthStencilTexture(size: number | {
  8221. width: number;
  8222. height: number;
  8223. }, options: DepthTextureCreationOptions): InternalTexture;
  8224. /** @hidden */ private _createDepthStencilTexture(size: number | {
  8225. width: number;
  8226. height: number;
  8227. }, options: DepthTextureCreationOptions): InternalTexture;
  8228. }
  8229. }
  8230. declare module BABYLON {
  8231. /** Defines supported spaces */
  8232. export enum Space {
  8233. /** Local (object) space */
  8234. LOCAL = 0,
  8235. /** World space */
  8236. WORLD = 1,
  8237. /** Bone space */
  8238. BONE = 2
  8239. }
  8240. /** Defines the 3 main axes */
  8241. export class Axis {
  8242. /** X axis */
  8243. static X: Vector3;
  8244. /** Y axis */
  8245. static Y: Vector3;
  8246. /** Z axis */
  8247. static Z: Vector3;
  8248. }
  8249. }
  8250. declare module BABYLON {
  8251. /**
  8252. * A target camera 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. */
  8256. export class TargetCamera extends Camera {
  8257. private static _RigCamTransformMatrix;
  8258. private static _TargetTransformMatrix;
  8259. private static _TargetFocalPoint;
  8260. /**
  8261. * Define the current direction the camera is moving to
  8262. */
  8263. cameraDirection: Vector3;
  8264. /**
  8265. * Define the current rotation the camera is rotating to
  8266. */
  8267. cameraRotation: Vector2;
  8268. /**
  8269. * When set, the up vector of the camera will be updated by the rotation of the camera
  8270. */
  8271. updateUpVectorFromRotation: boolean;
  8272. private _tmpQuaternion;
  8273. /**
  8274. * Define the current rotation of the camera
  8275. */
  8276. rotation: Vector3;
  8277. /**
  8278. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8279. */
  8280. rotationQuaternion: Quaternion;
  8281. /**
  8282. * Define the current speed of the camera
  8283. */
  8284. speed: number;
  8285. /**
  8286. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8287. * around all axis.
  8288. */
  8289. noRotationConstraint: boolean;
  8290. /**
  8291. * Define the current target of the camera as an object or a position.
  8292. */
  8293. lockedTarget: any;
  8294. /** @hidden */ private _currentTarget: Vector3;
  8295. /** @hidden */ private _initialFocalDistance: number;
  8296. /** @hidden */ private _viewMatrix: Matrix;
  8297. /** @hidden */ private _camMatrix: Matrix;
  8298. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8299. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8300. /** @hidden */ private _referencePoint: Vector3;
  8301. /** @hidden */ private _transformedReferencePoint: Vector3;
  8302. protected _globalCurrentTarget: Vector3;
  8303. protected _globalCurrentUpVector: Vector3;
  8304. /** @hidden */ private _reset: () => void;
  8305. private _defaultUp;
  8306. /**
  8307. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8308. * This is the base of the follow, arc rotate cameras and Free camera
  8309. * @see http://doc.babylonjs.com/features/cameras
  8310. * @param name Defines the name of the camera in the scene
  8311. * @param position Defines the start position of the camera in the scene
  8312. * @param scene Defines the scene the camera belongs to
  8313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8314. */
  8315. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8316. /**
  8317. * Gets the position in front of the camera at a given distance.
  8318. * @param distance The distance from the camera we want the position to be
  8319. * @returns the position
  8320. */
  8321. getFrontPosition(distance: number): Vector3;
  8322. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8323. private _storedPosition;
  8324. private _storedRotation;
  8325. private _storedRotationQuaternion;
  8326. /**
  8327. * Store current camera state of the camera (fov, position, rotation, etc..)
  8328. * @returns the camera
  8329. */
  8330. storeState(): Camera;
  8331. /**
  8332. * Restored camera state. You must call storeState() first
  8333. * @returns whether it was successful or not
  8334. * @hidden
  8335. */ private _restoreStateValues(): boolean;
  8336. /** @hidden */ private _initCache(): void;
  8337. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8339. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8340. /**
  8341. * Defines the target the camera should look at.
  8342. * @param target Defines the new target as a Vector or a mesh
  8343. */
  8344. setTarget(target: Vector3): void;
  8345. /**
  8346. * Return the current target position of the camera. This value is expressed in local space.
  8347. * @returns the target position
  8348. */
  8349. getTarget(): Vector3;
  8350. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8351. /** @hidden */ private _updatePosition(): void;
  8352. /** @hidden */ private _checkInputs(): void;
  8353. protected _updateCameraRotationMatrix(): void;
  8354. /**
  8355. * 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)
  8356. * @returns the current camera
  8357. */
  8358. private _rotateUpVectorWithCameraRotationMatrix;
  8359. private _cachedRotationZ;
  8360. private _cachedQuaternionRotationZ;
  8361. /** @hidden */ private _getViewMatrix(): Matrix;
  8362. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8363. /**
  8364. * @hidden
  8365. */
  8366. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8367. /**
  8368. * @hidden
  8369. */ private _updateRigCameras(): void;
  8370. private _getRigCamPositionAndTarget;
  8371. /**
  8372. * Gets the current object class name.
  8373. * @return the class name
  8374. */
  8375. getClassName(): string;
  8376. }
  8377. }
  8378. declare module BABYLON {
  8379. /**
  8380. * Gather the list of keyboard event types as constants.
  8381. */
  8382. export class KeyboardEventTypes {
  8383. /**
  8384. * The keydown event is fired when a key becomes active (pressed).
  8385. */
  8386. static readonly KEYDOWN: number;
  8387. /**
  8388. * The keyup event is fired when a key has been released.
  8389. */
  8390. static readonly KEYUP: number;
  8391. }
  8392. /**
  8393. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8394. */
  8395. export class KeyboardInfo {
  8396. /**
  8397. * Defines the type of event (KeyboardEventTypes)
  8398. */
  8399. type: number;
  8400. /**
  8401. * Defines the related dom event
  8402. */
  8403. event: KeyboardEvent;
  8404. /**
  8405. * Instantiates a new keyboard info.
  8406. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8407. * @param type Defines the type of event (KeyboardEventTypes)
  8408. * @param event Defines the related dom event
  8409. */
  8410. constructor(
  8411. /**
  8412. * Defines the type of event (KeyboardEventTypes)
  8413. */
  8414. type: number,
  8415. /**
  8416. * Defines the related dom event
  8417. */
  8418. event: KeyboardEvent);
  8419. }
  8420. /**
  8421. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8422. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8423. */
  8424. export class KeyboardInfoPre extends KeyboardInfo {
  8425. /**
  8426. * Defines the type of event (KeyboardEventTypes)
  8427. */
  8428. type: number;
  8429. /**
  8430. * Defines the related dom event
  8431. */
  8432. event: KeyboardEvent;
  8433. /**
  8434. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8435. */
  8436. skipOnPointerObservable: boolean;
  8437. /**
  8438. * Instantiates a new keyboard pre info.
  8439. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8440. * @param type Defines the type of event (KeyboardEventTypes)
  8441. * @param event Defines the related dom event
  8442. */
  8443. constructor(
  8444. /**
  8445. * Defines the type of event (KeyboardEventTypes)
  8446. */
  8447. type: number,
  8448. /**
  8449. * Defines the related dom event
  8450. */
  8451. event: KeyboardEvent);
  8452. }
  8453. }
  8454. declare module BABYLON {
  8455. /**
  8456. * Manage the keyboard inputs to control the movement of a free camera.
  8457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8458. */
  8459. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8460. /**
  8461. * Defines the camera the input is attached to.
  8462. */
  8463. camera: FreeCamera;
  8464. /**
  8465. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8466. */
  8467. keysUp: number[];
  8468. /**
  8469. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8470. */
  8471. keysDown: number[];
  8472. /**
  8473. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8474. */
  8475. keysLeft: number[];
  8476. /**
  8477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8478. */
  8479. keysRight: number[];
  8480. private _keys;
  8481. private _onCanvasBlurObserver;
  8482. private _onKeyboardObserver;
  8483. private _engine;
  8484. private _scene;
  8485. /**
  8486. * Attach the input controls to a specific dom element to get the input from.
  8487. * @param element Defines the element the controls should be listened from
  8488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8489. */
  8490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8491. /**
  8492. * Detach the current controls from the specified dom element.
  8493. * @param element Defines the element to stop listening the inputs from
  8494. */
  8495. detachControl(element: Nullable<HTMLElement>): void;
  8496. /**
  8497. * Update the current camera state depending on the inputs that have been used this frame.
  8498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8499. */
  8500. checkInputs(): void;
  8501. /**
  8502. * Gets the class name of the current intput.
  8503. * @returns the class name
  8504. */
  8505. getClassName(): string;
  8506. /** @hidden */ private _onLostFocus(): void;
  8507. /**
  8508. * Get the friendly name associated with the input class.
  8509. * @returns the input friendly name
  8510. */
  8511. getSimpleName(): string;
  8512. }
  8513. }
  8514. declare module BABYLON {
  8515. /**
  8516. * Interface describing all the common properties and methods a shadow light needs to implement.
  8517. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8518. * as well as binding the different shadow properties to the effects.
  8519. */
  8520. export interface IShadowLight extends Light {
  8521. /**
  8522. * The light id in the scene (used in scene.findLighById for instance)
  8523. */
  8524. id: string;
  8525. /**
  8526. * The position the shdow will be casted from.
  8527. */
  8528. position: Vector3;
  8529. /**
  8530. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8531. */
  8532. direction: Vector3;
  8533. /**
  8534. * The transformed position. Position of the light in world space taking parenting in account.
  8535. */
  8536. transformedPosition: Vector3;
  8537. /**
  8538. * The transformed direction. Direction of the light in world space taking parenting in account.
  8539. */
  8540. transformedDirection: Vector3;
  8541. /**
  8542. * The friendly name of the light in the scene.
  8543. */
  8544. name: string;
  8545. /**
  8546. * Defines the shadow projection clipping minimum z value.
  8547. */
  8548. shadowMinZ: number;
  8549. /**
  8550. * Defines the shadow projection clipping maximum z value.
  8551. */
  8552. shadowMaxZ: number;
  8553. /**
  8554. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8555. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8556. */
  8557. computeTransformedInformation(): boolean;
  8558. /**
  8559. * Gets the scene the light belongs to.
  8560. * @returns The scene
  8561. */
  8562. getScene(): Scene;
  8563. /**
  8564. * Callback defining a custom Projection Matrix Builder.
  8565. * This can be used to override the default projection matrix computation.
  8566. */
  8567. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8568. /**
  8569. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8570. * @param matrix The materix to updated with the projection information
  8571. * @param viewMatrix The transform matrix of the light
  8572. * @param renderList The list of mesh to render in the map
  8573. * @returns The current light
  8574. */
  8575. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8576. /**
  8577. * Gets the current depth scale used in ESM.
  8578. * @returns The scale
  8579. */
  8580. getDepthScale(): number;
  8581. /**
  8582. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8583. * @returns true if a cube texture needs to be use
  8584. */
  8585. needCube(): boolean;
  8586. /**
  8587. * Detects if the projection matrix requires to be recomputed this frame.
  8588. * @returns true if it requires to be recomputed otherwise, false.
  8589. */
  8590. needProjectionMatrixCompute(): boolean;
  8591. /**
  8592. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8593. */
  8594. forceProjectionMatrixCompute(): void;
  8595. /**
  8596. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8597. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8598. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8599. */
  8600. getShadowDirection(faceIndex?: number): Vector3;
  8601. /**
  8602. * Gets the minZ used for shadow according to both the scene and the light.
  8603. * @param activeCamera The camera we are returning the min for
  8604. * @returns the depth min z
  8605. */
  8606. getDepthMinZ(activeCamera: Camera): number;
  8607. /**
  8608. * Gets the maxZ used for shadow according to both the scene and the light.
  8609. * @param activeCamera The camera we are returning the max for
  8610. * @returns the depth max z
  8611. */
  8612. getDepthMaxZ(activeCamera: Camera): number;
  8613. }
  8614. /**
  8615. * Base implementation IShadowLight
  8616. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8617. */
  8618. export abstract class ShadowLight extends Light implements IShadowLight {
  8619. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8620. protected _position: Vector3;
  8621. protected _setPosition(value: Vector3): void;
  8622. /**
  8623. * Sets the position the shadow will be casted from. Also use as the light position for both
  8624. * point and spot lights.
  8625. */
  8626. /**
  8627. * Sets the position the shadow will be casted from. Also use as the light position for both
  8628. * point and spot lights.
  8629. */
  8630. position: Vector3;
  8631. protected _direction: Vector3;
  8632. protected _setDirection(value: Vector3): void;
  8633. /**
  8634. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8635. * Also use as the light direction on spot and directional lights.
  8636. */
  8637. /**
  8638. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8639. * Also use as the light direction on spot and directional lights.
  8640. */
  8641. direction: Vector3;
  8642. private _shadowMinZ;
  8643. /**
  8644. * Gets the shadow projection clipping minimum z value.
  8645. */
  8646. /**
  8647. * Sets the shadow projection clipping minimum z value.
  8648. */
  8649. shadowMinZ: number;
  8650. private _shadowMaxZ;
  8651. /**
  8652. * Sets the shadow projection clipping maximum z value.
  8653. */
  8654. /**
  8655. * Gets the shadow projection clipping maximum z value.
  8656. */
  8657. shadowMaxZ: number;
  8658. /**
  8659. * Callback defining a custom Projection Matrix Builder.
  8660. * This can be used to override the default projection matrix computation.
  8661. */
  8662. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8663. /**
  8664. * The transformed position. Position of the light in world space taking parenting in account.
  8665. */
  8666. transformedPosition: Vector3;
  8667. /**
  8668. * The transformed direction. Direction of the light in world space taking parenting in account.
  8669. */
  8670. transformedDirection: Vector3;
  8671. private _needProjectionMatrixCompute;
  8672. /**
  8673. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8674. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8675. */
  8676. computeTransformedInformation(): boolean;
  8677. /**
  8678. * Return the depth scale used for the shadow map.
  8679. * @returns the depth scale.
  8680. */
  8681. getDepthScale(): number;
  8682. /**
  8683. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8684. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8685. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8686. */
  8687. getShadowDirection(faceIndex?: number): Vector3;
  8688. /**
  8689. * Returns the ShadowLight absolute position in the World.
  8690. * @returns the position vector in world space
  8691. */
  8692. getAbsolutePosition(): Vector3;
  8693. /**
  8694. * Sets the ShadowLight direction toward the passed target.
  8695. * @param target The point to target in local space
  8696. * @returns the updated ShadowLight direction
  8697. */
  8698. setDirectionToTarget(target: Vector3): Vector3;
  8699. /**
  8700. * Returns the light rotation in euler definition.
  8701. * @returns the x y z rotation in local space.
  8702. */
  8703. getRotation(): Vector3;
  8704. /**
  8705. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8706. * @returns true if a cube texture needs to be use
  8707. */
  8708. needCube(): boolean;
  8709. /**
  8710. * Detects if the projection matrix requires to be recomputed this frame.
  8711. * @returns true if it requires to be recomputed otherwise, false.
  8712. */
  8713. needProjectionMatrixCompute(): boolean;
  8714. /**
  8715. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8716. */
  8717. forceProjectionMatrixCompute(): void;
  8718. /** @hidden */ private _initCache(): void;
  8719. /** @hidden */ private _isSynchronized(): boolean;
  8720. /**
  8721. * Computes the world matrix of the node
  8722. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8723. * @returns the world matrix
  8724. */
  8725. computeWorldMatrix(force?: boolean): Matrix;
  8726. /**
  8727. * Gets the minZ used for shadow according to both the scene and the light.
  8728. * @param activeCamera The camera we are returning the min for
  8729. * @returns the depth min z
  8730. */
  8731. getDepthMinZ(activeCamera: Camera): number;
  8732. /**
  8733. * Gets the maxZ used for shadow according to both the scene and the light.
  8734. * @param activeCamera The camera we are returning the max for
  8735. * @returns the depth max z
  8736. */
  8737. getDepthMaxZ(activeCamera: Camera): number;
  8738. /**
  8739. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8740. * @param matrix The materix to updated with the projection information
  8741. * @param viewMatrix The transform matrix of the light
  8742. * @param renderList The list of mesh to render in the map
  8743. * @returns The current light
  8744. */
  8745. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8746. }
  8747. }
  8748. declare module BABYLON {
  8749. /**
  8750. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8751. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8752. */
  8753. export class EffectFallbacks implements IEffectFallbacks {
  8754. private _defines;
  8755. private _currentRank;
  8756. private _maxRank;
  8757. private _mesh;
  8758. /**
  8759. * Removes the fallback from the bound mesh.
  8760. */
  8761. unBindMesh(): void;
  8762. /**
  8763. * Adds a fallback on the specified property.
  8764. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8765. * @param define The name of the define in the shader
  8766. */
  8767. addFallback(rank: number, define: string): void;
  8768. /**
  8769. * Sets the mesh to use CPU skinning when needing to fallback.
  8770. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8771. * @param mesh The mesh to use the fallbacks.
  8772. */
  8773. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8774. /**
  8775. * Checks to see if more fallbacks are still availible.
  8776. */
  8777. readonly hasMoreFallbacks: boolean;
  8778. /**
  8779. * Removes the defines that should be removed when falling back.
  8780. * @param currentDefines defines the current define statements for the shader.
  8781. * @param effect defines the current effect we try to compile
  8782. * @returns The resulting defines with defines of the current rank removed.
  8783. */
  8784. reduce(currentDefines: string, effect: Effect): string;
  8785. }
  8786. }
  8787. declare module BABYLON {
  8788. /**
  8789. * "Static Class" containing the most commonly used helper while dealing with material for
  8790. * rendering purpose.
  8791. *
  8792. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8793. *
  8794. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8795. */
  8796. export class MaterialHelper {
  8797. /**
  8798. * Bind the current view position to an effect.
  8799. * @param effect The effect to be bound
  8800. * @param scene The scene the eyes position is used from
  8801. */
  8802. static BindEyePosition(effect: Effect, scene: Scene): void;
  8803. /**
  8804. * Helps preparing the defines values about the UVs in used in the effect.
  8805. * UVs are shared as much as we can accross channels in the shaders.
  8806. * @param texture The texture we are preparing the UVs for
  8807. * @param defines The defines to update
  8808. * @param key The channel key "diffuse", "specular"... used in the shader
  8809. */
  8810. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8811. /**
  8812. * Binds a texture matrix value to its corrsponding uniform
  8813. * @param texture The texture to bind the matrix for
  8814. * @param uniformBuffer The uniform buffer receivin the data
  8815. * @param key The channel key "diffuse", "specular"... used in the shader
  8816. */
  8817. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8818. /**
  8819. * Gets the current status of the fog (should it be enabled?)
  8820. * @param mesh defines the mesh to evaluate for fog support
  8821. * @param scene defines the hosting scene
  8822. * @returns true if fog must be enabled
  8823. */
  8824. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8825. /**
  8826. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8827. * @param mesh defines the current mesh
  8828. * @param scene defines the current scene
  8829. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8830. * @param pointsCloud defines if point cloud rendering has to be turned on
  8831. * @param fogEnabled defines if fog has to be turned on
  8832. * @param alphaTest defines if alpha testing has to be turned on
  8833. * @param defines defines the current list of defines
  8834. */
  8835. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8836. /**
  8837. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8838. * @param scene defines the current scene
  8839. * @param engine defines the current engine
  8840. * @param defines specifies the list of active defines
  8841. * @param useInstances defines if instances have to be turned on
  8842. * @param useClipPlane defines if clip plane have to be turned on
  8843. */
  8844. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8845. /**
  8846. * Prepares the defines for bones
  8847. * @param mesh The mesh containing the geometry data we will draw
  8848. * @param defines The defines to update
  8849. */
  8850. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8851. /**
  8852. * Prepares the defines for morph targets
  8853. * @param mesh The mesh containing the geometry data we will draw
  8854. * @param defines The defines to update
  8855. */
  8856. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8857. /**
  8858. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8859. * @param mesh The mesh containing the geometry data we will draw
  8860. * @param defines The defines to update
  8861. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8862. * @param useBones Precise whether bones should be used or not (override mesh info)
  8863. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8864. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8865. * @returns false if defines are considered not dirty and have not been checked
  8866. */
  8867. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8868. /**
  8869. * Prepares the defines related to multiview
  8870. * @param scene The scene we are intending to draw
  8871. * @param defines The defines to update
  8872. */
  8873. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8874. /**
  8875. * Prepares the defines related to the light information passed in parameter
  8876. * @param scene The scene we are intending to draw
  8877. * @param mesh The mesh the effect is compiling for
  8878. * @param light The light the effect is compiling for
  8879. * @param lightIndex The index of the light
  8880. * @param defines The defines to update
  8881. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8882. * @param state Defines the current state regarding what is needed (normals, etc...)
  8883. */
  8884. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8885. needNormals: boolean;
  8886. needRebuild: boolean;
  8887. shadowEnabled: boolean;
  8888. specularEnabled: boolean;
  8889. lightmapMode: boolean;
  8890. }): void;
  8891. /**
  8892. * Prepares the defines related to the light information passed in parameter
  8893. * @param scene The scene we are intending to draw
  8894. * @param mesh The mesh the effect is compiling for
  8895. * @param defines The defines to update
  8896. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8897. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8898. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8899. * @returns true if normals will be required for the rest of the effect
  8900. */
  8901. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8902. /**
  8903. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8904. * @param lightIndex defines the light index
  8905. * @param uniformsList The uniform list
  8906. * @param samplersList The sampler list
  8907. * @param projectedLightTexture defines if projected texture must be used
  8908. * @param uniformBuffersList defines an optional list of uniform buffers
  8909. */
  8910. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8911. /**
  8912. * Prepares the uniforms and samplers list to be used in the effect
  8913. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8914. * @param samplersList The sampler list
  8915. * @param defines The defines helping in the list generation
  8916. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8917. */
  8918. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8919. /**
  8920. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8921. * @param defines The defines to update while falling back
  8922. * @param fallbacks The authorized effect fallbacks
  8923. * @param maxSimultaneousLights The maximum number of lights allowed
  8924. * @param rank the current rank of the Effect
  8925. * @returns The newly affected rank
  8926. */
  8927. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8928. private static _TmpMorphInfluencers;
  8929. /**
  8930. * Prepares the list of attributes required for morph targets according to the effect defines.
  8931. * @param attribs The current list of supported attribs
  8932. * @param mesh The mesh to prepare the morph targets attributes for
  8933. * @param influencers The number of influencers
  8934. */
  8935. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8936. /**
  8937. * Prepares the list of attributes required for morph targets according to the effect defines.
  8938. * @param attribs The current list of supported attribs
  8939. * @param mesh The mesh to prepare the morph targets attributes for
  8940. * @param defines The current Defines of the effect
  8941. */
  8942. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8943. /**
  8944. * Prepares the list of attributes required for bones according to the effect defines.
  8945. * @param attribs The current list of supported attribs
  8946. * @param mesh The mesh to prepare the bones attributes for
  8947. * @param defines The current Defines of the effect
  8948. * @param fallbacks The current efffect fallback strategy
  8949. */
  8950. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8951. /**
  8952. * Check and prepare the list of attributes required for instances according to the effect defines.
  8953. * @param attribs The current list of supported attribs
  8954. * @param defines The current MaterialDefines of the effect
  8955. */
  8956. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8957. /**
  8958. * Add the list of attributes required for instances to the attribs array.
  8959. * @param attribs The current list of supported attribs
  8960. */
  8961. static PushAttributesForInstances(attribs: string[]): void;
  8962. /**
  8963. * Binds the light information to the effect.
  8964. * @param light The light containing the generator
  8965. * @param effect The effect we are binding the data to
  8966. * @param lightIndex The light index in the effect used to render
  8967. */
  8968. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8969. /**
  8970. * Binds the lights information from the scene to the effect for the given mesh.
  8971. * @param light Light to bind
  8972. * @param lightIndex Light index
  8973. * @param scene The scene where the light belongs to
  8974. * @param effect The effect we are binding the data to
  8975. * @param useSpecular Defines if specular is supported
  8976. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8977. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8978. */
  8979. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8980. /**
  8981. * Binds the lights information from the scene to the effect for the given mesh.
  8982. * @param scene The scene the lights belongs to
  8983. * @param mesh The mesh we are binding the information to render
  8984. * @param effect The effect we are binding the data to
  8985. * @param defines The generated defines for the effect
  8986. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8987. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8988. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8989. */
  8990. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8991. private static _tempFogColor;
  8992. /**
  8993. * Binds the fog information from the scene to the effect for the given mesh.
  8994. * @param scene The scene the lights belongs to
  8995. * @param mesh The mesh we are binding the information to render
  8996. * @param effect The effect we are binding the data to
  8997. * @param linearSpace Defines if the fog effect is applied in linear space
  8998. */
  8999. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9000. /**
  9001. * Binds the bones information from the mesh to the effect.
  9002. * @param mesh The mesh we are binding the information to render
  9003. * @param effect The effect we are binding the data to
  9004. */
  9005. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9006. /**
  9007. * Binds the morph targets information from the mesh to the effect.
  9008. * @param abstractMesh The mesh we are binding the information to render
  9009. * @param effect The effect we are binding the data to
  9010. */
  9011. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9012. /**
  9013. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9014. * @param defines The generated defines used in the effect
  9015. * @param effect The effect we are binding the data to
  9016. * @param scene The scene we are willing to render with logarithmic scale for
  9017. */
  9018. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9019. /**
  9020. * Binds the clip plane information from the scene to the effect.
  9021. * @param scene The scene the clip plane information are extracted from
  9022. * @param effect The effect we are binding the data to
  9023. */
  9024. static BindClipPlane(effect: Effect, scene: Scene): void;
  9025. }
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var packingFunctions: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var shadowMapPixelShader: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var bonesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var morphTargetsVertexGlobalDeclaration: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertexDeclaration: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesDeclaration: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var helperFunctions: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var morphTargetsVertex: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var instancesVertex: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /** @hidden */
  9092. export var bonesVertex: {
  9093. name: string;
  9094. shader: string;
  9095. };
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var shadowMapVertexShader: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var depthBoxBlurPixelShader: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /**
  9113. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9114. */
  9115. export interface ICustomShaderOptions {
  9116. /**
  9117. * Gets or sets the custom shader name to use
  9118. */
  9119. shaderName: string;
  9120. /**
  9121. * The list of attribute names used in the shader
  9122. */
  9123. attributes?: string[];
  9124. /**
  9125. * The list of unifrom names used in the shader
  9126. */
  9127. uniforms?: string[];
  9128. /**
  9129. * The list of sampler names used in the shader
  9130. */
  9131. samplers?: string[];
  9132. /**
  9133. * The list of defines used in the shader
  9134. */
  9135. defines?: string[];
  9136. }
  9137. /**
  9138. * Interface to implement to create a shadow generator compatible with BJS.
  9139. */
  9140. export interface IShadowGenerator {
  9141. /**
  9142. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9143. * @returns The render target texture if present otherwise, null
  9144. */
  9145. getShadowMap(): Nullable<RenderTargetTexture>;
  9146. /**
  9147. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9148. * @returns The render target texture if the shadow map is present otherwise, null
  9149. */
  9150. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9151. /**
  9152. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9153. * @param subMesh The submesh we want to render in the shadow map
  9154. * @param useInstances Defines wether will draw in the map using instances
  9155. * @returns true if ready otherwise, false
  9156. */
  9157. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9158. /**
  9159. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9160. * @param defines Defines of the material we want to update
  9161. * @param lightIndex Index of the light in the enabled light list of the material
  9162. */
  9163. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9164. /**
  9165. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9166. * defined in the generator but impacting the effect).
  9167. * It implies the unifroms available on the materials are the standard BJS ones.
  9168. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9169. * @param effect The effect we are binfing the information for
  9170. */
  9171. bindShadowLight(lightIndex: string, effect: Effect): void;
  9172. /**
  9173. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9174. * (eq to shadow prjection matrix * light transform matrix)
  9175. * @returns The transform matrix used to create the shadow map
  9176. */
  9177. getTransformMatrix(): Matrix;
  9178. /**
  9179. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9180. * Cube and 2D textures for instance.
  9181. */
  9182. recreateShadowMap(): void;
  9183. /**
  9184. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9185. * @param onCompiled Callback triggered at the and of the effects compilation
  9186. * @param options Sets of optional options forcing the compilation with different modes
  9187. */
  9188. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9189. useInstances: boolean;
  9190. }>): void;
  9191. /**
  9192. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9193. * @param options Sets of optional options forcing the compilation with different modes
  9194. * @returns A promise that resolves when the compilation completes
  9195. */
  9196. forceCompilationAsync(options?: Partial<{
  9197. useInstances: boolean;
  9198. }>): Promise<void>;
  9199. /**
  9200. * Serializes the shadow generator setup to a json object.
  9201. * @returns The serialized JSON object
  9202. */
  9203. serialize(): any;
  9204. /**
  9205. * Disposes the Shadow map and related Textures and effects.
  9206. */
  9207. dispose(): void;
  9208. }
  9209. /**
  9210. * Default implementation IShadowGenerator.
  9211. * This is the main object responsible of generating shadows in the framework.
  9212. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9213. */
  9214. export class ShadowGenerator implements IShadowGenerator {
  9215. /**
  9216. * Shadow generator mode None: no filtering applied.
  9217. */
  9218. static readonly FILTER_NONE: number;
  9219. /**
  9220. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9222. */
  9223. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9224. /**
  9225. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9226. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9227. */
  9228. static readonly FILTER_POISSONSAMPLING: number;
  9229. /**
  9230. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9231. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9232. */
  9233. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9234. /**
  9235. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9236. * edge artifacts on steep falloff.
  9237. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9238. */
  9239. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9240. /**
  9241. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9242. * edge artifacts on steep falloff.
  9243. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9244. */
  9245. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9246. /**
  9247. * Shadow generator mode PCF: Percentage Closer Filtering
  9248. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9249. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9250. */
  9251. static readonly FILTER_PCF: number;
  9252. /**
  9253. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9254. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9255. * Contact Hardening
  9256. */
  9257. static readonly FILTER_PCSS: number;
  9258. /**
  9259. * Reserved for PCF and PCSS
  9260. * Highest Quality.
  9261. *
  9262. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9263. *
  9264. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9265. */
  9266. static readonly QUALITY_HIGH: number;
  9267. /**
  9268. * Reserved for PCF and PCSS
  9269. * Good tradeoff for quality/perf cross devices
  9270. *
  9271. * Execute PCF on a 3*3 kernel.
  9272. *
  9273. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9274. */
  9275. static readonly QUALITY_MEDIUM: number;
  9276. /**
  9277. * Reserved for PCF and PCSS
  9278. * The lowest quality but the fastest.
  9279. *
  9280. * Execute PCF on a 1*1 kernel.
  9281. *
  9282. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9283. */
  9284. static readonly QUALITY_LOW: number;
  9285. /** Gets or sets the custom shader name to use */
  9286. customShaderOptions: ICustomShaderOptions;
  9287. /**
  9288. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9289. */
  9290. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9291. /**
  9292. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9293. */
  9294. onAfterShadowMapRenderObservable: Observable<Effect>;
  9295. /**
  9296. * Observable triggered before a mesh is rendered in the shadow map.
  9297. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9298. */
  9299. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9300. /**
  9301. * Observable triggered after a mesh is rendered in the shadow map.
  9302. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9303. */
  9304. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9305. private _bias;
  9306. /**
  9307. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9308. */
  9309. /**
  9310. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9311. */
  9312. bias: number;
  9313. private _normalBias;
  9314. /**
  9315. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9316. */
  9317. /**
  9318. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9319. */
  9320. normalBias: number;
  9321. private _blurBoxOffset;
  9322. /**
  9323. * Gets the blur box offset: offset applied during the blur pass.
  9324. * Only useful if useKernelBlur = false
  9325. */
  9326. /**
  9327. * Sets the blur box offset: offset applied during the blur pass.
  9328. * Only useful if useKernelBlur = false
  9329. */
  9330. blurBoxOffset: number;
  9331. private _blurScale;
  9332. /**
  9333. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9334. * 2 means half of the size.
  9335. */
  9336. /**
  9337. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9338. * 2 means half of the size.
  9339. */
  9340. blurScale: number;
  9341. private _blurKernel;
  9342. /**
  9343. * Gets the blur kernel: kernel size of the blur pass.
  9344. * Only useful if useKernelBlur = true
  9345. */
  9346. /**
  9347. * Sets the blur kernel: kernel size of the blur pass.
  9348. * Only useful if useKernelBlur = true
  9349. */
  9350. blurKernel: number;
  9351. private _useKernelBlur;
  9352. /**
  9353. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9354. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9355. */
  9356. /**
  9357. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9358. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9359. */
  9360. useKernelBlur: boolean;
  9361. private _depthScale;
  9362. /**
  9363. * Gets the depth scale used in ESM mode.
  9364. */
  9365. /**
  9366. * Sets the depth scale used in ESM mode.
  9367. * This can override the scale stored on the light.
  9368. */
  9369. depthScale: number;
  9370. private _filter;
  9371. /**
  9372. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9373. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9374. */
  9375. /**
  9376. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9377. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9378. */
  9379. filter: number;
  9380. /**
  9381. * Gets if the current filter is set to Poisson Sampling.
  9382. */
  9383. /**
  9384. * Sets the current filter to Poisson Sampling.
  9385. */
  9386. usePoissonSampling: boolean;
  9387. /**
  9388. * Gets if the current filter is set to ESM.
  9389. */
  9390. /**
  9391. * Sets the current filter is to ESM.
  9392. */
  9393. useExponentialShadowMap: boolean;
  9394. /**
  9395. * Gets if the current filter is set to filtered ESM.
  9396. */
  9397. /**
  9398. * Gets if the current filter is set to filtered ESM.
  9399. */
  9400. useBlurExponentialShadowMap: boolean;
  9401. /**
  9402. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9403. * exponential to prevent steep falloff artifacts).
  9404. */
  9405. /**
  9406. * Sets the current filter to "close ESM" (using the inverse of the
  9407. * exponential to prevent steep falloff artifacts).
  9408. */
  9409. useCloseExponentialShadowMap: boolean;
  9410. /**
  9411. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9412. * exponential to prevent steep falloff artifacts).
  9413. */
  9414. /**
  9415. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9416. * exponential to prevent steep falloff artifacts).
  9417. */
  9418. useBlurCloseExponentialShadowMap: boolean;
  9419. /**
  9420. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9421. */
  9422. /**
  9423. * Sets the current filter to "PCF" (percentage closer filtering).
  9424. */
  9425. usePercentageCloserFiltering: boolean;
  9426. private _filteringQuality;
  9427. /**
  9428. * Gets the PCF or PCSS Quality.
  9429. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9430. */
  9431. /**
  9432. * Sets the PCF or PCSS Quality.
  9433. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9434. */
  9435. filteringQuality: number;
  9436. /**
  9437. * Gets if the current filter is set to "PCSS" (contact hardening).
  9438. */
  9439. /**
  9440. * Sets the current filter to "PCSS" (contact hardening).
  9441. */
  9442. useContactHardeningShadow: boolean;
  9443. private _contactHardeningLightSizeUVRatio;
  9444. /**
  9445. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9446. * Using a ratio helps keeping shape stability independently of the map size.
  9447. *
  9448. * It does not account for the light projection as it was having too much
  9449. * instability during the light setup or during light position changes.
  9450. *
  9451. * Only valid if useContactHardeningShadow is true.
  9452. */
  9453. /**
  9454. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9455. * Using a ratio helps keeping shape stability independently of the map size.
  9456. *
  9457. * It does not account for the light projection as it was having too much
  9458. * instability during the light setup or during light position changes.
  9459. *
  9460. * Only valid if useContactHardeningShadow is true.
  9461. */
  9462. contactHardeningLightSizeUVRatio: number;
  9463. private _darkness;
  9464. /** Gets or sets the actual darkness of a shadow */
  9465. darkness: number;
  9466. /**
  9467. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9468. * 0 means strongest and 1 would means no shadow.
  9469. * @returns the darkness.
  9470. */
  9471. getDarkness(): number;
  9472. /**
  9473. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9474. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9475. * @returns the shadow generator allowing fluent coding.
  9476. */
  9477. setDarkness(darkness: number): ShadowGenerator;
  9478. private _transparencyShadow;
  9479. /** Gets or sets the ability to have transparent shadow */
  9480. transparencyShadow: boolean;
  9481. /**
  9482. * Sets the ability to have transparent shadow (boolean).
  9483. * @param transparent True if transparent else False
  9484. * @returns the shadow generator allowing fluent coding
  9485. */
  9486. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9487. private _shadowMap;
  9488. private _shadowMap2;
  9489. /**
  9490. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9491. * @returns The render target texture if present otherwise, null
  9492. */
  9493. getShadowMap(): Nullable<RenderTargetTexture>;
  9494. /**
  9495. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9496. * @returns The render target texture if the shadow map is present otherwise, null
  9497. */
  9498. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9499. /**
  9500. * Gets the class name of that object
  9501. * @returns "ShadowGenerator"
  9502. */
  9503. getClassName(): string;
  9504. /**
  9505. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9506. * @param mesh Mesh to add
  9507. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9508. * @returns the Shadow Generator itself
  9509. */
  9510. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9511. /**
  9512. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9513. * @param mesh Mesh to remove
  9514. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9515. * @returns the Shadow Generator itself
  9516. */
  9517. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9518. /**
  9519. * Controls the extent to which the shadows fade out at the edge of the frustum
  9520. * Used only by directionals and spots
  9521. */
  9522. frustumEdgeFalloff: number;
  9523. private _light;
  9524. /**
  9525. * Returns the associated light object.
  9526. * @returns the light generating the shadow
  9527. */
  9528. getLight(): IShadowLight;
  9529. /**
  9530. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9531. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9532. * It might on the other hand introduce peter panning.
  9533. */
  9534. forceBackFacesOnly: boolean;
  9535. private _scene;
  9536. private _lightDirection;
  9537. private _effect;
  9538. private _viewMatrix;
  9539. private _projectionMatrix;
  9540. private _transformMatrix;
  9541. private _cachedPosition;
  9542. private _cachedDirection;
  9543. private _cachedDefines;
  9544. private _currentRenderID;
  9545. private _boxBlurPostprocess;
  9546. private _kernelBlurXPostprocess;
  9547. private _kernelBlurYPostprocess;
  9548. private _blurPostProcesses;
  9549. private _mapSize;
  9550. private _currentFaceIndex;
  9551. private _currentFaceIndexCache;
  9552. private _textureType;
  9553. private _defaultTextureMatrix;
  9554. private _storedUniqueId;
  9555. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9556. /**
  9557. * Creates a ShadowGenerator object.
  9558. * A ShadowGenerator is the required tool to use the shadows.
  9559. * Each light casting shadows needs to use its own ShadowGenerator.
  9560. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9561. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9562. * @param light The light object generating the shadows.
  9563. * @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.
  9564. */
  9565. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9566. private _initializeGenerator;
  9567. private _initializeShadowMap;
  9568. private _initializeBlurRTTAndPostProcesses;
  9569. private _renderForShadowMap;
  9570. private _renderSubMeshForShadowMap;
  9571. private _applyFilterValues;
  9572. /**
  9573. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9574. * @param onCompiled Callback triggered at the and of the effects compilation
  9575. * @param options Sets of optional options forcing the compilation with different modes
  9576. */
  9577. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9578. useInstances: boolean;
  9579. }>): void;
  9580. /**
  9581. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9582. * @param options Sets of optional options forcing the compilation with different modes
  9583. * @returns A promise that resolves when the compilation completes
  9584. */
  9585. forceCompilationAsync(options?: Partial<{
  9586. useInstances: boolean;
  9587. }>): Promise<void>;
  9588. /**
  9589. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9590. * @param subMesh The submesh we want to render in the shadow map
  9591. * @param useInstances Defines wether will draw in the map using instances
  9592. * @returns true if ready otherwise, false
  9593. */
  9594. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9595. /**
  9596. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9597. * @param defines Defines of the material we want to update
  9598. * @param lightIndex Index of the light in the enabled light list of the material
  9599. */
  9600. prepareDefines(defines: any, lightIndex: number): void;
  9601. /**
  9602. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9603. * defined in the generator but impacting the effect).
  9604. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9605. * @param effect The effect we are binfing the information for
  9606. */
  9607. bindShadowLight(lightIndex: string, effect: Effect): void;
  9608. /**
  9609. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9610. * (eq to shadow prjection matrix * light transform matrix)
  9611. * @returns The transform matrix used to create the shadow map
  9612. */
  9613. getTransformMatrix(): Matrix;
  9614. /**
  9615. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9616. * Cube and 2D textures for instance.
  9617. */
  9618. recreateShadowMap(): void;
  9619. private _disposeBlurPostProcesses;
  9620. private _disposeRTTandPostProcesses;
  9621. /**
  9622. * Disposes the ShadowGenerator.
  9623. * Returns nothing.
  9624. */
  9625. dispose(): void;
  9626. /**
  9627. * Serializes the shadow generator setup to a json object.
  9628. * @returns The serialized JSON object
  9629. */
  9630. serialize(): any;
  9631. /**
  9632. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9633. * @param parsedShadowGenerator The JSON object to parse
  9634. * @param scene The scene to create the shadow map for
  9635. * @returns The parsed shadow generator
  9636. */
  9637. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9638. }
  9639. }
  9640. declare module BABYLON {
  9641. /**
  9642. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9643. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9644. * 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.
  9645. */
  9646. export abstract class Light extends Node {
  9647. /**
  9648. * Falloff Default: light is falling off following the material specification:
  9649. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9650. */
  9651. static readonly FALLOFF_DEFAULT: number;
  9652. /**
  9653. * Falloff Physical: light is falling off following the inverse squared distance law.
  9654. */
  9655. static readonly FALLOFF_PHYSICAL: number;
  9656. /**
  9657. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9658. * to enhance interoperability with other engines.
  9659. */
  9660. static readonly FALLOFF_GLTF: number;
  9661. /**
  9662. * Falloff Standard: light is falling off like in the standard material
  9663. * to enhance interoperability with other materials.
  9664. */
  9665. static readonly FALLOFF_STANDARD: number;
  9666. /**
  9667. * If every light affecting the material is in this lightmapMode,
  9668. * material.lightmapTexture adds or multiplies
  9669. * (depends on material.useLightmapAsShadowmap)
  9670. * after every other light calculations.
  9671. */
  9672. static readonly LIGHTMAP_DEFAULT: number;
  9673. /**
  9674. * material.lightmapTexture as only diffuse lighting from this light
  9675. * adds only specular lighting from this light
  9676. * adds dynamic shadows
  9677. */
  9678. static readonly LIGHTMAP_SPECULAR: number;
  9679. /**
  9680. * material.lightmapTexture as only lighting
  9681. * no light calculation from this light
  9682. * only adds dynamic shadows from this light
  9683. */
  9684. static readonly LIGHTMAP_SHADOWSONLY: number;
  9685. /**
  9686. * Each light type uses the default quantity according to its type:
  9687. * point/spot lights use luminous intensity
  9688. * directional lights use illuminance
  9689. */
  9690. static readonly INTENSITYMODE_AUTOMATIC: number;
  9691. /**
  9692. * lumen (lm)
  9693. */
  9694. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9695. /**
  9696. * candela (lm/sr)
  9697. */
  9698. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9699. /**
  9700. * lux (lm/m^2)
  9701. */
  9702. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9703. /**
  9704. * nit (cd/m^2)
  9705. */
  9706. static readonly INTENSITYMODE_LUMINANCE: number;
  9707. /**
  9708. * Light type const id of the point light.
  9709. */
  9710. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9711. /**
  9712. * Light type const id of the directional light.
  9713. */
  9714. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9715. /**
  9716. * Light type const id of the spot light.
  9717. */
  9718. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9719. /**
  9720. * Light type const id of the hemispheric light.
  9721. */
  9722. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9723. /**
  9724. * Diffuse gives the basic color to an object.
  9725. */
  9726. diffuse: Color3;
  9727. /**
  9728. * Specular produces a highlight color on an object.
  9729. * Note: This is note affecting PBR materials.
  9730. */
  9731. specular: Color3;
  9732. /**
  9733. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9734. * falling off base on range or angle.
  9735. * This can be set to any values in Light.FALLOFF_x.
  9736. *
  9737. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9738. * other types of materials.
  9739. */
  9740. falloffType: number;
  9741. /**
  9742. * Strength of the light.
  9743. * Note: By default it is define in the framework own unit.
  9744. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9745. */
  9746. intensity: number;
  9747. private _range;
  9748. protected _inverseSquaredRange: number;
  9749. /**
  9750. * Defines how far from the source the light is impacting in scene units.
  9751. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9752. */
  9753. /**
  9754. * Defines how far from the source the light is impacting in scene units.
  9755. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9756. */
  9757. range: number;
  9758. /**
  9759. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9760. * of light.
  9761. */
  9762. private _photometricScale;
  9763. private _intensityMode;
  9764. /**
  9765. * Gets the photometric scale used to interpret the intensity.
  9766. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9767. */
  9768. /**
  9769. * Sets the photometric scale used to interpret the intensity.
  9770. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9771. */
  9772. intensityMode: number;
  9773. private _radius;
  9774. /**
  9775. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9776. */
  9777. /**
  9778. * sets the light radius used by PBR Materials to simulate soft area lights.
  9779. */
  9780. radius: number;
  9781. private _renderPriority;
  9782. /**
  9783. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9784. * exceeding the number allowed of the materials.
  9785. */
  9786. renderPriority: number;
  9787. private _shadowEnabled;
  9788. /**
  9789. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9790. * the current shadow generator.
  9791. */
  9792. /**
  9793. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9794. * the current shadow generator.
  9795. */
  9796. shadowEnabled: boolean;
  9797. private _includedOnlyMeshes;
  9798. /**
  9799. * Gets the only meshes impacted by this light.
  9800. */
  9801. /**
  9802. * Sets the only meshes impacted by this light.
  9803. */
  9804. includedOnlyMeshes: AbstractMesh[];
  9805. private _excludedMeshes;
  9806. /**
  9807. * Gets the meshes not impacted by this light.
  9808. */
  9809. /**
  9810. * Sets the meshes not impacted by this light.
  9811. */
  9812. excludedMeshes: AbstractMesh[];
  9813. private _excludeWithLayerMask;
  9814. /**
  9815. * Gets the layer id use to find what meshes are not impacted by the light.
  9816. * Inactive if 0
  9817. */
  9818. /**
  9819. * Sets the layer id use to find what meshes are not impacted by the light.
  9820. * Inactive if 0
  9821. */
  9822. excludeWithLayerMask: number;
  9823. private _includeOnlyWithLayerMask;
  9824. /**
  9825. * Gets the layer id use to find what meshes are impacted by the light.
  9826. * Inactive if 0
  9827. */
  9828. /**
  9829. * Sets the layer id use to find what meshes are impacted by the light.
  9830. * Inactive if 0
  9831. */
  9832. includeOnlyWithLayerMask: number;
  9833. private _lightmapMode;
  9834. /**
  9835. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9836. */
  9837. /**
  9838. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9839. */
  9840. lightmapMode: number;
  9841. /**
  9842. * Shadow generator associted to the light.
  9843. * @hidden Internal use only.
  9844. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9845. /**
  9846. * @hidden Internal use only.
  9847. */ private _excludedMeshesIds: string[];
  9848. /**
  9849. * @hidden Internal use only.
  9850. */ private _includedOnlyMeshesIds: string[];
  9851. /**
  9852. * The current light unifom buffer.
  9853. * @hidden Internal use only.
  9854. */ private _uniformBuffer: UniformBuffer;
  9855. /** @hidden */ private _renderId: number;
  9856. /**
  9857. * Creates a Light object in the scene.
  9858. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9859. * @param name The firendly name of the light
  9860. * @param scene The scene the light belongs too
  9861. */
  9862. constructor(name: string, scene: Scene);
  9863. protected abstract _buildUniformLayout(): void;
  9864. /**
  9865. * Sets the passed Effect "effect" with the Light information.
  9866. * @param effect The effect to update
  9867. * @param lightIndex The index of the light in the effect to update
  9868. * @returns The light
  9869. */
  9870. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9871. /**
  9872. * Sets the passed Effect "effect" with the Light information.
  9873. * @param effect The effect to update
  9874. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9875. * @returns The light
  9876. */
  9877. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9878. /**
  9879. * Returns the string "Light".
  9880. * @returns the class name
  9881. */
  9882. getClassName(): string;
  9883. /** @hidden */ protected readonly _isLight: boolean;
  9884. /**
  9885. * Converts the light information to a readable string for debug purpose.
  9886. * @param fullDetails Supports for multiple levels of logging within scene loading
  9887. * @returns the human readable light info
  9888. */
  9889. toString(fullDetails?: boolean): string;
  9890. /** @hidden */
  9891. protected _syncParentEnabledState(): void;
  9892. /**
  9893. * Set the enabled state of this node.
  9894. * @param value - the new enabled state
  9895. */
  9896. setEnabled(value: boolean): void;
  9897. /**
  9898. * Returns the Light associated shadow generator if any.
  9899. * @return the associated shadow generator.
  9900. */
  9901. getShadowGenerator(): Nullable<IShadowGenerator>;
  9902. /**
  9903. * Returns a Vector3, the absolute light position in the World.
  9904. * @returns the world space position of the light
  9905. */
  9906. getAbsolutePosition(): Vector3;
  9907. /**
  9908. * Specifies if the light will affect the passed mesh.
  9909. * @param mesh The mesh to test against the light
  9910. * @return true the mesh is affected otherwise, false.
  9911. */
  9912. canAffectMesh(mesh: AbstractMesh): boolean;
  9913. /**
  9914. * Sort function to order lights for rendering.
  9915. * @param a First Light object to compare to second.
  9916. * @param b Second Light object to compare first.
  9917. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9918. */
  9919. static CompareLightsPriority(a: Light, b: Light): number;
  9920. /**
  9921. * Releases resources associated with this node.
  9922. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9923. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9924. */
  9925. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9926. /**
  9927. * Returns the light type ID (integer).
  9928. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9929. */
  9930. getTypeID(): number;
  9931. /**
  9932. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9933. * @returns the scaled intensity in intensity mode unit
  9934. */
  9935. getScaledIntensity(): number;
  9936. /**
  9937. * Returns a new Light object, named "name", from the current one.
  9938. * @param name The name of the cloned light
  9939. * @returns the new created light
  9940. */
  9941. clone(name: string): Nullable<Light>;
  9942. /**
  9943. * Serializes the current light into a Serialization object.
  9944. * @returns the serialized object.
  9945. */
  9946. serialize(): any;
  9947. /**
  9948. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9949. * This new light is named "name" and added to the passed scene.
  9950. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9951. * @param name The friendly name of the light
  9952. * @param scene The scene the new light will belong to
  9953. * @returns the constructor function
  9954. */
  9955. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9956. /**
  9957. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9958. * @param parsedLight The JSON representation of the light
  9959. * @param scene The scene to create the parsed light in
  9960. * @returns the created light after parsing
  9961. */
  9962. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9963. private _hookArrayForExcluded;
  9964. private _hookArrayForIncludedOnly;
  9965. private _resyncMeshes;
  9966. /**
  9967. * Forces the meshes to update their light related information in their rendering used effects
  9968. * @hidden Internal Use Only
  9969. */ private _markMeshesAsLightDirty(): void;
  9970. /**
  9971. * Recomputes the cached photometric scale if needed.
  9972. */
  9973. private _computePhotometricScale;
  9974. /**
  9975. * Returns the Photometric Scale according to the light type and intensity mode.
  9976. */
  9977. private _getPhotometricScale;
  9978. /**
  9979. * Reorder the light in the scene according to their defined priority.
  9980. * @hidden Internal Use Only
  9981. */ private _reorderLightsInScene(): void;
  9982. /**
  9983. * Prepares the list of defines specific to the light type.
  9984. * @param defines the list of defines
  9985. * @param lightIndex defines the index of the light for the effect
  9986. */
  9987. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9988. }
  9989. }
  9990. declare module BABYLON {
  9991. /**
  9992. * Interface used to define Action
  9993. */
  9994. export interface IAction {
  9995. /**
  9996. * Trigger for the action
  9997. */
  9998. trigger: number;
  9999. /** Options of the trigger */
  10000. triggerOptions: any;
  10001. /**
  10002. * Gets the trigger parameters
  10003. * @returns the trigger parameters
  10004. */
  10005. getTriggerParameter(): any;
  10006. /**
  10007. * Internal only - executes current action event
  10008. * @hidden
  10009. */ private _executeCurrent(evt?: ActionEvent): void;
  10010. /**
  10011. * Serialize placeholder for child classes
  10012. * @param parent of child
  10013. * @returns the serialized object
  10014. */
  10015. serialize(parent: any): any;
  10016. /**
  10017. * Internal only
  10018. * @hidden
  10019. */ private _prepare(): void;
  10020. /**
  10021. * Internal only - manager for action
  10022. * @hidden
  10023. */ private _actionManager: AbstractActionManager;
  10024. /**
  10025. * Adds action to chain of actions, may be a DoNothingAction
  10026. * @param action defines the next action to execute
  10027. * @returns The action passed in
  10028. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10029. */
  10030. then(action: IAction): IAction;
  10031. }
  10032. /**
  10033. * The action to be carried out following a trigger
  10034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10035. */
  10036. export class Action implements IAction {
  10037. /** the trigger, with or without parameters, for the action */
  10038. triggerOptions: any;
  10039. /**
  10040. * Trigger for the action
  10041. */
  10042. trigger: number;
  10043. /**
  10044. * Internal only - manager for action
  10045. * @hidden
  10046. */ private _actionManager: ActionManager;
  10047. private _nextActiveAction;
  10048. private _child;
  10049. private _condition?;
  10050. private _triggerParameter;
  10051. /**
  10052. * An event triggered prior to action being executed.
  10053. */
  10054. onBeforeExecuteObservable: Observable<Action>;
  10055. /**
  10056. * Creates a new Action
  10057. * @param triggerOptions the trigger, with or without parameters, for the action
  10058. * @param condition an optional determinant of action
  10059. */
  10060. constructor(
  10061. /** the trigger, with or without parameters, for the action */
  10062. triggerOptions: any, condition?: Condition);
  10063. /**
  10064. * Internal only
  10065. * @hidden
  10066. */ private _prepare(): void;
  10067. /**
  10068. * Gets the trigger parameters
  10069. * @returns the trigger parameters
  10070. */
  10071. getTriggerParameter(): any;
  10072. /**
  10073. * Internal only - executes current action event
  10074. * @hidden
  10075. */ private _executeCurrent(evt?: ActionEvent): void;
  10076. /**
  10077. * Execute placeholder for child classes
  10078. * @param evt optional action event
  10079. */
  10080. execute(evt?: ActionEvent): void;
  10081. /**
  10082. * Skips to next active action
  10083. */
  10084. skipToNextActiveAction(): void;
  10085. /**
  10086. * Adds action to chain of actions, may be a DoNothingAction
  10087. * @param action defines the next action to execute
  10088. * @returns The action passed in
  10089. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10090. */
  10091. then(action: Action): Action;
  10092. /**
  10093. * Internal only
  10094. * @hidden
  10095. */ private _getProperty(propertyPath: string): string;
  10096. /**
  10097. * Internal only
  10098. * @hidden
  10099. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10100. /**
  10101. * Serialize placeholder for child classes
  10102. * @param parent of child
  10103. * @returns the serialized object
  10104. */
  10105. serialize(parent: any): any;
  10106. /**
  10107. * Internal only called by serialize
  10108. * @hidden
  10109. */
  10110. protected _serialize(serializedAction: any, parent?: any): any;
  10111. /**
  10112. * Internal only
  10113. * @hidden
  10114. */ private static _SerializeValueAsString: (value: any) => string;
  10115. /**
  10116. * Internal only
  10117. * @hidden
  10118. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10119. name: string;
  10120. targetType: string;
  10121. value: string;
  10122. };
  10123. }
  10124. }
  10125. declare module BABYLON {
  10126. /**
  10127. * A Condition applied to an Action
  10128. */
  10129. export class Condition {
  10130. /**
  10131. * Internal only - manager for action
  10132. * @hidden
  10133. */ private _actionManager: ActionManager;
  10134. /**
  10135. * Internal only
  10136. * @hidden
  10137. */ private _evaluationId: number;
  10138. /**
  10139. * Internal only
  10140. * @hidden
  10141. */ private _currentResult: boolean;
  10142. /**
  10143. * Creates a new Condition
  10144. * @param actionManager the manager of the action the condition is applied to
  10145. */
  10146. constructor(actionManager: ActionManager);
  10147. /**
  10148. * Check if the current condition is valid
  10149. * @returns a boolean
  10150. */
  10151. isValid(): boolean;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */ private _getProperty(propertyPath: string): string;
  10156. /**
  10157. * Internal only
  10158. * @hidden
  10159. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10160. /**
  10161. * Serialize placeholder for child classes
  10162. * @returns the serialized object
  10163. */
  10164. serialize(): any;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. protected _serialize(serializedCondition: any): any;
  10170. }
  10171. /**
  10172. * Defines specific conditional operators as extensions of Condition
  10173. */
  10174. export class ValueCondition extends Condition {
  10175. /** path to specify the property of the target the conditional operator uses */
  10176. propertyPath: string;
  10177. /** the value compared by the conditional operator against the current value of the property */
  10178. value: any;
  10179. /** the conditional operator, default ValueCondition.IsEqual */
  10180. operator: number;
  10181. /**
  10182. * Internal only
  10183. * @hidden
  10184. */
  10185. private static _IsEqual;
  10186. /**
  10187. * Internal only
  10188. * @hidden
  10189. */
  10190. private static _IsDifferent;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. private static _IsGreater;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. private static _IsLesser;
  10201. /**
  10202. * returns the number for IsEqual
  10203. */
  10204. static readonly IsEqual: number;
  10205. /**
  10206. * Returns the number for IsDifferent
  10207. */
  10208. static readonly IsDifferent: number;
  10209. /**
  10210. * Returns the number for IsGreater
  10211. */
  10212. static readonly IsGreater: number;
  10213. /**
  10214. * Returns the number for IsLesser
  10215. */
  10216. static readonly IsLesser: number;
  10217. /**
  10218. * Internal only The action manager for the condition
  10219. * @hidden
  10220. */ private _actionManager: ActionManager;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. private _target;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. private _effectiveTarget;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. private _property;
  10236. /**
  10237. * Creates a new ValueCondition
  10238. * @param actionManager manager for the action the condition applies to
  10239. * @param target for the action
  10240. * @param propertyPath path to specify the property of the target the conditional operator uses
  10241. * @param value the value compared by the conditional operator against the current value of the property
  10242. * @param operator the conditional operator, default ValueCondition.IsEqual
  10243. */
  10244. constructor(actionManager: ActionManager, target: any,
  10245. /** path to specify the property of the target the conditional operator uses */
  10246. propertyPath: string,
  10247. /** the value compared by the conditional operator against the current value of the property */
  10248. value: any,
  10249. /** the conditional operator, default ValueCondition.IsEqual */
  10250. operator?: number);
  10251. /**
  10252. * Compares the given value with the property value for the specified conditional operator
  10253. * @returns the result of the comparison
  10254. */
  10255. isValid(): boolean;
  10256. /**
  10257. * Serialize the ValueCondition into a JSON compatible object
  10258. * @returns serialization object
  10259. */
  10260. serialize(): any;
  10261. /**
  10262. * Gets the name of the conditional operator for the ValueCondition
  10263. * @param operator the conditional operator
  10264. * @returns the name
  10265. */
  10266. static GetOperatorName(operator: number): string;
  10267. }
  10268. /**
  10269. * Defines a predicate condition as an extension of Condition
  10270. */
  10271. export class PredicateCondition extends Condition {
  10272. /** defines the predicate function used to validate the condition */
  10273. predicate: () => boolean;
  10274. /**
  10275. * Internal only - manager for action
  10276. * @hidden
  10277. */ private _actionManager: ActionManager;
  10278. /**
  10279. * Creates a new PredicateCondition
  10280. * @param actionManager manager for the action the condition applies to
  10281. * @param predicate defines the predicate function used to validate the condition
  10282. */
  10283. constructor(actionManager: ActionManager,
  10284. /** defines the predicate function used to validate the condition */
  10285. predicate: () => boolean);
  10286. /**
  10287. * @returns the validity of the predicate condition
  10288. */
  10289. isValid(): boolean;
  10290. }
  10291. /**
  10292. * Defines a state condition as an extension of Condition
  10293. */
  10294. export class StateCondition extends Condition {
  10295. /** Value to compare with target state */
  10296. value: string;
  10297. /**
  10298. * Internal only - manager for action
  10299. * @hidden
  10300. */ private _actionManager: ActionManager;
  10301. /**
  10302. * Internal only
  10303. * @hidden
  10304. */
  10305. private _target;
  10306. /**
  10307. * Creates a new StateCondition
  10308. * @param actionManager manager for the action the condition applies to
  10309. * @param target of the condition
  10310. * @param value to compare with target state
  10311. */
  10312. constructor(actionManager: ActionManager, target: any,
  10313. /** Value to compare with target state */
  10314. value: string);
  10315. /**
  10316. * Gets a boolean indicating if the current condition is met
  10317. * @returns the validity of the state
  10318. */
  10319. isValid(): boolean;
  10320. /**
  10321. * Serialize the StateCondition into a JSON compatible object
  10322. * @returns serialization object
  10323. */
  10324. serialize(): any;
  10325. }
  10326. }
  10327. declare module BABYLON {
  10328. /**
  10329. * This defines an action responsible to toggle a boolean once triggered.
  10330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10331. */
  10332. export class SwitchBooleanAction extends Action {
  10333. /**
  10334. * The path to the boolean property in the target object
  10335. */
  10336. propertyPath: string;
  10337. private _target;
  10338. private _effectiveTarget;
  10339. private _property;
  10340. /**
  10341. * Instantiate the action
  10342. * @param triggerOptions defines the trigger options
  10343. * @param target defines the object containing the boolean
  10344. * @param propertyPath defines the path to the boolean property in the target object
  10345. * @param condition defines the trigger related conditions
  10346. */
  10347. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10348. /** @hidden */ private _prepare(): void;
  10349. /**
  10350. * Execute the action toggle the boolean value.
  10351. */
  10352. execute(): void;
  10353. /**
  10354. * Serializes the actions and its related information.
  10355. * @param parent defines the object to serialize in
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. }
  10360. /**
  10361. * This defines an action responsible to set a the state field of the target
  10362. * to a desired value once triggered.
  10363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10364. */
  10365. export class SetStateAction extends Action {
  10366. /**
  10367. * The value to store in the state field.
  10368. */
  10369. value: string;
  10370. private _target;
  10371. /**
  10372. * Instantiate the action
  10373. * @param triggerOptions defines the trigger options
  10374. * @param target defines the object containing the state property
  10375. * @param value defines the value to store in the state field
  10376. * @param condition defines the trigger related conditions
  10377. */
  10378. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10379. /**
  10380. * Execute the action and store the value on the target state property.
  10381. */
  10382. execute(): void;
  10383. /**
  10384. * Serializes the actions and its related information.
  10385. * @param parent defines the object to serialize in
  10386. * @returns the serialized object
  10387. */
  10388. serialize(parent: any): any;
  10389. }
  10390. /**
  10391. * This defines an action responsible to set a property of the target
  10392. * to a desired value once triggered.
  10393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10394. */
  10395. export class SetValueAction extends Action {
  10396. /**
  10397. * The path of the property to set in the target.
  10398. */
  10399. propertyPath: string;
  10400. /**
  10401. * The value to set in the property
  10402. */
  10403. value: any;
  10404. private _target;
  10405. private _effectiveTarget;
  10406. private _property;
  10407. /**
  10408. * Instantiate the action
  10409. * @param triggerOptions defines the trigger options
  10410. * @param target defines the object containing the property
  10411. * @param propertyPath defines the path of the property to set in the target
  10412. * @param value defines the value to set in the property
  10413. * @param condition defines the trigger related conditions
  10414. */
  10415. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10416. /** @hidden */ private _prepare(): void;
  10417. /**
  10418. * Execute the action and set the targetted property to the desired value.
  10419. */
  10420. execute(): void;
  10421. /**
  10422. * Serializes the actions and its related information.
  10423. * @param parent defines the object to serialize in
  10424. * @returns the serialized object
  10425. */
  10426. serialize(parent: any): any;
  10427. }
  10428. /**
  10429. * This defines an action responsible to increment the target value
  10430. * to a desired value once triggered.
  10431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10432. */
  10433. export class IncrementValueAction extends Action {
  10434. /**
  10435. * The path of the property to increment in the target.
  10436. */
  10437. propertyPath: string;
  10438. /**
  10439. * The value we should increment the property by.
  10440. */
  10441. value: any;
  10442. private _target;
  10443. private _effectiveTarget;
  10444. private _property;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the object containing the property
  10449. * @param propertyPath defines the path of the property to increment in the target
  10450. * @param value defines the value value we should increment the property by
  10451. * @param condition defines the trigger related conditions
  10452. */
  10453. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10454. /** @hidden */ private _prepare(): void;
  10455. /**
  10456. * Execute the action and increment the target of the value amount.
  10457. */
  10458. execute(): void;
  10459. /**
  10460. * Serializes the actions and its related information.
  10461. * @param parent defines the object to serialize in
  10462. * @returns the serialized object
  10463. */
  10464. serialize(parent: any): any;
  10465. }
  10466. /**
  10467. * This defines an action responsible to start an animation once triggered.
  10468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10469. */
  10470. export class PlayAnimationAction extends Action {
  10471. /**
  10472. * Where the animation should start (animation frame)
  10473. */
  10474. from: number;
  10475. /**
  10476. * Where the animation should stop (animation frame)
  10477. */
  10478. to: number;
  10479. /**
  10480. * Define if the animation should loop or stop after the first play.
  10481. */
  10482. loop?: boolean;
  10483. private _target;
  10484. /**
  10485. * Instantiate the action
  10486. * @param triggerOptions defines the trigger options
  10487. * @param target defines the target animation or animation name
  10488. * @param from defines from where the animation should start (animation frame)
  10489. * @param end defines where the animation should stop (animation frame)
  10490. * @param loop defines if the animation should loop or stop after the first play
  10491. * @param condition defines the trigger related conditions
  10492. */
  10493. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10494. /** @hidden */ private _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */ private _prepare(): void;
  10520. /**
  10521. * Execute the action and stop the animation.
  10522. */
  10523. execute(): void;
  10524. /**
  10525. * Serializes the actions and its related information.
  10526. * @param parent defines the object to serialize in
  10527. * @returns the serialized object
  10528. */
  10529. serialize(parent: any): any;
  10530. }
  10531. /**
  10532. * This defines an action responsible that does nothing once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class DoNothingAction extends Action {
  10536. /**
  10537. * Instantiate the action
  10538. * @param triggerOptions defines the trigger options
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions?: any, condition?: Condition);
  10542. /**
  10543. * Execute the action and do nothing.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to trigger several actions once triggered.
  10555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10556. */
  10557. export class CombineAction extends Action {
  10558. /**
  10559. * The list of aggregated animations to run.
  10560. */
  10561. children: Action[];
  10562. /**
  10563. * Instantiate the action
  10564. * @param triggerOptions defines the trigger options
  10565. * @param children defines the list of aggregated animations to run
  10566. * @param condition defines the trigger related conditions
  10567. */
  10568. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10569. /** @hidden */ private _prepare(): void;
  10570. /**
  10571. * Execute the action and executes all the aggregated actions.
  10572. */
  10573. execute(evt: ActionEvent): void;
  10574. /**
  10575. * Serializes the actions and its related information.
  10576. * @param parent defines the object to serialize in
  10577. * @returns the serialized object
  10578. */
  10579. serialize(parent: any): any;
  10580. }
  10581. /**
  10582. * This defines an action responsible to run code (external event) once triggered.
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10584. */
  10585. export class ExecuteCodeAction extends Action {
  10586. /**
  10587. * The callback function to run.
  10588. */
  10589. func: (evt: ActionEvent) => void;
  10590. /**
  10591. * Instantiate the action
  10592. * @param triggerOptions defines the trigger options
  10593. * @param func defines the callback function to run
  10594. * @param condition defines the trigger related conditions
  10595. */
  10596. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10597. /**
  10598. * Execute the action and run the attached code.
  10599. */
  10600. execute(evt: ActionEvent): void;
  10601. }
  10602. /**
  10603. * This defines an action responsible to set the parent property of the target once triggered.
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10605. */
  10606. export class SetParentAction extends Action {
  10607. private _parent;
  10608. private _target;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param target defines the target containing the parent property
  10613. * @param parent defines from where the animation should start (animation frame)
  10614. * @param condition defines the trigger related conditions
  10615. */
  10616. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10617. /** @hidden */ private _prepare(): void;
  10618. /**
  10619. * Execute the action and set the parent property.
  10620. */
  10621. execute(): void;
  10622. /**
  10623. * Serializes the actions and its related information.
  10624. * @param parent defines the object to serialize in
  10625. * @returns the serialized object
  10626. */
  10627. serialize(parent: any): any;
  10628. }
  10629. }
  10630. declare module BABYLON {
  10631. /**
  10632. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10633. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10635. */
  10636. export class ActionManager extends AbstractActionManager {
  10637. /**
  10638. * Nothing
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10640. */
  10641. static readonly NothingTrigger: number;
  10642. /**
  10643. * On pick
  10644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10645. */
  10646. static readonly OnPickTrigger: number;
  10647. /**
  10648. * On left pick
  10649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10650. */
  10651. static readonly OnLeftPickTrigger: number;
  10652. /**
  10653. * On right pick
  10654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10655. */
  10656. static readonly OnRightPickTrigger: number;
  10657. /**
  10658. * On center pick
  10659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10660. */
  10661. static readonly OnCenterPickTrigger: number;
  10662. /**
  10663. * On pick down
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10665. */
  10666. static readonly OnPickDownTrigger: number;
  10667. /**
  10668. * On double pick
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10670. */
  10671. static readonly OnDoublePickTrigger: number;
  10672. /**
  10673. * On pick up
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly OnPickUpTrigger: number;
  10677. /**
  10678. * On pick out.
  10679. * This trigger will only be raised if you also declared a OnPickDown
  10680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10681. */
  10682. static readonly OnPickOutTrigger: number;
  10683. /**
  10684. * On long press
  10685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10686. */
  10687. static readonly OnLongPressTrigger: number;
  10688. /**
  10689. * On pointer over
  10690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10691. */
  10692. static readonly OnPointerOverTrigger: number;
  10693. /**
  10694. * On pointer out
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10696. */
  10697. static readonly OnPointerOutTrigger: number;
  10698. /**
  10699. * On every frame
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnEveryFrameTrigger: number;
  10703. /**
  10704. * On intersection enter
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnIntersectionEnterTrigger: number;
  10708. /**
  10709. * On intersection exit
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnIntersectionExitTrigger: number;
  10713. /**
  10714. * On key down
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnKeyDownTrigger: number;
  10718. /**
  10719. * On key up
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnKeyUpTrigger: number;
  10723. private _scene;
  10724. /**
  10725. * Creates a new action manager
  10726. * @param scene defines the hosting scene
  10727. */
  10728. constructor(scene: Scene);
  10729. /**
  10730. * Releases all associated resources
  10731. */
  10732. dispose(): void;
  10733. /**
  10734. * Gets hosting scene
  10735. * @returns the hosting scene
  10736. */
  10737. getScene(): Scene;
  10738. /**
  10739. * Does this action manager handles actions of any of the given triggers
  10740. * @param triggers defines the triggers to be tested
  10741. * @return a boolean indicating whether one (or more) of the triggers is handled
  10742. */
  10743. hasSpecificTriggers(triggers: number[]): boolean;
  10744. /**
  10745. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10746. * speed.
  10747. * @param triggerA defines the trigger to be tested
  10748. * @param triggerB defines the trigger to be tested
  10749. * @return a boolean indicating whether one (or more) of the triggers is handled
  10750. */
  10751. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10752. /**
  10753. * Does this action manager handles actions of a given trigger
  10754. * @param trigger defines the trigger to be tested
  10755. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10756. * @return whether the trigger is handled
  10757. */
  10758. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10759. /**
  10760. * Does this action manager has pointer triggers
  10761. */
  10762. readonly hasPointerTriggers: boolean;
  10763. /**
  10764. * Does this action manager has pick triggers
  10765. */
  10766. readonly hasPickTriggers: boolean;
  10767. /**
  10768. * Registers an action to this action manager
  10769. * @param action defines the action to be registered
  10770. * @return the action amended (prepared) after registration
  10771. */
  10772. registerAction(action: IAction): Nullable<IAction>;
  10773. /**
  10774. * Unregisters an action to this action manager
  10775. * @param action defines the action to be unregistered
  10776. * @return a boolean indicating whether the action has been unregistered
  10777. */
  10778. unregisterAction(action: IAction): Boolean;
  10779. /**
  10780. * Process a specific trigger
  10781. * @param trigger defines the trigger to process
  10782. * @param evt defines the event details to be processed
  10783. */
  10784. processTrigger(trigger: number, evt?: IActionEvent): void;
  10785. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10786. /** @hidden */ private _getProperty(propertyPath: string): string;
  10787. /**
  10788. * Serialize this manager to a JSON object
  10789. * @param name defines the property name to store this manager
  10790. * @returns a JSON representation of this manager
  10791. */
  10792. serialize(name: string): any;
  10793. /**
  10794. * Creates a new ActionManager from a JSON data
  10795. * @param parsedActions defines the JSON data to read from
  10796. * @param object defines the hosting mesh
  10797. * @param scene defines the hosting scene
  10798. */
  10799. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10800. /**
  10801. * Get a trigger name by index
  10802. * @param trigger defines the trigger index
  10803. * @returns a trigger name
  10804. */
  10805. static GetTriggerName(trigger: number): string;
  10806. }
  10807. }
  10808. declare module BABYLON {
  10809. /**
  10810. * Class representing a ray with position and direction
  10811. */
  10812. export class Ray {
  10813. /** origin point */
  10814. origin: Vector3;
  10815. /** direction */
  10816. direction: Vector3;
  10817. /** length of the ray */
  10818. length: number;
  10819. private static readonly TmpVector3;
  10820. private _tmpRay;
  10821. /**
  10822. * Creates a new ray
  10823. * @param origin origin point
  10824. * @param direction direction
  10825. * @param length length of the ray
  10826. */
  10827. constructor(
  10828. /** origin point */
  10829. origin: Vector3,
  10830. /** direction */
  10831. direction: Vector3,
  10832. /** length of the ray */
  10833. length?: number);
  10834. /**
  10835. * Checks if the ray intersects a box
  10836. * @param minimum bound of the box
  10837. * @param maximum bound of the box
  10838. * @param intersectionTreshold extra extend to be added to the box in all direction
  10839. * @returns if the box was hit
  10840. */
  10841. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10842. /**
  10843. * Checks if the ray intersects a box
  10844. * @param box the bounding box to check
  10845. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10846. * @returns if the box was hit
  10847. */
  10848. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10849. /**
  10850. * If the ray hits a sphere
  10851. * @param sphere the bounding sphere to check
  10852. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10853. * @returns true if it hits the sphere
  10854. */
  10855. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10856. /**
  10857. * If the ray hits a triange
  10858. * @param vertex0 triangle vertex
  10859. * @param vertex1 triangle vertex
  10860. * @param vertex2 triangle vertex
  10861. * @returns intersection information if hit
  10862. */
  10863. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10864. /**
  10865. * Checks if ray intersects a plane
  10866. * @param plane the plane to check
  10867. * @returns the distance away it was hit
  10868. */
  10869. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10870. /**
  10871. * Calculate the intercept of a ray on a given axis
  10872. * @param axis to check 'x' | 'y' | 'z'
  10873. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10874. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10875. */
  10876. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10877. /**
  10878. * Checks if ray intersects a mesh
  10879. * @param mesh the mesh to check
  10880. * @param fastCheck if only the bounding box should checked
  10881. * @returns picking info of the intersecton
  10882. */
  10883. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10884. /**
  10885. * Checks if ray intersects a mesh
  10886. * @param meshes the meshes to check
  10887. * @param fastCheck if only the bounding box should checked
  10888. * @param results array to store result in
  10889. * @returns Array of picking infos
  10890. */
  10891. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10892. private _comparePickingInfo;
  10893. private static smallnum;
  10894. private static rayl;
  10895. /**
  10896. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10897. * @param sega the first point of the segment to test the intersection against
  10898. * @param segb the second point of the segment to test the intersection against
  10899. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10900. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10901. */
  10902. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10903. /**
  10904. * Update the ray from viewport position
  10905. * @param x position
  10906. * @param y y position
  10907. * @param viewportWidth viewport width
  10908. * @param viewportHeight viewport height
  10909. * @param world world matrix
  10910. * @param view view matrix
  10911. * @param projection projection matrix
  10912. * @returns this ray updated
  10913. */
  10914. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10915. /**
  10916. * Creates a ray with origin and direction of 0,0,0
  10917. * @returns the new ray
  10918. */
  10919. static Zero(): Ray;
  10920. /**
  10921. * Creates a new ray from screen space and viewport
  10922. * @param x position
  10923. * @param y y position
  10924. * @param viewportWidth viewport width
  10925. * @param viewportHeight viewport height
  10926. * @param world world matrix
  10927. * @param view view matrix
  10928. * @param projection projection matrix
  10929. * @returns new ray
  10930. */
  10931. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10932. /**
  10933. * 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
  10934. * transformed to the given world matrix.
  10935. * @param origin The origin point
  10936. * @param end The end point
  10937. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10938. * @returns the new ray
  10939. */
  10940. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10941. /**
  10942. * Transforms a ray by a matrix
  10943. * @param ray ray to transform
  10944. * @param matrix matrix to apply
  10945. * @returns the resulting new ray
  10946. */
  10947. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10948. /**
  10949. * Transforms a ray by a matrix
  10950. * @param ray ray to transform
  10951. * @param matrix matrix to apply
  10952. * @param result ray to store result in
  10953. */
  10954. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10955. /**
  10956. * Unproject a ray from screen space to object space
  10957. * @param sourceX defines the screen space x coordinate to use
  10958. * @param sourceY defines the screen space y coordinate to use
  10959. * @param viewportWidth defines the current width of the viewport
  10960. * @param viewportHeight defines the current height of the viewport
  10961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10962. * @param view defines the view matrix to use
  10963. * @param projection defines the projection matrix to use
  10964. */
  10965. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10966. }
  10967. /**
  10968. * Type used to define predicate used to select faces when a mesh intersection is detected
  10969. */
  10970. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10971. interface Scene {
  10972. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10973. /** @hidden */ private _cachedRayForTransform: Ray;
  10974. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10975. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10976. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10977. }
  10978. }
  10979. declare module BABYLON {
  10980. /**
  10981. * Groups all the scene component constants in one place to ease maintenance.
  10982. * @hidden
  10983. */
  10984. export class SceneComponentConstants {
  10985. static readonly NAME_EFFECTLAYER: string;
  10986. static readonly NAME_LAYER: string;
  10987. static readonly NAME_LENSFLARESYSTEM: string;
  10988. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10989. static readonly NAME_PARTICLESYSTEM: string;
  10990. static readonly NAME_GAMEPAD: string;
  10991. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10992. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10993. static readonly NAME_DEPTHRENDERER: string;
  10994. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10995. static readonly NAME_SPRITE: string;
  10996. static readonly NAME_OUTLINERENDERER: string;
  10997. static readonly NAME_PROCEDURALTEXTURE: string;
  10998. static readonly NAME_SHADOWGENERATOR: string;
  10999. static readonly NAME_OCTREE: string;
  11000. static readonly NAME_PHYSICSENGINE: string;
  11001. static readonly NAME_AUDIO: string;
  11002. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11003. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11004. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11005. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11006. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11007. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11008. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11009. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11010. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11011. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11012. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11013. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11015. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11016. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11017. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11018. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11019. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11020. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11021. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11022. static readonly STEP_AFTERRENDER_AUDIO: number;
  11023. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11024. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11025. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11026. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11027. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11028. static readonly STEP_POINTERMOVE_SPRITE: number;
  11029. static readonly STEP_POINTERDOWN_SPRITE: number;
  11030. static readonly STEP_POINTERUP_SPRITE: number;
  11031. }
  11032. /**
  11033. * This represents a scene component.
  11034. *
  11035. * This is used to decouple the dependency the scene is having on the different workloads like
  11036. * layers, post processes...
  11037. */
  11038. export interface ISceneComponent {
  11039. /**
  11040. * The name of the component. Each component must have a unique name.
  11041. */
  11042. name: string;
  11043. /**
  11044. * The scene the component belongs to.
  11045. */
  11046. scene: Scene;
  11047. /**
  11048. * Register the component to one instance of a scene.
  11049. */
  11050. register(): void;
  11051. /**
  11052. * Rebuilds the elements related to this component in case of
  11053. * context lost for instance.
  11054. */
  11055. rebuild(): void;
  11056. /**
  11057. * Disposes the component and the associated ressources.
  11058. */
  11059. dispose(): void;
  11060. }
  11061. /**
  11062. * This represents a SERIALIZABLE scene component.
  11063. *
  11064. * This extends Scene Component to add Serialization methods on top.
  11065. */
  11066. export interface ISceneSerializableComponent extends ISceneComponent {
  11067. /**
  11068. * Adds all the elements from the container to the scene
  11069. * @param container the container holding the elements
  11070. */
  11071. addFromContainer(container: AbstractScene): void;
  11072. /**
  11073. * Removes all the elements in the container from the scene
  11074. * @param container contains the elements to remove
  11075. * @param dispose if the removed element should be disposed (default: false)
  11076. */
  11077. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11078. /**
  11079. * Serializes the component data to the specified json object
  11080. * @param serializationObject The object to serialize to
  11081. */
  11082. serialize(serializationObject: any): void;
  11083. }
  11084. /**
  11085. * Strong typing of a Mesh related stage step action
  11086. */
  11087. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11088. /**
  11089. * Strong typing of a Evaluate Sub Mesh related stage step action
  11090. */
  11091. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11092. /**
  11093. * Strong typing of a Active Mesh related stage step action
  11094. */
  11095. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11096. /**
  11097. * Strong typing of a Camera related stage step action
  11098. */
  11099. export type CameraStageAction = (camera: Camera) => void;
  11100. /**
  11101. * Strong typing of a Camera Frame buffer related stage step action
  11102. */
  11103. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11104. /**
  11105. * Strong typing of a Render Target related stage step action
  11106. */
  11107. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11108. /**
  11109. * Strong typing of a RenderingGroup related stage step action
  11110. */
  11111. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11112. /**
  11113. * Strong typing of a Mesh Render related stage step action
  11114. */
  11115. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11116. /**
  11117. * Strong typing of a simple stage step action
  11118. */
  11119. export type SimpleStageAction = () => void;
  11120. /**
  11121. * Strong typing of a render target action.
  11122. */
  11123. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11124. /**
  11125. * Strong typing of a pointer move action.
  11126. */
  11127. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11128. /**
  11129. * Strong typing of a pointer up/down action.
  11130. */
  11131. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11132. /**
  11133. * Representation of a stage in the scene (Basically a list of ordered steps)
  11134. * @hidden
  11135. */
  11136. export class Stage<T extends Function> extends Array<{
  11137. index: number;
  11138. component: ISceneComponent;
  11139. action: T;
  11140. }> {
  11141. /**
  11142. * Hide ctor from the rest of the world.
  11143. * @param items The items to add.
  11144. */
  11145. private constructor();
  11146. /**
  11147. * Creates a new Stage.
  11148. * @returns A new instance of a Stage
  11149. */
  11150. static Create<T extends Function>(): Stage<T>;
  11151. /**
  11152. * Registers a step in an ordered way in the targeted stage.
  11153. * @param index Defines the position to register the step in
  11154. * @param component Defines the component attached to the step
  11155. * @param action Defines the action to launch during the step
  11156. */
  11157. registerStep(index: number, component: ISceneComponent, action: T): void;
  11158. /**
  11159. * Clears all the steps from the stage.
  11160. */
  11161. clear(): void;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. interface Scene {
  11166. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11167. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11168. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11169. /**
  11170. * All of the sprite managers added to this scene
  11171. * @see http://doc.babylonjs.com/babylon101/sprites
  11172. */
  11173. spriteManagers: Array<ISpriteManager>;
  11174. /**
  11175. * An event triggered when sprites rendering is about to start
  11176. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11177. */
  11178. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11179. /**
  11180. * An event triggered when sprites rendering is done
  11181. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11182. */
  11183. onAfterSpritesRenderingObservable: Observable<Scene>;
  11184. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11185. /** Launch a ray to try to pick a sprite in the scene
  11186. * @param x position on screen
  11187. * @param y position on screen
  11188. * @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
  11189. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11190. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11191. * @returns a PickingInfo
  11192. */
  11193. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11194. /** Use the given ray to pick a sprite in the scene
  11195. * @param ray The ray (in world space) to use to pick meshes
  11196. * @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
  11197. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11198. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11199. * @returns a PickingInfo
  11200. */
  11201. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11202. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11203. /** Launch a ray to try to pick sprites in the scene
  11204. * @param x position on screen
  11205. * @param y position on screen
  11206. * @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
  11207. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11208. * @returns a PickingInfo array
  11209. */
  11210. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11211. /** Use the given ray to pick sprites in the scene
  11212. * @param ray The ray (in world space) to use to pick meshes
  11213. * @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
  11214. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11215. * @returns a PickingInfo array
  11216. */
  11217. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11218. /**
  11219. * Force the sprite under the pointer
  11220. * @param sprite defines the sprite to use
  11221. */
  11222. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11223. /**
  11224. * Gets the sprite under the pointer
  11225. * @returns a Sprite or null if no sprite is under the pointer
  11226. */
  11227. getPointerOverSprite(): Nullable<Sprite>;
  11228. }
  11229. /**
  11230. * Defines the sprite scene component responsible to manage sprites
  11231. * in a given scene.
  11232. */
  11233. export class SpriteSceneComponent implements ISceneComponent {
  11234. /**
  11235. * The component name helpfull to identify the component in the list of scene components.
  11236. */
  11237. readonly name: string;
  11238. /**
  11239. * The scene the component belongs to.
  11240. */
  11241. scene: Scene;
  11242. /** @hidden */
  11243. private _spritePredicate;
  11244. /**
  11245. * Creates a new instance of the component for the given scene
  11246. * @param scene Defines the scene to register the component in
  11247. */
  11248. constructor(scene: Scene);
  11249. /**
  11250. * Registers the component in a given scene
  11251. */
  11252. register(): void;
  11253. /**
  11254. * Rebuilds the elements related to this component in case of
  11255. * context lost for instance.
  11256. */
  11257. rebuild(): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. private _pickSpriteButKeepRay;
  11263. private _pointerMove;
  11264. private _pointerDown;
  11265. private _pointerUp;
  11266. }
  11267. }
  11268. declare module BABYLON {
  11269. /** @hidden */
  11270. export var fogFragmentDeclaration: {
  11271. name: string;
  11272. shader: string;
  11273. };
  11274. }
  11275. declare module BABYLON {
  11276. /** @hidden */
  11277. export var fogFragment: {
  11278. name: string;
  11279. shader: string;
  11280. };
  11281. }
  11282. declare module BABYLON {
  11283. /** @hidden */
  11284. export var spritesPixelShader: {
  11285. name: string;
  11286. shader: string;
  11287. };
  11288. }
  11289. declare module BABYLON {
  11290. /** @hidden */
  11291. export var fogVertexDeclaration: {
  11292. name: string;
  11293. shader: string;
  11294. };
  11295. }
  11296. declare module BABYLON {
  11297. /** @hidden */
  11298. export var spritesVertexShader: {
  11299. name: string;
  11300. shader: string;
  11301. };
  11302. }
  11303. declare module BABYLON {
  11304. /**
  11305. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11306. */
  11307. export interface ISpriteManager extends IDisposable {
  11308. /**
  11309. * Restricts the camera to viewing objects with the same layerMask.
  11310. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11311. */
  11312. layerMask: number;
  11313. /**
  11314. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11315. */
  11316. isPickable: boolean;
  11317. /**
  11318. * Specifies the rendering group id for this mesh (0 by default)
  11319. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11320. */
  11321. renderingGroupId: number;
  11322. /**
  11323. * Defines the list of sprites managed by the manager.
  11324. */
  11325. sprites: Array<Sprite>;
  11326. /**
  11327. * Tests the intersection of a sprite with a specific ray.
  11328. * @param ray The ray we are sending to test the collision
  11329. * @param camera The camera space we are sending rays in
  11330. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11331. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11332. * @returns picking info or null.
  11333. */
  11334. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11335. /**
  11336. * Intersects the sprites with a ray
  11337. * @param ray defines the ray to intersect with
  11338. * @param camera defines the current active camera
  11339. * @param predicate defines a predicate used to select candidate sprites
  11340. * @returns null if no hit or a PickingInfo array
  11341. */
  11342. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11343. /**
  11344. * Renders the list of sprites on screen.
  11345. */
  11346. render(): void;
  11347. }
  11348. /**
  11349. * Class used to manage multiple sprites on the same spritesheet
  11350. * @see http://doc.babylonjs.com/babylon101/sprites
  11351. */
  11352. export class SpriteManager implements ISpriteManager {
  11353. /** defines the manager's name */
  11354. name: string;
  11355. /** Gets the list of sprites */
  11356. sprites: Sprite[];
  11357. /** Gets or sets the rendering group id (0 by default) */
  11358. renderingGroupId: number;
  11359. /** Gets or sets camera layer mask */
  11360. layerMask: number;
  11361. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11362. fogEnabled: boolean;
  11363. /** Gets or sets a boolean indicating if the sprites are pickable */
  11364. isPickable: boolean;
  11365. /** Defines the default width of a cell in the spritesheet */
  11366. cellWidth: number;
  11367. /** Defines the default height of a cell in the spritesheet */
  11368. cellHeight: number;
  11369. /** Associative array from JSON sprite data file */
  11370. private _cellData;
  11371. /** Array of sprite names from JSON sprite data file */
  11372. private _spriteMap;
  11373. /** True when packed cell data from JSON file is ready*/
  11374. private _packedAndReady;
  11375. /**
  11376. * An event triggered when the manager is disposed.
  11377. */
  11378. onDisposeObservable: Observable<SpriteManager>;
  11379. private _onDisposeObserver;
  11380. /**
  11381. * Callback called when the manager is disposed
  11382. */
  11383. onDispose: () => void;
  11384. private _capacity;
  11385. private _fromPacked;
  11386. private _spriteTexture;
  11387. private _epsilon;
  11388. private _scene;
  11389. private _vertexData;
  11390. private _buffer;
  11391. private _vertexBuffers;
  11392. private _indexBuffer;
  11393. private _effectBase;
  11394. private _effectFog;
  11395. /**
  11396. * Gets or sets the spritesheet texture
  11397. */
  11398. texture: Texture;
  11399. /**
  11400. * Creates a new sprite manager
  11401. * @param name defines the manager's name
  11402. * @param imgUrl defines the sprite sheet url
  11403. * @param capacity defines the maximum allowed number of sprites
  11404. * @param cellSize defines the size of a sprite cell
  11405. * @param scene defines the hosting scene
  11406. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11407. * @param samplingMode defines the smapling mode to use with spritesheet
  11408. * @param fromPacked set to false; do not alter
  11409. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11410. */
  11411. constructor(
  11412. /** defines the manager's name */
  11413. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11414. private _makePacked;
  11415. private _appendSpriteVertex;
  11416. /**
  11417. * Intersects the sprites with a ray
  11418. * @param ray defines the ray to intersect with
  11419. * @param camera defines the current active camera
  11420. * @param predicate defines a predicate used to select candidate sprites
  11421. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11422. * @returns null if no hit or a PickingInfo
  11423. */
  11424. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11425. /**
  11426. * Intersects the sprites with a ray
  11427. * @param ray defines the ray to intersect with
  11428. * @param camera defines the current active camera
  11429. * @param predicate defines a predicate used to select candidate sprites
  11430. * @returns null if no hit or a PickingInfo array
  11431. */
  11432. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11433. /**
  11434. * Render all child sprites
  11435. */
  11436. render(): void;
  11437. /**
  11438. * Release associated resources
  11439. */
  11440. dispose(): void;
  11441. }
  11442. }
  11443. declare module BABYLON {
  11444. /**
  11445. * Class used to represent a sprite
  11446. * @see http://doc.babylonjs.com/babylon101/sprites
  11447. */
  11448. export class Sprite {
  11449. /** defines the name */
  11450. name: string;
  11451. /** Gets or sets the current world position */
  11452. position: Vector3;
  11453. /** Gets or sets the main color */
  11454. color: Color4;
  11455. /** Gets or sets the width */
  11456. width: number;
  11457. /** Gets or sets the height */
  11458. height: number;
  11459. /** Gets or sets rotation angle */
  11460. angle: number;
  11461. /** Gets or sets the cell index in the sprite sheet */
  11462. cellIndex: number;
  11463. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11464. cellRef: string;
  11465. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11466. invertU: number;
  11467. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11468. invertV: number;
  11469. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11470. disposeWhenFinishedAnimating: boolean;
  11471. /** Gets the list of attached animations */
  11472. animations: Animation[];
  11473. /** Gets or sets a boolean indicating if the sprite can be picked */
  11474. isPickable: boolean;
  11475. /**
  11476. * Gets or sets the associated action manager
  11477. */
  11478. actionManager: Nullable<ActionManager>;
  11479. private _animationStarted;
  11480. private _loopAnimation;
  11481. private _fromIndex;
  11482. private _toIndex;
  11483. private _delay;
  11484. private _direction;
  11485. private _manager;
  11486. private _time;
  11487. private _onAnimationEnd;
  11488. /**
  11489. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11490. */
  11491. isVisible: boolean;
  11492. /**
  11493. * Gets or sets the sprite size
  11494. */
  11495. size: number;
  11496. /**
  11497. * Creates a new Sprite
  11498. * @param name defines the name
  11499. * @param manager defines the manager
  11500. */
  11501. constructor(
  11502. /** defines the name */
  11503. name: string, manager: ISpriteManager);
  11504. /**
  11505. * Starts an animation
  11506. * @param from defines the initial key
  11507. * @param to defines the end key
  11508. * @param loop defines if the animation must loop
  11509. * @param delay defines the start delay (in ms)
  11510. * @param onAnimationEnd defines a callback to call when animation ends
  11511. */
  11512. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11513. /** Stops current animation (if any) */
  11514. stopAnimation(): void;
  11515. /** @hidden */ private _animate(deltaTime: number): void;
  11516. /** Release associated resources */
  11517. dispose(): void;
  11518. }
  11519. }
  11520. declare module BABYLON {
  11521. /**
  11522. * Information about the result of picking within a scene
  11523. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11524. */
  11525. export class PickingInfo {
  11526. /** @hidden */ private _pickingUnavailable: boolean;
  11527. /**
  11528. * If the pick collided with an object
  11529. */
  11530. hit: boolean;
  11531. /**
  11532. * Distance away where the pick collided
  11533. */
  11534. distance: number;
  11535. /**
  11536. * The location of pick collision
  11537. */
  11538. pickedPoint: Nullable<Vector3>;
  11539. /**
  11540. * The mesh corresponding the the pick collision
  11541. */
  11542. pickedMesh: Nullable<AbstractMesh>;
  11543. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11544. bu: number;
  11545. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11546. bv: number;
  11547. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11548. faceId: number;
  11549. /** Id of the the submesh that was picked */
  11550. subMeshId: number;
  11551. /** If a sprite was picked, this will be the sprite the pick collided with */
  11552. pickedSprite: Nullable<Sprite>;
  11553. /**
  11554. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11555. */
  11556. originMesh: Nullable<AbstractMesh>;
  11557. /**
  11558. * The ray that was used to perform the picking.
  11559. */
  11560. ray: Nullable<Ray>;
  11561. /**
  11562. * Gets the normal correspodning to the face the pick collided with
  11563. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11564. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11565. * @returns The normal correspodning to the face the pick collided with
  11566. */
  11567. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11568. /**
  11569. * Gets the texture coordinates of where the pick occured
  11570. * @returns the vector containing the coordnates of the texture
  11571. */
  11572. getTextureCoordinates(): Nullable<Vector2>;
  11573. }
  11574. }
  11575. declare module BABYLON {
  11576. /**
  11577. * Gather the list of pointer event types as constants.
  11578. */
  11579. export class PointerEventTypes {
  11580. /**
  11581. * 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.
  11582. */
  11583. static readonly POINTERDOWN: number;
  11584. /**
  11585. * The pointerup event is fired when a pointer is no longer active.
  11586. */
  11587. static readonly POINTERUP: number;
  11588. /**
  11589. * The pointermove event is fired when a pointer changes coordinates.
  11590. */
  11591. static readonly POINTERMOVE: number;
  11592. /**
  11593. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11594. */
  11595. static readonly POINTERWHEEL: number;
  11596. /**
  11597. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11598. */
  11599. static readonly POINTERPICK: number;
  11600. /**
  11601. * The pointertap event is fired when a the object has been touched and released without drag.
  11602. */
  11603. static readonly POINTERTAP: number;
  11604. /**
  11605. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11606. */
  11607. static readonly POINTERDOUBLETAP: number;
  11608. }
  11609. /**
  11610. * Base class of pointer info types.
  11611. */
  11612. export class PointerInfoBase {
  11613. /**
  11614. * Defines the type of event (PointerEventTypes)
  11615. */
  11616. type: number;
  11617. /**
  11618. * Defines the related dom event
  11619. */
  11620. event: PointerEvent | MouseWheelEvent;
  11621. /**
  11622. * Instantiates the base class of pointers info.
  11623. * @param type Defines the type of event (PointerEventTypes)
  11624. * @param event Defines the related dom event
  11625. */
  11626. constructor(
  11627. /**
  11628. * Defines the type of event (PointerEventTypes)
  11629. */
  11630. type: number,
  11631. /**
  11632. * Defines the related dom event
  11633. */
  11634. event: PointerEvent | MouseWheelEvent);
  11635. }
  11636. /**
  11637. * This class is used to store pointer related info for the onPrePointerObservable event.
  11638. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11639. */
  11640. export class PointerInfoPre extends PointerInfoBase {
  11641. /**
  11642. * Ray from a pointer if availible (eg. 6dof controller)
  11643. */
  11644. ray: Nullable<Ray>;
  11645. /**
  11646. * Defines the local position of the pointer on the canvas.
  11647. */
  11648. localPosition: Vector2;
  11649. /**
  11650. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11651. */
  11652. skipOnPointerObservable: boolean;
  11653. /**
  11654. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11655. * @param type Defines the type of event (PointerEventTypes)
  11656. * @param event Defines the related dom event
  11657. * @param localX Defines the local x coordinates of the pointer when the event occured
  11658. * @param localY Defines the local y coordinates of the pointer when the event occured
  11659. */
  11660. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11661. }
  11662. /**
  11663. * This type contains all the data related to a pointer event in Babylon.js.
  11664. * 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.
  11665. */
  11666. export class PointerInfo extends PointerInfoBase {
  11667. /**
  11668. * Defines the picking info associated to the info (if any)\
  11669. */
  11670. pickInfo: Nullable<PickingInfo>;
  11671. /**
  11672. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11673. * @param type Defines the type of event (PointerEventTypes)
  11674. * @param event Defines the related dom event
  11675. * @param pickInfo Defines the picking info associated to the info (if any)\
  11676. */
  11677. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11678. /**
  11679. * Defines the picking info associated to the info (if any)\
  11680. */
  11681. pickInfo: Nullable<PickingInfo>);
  11682. }
  11683. /**
  11684. * Data relating to a touch event on the screen.
  11685. */
  11686. export interface PointerTouch {
  11687. /**
  11688. * X coordinate of touch.
  11689. */
  11690. x: number;
  11691. /**
  11692. * Y coordinate of touch.
  11693. */
  11694. y: number;
  11695. /**
  11696. * Id of touch. Unique for each finger.
  11697. */
  11698. pointerId: number;
  11699. /**
  11700. * Event type passed from DOM.
  11701. */
  11702. type: any;
  11703. }
  11704. }
  11705. declare module BABYLON {
  11706. /**
  11707. * Manage the mouse inputs to control the movement of a free camera.
  11708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11709. */
  11710. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11711. /**
  11712. * Define if touch is enabled in the mouse input
  11713. */
  11714. touchEnabled: boolean;
  11715. /**
  11716. * Defines the camera the input is attached to.
  11717. */
  11718. camera: FreeCamera;
  11719. /**
  11720. * Defines the buttons associated with the input to handle camera move.
  11721. */
  11722. buttons: number[];
  11723. /**
  11724. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11725. */
  11726. angularSensibility: number;
  11727. private _pointerInput;
  11728. private _onMouseMove;
  11729. private _observer;
  11730. private previousPosition;
  11731. /**
  11732. * Observable for when a pointer move event occurs containing the move offset
  11733. */
  11734. onPointerMovedObservable: Observable<{
  11735. offsetX: number;
  11736. offsetY: number;
  11737. }>;
  11738. /**
  11739. * @hidden
  11740. * If the camera should be rotated automatically based on pointer movement
  11741. */ private _allowCameraRotation: boolean;
  11742. /**
  11743. * Manage the mouse inputs to control the movement of a free camera.
  11744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11745. * @param touchEnabled Defines if touch is enabled or not
  11746. */
  11747. constructor(
  11748. /**
  11749. * Define if touch is enabled in the mouse input
  11750. */
  11751. touchEnabled?: boolean);
  11752. /**
  11753. * Attach the input controls to a specific dom element to get the input from.
  11754. * @param element Defines the element the controls should be listened from
  11755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11756. */
  11757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11758. /**
  11759. * Called on JS contextmenu event.
  11760. * Override this method to provide functionality.
  11761. */
  11762. protected onContextMenu(evt: PointerEvent): void;
  11763. /**
  11764. * Detach the current controls from the specified dom element.
  11765. * @param element Defines the element to stop listening the inputs from
  11766. */
  11767. detachControl(element: Nullable<HTMLElement>): void;
  11768. /**
  11769. * Gets the class name of the current intput.
  11770. * @returns the class name
  11771. */
  11772. getClassName(): string;
  11773. /**
  11774. * Get the friendly name associated with the input class.
  11775. * @returns the input friendly name
  11776. */
  11777. getSimpleName(): string;
  11778. }
  11779. }
  11780. declare module BABYLON {
  11781. /**
  11782. * Manage the touch inputs to control the movement of a free camera.
  11783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11784. */
  11785. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11786. /**
  11787. * Defines the camera the input is attached to.
  11788. */
  11789. camera: FreeCamera;
  11790. /**
  11791. * Defines the touch sensibility for rotation.
  11792. * The higher the faster.
  11793. */
  11794. touchAngularSensibility: number;
  11795. /**
  11796. * Defines the touch sensibility for move.
  11797. * The higher the faster.
  11798. */
  11799. touchMoveSensibility: number;
  11800. private _offsetX;
  11801. private _offsetY;
  11802. private _pointerPressed;
  11803. private _pointerInput;
  11804. private _observer;
  11805. private _onLostFocus;
  11806. /**
  11807. * Attach the input controls to a specific dom element to get the input from.
  11808. * @param element Defines the element the controls should be listened from
  11809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11810. */
  11811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11812. /**
  11813. * Detach the current controls from the specified dom element.
  11814. * @param element Defines the element to stop listening the inputs from
  11815. */
  11816. detachControl(element: Nullable<HTMLElement>): void;
  11817. /**
  11818. * Update the current camera state depending on the inputs that have been used this frame.
  11819. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11820. */
  11821. checkInputs(): void;
  11822. /**
  11823. * Gets the class name of the current intput.
  11824. * @returns the class name
  11825. */
  11826. getClassName(): string;
  11827. /**
  11828. * Get the friendly name associated with the input class.
  11829. * @returns the input friendly name
  11830. */
  11831. getSimpleName(): string;
  11832. }
  11833. }
  11834. declare module BABYLON {
  11835. /**
  11836. * Default Inputs manager for the FreeCamera.
  11837. * It groups all the default supported inputs for ease of use.
  11838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11839. */
  11840. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11841. /**
  11842. * @hidden
  11843. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11844. /**
  11845. * Instantiates a new FreeCameraInputsManager.
  11846. * @param camera Defines the camera the inputs belong to
  11847. */
  11848. constructor(camera: FreeCamera);
  11849. /**
  11850. * Add keyboard input support to the input manager.
  11851. * @returns the current input manager
  11852. */
  11853. addKeyboard(): FreeCameraInputsManager;
  11854. /**
  11855. * Add mouse input support to the input manager.
  11856. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11857. * @returns the current input manager
  11858. */
  11859. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11860. /**
  11861. * Removes the mouse input support from the manager
  11862. * @returns the current input manager
  11863. */
  11864. removeMouse(): FreeCameraInputsManager;
  11865. /**
  11866. * Add touch input support to the input manager.
  11867. * @returns the current input manager
  11868. */
  11869. addTouch(): FreeCameraInputsManager;
  11870. /**
  11871. * Remove all attached input methods from a camera
  11872. */
  11873. clear(): void;
  11874. }
  11875. }
  11876. declare module BABYLON {
  11877. /**
  11878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11879. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11881. */
  11882. export class FreeCamera extends TargetCamera {
  11883. /**
  11884. * Define the collision ellipsoid of the camera.
  11885. * This is helpful to simulate a camera body like the player body around the camera
  11886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11887. */
  11888. ellipsoid: Vector3;
  11889. /**
  11890. * Define an offset for the position of the ellipsoid around the camera.
  11891. * This can be helpful to determine the center of the body near the gravity center of the body
  11892. * instead of its head.
  11893. */
  11894. ellipsoidOffset: Vector3;
  11895. /**
  11896. * Enable or disable collisions of the camera with the rest of the scene objects.
  11897. */
  11898. checkCollisions: boolean;
  11899. /**
  11900. * Enable or disable gravity on the camera.
  11901. */
  11902. applyGravity: boolean;
  11903. /**
  11904. * Define the input manager associated to the camera.
  11905. */
  11906. inputs: FreeCameraInputsManager;
  11907. /**
  11908. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11909. * Higher values reduce sensitivity.
  11910. */
  11911. /**
  11912. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11913. * Higher values reduce sensitivity.
  11914. */
  11915. angularSensibility: number;
  11916. /**
  11917. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11918. */
  11919. keysUp: number[];
  11920. /**
  11921. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11922. */
  11923. keysDown: number[];
  11924. /**
  11925. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11926. */
  11927. keysLeft: number[];
  11928. /**
  11929. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11930. */
  11931. keysRight: number[];
  11932. /**
  11933. * Event raised when the camera collide with a mesh in the scene.
  11934. */
  11935. onCollide: (collidedMesh: AbstractMesh) => void;
  11936. private _collider;
  11937. private _needMoveForGravity;
  11938. private _oldPosition;
  11939. private _diffPosition;
  11940. private _newPosition;
  11941. /** @hidden */ private _localDirection: Vector3;
  11942. /** @hidden */ private _transformedDirection: Vector3;
  11943. /**
  11944. * Instantiates a Free Camera.
  11945. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11946. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11948. * @param name Define the name of the camera in the scene
  11949. * @param position Define the start position of the camera in the scene
  11950. * @param scene Define the scene the camera belongs to
  11951. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11952. */
  11953. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11954. /**
  11955. * Attached controls to the current camera.
  11956. * @param element Defines the element the controls should be listened from
  11957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11958. */
  11959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11960. /**
  11961. * Detach the current controls from the camera.
  11962. * The camera will stop reacting to inputs.
  11963. * @param element Defines the element to stop listening the inputs from
  11964. */
  11965. detachControl(element: HTMLElement): void;
  11966. private _collisionMask;
  11967. /**
  11968. * Define a collision mask to limit the list of object the camera can collide with
  11969. */
  11970. collisionMask: number;
  11971. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11972. private _onCollisionPositionChange;
  11973. /** @hidden */ private _checkInputs(): void;
  11974. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11975. /** @hidden */ private _updatePosition(): void;
  11976. /**
  11977. * Destroy the camera and release the current resources hold by it.
  11978. */
  11979. dispose(): void;
  11980. /**
  11981. * Gets the current object class name.
  11982. * @return the class name
  11983. */
  11984. getClassName(): string;
  11985. }
  11986. }
  11987. declare module BABYLON {
  11988. /**
  11989. * Represents a gamepad control stick position
  11990. */
  11991. export class StickValues {
  11992. /**
  11993. * The x component of the control stick
  11994. */
  11995. x: number;
  11996. /**
  11997. * The y component of the control stick
  11998. */
  11999. y: number;
  12000. /**
  12001. * Initializes the gamepad x and y control stick values
  12002. * @param x The x component of the gamepad control stick value
  12003. * @param y The y component of the gamepad control stick value
  12004. */
  12005. constructor(
  12006. /**
  12007. * The x component of the control stick
  12008. */
  12009. x: number,
  12010. /**
  12011. * The y component of the control stick
  12012. */
  12013. y: number);
  12014. }
  12015. /**
  12016. * An interface which manages callbacks for gamepad button changes
  12017. */
  12018. export interface GamepadButtonChanges {
  12019. /**
  12020. * Called when a gamepad has been changed
  12021. */
  12022. changed: boolean;
  12023. /**
  12024. * Called when a gamepad press event has been triggered
  12025. */
  12026. pressChanged: boolean;
  12027. /**
  12028. * Called when a touch event has been triggered
  12029. */
  12030. touchChanged: boolean;
  12031. /**
  12032. * Called when a value has changed
  12033. */
  12034. valueChanged: boolean;
  12035. }
  12036. /**
  12037. * Represents a gamepad
  12038. */
  12039. export class Gamepad {
  12040. /**
  12041. * The id of the gamepad
  12042. */
  12043. id: string;
  12044. /**
  12045. * The index of the gamepad
  12046. */
  12047. index: number;
  12048. /**
  12049. * The browser gamepad
  12050. */
  12051. browserGamepad: any;
  12052. /**
  12053. * Specifies what type of gamepad this represents
  12054. */
  12055. type: number;
  12056. private _leftStick;
  12057. private _rightStick;
  12058. /** @hidden */ private _isConnected: boolean;
  12059. private _leftStickAxisX;
  12060. private _leftStickAxisY;
  12061. private _rightStickAxisX;
  12062. private _rightStickAxisY;
  12063. /**
  12064. * Triggered when the left control stick has been changed
  12065. */
  12066. private _onleftstickchanged;
  12067. /**
  12068. * Triggered when the right control stick has been changed
  12069. */
  12070. private _onrightstickchanged;
  12071. /**
  12072. * Represents a gamepad controller
  12073. */
  12074. static GAMEPAD: number;
  12075. /**
  12076. * Represents a generic controller
  12077. */
  12078. static GENERIC: number;
  12079. /**
  12080. * Represents an XBox controller
  12081. */
  12082. static XBOX: number;
  12083. /**
  12084. * Represents a pose-enabled controller
  12085. */
  12086. static POSE_ENABLED: number;
  12087. /**
  12088. * Represents an Dual Shock controller
  12089. */
  12090. static DUALSHOCK: number;
  12091. /**
  12092. * Specifies whether the left control stick should be Y-inverted
  12093. */
  12094. protected _invertLeftStickY: boolean;
  12095. /**
  12096. * Specifies if the gamepad has been connected
  12097. */
  12098. readonly isConnected: boolean;
  12099. /**
  12100. * Initializes the gamepad
  12101. * @param id The id of the gamepad
  12102. * @param index The index of the gamepad
  12103. * @param browserGamepad The browser gamepad
  12104. * @param leftStickX The x component of the left joystick
  12105. * @param leftStickY The y component of the left joystick
  12106. * @param rightStickX The x component of the right joystick
  12107. * @param rightStickY The y component of the right joystick
  12108. */
  12109. constructor(
  12110. /**
  12111. * The id of the gamepad
  12112. */
  12113. id: string,
  12114. /**
  12115. * The index of the gamepad
  12116. */
  12117. index: number,
  12118. /**
  12119. * The browser gamepad
  12120. */
  12121. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12122. /**
  12123. * Callback triggered when the left joystick has changed
  12124. * @param callback
  12125. */
  12126. onleftstickchanged(callback: (values: StickValues) => void): void;
  12127. /**
  12128. * Callback triggered when the right joystick has changed
  12129. * @param callback
  12130. */
  12131. onrightstickchanged(callback: (values: StickValues) => void): void;
  12132. /**
  12133. * Gets the left joystick
  12134. */
  12135. /**
  12136. * Sets the left joystick values
  12137. */
  12138. leftStick: StickValues;
  12139. /**
  12140. * Gets the right joystick
  12141. */
  12142. /**
  12143. * Sets the right joystick value
  12144. */
  12145. rightStick: StickValues;
  12146. /**
  12147. * Updates the gamepad joystick positions
  12148. */
  12149. update(): void;
  12150. /**
  12151. * Disposes the gamepad
  12152. */
  12153. dispose(): void;
  12154. }
  12155. /**
  12156. * Represents a generic gamepad
  12157. */
  12158. export class GenericPad extends Gamepad {
  12159. private _buttons;
  12160. private _onbuttondown;
  12161. private _onbuttonup;
  12162. /**
  12163. * Observable triggered when a button has been pressed
  12164. */
  12165. onButtonDownObservable: Observable<number>;
  12166. /**
  12167. * Observable triggered when a button has been released
  12168. */
  12169. onButtonUpObservable: Observable<number>;
  12170. /**
  12171. * Callback triggered when a button has been pressed
  12172. * @param callback Called when a button has been pressed
  12173. */
  12174. onbuttondown(callback: (buttonPressed: number) => void): void;
  12175. /**
  12176. * Callback triggered when a button has been released
  12177. * @param callback Called when a button has been released
  12178. */
  12179. onbuttonup(callback: (buttonReleased: number) => void): void;
  12180. /**
  12181. * Initializes the generic gamepad
  12182. * @param id The id of the generic gamepad
  12183. * @param index The index of the generic gamepad
  12184. * @param browserGamepad The browser gamepad
  12185. */
  12186. constructor(id: string, index: number, browserGamepad: any);
  12187. private _setButtonValue;
  12188. /**
  12189. * Updates the generic gamepad
  12190. */
  12191. update(): void;
  12192. /**
  12193. * Disposes the generic gamepad
  12194. */
  12195. dispose(): void;
  12196. }
  12197. }
  12198. declare module BABYLON {
  12199. interface Engine {
  12200. /**
  12201. * Creates a raw texture
  12202. * @param data defines the data to store in the texture
  12203. * @param width defines the width of the texture
  12204. * @param height defines the height of the texture
  12205. * @param format defines the format of the data
  12206. * @param generateMipMaps defines if the engine should generate the mip levels
  12207. * @param invertY defines if data must be stored with Y axis inverted
  12208. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12209. * @param compression defines the compression used (null by default)
  12210. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12211. * @returns the raw texture inside an InternalTexture
  12212. */
  12213. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12214. /**
  12215. * Update a raw texture
  12216. * @param texture defines the texture to update
  12217. * @param data defines the data to store in the texture
  12218. * @param format defines the format of the data
  12219. * @param invertY defines if data must be stored with Y axis inverted
  12220. */
  12221. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12222. /**
  12223. * Update a raw texture
  12224. * @param texture defines the texture to update
  12225. * @param data defines the data to store in the texture
  12226. * @param format defines the format of the data
  12227. * @param invertY defines if data must be stored with Y axis inverted
  12228. * @param compression defines the compression used (null by default)
  12229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12230. */
  12231. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12232. /**
  12233. * Creates a new raw cube texture
  12234. * @param data defines the array of data to use to create each face
  12235. * @param size defines the size of the textures
  12236. * @param format defines the format of the data
  12237. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12238. * @param generateMipMaps defines if the engine should generate the mip levels
  12239. * @param invertY defines if data must be stored with Y axis inverted
  12240. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12241. * @param compression defines the compression used (null by default)
  12242. * @returns the cube texture as an InternalTexture
  12243. */
  12244. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12245. /**
  12246. * Update a raw cube texture
  12247. * @param texture defines the texture to udpdate
  12248. * @param data defines the data to store
  12249. * @param format defines the data format
  12250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12251. * @param invertY defines if data must be stored with Y axis inverted
  12252. */
  12253. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12254. /**
  12255. * Update a raw cube texture
  12256. * @param texture defines the texture to udpdate
  12257. * @param data defines the data to store
  12258. * @param format defines the data format
  12259. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12260. * @param invertY defines if data must be stored with Y axis inverted
  12261. * @param compression defines the compression used (null by default)
  12262. */
  12263. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12264. /**
  12265. * Update a raw cube texture
  12266. * @param texture defines the texture to udpdate
  12267. * @param data defines the data to store
  12268. * @param format defines the data format
  12269. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12270. * @param invertY defines if data must be stored with Y axis inverted
  12271. * @param compression defines the compression used (null by default)
  12272. * @param level defines which level of the texture to update
  12273. */
  12274. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12275. /**
  12276. * Creates a new raw cube texture from a specified url
  12277. * @param url defines the url where the data is located
  12278. * @param scene defines the current scene
  12279. * @param size defines the size of the textures
  12280. * @param format defines the format of the data
  12281. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12282. * @param noMipmap defines if the engine should avoid generating the mip levels
  12283. * @param callback defines a callback used to extract texture data from loaded data
  12284. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12285. * @param onLoad defines a callback called when texture is loaded
  12286. * @param onError defines a callback called if there is an error
  12287. * @returns the cube texture as an InternalTexture
  12288. */
  12289. 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;
  12290. /**
  12291. * Creates a new raw cube texture from a specified url
  12292. * @param url defines the url where the data is located
  12293. * @param scene defines the current scene
  12294. * @param size defines the size of the textures
  12295. * @param format defines the format of the data
  12296. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12297. * @param noMipmap defines if the engine should avoid generating the mip levels
  12298. * @param callback defines a callback used to extract texture data from loaded data
  12299. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12300. * @param onLoad defines a callback called when texture is loaded
  12301. * @param onError defines a callback called if there is an error
  12302. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @returns the cube texture as an InternalTexture
  12305. */
  12306. 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;
  12307. /**
  12308. * Creates a new raw 3D texture
  12309. * @param data defines the data used to create the texture
  12310. * @param width defines the width of the texture
  12311. * @param height defines the height of the texture
  12312. * @param depth defines the depth of the texture
  12313. * @param format defines the format of the texture
  12314. * @param generateMipMaps defines if the engine must generate mip levels
  12315. * @param invertY defines if data must be stored with Y axis inverted
  12316. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12317. * @param compression defines the compressed used (can be null)
  12318. * @param textureType defines the compressed used (can be null)
  12319. * @returns a new raw 3D texture (stored in an InternalTexture)
  12320. */
  12321. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12322. /**
  12323. * Update a raw 3D texture
  12324. * @param texture defines the texture to update
  12325. * @param data defines the data to store
  12326. * @param format defines the data format
  12327. * @param invertY defines if data must be stored with Y axis inverted
  12328. */
  12329. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12330. /**
  12331. * Update a raw 3D texture
  12332. * @param texture defines the texture to update
  12333. * @param data defines the data to store
  12334. * @param format defines the data format
  12335. * @param invertY defines if data must be stored with Y axis inverted
  12336. * @param compression defines the used compression (can be null)
  12337. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12338. */
  12339. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12340. }
  12341. }
  12342. declare module BABYLON {
  12343. /**
  12344. * Raw texture can help creating a texture directly from an array of data.
  12345. * This can be super useful if you either get the data from an uncompressed source or
  12346. * if you wish to create your texture pixel by pixel.
  12347. */
  12348. export class RawTexture extends Texture {
  12349. /**
  12350. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12351. */
  12352. format: number;
  12353. private _engine;
  12354. /**
  12355. * Instantiates a new RawTexture.
  12356. * Raw texture can help creating a texture directly from an array of data.
  12357. * This can be super useful if you either get the data from an uncompressed source or
  12358. * if you wish to create your texture pixel by pixel.
  12359. * @param data define the array of data to use to create the texture
  12360. * @param width define the width of the texture
  12361. * @param height define the height of the texture
  12362. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12363. * @param scene define the scene the texture belongs to
  12364. * @param generateMipMaps define whether mip maps should be generated or not
  12365. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12366. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12367. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12368. */
  12369. constructor(data: ArrayBufferView, width: number, height: number,
  12370. /**
  12371. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12372. */
  12373. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12374. /**
  12375. * Updates the texture underlying data.
  12376. * @param data Define the new data of the texture
  12377. */
  12378. update(data: ArrayBufferView): void;
  12379. /**
  12380. * Creates a luminance texture from some data.
  12381. * @param data Define the texture data
  12382. * @param width Define the width of the texture
  12383. * @param height Define the height of the texture
  12384. * @param scene Define the scene the texture belongs to
  12385. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12386. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12387. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12388. * @returns the luminance texture
  12389. */
  12390. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12391. /**
  12392. * Creates a luminance alpha texture from some data.
  12393. * @param data Define the texture data
  12394. * @param width Define the width of the texture
  12395. * @param height Define the height of the texture
  12396. * @param scene Define the scene the texture belongs to
  12397. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12400. * @returns the luminance alpha texture
  12401. */
  12402. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12403. /**
  12404. * Creates an alpha texture from some data.
  12405. * @param data Define the texture data
  12406. * @param width Define the width of the texture
  12407. * @param height Define the height of the texture
  12408. * @param scene Define the scene the texture belongs to
  12409. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12410. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12411. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12412. * @returns the alpha texture
  12413. */
  12414. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12415. /**
  12416. * Creates a RGB texture from some data.
  12417. * @param data Define the texture data
  12418. * @param width Define the width of the texture
  12419. * @param height Define the height of the texture
  12420. * @param scene Define the scene the texture belongs to
  12421. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12422. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12423. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12424. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12425. * @returns the RGB alpha texture
  12426. */
  12427. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12428. /**
  12429. * Creates a RGBA texture from some data.
  12430. * @param data Define the texture data
  12431. * @param width Define the width of the texture
  12432. * @param height Define the height of the texture
  12433. * @param scene Define the scene the texture belongs to
  12434. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12435. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12436. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12437. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12438. * @returns the RGBA texture
  12439. */
  12440. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12441. /**
  12442. * Creates a R texture from some data.
  12443. * @param data Define the texture data
  12444. * @param width Define the width of the texture
  12445. * @param height Define the height of the texture
  12446. * @param scene Define the scene the texture belongs to
  12447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12450. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12451. * @returns the R texture
  12452. */
  12453. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12454. }
  12455. }
  12456. declare module BABYLON {
  12457. /**
  12458. * Interface for the size containing width and height
  12459. */
  12460. export interface ISize {
  12461. /**
  12462. * Width
  12463. */
  12464. width: number;
  12465. /**
  12466. * Heighht
  12467. */
  12468. height: number;
  12469. }
  12470. /**
  12471. * Size containing widht and height
  12472. */
  12473. export class Size implements ISize {
  12474. /**
  12475. * Width
  12476. */
  12477. width: number;
  12478. /**
  12479. * Height
  12480. */
  12481. height: number;
  12482. /**
  12483. * Creates a Size object from the given width and height (floats).
  12484. * @param width width of the new size
  12485. * @param height height of the new size
  12486. */
  12487. constructor(width: number, height: number);
  12488. /**
  12489. * Returns a string with the Size width and height
  12490. * @returns a string with the Size width and height
  12491. */
  12492. toString(): string;
  12493. /**
  12494. * "Size"
  12495. * @returns the string "Size"
  12496. */
  12497. getClassName(): string;
  12498. /**
  12499. * Returns the Size hash code.
  12500. * @returns a hash code for a unique width and height
  12501. */
  12502. getHashCode(): number;
  12503. /**
  12504. * Updates the current size from the given one.
  12505. * @param src the given size
  12506. */
  12507. copyFrom(src: Size): void;
  12508. /**
  12509. * Updates in place the current Size from the given floats.
  12510. * @param width width of the new size
  12511. * @param height height of the new size
  12512. * @returns the updated Size.
  12513. */
  12514. copyFromFloats(width: number, height: number): Size;
  12515. /**
  12516. * Updates in place the current Size from the given floats.
  12517. * @param width width to set
  12518. * @param height height to set
  12519. * @returns the updated Size.
  12520. */
  12521. set(width: number, height: number): Size;
  12522. /**
  12523. * Multiplies the width and height by numbers
  12524. * @param w factor to multiple the width by
  12525. * @param h factor to multiple the height by
  12526. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12527. */
  12528. multiplyByFloats(w: number, h: number): Size;
  12529. /**
  12530. * Clones the size
  12531. * @returns a new Size copied from the given one.
  12532. */
  12533. clone(): Size;
  12534. /**
  12535. * True if the current Size and the given one width and height are strictly equal.
  12536. * @param other the other size to compare against
  12537. * @returns True if the current Size and the given one width and height are strictly equal.
  12538. */
  12539. equals(other: Size): boolean;
  12540. /**
  12541. * The surface of the Size : width * height (float).
  12542. */
  12543. readonly surface: number;
  12544. /**
  12545. * Create a new size of zero
  12546. * @returns a new Size set to (0.0, 0.0)
  12547. */
  12548. static Zero(): Size;
  12549. /**
  12550. * Sums the width and height of two sizes
  12551. * @param otherSize size to add to this size
  12552. * @returns a new Size set as the addition result of the current Size and the given one.
  12553. */
  12554. add(otherSize: Size): Size;
  12555. /**
  12556. * Subtracts the width and height of two
  12557. * @param otherSize size to subtract to this size
  12558. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12559. */
  12560. subtract(otherSize: Size): Size;
  12561. /**
  12562. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12563. * @param start starting size to lerp between
  12564. * @param end end size to lerp between
  12565. * @param amount amount to lerp between the start and end values
  12566. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12567. */
  12568. static Lerp(start: Size, end: Size, amount: number): Size;
  12569. }
  12570. }
  12571. declare module BABYLON {
  12572. /**
  12573. * Defines a runtime animation
  12574. */
  12575. export class RuntimeAnimation {
  12576. private _events;
  12577. /**
  12578. * The current frame of the runtime animation
  12579. */
  12580. private _currentFrame;
  12581. /**
  12582. * The animation used by the runtime animation
  12583. */
  12584. private _animation;
  12585. /**
  12586. * The target of the runtime animation
  12587. */
  12588. private _target;
  12589. /**
  12590. * The initiating animatable
  12591. */
  12592. private _host;
  12593. /**
  12594. * The original value of the runtime animation
  12595. */
  12596. private _originalValue;
  12597. /**
  12598. * The original blend value of the runtime animation
  12599. */
  12600. private _originalBlendValue;
  12601. /**
  12602. * The offsets cache of the runtime animation
  12603. */
  12604. private _offsetsCache;
  12605. /**
  12606. * The high limits cache of the runtime animation
  12607. */
  12608. private _highLimitsCache;
  12609. /**
  12610. * Specifies if the runtime animation has been stopped
  12611. */
  12612. private _stopped;
  12613. /**
  12614. * The blending factor of the runtime animation
  12615. */
  12616. private _blendingFactor;
  12617. /**
  12618. * The BabylonJS scene
  12619. */
  12620. private _scene;
  12621. /**
  12622. * The current value of the runtime animation
  12623. */
  12624. private _currentValue;
  12625. /** @hidden */ private _animationState: _IAnimationState;
  12626. /**
  12627. * The active target of the runtime animation
  12628. */
  12629. private _activeTargets;
  12630. private _currentActiveTarget;
  12631. private _directTarget;
  12632. /**
  12633. * The target path of the runtime animation
  12634. */
  12635. private _targetPath;
  12636. /**
  12637. * The weight of the runtime animation
  12638. */
  12639. private _weight;
  12640. /**
  12641. * The ratio offset of the runtime animation
  12642. */
  12643. private _ratioOffset;
  12644. /**
  12645. * The previous delay of the runtime animation
  12646. */
  12647. private _previousDelay;
  12648. /**
  12649. * The previous ratio of the runtime animation
  12650. */
  12651. private _previousRatio;
  12652. private _enableBlending;
  12653. private _keys;
  12654. private _minFrame;
  12655. private _maxFrame;
  12656. private _minValue;
  12657. private _maxValue;
  12658. private _targetIsArray;
  12659. /**
  12660. * Gets the current frame of the runtime animation
  12661. */
  12662. readonly currentFrame: number;
  12663. /**
  12664. * Gets the weight of the runtime animation
  12665. */
  12666. readonly weight: number;
  12667. /**
  12668. * Gets the current value of the runtime animation
  12669. */
  12670. readonly currentValue: any;
  12671. /**
  12672. * Gets the target path of the runtime animation
  12673. */
  12674. readonly targetPath: string;
  12675. /**
  12676. * Gets the actual target of the runtime animation
  12677. */
  12678. readonly target: any;
  12679. /** @hidden */ private _onLoop: () => void;
  12680. /**
  12681. * Create a new RuntimeAnimation object
  12682. * @param target defines the target of the animation
  12683. * @param animation defines the source animation object
  12684. * @param scene defines the hosting scene
  12685. * @param host defines the initiating Animatable
  12686. */
  12687. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12688. private _preparePath;
  12689. /**
  12690. * Gets the animation from the runtime animation
  12691. */
  12692. readonly animation: Animation;
  12693. /**
  12694. * Resets the runtime animation to the beginning
  12695. * @param restoreOriginal defines whether to restore the target property to the original value
  12696. */
  12697. reset(restoreOriginal?: boolean): void;
  12698. /**
  12699. * Specifies if the runtime animation is stopped
  12700. * @returns Boolean specifying if the runtime animation is stopped
  12701. */
  12702. isStopped(): boolean;
  12703. /**
  12704. * Disposes of the runtime animation
  12705. */
  12706. dispose(): void;
  12707. /**
  12708. * Apply the interpolated value to the target
  12709. * @param currentValue defines the value computed by the animation
  12710. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12711. */
  12712. setValue(currentValue: any, weight: number): void;
  12713. private _getOriginalValues;
  12714. private _setValue;
  12715. /**
  12716. * Gets the loop pmode of the runtime animation
  12717. * @returns Loop Mode
  12718. */
  12719. private _getCorrectLoopMode;
  12720. /**
  12721. * Move the current animation to a given frame
  12722. * @param frame defines the frame to move to
  12723. */
  12724. goToFrame(frame: number): void;
  12725. /**
  12726. * @hidden Internal use only
  12727. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12728. /**
  12729. * Execute the current animation
  12730. * @param delay defines the delay to add to the current frame
  12731. * @param from defines the lower bound of the animation range
  12732. * @param to defines the upper bound of the animation range
  12733. * @param loop defines if the current animation must loop
  12734. * @param speedRatio defines the current speed ratio
  12735. * @param weight defines the weight of the animation (default is -1 so no weight)
  12736. * @param onLoop optional callback called when animation loops
  12737. * @returns a boolean indicating if the animation is running
  12738. */
  12739. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12740. }
  12741. }
  12742. declare module BABYLON {
  12743. /**
  12744. * Class used to store an actual running animation
  12745. */
  12746. export class Animatable {
  12747. /** defines the target object */
  12748. target: any;
  12749. /** defines the starting frame number (default is 0) */
  12750. fromFrame: number;
  12751. /** defines the ending frame number (default is 100) */
  12752. toFrame: number;
  12753. /** defines if the animation must loop (default is false) */
  12754. loopAnimation: boolean;
  12755. /** defines a callback to call when animation ends if it is not looping */
  12756. onAnimationEnd?: (() => void) | null | undefined;
  12757. /** defines a callback to call when animation loops */
  12758. onAnimationLoop?: (() => void) | null | undefined;
  12759. private _localDelayOffset;
  12760. private _pausedDelay;
  12761. private _runtimeAnimations;
  12762. private _paused;
  12763. private _scene;
  12764. private _speedRatio;
  12765. private _weight;
  12766. private _syncRoot;
  12767. /**
  12768. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12769. * This will only apply for non looping animation (default is true)
  12770. */
  12771. disposeOnEnd: boolean;
  12772. /**
  12773. * Gets a boolean indicating if the animation has started
  12774. */
  12775. animationStarted: boolean;
  12776. /**
  12777. * Observer raised when the animation ends
  12778. */
  12779. onAnimationEndObservable: Observable<Animatable>;
  12780. /**
  12781. * Observer raised when the animation loops
  12782. */
  12783. onAnimationLoopObservable: Observable<Animatable>;
  12784. /**
  12785. * Gets the root Animatable used to synchronize and normalize animations
  12786. */
  12787. readonly syncRoot: Nullable<Animatable>;
  12788. /**
  12789. * Gets the current frame of the first RuntimeAnimation
  12790. * Used to synchronize Animatables
  12791. */
  12792. readonly masterFrame: number;
  12793. /**
  12794. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12795. */
  12796. weight: number;
  12797. /**
  12798. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12799. */
  12800. speedRatio: number;
  12801. /**
  12802. * Creates a new Animatable
  12803. * @param scene defines the hosting scene
  12804. * @param target defines the target object
  12805. * @param fromFrame defines the starting frame number (default is 0)
  12806. * @param toFrame defines the ending frame number (default is 100)
  12807. * @param loopAnimation defines if the animation must loop (default is false)
  12808. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12809. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12810. * @param animations defines a group of animation to add to the new Animatable
  12811. * @param onAnimationLoop defines a callback to call when animation loops
  12812. */
  12813. constructor(scene: Scene,
  12814. /** defines the target object */
  12815. target: any,
  12816. /** defines the starting frame number (default is 0) */
  12817. fromFrame?: number,
  12818. /** defines the ending frame number (default is 100) */
  12819. toFrame?: number,
  12820. /** defines if the animation must loop (default is false) */
  12821. loopAnimation?: boolean, speedRatio?: number,
  12822. /** defines a callback to call when animation ends if it is not looping */
  12823. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12824. /** defines a callback to call when animation loops */
  12825. onAnimationLoop?: (() => void) | null | undefined);
  12826. /**
  12827. * Synchronize and normalize current Animatable with a source Animatable
  12828. * This is useful when using animation weights and when animations are not of the same length
  12829. * @param root defines the root Animatable to synchronize with
  12830. * @returns the current Animatable
  12831. */
  12832. syncWith(root: Animatable): Animatable;
  12833. /**
  12834. * Gets the list of runtime animations
  12835. * @returns an array of RuntimeAnimation
  12836. */
  12837. getAnimations(): RuntimeAnimation[];
  12838. /**
  12839. * Adds more animations to the current animatable
  12840. * @param target defines the target of the animations
  12841. * @param animations defines the new animations to add
  12842. */
  12843. appendAnimations(target: any, animations: Animation[]): void;
  12844. /**
  12845. * Gets the source animation for a specific property
  12846. * @param property defines the propertyu to look for
  12847. * @returns null or the source animation for the given property
  12848. */
  12849. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12850. /**
  12851. * Gets the runtime animation for a specific property
  12852. * @param property defines the propertyu to look for
  12853. * @returns null or the runtime animation for the given property
  12854. */
  12855. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12856. /**
  12857. * Resets the animatable to its original state
  12858. */
  12859. reset(): void;
  12860. /**
  12861. * Allows the animatable to blend with current running animations
  12862. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12863. * @param blendingSpeed defines the blending speed to use
  12864. */
  12865. enableBlending(blendingSpeed: number): void;
  12866. /**
  12867. * Disable animation blending
  12868. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12869. */
  12870. disableBlending(): void;
  12871. /**
  12872. * Jump directly to a given frame
  12873. * @param frame defines the frame to jump to
  12874. */
  12875. goToFrame(frame: number): void;
  12876. /**
  12877. * Pause the animation
  12878. */
  12879. pause(): void;
  12880. /**
  12881. * Restart the animation
  12882. */
  12883. restart(): void;
  12884. private _raiseOnAnimationEnd;
  12885. /**
  12886. * Stop and delete the current animation
  12887. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12888. * @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)
  12889. */
  12890. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12891. /**
  12892. * Wait asynchronously for the animation to end
  12893. * @returns a promise which will be fullfilled when the animation ends
  12894. */
  12895. waitAsync(): Promise<Animatable>;
  12896. /** @hidden */ private _animate(delay: number): boolean;
  12897. }
  12898. interface Scene {
  12899. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12900. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12901. totalWeight: number;
  12902. animations: RuntimeAnimation[];
  12903. originalValue: Matrix;
  12904. }): any;
  12905. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12906. totalWeight: number;
  12907. animations: RuntimeAnimation[];
  12908. originalValue: Quaternion;
  12909. }, refQuaternion: Quaternion): Quaternion;
  12910. /** @hidden */ private _processLateAnimationBindings(): void;
  12911. /**
  12912. * Will start the animation sequence of a given target
  12913. * @param target defines the target
  12914. * @param from defines from which frame should animation start
  12915. * @param to defines until which frame should animation run.
  12916. * @param weight defines the weight to apply to the animation (1.0 by default)
  12917. * @param loop defines if the animation loops
  12918. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12919. * @param onAnimationEnd defines the function to be executed when the animation ends
  12920. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12921. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12922. * @param onAnimationLoop defines the callback to call when an animation loops
  12923. * @returns the animatable object created for this animation
  12924. */
  12925. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12926. /**
  12927. * Will start the animation sequence of a given target
  12928. * @param target defines the target
  12929. * @param from defines from which frame should animation start
  12930. * @param to defines until which frame should animation run.
  12931. * @param loop defines if the animation loops
  12932. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12933. * @param onAnimationEnd defines the function to be executed when the animation ends
  12934. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12935. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12936. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12937. * @param onAnimationLoop defines the callback to call when an animation loops
  12938. * @returns the animatable object created for this animation
  12939. */
  12940. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12941. /**
  12942. * Will start the animation sequence of a given target and its hierarchy
  12943. * @param target defines the target
  12944. * @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.
  12945. * @param from defines from which frame should animation start
  12946. * @param to defines until which frame should animation run.
  12947. * @param loop defines if the animation loops
  12948. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12949. * @param onAnimationEnd defines the function to be executed when the animation ends
  12950. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12951. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12952. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12953. * @param onAnimationLoop defines the callback to call when an animation loops
  12954. * @returns the list of created animatables
  12955. */
  12956. 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[];
  12957. /**
  12958. * Begin a new animation on a given node
  12959. * @param target defines the target where the animation will take place
  12960. * @param animations defines the list of animations to start
  12961. * @param from defines the initial value
  12962. * @param to defines the final value
  12963. * @param loop defines if you want animation to loop (off by default)
  12964. * @param speedRatio defines the speed ratio to apply to all animations
  12965. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12966. * @param onAnimationLoop defines the callback to call when an animation loops
  12967. * @returns the list of created animatables
  12968. */
  12969. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12970. /**
  12971. * Begin a new animation on a given node and its hierarchy
  12972. * @param target defines the root node where the animation will take place
  12973. * @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.
  12974. * @param animations defines the list of animations to start
  12975. * @param from defines the initial value
  12976. * @param to defines the final value
  12977. * @param loop defines if you want animation to loop (off by default)
  12978. * @param speedRatio defines the speed ratio to apply to all animations
  12979. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12980. * @param onAnimationLoop defines the callback to call when an animation loops
  12981. * @returns the list of animatables created for all nodes
  12982. */
  12983. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12984. /**
  12985. * Gets the animatable associated with a specific target
  12986. * @param target defines the target of the animatable
  12987. * @returns the required animatable if found
  12988. */
  12989. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12990. /**
  12991. * Gets all animatables associated with a given target
  12992. * @param target defines the target to look animatables for
  12993. * @returns an array of Animatables
  12994. */
  12995. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12996. /**
  12997. * Stops and removes all animations that have been applied to the scene
  12998. */
  12999. stopAllAnimations(): void;
  13000. /**
  13001. * Gets the current delta time used by animation engine
  13002. */
  13003. deltaTime: number;
  13004. }
  13005. interface Bone {
  13006. /**
  13007. * Copy an animation range from another bone
  13008. * @param source defines the source bone
  13009. * @param rangeName defines the range name to copy
  13010. * @param frameOffset defines the frame offset
  13011. * @param rescaleAsRequired defines if rescaling must be applied if required
  13012. * @param skelDimensionsRatio defines the scaling ratio
  13013. * @returns true if operation was successful
  13014. */
  13015. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13016. }
  13017. }
  13018. declare module BABYLON {
  13019. /**
  13020. * Class used to override all child animations of a given target
  13021. */
  13022. export class AnimationPropertiesOverride {
  13023. /**
  13024. * Gets or sets a value indicating if animation blending must be used
  13025. */
  13026. enableBlending: boolean;
  13027. /**
  13028. * Gets or sets the blending speed to use when enableBlending is true
  13029. */
  13030. blendingSpeed: number;
  13031. /**
  13032. * Gets or sets the default loop mode to use
  13033. */
  13034. loopMode: number;
  13035. }
  13036. }
  13037. declare module BABYLON {
  13038. /**
  13039. * Class used to handle skinning animations
  13040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13041. */
  13042. export class Skeleton implements IAnimatable {
  13043. /** defines the skeleton name */
  13044. name: string;
  13045. /** defines the skeleton Id */
  13046. id: string;
  13047. /**
  13048. * Defines the list of child bones
  13049. */
  13050. bones: Bone[];
  13051. /**
  13052. * Defines an estimate of the dimension of the skeleton at rest
  13053. */
  13054. dimensionsAtRest: Vector3;
  13055. /**
  13056. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13057. */
  13058. needInitialSkinMatrix: boolean;
  13059. /**
  13060. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13061. */
  13062. overrideMesh: Nullable<AbstractMesh>;
  13063. /**
  13064. * Gets the list of animations attached to this skeleton
  13065. */
  13066. animations: Array<Animation>;
  13067. private _scene;
  13068. private _isDirty;
  13069. private _transformMatrices;
  13070. private _transformMatrixTexture;
  13071. private _meshesWithPoseMatrix;
  13072. private _animatables;
  13073. private _identity;
  13074. private _synchronizedWithMesh;
  13075. private _ranges;
  13076. private _lastAbsoluteTransformsUpdateId;
  13077. private _canUseTextureForBones;
  13078. private _uniqueId;
  13079. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13080. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13081. /**
  13082. * Specifies if the skeleton should be serialized
  13083. */
  13084. doNotSerialize: boolean;
  13085. private _useTextureToStoreBoneMatrices;
  13086. /**
  13087. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13088. * Please note that this option is not available if the hardware does not support it
  13089. */
  13090. useTextureToStoreBoneMatrices: boolean;
  13091. private _animationPropertiesOverride;
  13092. /**
  13093. * Gets or sets the animation properties override
  13094. */
  13095. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13096. /**
  13097. * List of inspectable custom properties (used by the Inspector)
  13098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13099. */
  13100. inspectableCustomProperties: IInspectable[];
  13101. /**
  13102. * An observable triggered before computing the skeleton's matrices
  13103. */
  13104. onBeforeComputeObservable: Observable<Skeleton>;
  13105. /**
  13106. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13107. */
  13108. readonly isUsingTextureForMatrices: boolean;
  13109. /**
  13110. * Gets the unique ID of this skeleton
  13111. */
  13112. readonly uniqueId: number;
  13113. /**
  13114. * Creates a new skeleton
  13115. * @param name defines the skeleton name
  13116. * @param id defines the skeleton Id
  13117. * @param scene defines the hosting scene
  13118. */
  13119. constructor(
  13120. /** defines the skeleton name */
  13121. name: string,
  13122. /** defines the skeleton Id */
  13123. id: string, scene: Scene);
  13124. /**
  13125. * Gets the current object class name.
  13126. * @return the class name
  13127. */
  13128. getClassName(): string;
  13129. /**
  13130. * Returns an array containing the root bones
  13131. * @returns an array containing the root bones
  13132. */
  13133. getChildren(): Array<Bone>;
  13134. /**
  13135. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13136. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13137. * @returns a Float32Array containing matrices data
  13138. */
  13139. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13140. /**
  13141. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13142. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13143. * @returns a raw texture containing the data
  13144. */
  13145. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13146. /**
  13147. * Gets the current hosting scene
  13148. * @returns a scene object
  13149. */
  13150. getScene(): Scene;
  13151. /**
  13152. * Gets a string representing the current skeleton data
  13153. * @param fullDetails defines a boolean indicating if we want a verbose version
  13154. * @returns a string representing the current skeleton data
  13155. */
  13156. toString(fullDetails?: boolean): string;
  13157. /**
  13158. * Get bone's index searching by name
  13159. * @param name defines bone's name to search for
  13160. * @return the indice of the bone. Returns -1 if not found
  13161. */
  13162. getBoneIndexByName(name: string): number;
  13163. /**
  13164. * Creater a new animation range
  13165. * @param name defines the name of the range
  13166. * @param from defines the start key
  13167. * @param to defines the end key
  13168. */
  13169. createAnimationRange(name: string, from: number, to: number): void;
  13170. /**
  13171. * Delete a specific animation range
  13172. * @param name defines the name of the range
  13173. * @param deleteFrames defines if frames must be removed as well
  13174. */
  13175. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13176. /**
  13177. * Gets a specific animation range
  13178. * @param name defines the name of the range to look for
  13179. * @returns the requested animation range or null if not found
  13180. */
  13181. getAnimationRange(name: string): Nullable<AnimationRange>;
  13182. /**
  13183. * Gets the list of all animation ranges defined on this skeleton
  13184. * @returns an array
  13185. */
  13186. getAnimationRanges(): Nullable<AnimationRange>[];
  13187. /**
  13188. * Copy animation range from a source skeleton.
  13189. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13190. * @param source defines the source skeleton
  13191. * @param name defines the name of the range to copy
  13192. * @param rescaleAsRequired defines if rescaling must be applied if required
  13193. * @returns true if operation was successful
  13194. */
  13195. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13196. /**
  13197. * Forces the skeleton to go to rest pose
  13198. */
  13199. returnToRest(): void;
  13200. private _getHighestAnimationFrame;
  13201. /**
  13202. * Begin a specific animation range
  13203. * @param name defines the name of the range to start
  13204. * @param loop defines if looping must be turned on (false by default)
  13205. * @param speedRatio defines the speed ratio to apply (1 by default)
  13206. * @param onAnimationEnd defines a callback which will be called when animation will end
  13207. * @returns a new animatable
  13208. */
  13209. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13210. /** @hidden */ private _markAsDirty(): void;
  13211. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13212. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13213. private _computeTransformMatrices;
  13214. /**
  13215. * Build all resources required to render a skeleton
  13216. */
  13217. prepare(): void;
  13218. /**
  13219. * Gets the list of animatables currently running for this skeleton
  13220. * @returns an array of animatables
  13221. */
  13222. getAnimatables(): IAnimatable[];
  13223. /**
  13224. * Clone the current skeleton
  13225. * @param name defines the name of the new skeleton
  13226. * @param id defines the id of the new skeleton
  13227. * @returns the new skeleton
  13228. */
  13229. clone(name: string, id?: string): Skeleton;
  13230. /**
  13231. * Enable animation blending for this skeleton
  13232. * @param blendingSpeed defines the blending speed to apply
  13233. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13234. */
  13235. enableBlending(blendingSpeed?: number): void;
  13236. /**
  13237. * Releases all resources associated with the current skeleton
  13238. */
  13239. dispose(): void;
  13240. /**
  13241. * Serialize the skeleton in a JSON object
  13242. * @returns a JSON object
  13243. */
  13244. serialize(): any;
  13245. /**
  13246. * Creates a new skeleton from serialized data
  13247. * @param parsedSkeleton defines the serialized data
  13248. * @param scene defines the hosting scene
  13249. * @returns a new skeleton
  13250. */
  13251. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13252. /**
  13253. * Compute all node absolute transforms
  13254. * @param forceUpdate defines if computation must be done even if cache is up to date
  13255. */
  13256. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13257. /**
  13258. * Gets the root pose matrix
  13259. * @returns a matrix
  13260. */
  13261. getPoseMatrix(): Nullable<Matrix>;
  13262. /**
  13263. * Sorts bones per internal index
  13264. */
  13265. sortBones(): void;
  13266. private _sortBones;
  13267. }
  13268. }
  13269. declare module BABYLON {
  13270. /**
  13271. * Class used to store bone information
  13272. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13273. */
  13274. export class Bone extends Node {
  13275. /**
  13276. * defines the bone name
  13277. */
  13278. name: string;
  13279. private static _tmpVecs;
  13280. private static _tmpQuat;
  13281. private static _tmpMats;
  13282. /**
  13283. * Gets the list of child bones
  13284. */
  13285. children: Bone[];
  13286. /** Gets the animations associated with this bone */
  13287. animations: Animation[];
  13288. /**
  13289. * Gets or sets bone length
  13290. */
  13291. length: number;
  13292. /**
  13293. * @hidden Internal only
  13294. * Set this value to map this bone to a different index in the transform matrices
  13295. * Set this value to -1 to exclude the bone from the transform matrices
  13296. */ private _index: Nullable<number>;
  13297. private _skeleton;
  13298. private _localMatrix;
  13299. private _restPose;
  13300. private _baseMatrix;
  13301. private _absoluteTransform;
  13302. private _invertedAbsoluteTransform;
  13303. private _parent;
  13304. private _scalingDeterminant;
  13305. private _worldTransform;
  13306. private _localScaling;
  13307. private _localRotation;
  13308. private _localPosition;
  13309. private _needToDecompose;
  13310. private _needToCompose;
  13311. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13312. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13313. /** @hidden */
  13314. /** @hidden */ private _matrix: Matrix;
  13315. /**
  13316. * Create a new bone
  13317. * @param name defines the bone name
  13318. * @param skeleton defines the parent skeleton
  13319. * @param parentBone defines the parent (can be null if the bone is the root)
  13320. * @param localMatrix defines the local matrix
  13321. * @param restPose defines the rest pose matrix
  13322. * @param baseMatrix defines the base matrix
  13323. * @param index defines index of the bone in the hiearchy
  13324. */
  13325. constructor(
  13326. /**
  13327. * defines the bone name
  13328. */
  13329. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13330. /**
  13331. * Gets the current object class name.
  13332. * @return the class name
  13333. */
  13334. getClassName(): string;
  13335. /**
  13336. * Gets the parent skeleton
  13337. * @returns a skeleton
  13338. */
  13339. getSkeleton(): Skeleton;
  13340. /**
  13341. * Gets parent bone
  13342. * @returns a bone or null if the bone is the root of the bone hierarchy
  13343. */
  13344. getParent(): Nullable<Bone>;
  13345. /**
  13346. * Returns an array containing the root bones
  13347. * @returns an array containing the root bones
  13348. */
  13349. getChildren(): Array<Bone>;
  13350. /**
  13351. * Gets the node index in matrix array generated for rendering
  13352. * @returns the node index
  13353. */
  13354. getIndex(): number;
  13355. /**
  13356. * Sets the parent bone
  13357. * @param parent defines the parent (can be null if the bone is the root)
  13358. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13359. */
  13360. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13361. /**
  13362. * Gets the local matrix
  13363. * @returns a matrix
  13364. */
  13365. getLocalMatrix(): Matrix;
  13366. /**
  13367. * Gets the base matrix (initial matrix which remains unchanged)
  13368. * @returns a matrix
  13369. */
  13370. getBaseMatrix(): Matrix;
  13371. /**
  13372. * Gets the rest pose matrix
  13373. * @returns a matrix
  13374. */
  13375. getRestPose(): Matrix;
  13376. /**
  13377. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13378. */
  13379. getWorldMatrix(): Matrix;
  13380. /**
  13381. * Sets the local matrix to rest pose matrix
  13382. */
  13383. returnToRest(): void;
  13384. /**
  13385. * Gets the inverse of the absolute transform matrix.
  13386. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13387. * @returns a matrix
  13388. */
  13389. getInvertedAbsoluteTransform(): Matrix;
  13390. /**
  13391. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13392. * @returns a matrix
  13393. */
  13394. getAbsoluteTransform(): Matrix;
  13395. /**
  13396. * Links with the given transform node.
  13397. * The local matrix of this bone is copied from the transform node every frame.
  13398. * @param transformNode defines the transform node to link to
  13399. */
  13400. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13401. /**
  13402. * Gets the node used to drive the bone's transformation
  13403. * @returns a transform node or null
  13404. */
  13405. getTransformNode(): Nullable<TransformNode>;
  13406. /** Gets or sets current position (in local space) */
  13407. position: Vector3;
  13408. /** Gets or sets current rotation (in local space) */
  13409. rotation: Vector3;
  13410. /** Gets or sets current rotation quaternion (in local space) */
  13411. rotationQuaternion: Quaternion;
  13412. /** Gets or sets current scaling (in local space) */
  13413. scaling: Vector3;
  13414. /**
  13415. * Gets the animation properties override
  13416. */
  13417. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13418. private _decompose;
  13419. private _compose;
  13420. /**
  13421. * Update the base and local matrices
  13422. * @param matrix defines the new base or local matrix
  13423. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13424. * @param updateLocalMatrix defines if the local matrix should be updated
  13425. */
  13426. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13427. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13428. /**
  13429. * Flag the bone as dirty (Forcing it to update everything)
  13430. */
  13431. markAsDirty(): void;
  13432. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13433. private _markAsDirtyAndDecompose;
  13434. /**
  13435. * Translate the bone in local or world space
  13436. * @param vec The amount to translate the bone
  13437. * @param space The space that the translation is in
  13438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13439. */
  13440. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13441. /**
  13442. * Set the postion of the bone in local or world space
  13443. * @param position The position to set the bone
  13444. * @param space The space that the position is in
  13445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13446. */
  13447. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13448. /**
  13449. * Set the absolute position of the bone (world space)
  13450. * @param position The position to set the bone
  13451. * @param mesh The mesh that this bone is attached to
  13452. */
  13453. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13454. /**
  13455. * Scale the bone on the x, y and z axes (in local space)
  13456. * @param x The amount to scale the bone on the x axis
  13457. * @param y The amount to scale the bone on the y axis
  13458. * @param z The amount to scale the bone on the z axis
  13459. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13460. */
  13461. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13462. /**
  13463. * Set the bone scaling in local space
  13464. * @param scale defines the scaling vector
  13465. */
  13466. setScale(scale: Vector3): void;
  13467. /**
  13468. * Gets the current scaling in local space
  13469. * @returns the current scaling vector
  13470. */
  13471. getScale(): Vector3;
  13472. /**
  13473. * Gets the current scaling in local space and stores it in a target vector
  13474. * @param result defines the target vector
  13475. */
  13476. getScaleToRef(result: Vector3): void;
  13477. /**
  13478. * Set the yaw, pitch, and roll of the bone in local or world space
  13479. * @param yaw The rotation of the bone on the y axis
  13480. * @param pitch The rotation of the bone on the x axis
  13481. * @param roll The rotation of the bone on the z axis
  13482. * @param space The space that the axes of rotation are in
  13483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13484. */
  13485. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13486. /**
  13487. * Add a rotation to the bone on an axis in local or world space
  13488. * @param axis The axis to rotate the bone on
  13489. * @param amount The amount to rotate the bone
  13490. * @param space The space that the axis is in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. */
  13493. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13494. /**
  13495. * Set the rotation of the bone to a particular axis angle in local or world space
  13496. * @param axis The axis to rotate the bone on
  13497. * @param angle The angle that the bone should be rotated to
  13498. * @param space The space that the axis is in
  13499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13500. */
  13501. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13502. /**
  13503. * Set the euler rotation of the bone in local of world space
  13504. * @param rotation The euler rotation that the bone should be set to
  13505. * @param space The space that the rotation is in
  13506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13507. */
  13508. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13509. /**
  13510. * Set the quaternion rotation of the bone in local of world space
  13511. * @param quat The quaternion rotation that the bone should be set to
  13512. * @param space The space that the rotation is in
  13513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13514. */
  13515. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13516. /**
  13517. * Set the rotation matrix of the bone in local of world space
  13518. * @param rotMat The rotation matrix that the bone should be set to
  13519. * @param space The space that the rotation is in
  13520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13521. */
  13522. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13523. private _rotateWithMatrix;
  13524. private _getNegativeRotationToRef;
  13525. /**
  13526. * Get the position of the bone in local or world space
  13527. * @param space The space that the returned position is in
  13528. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13529. * @returns The position of the bone
  13530. */
  13531. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13532. /**
  13533. * Copy the position of the bone to a vector3 in local or world space
  13534. * @param space The space that the returned position is in
  13535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13536. * @param result The vector3 to copy the position to
  13537. */
  13538. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13539. /**
  13540. * Get the absolute position of the bone (world space)
  13541. * @param mesh The mesh that this bone is attached to
  13542. * @returns The absolute position of the bone
  13543. */
  13544. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13545. /**
  13546. * Copy the absolute position of the bone (world space) to the result param
  13547. * @param mesh The mesh that this bone is attached to
  13548. * @param result The vector3 to copy the absolute position to
  13549. */
  13550. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13551. /**
  13552. * Compute the absolute transforms of this bone and its children
  13553. */
  13554. computeAbsoluteTransforms(): void;
  13555. /**
  13556. * Get the world direction from an axis that is in the local space of the bone
  13557. * @param localAxis The local direction that is used to compute the world direction
  13558. * @param mesh The mesh that this bone is attached to
  13559. * @returns The world direction
  13560. */
  13561. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13562. /**
  13563. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13564. * @param localAxis The local direction that is used to compute the world direction
  13565. * @param mesh The mesh that this bone is attached to
  13566. * @param result The vector3 that the world direction will be copied to
  13567. */
  13568. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13569. /**
  13570. * Get the euler rotation of the bone in local or world space
  13571. * @param space The space that the rotation should be in
  13572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13573. * @returns The euler rotation
  13574. */
  13575. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13576. /**
  13577. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13578. * @param space The space that the rotation should be in
  13579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13580. * @param result The vector3 that the rotation should be copied to
  13581. */
  13582. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13583. /**
  13584. * Get the quaternion rotation of the bone in either local or world space
  13585. * @param space The space that the rotation should be in
  13586. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13587. * @returns The quaternion rotation
  13588. */
  13589. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13590. /**
  13591. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13592. * @param space The space that the rotation should be in
  13593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13594. * @param result The quaternion that the rotation should be copied to
  13595. */
  13596. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13597. /**
  13598. * Get the rotation matrix of the bone in local or world space
  13599. * @param space The space that the rotation should be in
  13600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13601. * @returns The rotation matrix
  13602. */
  13603. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13604. /**
  13605. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13606. * @param space The space that the rotation should be in
  13607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13608. * @param result The quaternion that the rotation should be copied to
  13609. */
  13610. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13611. /**
  13612. * Get the world position of a point that is in the local space of the bone
  13613. * @param position The local position
  13614. * @param mesh The mesh that this bone is attached to
  13615. * @returns The world position
  13616. */
  13617. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13618. /**
  13619. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13620. * @param position The local position
  13621. * @param mesh The mesh that this bone is attached to
  13622. * @param result The vector3 that the world position should be copied to
  13623. */
  13624. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13625. /**
  13626. * Get the local position of a point that is in world space
  13627. * @param position The world position
  13628. * @param mesh The mesh that this bone is attached to
  13629. * @returns The local position
  13630. */
  13631. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13632. /**
  13633. * Get the local position of a point that is in world space and copy it to the result param
  13634. * @param position The world position
  13635. * @param mesh The mesh that this bone is attached to
  13636. * @param result The vector3 that the local position should be copied to
  13637. */
  13638. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13639. }
  13640. }
  13641. declare module BABYLON {
  13642. /**
  13643. * 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.
  13644. * @see https://doc.babylonjs.com/how_to/transformnode
  13645. */
  13646. export class TransformNode extends Node {
  13647. /**
  13648. * Object will not rotate to face the camera
  13649. */
  13650. static BILLBOARDMODE_NONE: number;
  13651. /**
  13652. * Object will rotate to face the camera but only on the x axis
  13653. */
  13654. static BILLBOARDMODE_X: number;
  13655. /**
  13656. * Object will rotate to face the camera but only on the y axis
  13657. */
  13658. static BILLBOARDMODE_Y: number;
  13659. /**
  13660. * Object will rotate to face the camera but only on the z axis
  13661. */
  13662. static BILLBOARDMODE_Z: number;
  13663. /**
  13664. * Object will rotate to face the camera
  13665. */
  13666. static BILLBOARDMODE_ALL: number;
  13667. /**
  13668. * Object will rotate to face the camera's position instead of orientation
  13669. */
  13670. static BILLBOARDMODE_USE_POSITION: number;
  13671. private _forward;
  13672. private _forwardInverted;
  13673. private _up;
  13674. private _right;
  13675. private _rightInverted;
  13676. private _position;
  13677. private _rotation;
  13678. private _rotationQuaternion;
  13679. protected _scaling: Vector3;
  13680. protected _isDirty: boolean;
  13681. private _transformToBoneReferal;
  13682. private _isAbsoluteSynced;
  13683. private _billboardMode;
  13684. /**
  13685. * Gets or sets the billboard mode. Default is 0.
  13686. *
  13687. * | Value | Type | Description |
  13688. * | --- | --- | --- |
  13689. * | 0 | BILLBOARDMODE_NONE | |
  13690. * | 1 | BILLBOARDMODE_X | |
  13691. * | 2 | BILLBOARDMODE_Y | |
  13692. * | 4 | BILLBOARDMODE_Z | |
  13693. * | 7 | BILLBOARDMODE_ALL | |
  13694. *
  13695. */
  13696. billboardMode: number;
  13697. private _preserveParentRotationForBillboard;
  13698. /**
  13699. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13700. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13701. */
  13702. preserveParentRotationForBillboard: boolean;
  13703. /**
  13704. * 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
  13705. */
  13706. scalingDeterminant: number;
  13707. private _infiniteDistance;
  13708. /**
  13709. * Gets or sets the distance of the object to max, often used by skybox
  13710. */
  13711. infiniteDistance: boolean;
  13712. /**
  13713. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13714. * By default the system will update normals to compensate
  13715. */
  13716. ignoreNonUniformScaling: boolean;
  13717. /**
  13718. * 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
  13719. */
  13720. reIntegrateRotationIntoRotationQuaternion: boolean;
  13721. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13722. /** @hidden */ private _localMatrix: Matrix;
  13723. private _usePivotMatrix;
  13724. private _absolutePosition;
  13725. private _absoluteScaling;
  13726. private _absoluteRotationQuaternion;
  13727. private _pivotMatrix;
  13728. private _pivotMatrixInverse;
  13729. protected _postMultiplyPivotMatrix: boolean;
  13730. protected _isWorldMatrixFrozen: boolean;
  13731. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13732. /**
  13733. * An event triggered after the world matrix is updated
  13734. */
  13735. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13736. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13737. /**
  13738. * Gets a string identifying the name of the class
  13739. * @returns "TransformNode" string
  13740. */
  13741. getClassName(): string;
  13742. /**
  13743. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13744. */
  13745. position: Vector3;
  13746. /**
  13747. * 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)).
  13748. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13749. */
  13750. rotation: Vector3;
  13751. /**
  13752. * 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)).
  13753. */
  13754. scaling: Vector3;
  13755. /**
  13756. * 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).
  13757. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13758. */
  13759. rotationQuaternion: Nullable<Quaternion>;
  13760. /**
  13761. * The forward direction of that transform in world space.
  13762. */
  13763. readonly forward: Vector3;
  13764. /**
  13765. * The up direction of that transform in world space.
  13766. */
  13767. readonly up: Vector3;
  13768. /**
  13769. * The right direction of that transform in world space.
  13770. */
  13771. readonly right: Vector3;
  13772. /**
  13773. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13774. * @param matrix the matrix to copy the pose from
  13775. * @returns this TransformNode.
  13776. */
  13777. updatePoseMatrix(matrix: Matrix): TransformNode;
  13778. /**
  13779. * Returns the mesh Pose matrix.
  13780. * @returns the pose matrix
  13781. */
  13782. getPoseMatrix(): Matrix;
  13783. /** @hidden */ private _isSynchronized(): boolean;
  13784. /** @hidden */ private _initCache(): void;
  13785. /**
  13786. * Flag the transform node as dirty (Forcing it to update everything)
  13787. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13788. * @returns this transform node
  13789. */
  13790. markAsDirty(property: string): TransformNode;
  13791. /**
  13792. * Returns the current mesh absolute position.
  13793. * Returns a Vector3.
  13794. */
  13795. readonly absolutePosition: Vector3;
  13796. /**
  13797. * Returns the current mesh absolute scaling.
  13798. * Returns a Vector3.
  13799. */
  13800. readonly absoluteScaling: Vector3;
  13801. /**
  13802. * Returns the current mesh absolute rotation.
  13803. * Returns a Quaternion.
  13804. */
  13805. readonly absoluteRotationQuaternion: Quaternion;
  13806. /**
  13807. * Sets a new matrix to apply before all other transformation
  13808. * @param matrix defines the transform matrix
  13809. * @returns the current TransformNode
  13810. */
  13811. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13812. /**
  13813. * Sets a new pivot matrix to the current node
  13814. * @param matrix defines the new pivot matrix to use
  13815. * @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
  13816. * @returns the current TransformNode
  13817. */
  13818. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13819. /**
  13820. * Returns the mesh pivot matrix.
  13821. * Default : Identity.
  13822. * @returns the matrix
  13823. */
  13824. getPivotMatrix(): Matrix;
  13825. /**
  13826. * Instantiate (when possible) or clone that node with its hierarchy
  13827. * @param newParent defines the new parent to use for the instance (or clone)
  13828. * @param options defines options to configure how copy is done
  13829. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13830. * @returns an instance (or a clone) of the current node with its hiearchy
  13831. */
  13832. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13833. doNotInstantiate: boolean;
  13834. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13835. /**
  13836. * Prevents the World matrix to be computed any longer
  13837. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13838. * @returns the TransformNode.
  13839. */
  13840. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13841. /**
  13842. * Allows back the World matrix computation.
  13843. * @returns the TransformNode.
  13844. */
  13845. unfreezeWorldMatrix(): this;
  13846. /**
  13847. * True if the World matrix has been frozen.
  13848. */
  13849. readonly isWorldMatrixFrozen: boolean;
  13850. /**
  13851. * Retuns the mesh absolute position in the World.
  13852. * @returns a Vector3.
  13853. */
  13854. getAbsolutePosition(): Vector3;
  13855. /**
  13856. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13857. * @param absolutePosition the absolute position to set
  13858. * @returns the TransformNode.
  13859. */
  13860. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13861. /**
  13862. * Sets the mesh position in its local space.
  13863. * @param vector3 the position to set in localspace
  13864. * @returns the TransformNode.
  13865. */
  13866. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13867. /**
  13868. * Returns the mesh position in the local space from the current World matrix values.
  13869. * @returns a new Vector3.
  13870. */
  13871. getPositionExpressedInLocalSpace(): Vector3;
  13872. /**
  13873. * Translates the mesh along the passed Vector3 in its local space.
  13874. * @param vector3 the distance to translate in localspace
  13875. * @returns the TransformNode.
  13876. */
  13877. locallyTranslate(vector3: Vector3): TransformNode;
  13878. private static _lookAtVectorCache;
  13879. /**
  13880. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13881. * @param targetPoint the position (must be in same space as current mesh) to look at
  13882. * @param yawCor optional yaw (y-axis) correction in radians
  13883. * @param pitchCor optional pitch (x-axis) correction in radians
  13884. * @param rollCor optional roll (z-axis) correction in radians
  13885. * @param space the choosen space of the target
  13886. * @returns the TransformNode.
  13887. */
  13888. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13889. /**
  13890. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13891. * This Vector3 is expressed in the World space.
  13892. * @param localAxis axis to rotate
  13893. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13894. */
  13895. getDirection(localAxis: Vector3): Vector3;
  13896. /**
  13897. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13898. * localAxis is expressed in the mesh local space.
  13899. * result is computed in the Wordl space from the mesh World matrix.
  13900. * @param localAxis axis to rotate
  13901. * @param result the resulting transformnode
  13902. * @returns this TransformNode.
  13903. */
  13904. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13905. /**
  13906. * Sets this transform node rotation to the given local axis.
  13907. * @param localAxis the axis in local space
  13908. * @param yawCor optional yaw (y-axis) correction in radians
  13909. * @param pitchCor optional pitch (x-axis) correction in radians
  13910. * @param rollCor optional roll (z-axis) correction in radians
  13911. * @returns this TransformNode
  13912. */
  13913. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13914. /**
  13915. * Sets a new pivot point to the current node
  13916. * @param point defines the new pivot point to use
  13917. * @param space defines if the point is in world or local space (local by default)
  13918. * @returns the current TransformNode
  13919. */
  13920. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13921. /**
  13922. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13923. * @returns the pivot point
  13924. */
  13925. getPivotPoint(): Vector3;
  13926. /**
  13927. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13928. * @param result the vector3 to store the result
  13929. * @returns this TransformNode.
  13930. */
  13931. getPivotPointToRef(result: Vector3): TransformNode;
  13932. /**
  13933. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13934. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13935. */
  13936. getAbsolutePivotPoint(): Vector3;
  13937. /**
  13938. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13939. * @param result vector3 to store the result
  13940. * @returns this TransformNode.
  13941. */
  13942. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13943. /**
  13944. * Defines the passed node as the parent of the current node.
  13945. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13946. * @see https://doc.babylonjs.com/how_to/parenting
  13947. * @param node the node ot set as the parent
  13948. * @returns this TransformNode.
  13949. */
  13950. setParent(node: Nullable<Node>): TransformNode;
  13951. private _nonUniformScaling;
  13952. /**
  13953. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13954. */
  13955. readonly nonUniformScaling: boolean;
  13956. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13957. /**
  13958. * Attach the current TransformNode to another TransformNode associated with a bone
  13959. * @param bone Bone affecting the TransformNode
  13960. * @param affectedTransformNode TransformNode associated with the bone
  13961. * @returns this object
  13962. */
  13963. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13964. /**
  13965. * Detach the transform node if its associated with a bone
  13966. * @returns this object
  13967. */
  13968. detachFromBone(): TransformNode;
  13969. private static _rotationAxisCache;
  13970. /**
  13971. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13972. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13973. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13974. * The passed axis is also normalized.
  13975. * @param axis the axis to rotate around
  13976. * @param amount the amount to rotate in radians
  13977. * @param space Space to rotate in (Default: local)
  13978. * @returns the TransformNode.
  13979. */
  13980. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13981. /**
  13982. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13983. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13984. * The passed axis is also normalized. .
  13985. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13986. * @param point the point to rotate around
  13987. * @param axis the axis to rotate around
  13988. * @param amount the amount to rotate in radians
  13989. * @returns the TransformNode
  13990. */
  13991. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13992. /**
  13993. * Translates the mesh along the axis vector for the passed distance in the given space.
  13994. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13995. * @param axis the axis to translate in
  13996. * @param distance the distance to translate
  13997. * @param space Space to rotate in (Default: local)
  13998. * @returns the TransformNode.
  13999. */
  14000. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14001. /**
  14002. * Adds a rotation step to the mesh current rotation.
  14003. * x, y, z are Euler angles expressed in radians.
  14004. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14005. * This means this rotation is made in the mesh local space only.
  14006. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14007. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14008. * ```javascript
  14009. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14010. * ```
  14011. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14012. * 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.
  14013. * @param x Rotation to add
  14014. * @param y Rotation to add
  14015. * @param z Rotation to add
  14016. * @returns the TransformNode.
  14017. */
  14018. addRotation(x: number, y: number, z: number): TransformNode;
  14019. /**
  14020. * @hidden
  14021. */
  14022. protected _getEffectiveParent(): Nullable<Node>;
  14023. /**
  14024. * Computes the world matrix of the node
  14025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14026. * @returns the world matrix
  14027. */
  14028. computeWorldMatrix(force?: boolean): Matrix;
  14029. protected _afterComputeWorldMatrix(): void;
  14030. /**
  14031. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14032. * @param func callback function to add
  14033. *
  14034. * @returns the TransformNode.
  14035. */
  14036. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14037. /**
  14038. * Removes a registered callback function.
  14039. * @param func callback function to remove
  14040. * @returns the TransformNode.
  14041. */
  14042. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14043. /**
  14044. * Gets the position of the current mesh in camera space
  14045. * @param camera defines the camera to use
  14046. * @returns a position
  14047. */
  14048. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14049. /**
  14050. * Returns the distance from the mesh to the active camera
  14051. * @param camera defines the camera to use
  14052. * @returns the distance
  14053. */
  14054. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14055. /**
  14056. * Clone the current transform node
  14057. * @param name Name of the new clone
  14058. * @param newParent New parent for the clone
  14059. * @param doNotCloneChildren Do not clone children hierarchy
  14060. * @returns the new transform node
  14061. */
  14062. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14063. /**
  14064. * Serializes the objects information.
  14065. * @param currentSerializationObject defines the object to serialize in
  14066. * @returns the serialized object
  14067. */
  14068. serialize(currentSerializationObject?: any): any;
  14069. /**
  14070. * Returns a new TransformNode object parsed from the source provided.
  14071. * @param parsedTransformNode is the source.
  14072. * @param scene the scne the object belongs to
  14073. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14074. * @returns a new TransformNode object parsed from the source provided.
  14075. */
  14076. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14077. /**
  14078. * Get all child-transformNodes of this node
  14079. * @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
  14080. * @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
  14081. * @returns an array of TransformNode
  14082. */
  14083. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14084. /**
  14085. * Releases resources associated with this transform node.
  14086. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14087. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14088. */
  14089. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14090. /**
  14091. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14092. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14093. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14094. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14095. * @returns the current mesh
  14096. */
  14097. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14098. private _syncAbsoluteScalingAndRotation;
  14099. }
  14100. }
  14101. declare module BABYLON {
  14102. /**
  14103. * Defines the types of pose enabled controllers that are supported
  14104. */
  14105. export enum PoseEnabledControllerType {
  14106. /**
  14107. * HTC Vive
  14108. */
  14109. VIVE = 0,
  14110. /**
  14111. * Oculus Rift
  14112. */
  14113. OCULUS = 1,
  14114. /**
  14115. * Windows mixed reality
  14116. */
  14117. WINDOWS = 2,
  14118. /**
  14119. * Samsung gear VR
  14120. */
  14121. GEAR_VR = 3,
  14122. /**
  14123. * Google Daydream
  14124. */
  14125. DAYDREAM = 4,
  14126. /**
  14127. * Generic
  14128. */
  14129. GENERIC = 5
  14130. }
  14131. /**
  14132. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14133. */
  14134. export interface MutableGamepadButton {
  14135. /**
  14136. * Value of the button/trigger
  14137. */
  14138. value: number;
  14139. /**
  14140. * If the button/trigger is currently touched
  14141. */
  14142. touched: boolean;
  14143. /**
  14144. * If the button/trigger is currently pressed
  14145. */
  14146. pressed: boolean;
  14147. }
  14148. /**
  14149. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14150. * @hidden
  14151. */
  14152. export interface ExtendedGamepadButton extends GamepadButton {
  14153. /**
  14154. * If the button/trigger is currently pressed
  14155. */
  14156. readonly pressed: boolean;
  14157. /**
  14158. * If the button/trigger is currently touched
  14159. */
  14160. readonly touched: boolean;
  14161. /**
  14162. * Value of the button/trigger
  14163. */
  14164. readonly value: number;
  14165. }
  14166. /** @hidden */
  14167. export interface _GamePadFactory {
  14168. /**
  14169. * Returns wether or not the current gamepad can be created for this type of controller.
  14170. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14171. * @returns true if it can be created, otherwise false
  14172. */
  14173. canCreate(gamepadInfo: any): boolean;
  14174. /**
  14175. * Creates a new instance of the Gamepad.
  14176. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14177. * @returns the new gamepad instance
  14178. */
  14179. create(gamepadInfo: any): Gamepad;
  14180. }
  14181. /**
  14182. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14183. */
  14184. export class PoseEnabledControllerHelper {
  14185. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14186. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14187. /**
  14188. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14189. * @param vrGamepad the gamepad to initialized
  14190. * @returns a vr controller of the type the gamepad identified as
  14191. */
  14192. static InitiateController(vrGamepad: any): Gamepad;
  14193. }
  14194. /**
  14195. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14196. */
  14197. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14198. /**
  14199. * If the controller is used in a webXR session
  14200. */
  14201. isXR: boolean;
  14202. private _deviceRoomPosition;
  14203. private _deviceRoomRotationQuaternion;
  14204. /**
  14205. * The device position in babylon space
  14206. */
  14207. devicePosition: Vector3;
  14208. /**
  14209. * The device rotation in babylon space
  14210. */
  14211. deviceRotationQuaternion: Quaternion;
  14212. /**
  14213. * The scale factor of the device in babylon space
  14214. */
  14215. deviceScaleFactor: number;
  14216. /**
  14217. * (Likely devicePosition should be used instead) The device position in its room space
  14218. */
  14219. position: Vector3;
  14220. /**
  14221. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14222. */
  14223. rotationQuaternion: Quaternion;
  14224. /**
  14225. * The type of controller (Eg. Windows mixed reality)
  14226. */
  14227. controllerType: PoseEnabledControllerType;
  14228. protected _calculatedPosition: Vector3;
  14229. private _calculatedRotation;
  14230. /**
  14231. * The raw pose from the device
  14232. */
  14233. rawPose: DevicePose;
  14234. private _trackPosition;
  14235. private _maxRotationDistFromHeadset;
  14236. private _draggedRoomRotation;
  14237. /**
  14238. * @hidden
  14239. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14240. /**
  14241. * Internal, the mesh attached to the controller
  14242. * @hidden
  14243. */ private _mesh: Nullable<AbstractMesh>;
  14244. private _poseControlledCamera;
  14245. private _leftHandSystemQuaternion;
  14246. /**
  14247. * Internal, matrix used to convert room space to babylon space
  14248. * @hidden
  14249. */ private _deviceToWorld: Matrix;
  14250. /**
  14251. * Node to be used when casting a ray from the controller
  14252. * @hidden
  14253. */ private _pointingPoseNode: Nullable<TransformNode>;
  14254. /**
  14255. * Name of the child mesh that can be used to cast a ray from the controller
  14256. */
  14257. static readonly POINTING_POSE: string;
  14258. /**
  14259. * Creates a new PoseEnabledController from a gamepad
  14260. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14261. */
  14262. constructor(browserGamepad: any);
  14263. private _workingMatrix;
  14264. /**
  14265. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14266. */
  14267. update(): void;
  14268. /**
  14269. * Updates only the pose device and mesh without doing any button event checking
  14270. */
  14271. protected _updatePoseAndMesh(): void;
  14272. /**
  14273. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14274. * @param poseData raw pose fromthe device
  14275. */
  14276. updateFromDevice(poseData: DevicePose): void;
  14277. /**
  14278. * @hidden
  14279. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14280. /**
  14281. * Attaches a mesh to the controller
  14282. * @param mesh the mesh to be attached
  14283. */
  14284. attachToMesh(mesh: AbstractMesh): void;
  14285. /**
  14286. * Attaches the controllers mesh to a camera
  14287. * @param camera the camera the mesh should be attached to
  14288. */
  14289. attachToPoseControlledCamera(camera: TargetCamera): void;
  14290. /**
  14291. * Disposes of the controller
  14292. */
  14293. dispose(): void;
  14294. /**
  14295. * The mesh that is attached to the controller
  14296. */
  14297. readonly mesh: Nullable<AbstractMesh>;
  14298. /**
  14299. * Gets the ray of the controller in the direction the controller is pointing
  14300. * @param length the length the resulting ray should be
  14301. * @returns a ray in the direction the controller is pointing
  14302. */
  14303. getForwardRay(length?: number): Ray;
  14304. }
  14305. }
  14306. declare module BABYLON {
  14307. /**
  14308. * Defines the WebVRController object that represents controllers tracked in 3D space
  14309. */
  14310. export abstract class WebVRController extends PoseEnabledController {
  14311. /**
  14312. * Internal, the default controller model for the controller
  14313. */
  14314. protected _defaultModel: Nullable<AbstractMesh>;
  14315. /**
  14316. * Fired when the trigger state has changed
  14317. */
  14318. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14319. /**
  14320. * Fired when the main button state has changed
  14321. */
  14322. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14323. /**
  14324. * Fired when the secondary button state has changed
  14325. */
  14326. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14327. /**
  14328. * Fired when the pad state has changed
  14329. */
  14330. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14331. /**
  14332. * Fired when controllers stick values have changed
  14333. */
  14334. onPadValuesChangedObservable: Observable<StickValues>;
  14335. /**
  14336. * Array of button availible on the controller
  14337. */
  14338. protected _buttons: Array<MutableGamepadButton>;
  14339. private _onButtonStateChange;
  14340. /**
  14341. * Fired when a controller button's state has changed
  14342. * @param callback the callback containing the button that was modified
  14343. */
  14344. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14345. /**
  14346. * X and Y axis corresponding to the controllers joystick
  14347. */
  14348. pad: StickValues;
  14349. /**
  14350. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14351. */
  14352. hand: string;
  14353. /**
  14354. * The default controller model for the controller
  14355. */
  14356. readonly defaultModel: Nullable<AbstractMesh>;
  14357. /**
  14358. * Creates a new WebVRController from a gamepad
  14359. * @param vrGamepad the gamepad that the WebVRController should be created from
  14360. */
  14361. constructor(vrGamepad: any);
  14362. /**
  14363. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14364. */
  14365. update(): void;
  14366. /**
  14367. * Function to be called when a button is modified
  14368. */
  14369. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14370. /**
  14371. * Loads a mesh and attaches it to the controller
  14372. * @param scene the scene the mesh should be added to
  14373. * @param meshLoaded callback for when the mesh has been loaded
  14374. */
  14375. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14376. private _setButtonValue;
  14377. private _changes;
  14378. private _checkChanges;
  14379. /**
  14380. * Disposes of th webVRCOntroller
  14381. */
  14382. dispose(): void;
  14383. }
  14384. }
  14385. declare module BABYLON {
  14386. /**
  14387. * The HemisphericLight simulates the ambient environment light,
  14388. * so the passed direction is the light reflection direction, not the incoming direction.
  14389. */
  14390. export class HemisphericLight extends Light {
  14391. /**
  14392. * The groundColor is the light in the opposite direction to the one specified during creation.
  14393. * 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.
  14394. */
  14395. groundColor: Color3;
  14396. /**
  14397. * The light reflection direction, not the incoming direction.
  14398. */
  14399. direction: Vector3;
  14400. /**
  14401. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14402. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14403. * The HemisphericLight can't cast shadows.
  14404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14405. * @param name The friendly name of the light
  14406. * @param direction The direction of the light reflection
  14407. * @param scene The scene the light belongs to
  14408. */
  14409. constructor(name: string, direction: Vector3, scene: Scene);
  14410. protected _buildUniformLayout(): void;
  14411. /**
  14412. * Returns the string "HemisphericLight".
  14413. * @return The class name
  14414. */
  14415. getClassName(): string;
  14416. /**
  14417. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14418. * Returns the updated direction.
  14419. * @param target The target the direction should point to
  14420. * @return The computed direction
  14421. */
  14422. setDirectionToTarget(target: Vector3): Vector3;
  14423. /**
  14424. * Returns the shadow generator associated to the light.
  14425. * @returns Always null for hemispheric lights because it does not support shadows.
  14426. */
  14427. getShadowGenerator(): Nullable<IShadowGenerator>;
  14428. /**
  14429. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14430. * @param effect The effect to update
  14431. * @param lightIndex The index of the light in the effect to update
  14432. * @returns The hemispheric light
  14433. */
  14434. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14435. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14436. /**
  14437. * Computes the world matrix of the node
  14438. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14439. * @param useWasUpdatedFlag defines a reserved property
  14440. * @returns the world matrix
  14441. */
  14442. computeWorldMatrix(): Matrix;
  14443. /**
  14444. * Returns the integer 3.
  14445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14446. */
  14447. getTypeID(): number;
  14448. /**
  14449. * Prepares the list of defines specific to the light type.
  14450. * @param defines the list of defines
  14451. * @param lightIndex defines the index of the light for the effect
  14452. */
  14453. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14454. }
  14455. }
  14456. declare module BABYLON {
  14457. /** @hidden */
  14458. export var vrMultiviewToSingleviewPixelShader: {
  14459. name: string;
  14460. shader: string;
  14461. };
  14462. }
  14463. declare module BABYLON {
  14464. /**
  14465. * Renders to multiple views with a single draw call
  14466. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14467. */
  14468. export class MultiviewRenderTarget extends RenderTargetTexture {
  14469. /**
  14470. * Creates a multiview render target
  14471. * @param scene scene used with the render target
  14472. * @param size the size of the render target (used for each view)
  14473. */
  14474. constructor(scene: Scene, size?: number | {
  14475. width: number;
  14476. height: number;
  14477. } | {
  14478. ratio: number;
  14479. });
  14480. /**
  14481. * @hidden
  14482. * @param faceIndex the face index, if its a cube texture
  14483. */ private _bindFrameBuffer(faceIndex?: number): void;
  14484. /**
  14485. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14486. * @returns the view count
  14487. */
  14488. getViewCount(): number;
  14489. }
  14490. }
  14491. declare module BABYLON {
  14492. /**
  14493. * Represents a camera frustum
  14494. */
  14495. export class Frustum {
  14496. /**
  14497. * Gets the planes representing the frustum
  14498. * @param transform matrix to be applied to the returned planes
  14499. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14500. */
  14501. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14502. /**
  14503. * Gets the near frustum plane transformed by the transform matrix
  14504. * @param transform transformation matrix to be applied to the resulting frustum plane
  14505. * @param frustumPlane the resuling frustum plane
  14506. */
  14507. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14508. /**
  14509. * Gets the far frustum plane transformed by the transform matrix
  14510. * @param transform transformation matrix to be applied to the resulting frustum plane
  14511. * @param frustumPlane the resuling frustum plane
  14512. */
  14513. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14514. /**
  14515. * Gets the left frustum plane transformed by the transform matrix
  14516. * @param transform transformation matrix to be applied to the resulting frustum plane
  14517. * @param frustumPlane the resuling frustum plane
  14518. */
  14519. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14520. /**
  14521. * Gets the right frustum plane transformed by the transform matrix
  14522. * @param transform transformation matrix to be applied to the resulting frustum plane
  14523. * @param frustumPlane the resuling frustum plane
  14524. */
  14525. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14526. /**
  14527. * Gets the top frustum plane transformed by the transform matrix
  14528. * @param transform transformation matrix to be applied to the resulting frustum plane
  14529. * @param frustumPlane the resuling frustum plane
  14530. */
  14531. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14532. /**
  14533. * Gets the bottom frustum plane transformed by the transform matrix
  14534. * @param transform transformation matrix to be applied to the resulting frustum plane
  14535. * @param frustumPlane the resuling frustum plane
  14536. */
  14537. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14538. /**
  14539. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14540. * @param transform transformation matrix to be applied to the resulting frustum planes
  14541. * @param frustumPlanes the resuling frustum planes
  14542. */
  14543. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14544. }
  14545. }
  14546. declare module BABYLON {
  14547. interface Engine {
  14548. /**
  14549. * Creates a new multiview render target
  14550. * @param width defines the width of the texture
  14551. * @param height defines the height of the texture
  14552. * @returns the created multiview texture
  14553. */
  14554. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14555. /**
  14556. * Binds a multiview framebuffer to be drawn to
  14557. * @param multiviewTexture texture to bind
  14558. */
  14559. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14560. }
  14561. interface Camera {
  14562. /**
  14563. * @hidden
  14564. * 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)
  14565. */ private _useMultiviewToSingleView: boolean;
  14566. /**
  14567. * @hidden
  14568. * 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)
  14569. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14570. /**
  14571. * @hidden
  14572. * ensures the multiview texture of the camera exists and has the specified width/height
  14573. * @param width height to set on the multiview texture
  14574. * @param height width to set on the multiview texture
  14575. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14576. }
  14577. interface Scene {
  14578. /** @hidden */ private _transformMatrixR: Matrix;
  14579. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14580. /** @hidden */ private _createMultiviewUbo(): void;
  14581. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14582. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14583. }
  14584. }
  14585. declare module BABYLON {
  14586. /**
  14587. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14588. * This will not be used for webXR as it supports displaying texture arrays directly
  14589. */
  14590. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14591. /**
  14592. * Initializes a VRMultiviewToSingleview
  14593. * @param name name of the post process
  14594. * @param camera camera to be applied to
  14595. * @param scaleFactor scaling factor to the size of the output texture
  14596. */
  14597. constructor(name: string, camera: Camera, scaleFactor: number);
  14598. }
  14599. }
  14600. declare module BABYLON {
  14601. interface Engine {
  14602. /** @hidden */ private _vrDisplay: any;
  14603. /** @hidden */ private _vrSupported: boolean;
  14604. /** @hidden */ private _oldSize: Size;
  14605. /** @hidden */ private _oldHardwareScaleFactor: number;
  14606. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14607. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14608. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14609. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14610. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14611. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14612. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14613. /**
  14614. * Observable signaled when VR display mode changes
  14615. */
  14616. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14617. /**
  14618. * Observable signaled when VR request present is complete
  14619. */
  14620. onVRRequestPresentComplete: Observable<boolean>;
  14621. /**
  14622. * Observable signaled when VR request present starts
  14623. */
  14624. onVRRequestPresentStart: Observable<Engine>;
  14625. /**
  14626. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14627. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14628. */
  14629. isInVRExclusivePointerMode: boolean;
  14630. /**
  14631. * Gets a boolean indicating if a webVR device was detected
  14632. * @returns true if a webVR device was detected
  14633. */
  14634. isVRDevicePresent(): boolean;
  14635. /**
  14636. * Gets the current webVR device
  14637. * @returns the current webVR device (or null)
  14638. */
  14639. getVRDevice(): any;
  14640. /**
  14641. * Initializes a webVR display and starts listening to display change events
  14642. * The onVRDisplayChangedObservable will be notified upon these changes
  14643. * @returns A promise containing a VRDisplay and if vr is supported
  14644. */
  14645. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14646. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14647. /**
  14648. * Call this function to switch to webVR mode
  14649. * Will do nothing if webVR is not supported or if there is no webVR device
  14650. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14651. */
  14652. enableVR(): void;
  14653. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14654. }
  14655. }
  14656. declare module BABYLON {
  14657. /**
  14658. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14659. * IMPORTANT!! The data is right-hand data.
  14660. * @export
  14661. * @interface DevicePose
  14662. */
  14663. export interface DevicePose {
  14664. /**
  14665. * The position of the device, values in array are [x,y,z].
  14666. */
  14667. readonly position: Nullable<Float32Array>;
  14668. /**
  14669. * The linearVelocity of the device, values in array are [x,y,z].
  14670. */
  14671. readonly linearVelocity: Nullable<Float32Array>;
  14672. /**
  14673. * The linearAcceleration of the device, values in array are [x,y,z].
  14674. */
  14675. readonly linearAcceleration: Nullable<Float32Array>;
  14676. /**
  14677. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14678. */
  14679. readonly orientation: Nullable<Float32Array>;
  14680. /**
  14681. * The angularVelocity of the device, values in array are [x,y,z].
  14682. */
  14683. readonly angularVelocity: Nullable<Float32Array>;
  14684. /**
  14685. * The angularAcceleration of the device, values in array are [x,y,z].
  14686. */
  14687. readonly angularAcceleration: Nullable<Float32Array>;
  14688. }
  14689. /**
  14690. * Interface representing a pose controlled object in Babylon.
  14691. * A pose controlled object has both regular pose values as well as pose values
  14692. * from an external device such as a VR head mounted display
  14693. */
  14694. export interface PoseControlled {
  14695. /**
  14696. * The position of the object in babylon space.
  14697. */
  14698. position: Vector3;
  14699. /**
  14700. * The rotation quaternion of the object in babylon space.
  14701. */
  14702. rotationQuaternion: Quaternion;
  14703. /**
  14704. * The position of the device in babylon space.
  14705. */
  14706. devicePosition?: Vector3;
  14707. /**
  14708. * The rotation quaternion of the device in babylon space.
  14709. */
  14710. deviceRotationQuaternion: Quaternion;
  14711. /**
  14712. * The raw pose coming from the device.
  14713. */
  14714. rawPose: Nullable<DevicePose>;
  14715. /**
  14716. * The scale of the device to be used when translating from device space to babylon space.
  14717. */
  14718. deviceScaleFactor: number;
  14719. /**
  14720. * Updates the poseControlled values based on the input device pose.
  14721. * @param poseData the pose data to update the object with
  14722. */
  14723. updateFromDevice(poseData: DevicePose): void;
  14724. }
  14725. /**
  14726. * Set of options to customize the webVRCamera
  14727. */
  14728. export interface WebVROptions {
  14729. /**
  14730. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14731. */
  14732. trackPosition?: boolean;
  14733. /**
  14734. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14735. */
  14736. positionScale?: number;
  14737. /**
  14738. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14739. */
  14740. displayName?: string;
  14741. /**
  14742. * Should the native controller meshes be initialized. (default: true)
  14743. */
  14744. controllerMeshes?: boolean;
  14745. /**
  14746. * Creating a default HemiLight only on controllers. (default: true)
  14747. */
  14748. defaultLightingOnControllers?: boolean;
  14749. /**
  14750. * If you don't want to use the default VR button of the helper. (default: false)
  14751. */
  14752. useCustomVRButton?: boolean;
  14753. /**
  14754. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14755. */
  14756. customVRButton?: HTMLButtonElement;
  14757. /**
  14758. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14759. */
  14760. rayLength?: number;
  14761. /**
  14762. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14763. */
  14764. defaultHeight?: number;
  14765. /**
  14766. * If multiview should be used if availible (default: false)
  14767. */
  14768. useMultiview?: boolean;
  14769. }
  14770. /**
  14771. * This represents a WebVR camera.
  14772. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14773. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14774. */
  14775. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14776. private webVROptions;
  14777. /**
  14778. * @hidden
  14779. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14780. */ private _vrDevice: any;
  14781. /**
  14782. * The rawPose of the vrDevice.
  14783. */
  14784. rawPose: Nullable<DevicePose>;
  14785. private _onVREnabled;
  14786. private _specsVersion;
  14787. private _attached;
  14788. private _frameData;
  14789. protected _descendants: Array<Node>;
  14790. private _deviceRoomPosition;
  14791. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14792. private _standingMatrix;
  14793. /**
  14794. * Represents device position in babylon space.
  14795. */
  14796. devicePosition: Vector3;
  14797. /**
  14798. * Represents device rotation in babylon space.
  14799. */
  14800. deviceRotationQuaternion: Quaternion;
  14801. /**
  14802. * The scale of the device to be used when translating from device space to babylon space.
  14803. */
  14804. deviceScaleFactor: number;
  14805. private _deviceToWorld;
  14806. private _worldToDevice;
  14807. /**
  14808. * References to the webVR controllers for the vrDevice.
  14809. */
  14810. controllers: Array<WebVRController>;
  14811. /**
  14812. * Emits an event when a controller is attached.
  14813. */
  14814. onControllersAttachedObservable: Observable<WebVRController[]>;
  14815. /**
  14816. * Emits an event when a controller's mesh has been loaded;
  14817. */
  14818. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14819. /**
  14820. * Emits an event when the HMD's pose has been updated.
  14821. */
  14822. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14823. private _poseSet;
  14824. /**
  14825. * If the rig cameras be used as parent instead of this camera.
  14826. */
  14827. rigParenting: boolean;
  14828. private _lightOnControllers;
  14829. private _defaultHeight?;
  14830. /**
  14831. * Instantiates a WebVRFreeCamera.
  14832. * @param name The name of the WebVRFreeCamera
  14833. * @param position The starting anchor position for the camera
  14834. * @param scene The scene the camera belongs to
  14835. * @param webVROptions a set of customizable options for the webVRCamera
  14836. */
  14837. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14838. /**
  14839. * Gets the device distance from the ground in meters.
  14840. * @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.
  14841. */
  14842. deviceDistanceToRoomGround(): number;
  14843. /**
  14844. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14845. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14846. */
  14847. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14848. /**
  14849. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14850. * @returns A promise with a boolean set to if the standing matrix is supported.
  14851. */
  14852. useStandingMatrixAsync(): Promise<boolean>;
  14853. /**
  14854. * Disposes the camera
  14855. */
  14856. dispose(): void;
  14857. /**
  14858. * Gets a vrController by name.
  14859. * @param name The name of the controller to retreive
  14860. * @returns the controller matching the name specified or null if not found
  14861. */
  14862. getControllerByName(name: string): Nullable<WebVRController>;
  14863. private _leftController;
  14864. /**
  14865. * The controller corresponding to the users left hand.
  14866. */
  14867. readonly leftController: Nullable<WebVRController>;
  14868. private _rightController;
  14869. /**
  14870. * The controller corresponding to the users right hand.
  14871. */
  14872. readonly rightController: Nullable<WebVRController>;
  14873. /**
  14874. * Casts a ray forward from the vrCamera's gaze.
  14875. * @param length Length of the ray (default: 100)
  14876. * @returns the ray corresponding to the gaze
  14877. */
  14878. getForwardRay(length?: number): Ray;
  14879. /**
  14880. * @hidden
  14881. * Updates the camera based on device's frame data
  14882. */ private _checkInputs(): void;
  14883. /**
  14884. * Updates the poseControlled values based on the input device pose.
  14885. * @param poseData Pose coming from the device
  14886. */
  14887. updateFromDevice(poseData: DevicePose): void;
  14888. private _htmlElementAttached;
  14889. private _detachIfAttached;
  14890. /**
  14891. * WebVR's attach control will start broadcasting frames to the device.
  14892. * Note that in certain browsers (chrome for example) this function must be called
  14893. * within a user-interaction callback. Example:
  14894. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14895. *
  14896. * @param element html element to attach the vrDevice to
  14897. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14898. */
  14899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14900. /**
  14901. * Detaches the camera from the html element and disables VR
  14902. *
  14903. * @param element html element to detach from
  14904. */
  14905. detachControl(element: HTMLElement): void;
  14906. /**
  14907. * @returns the name of this class
  14908. */
  14909. getClassName(): string;
  14910. /**
  14911. * Calls resetPose on the vrDisplay
  14912. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14913. */
  14914. resetToCurrentRotation(): void;
  14915. /**
  14916. * @hidden
  14917. * Updates the rig cameras (left and right eye)
  14918. */ private _updateRigCameras(): void;
  14919. private _workingVector;
  14920. private _oneVector;
  14921. private _workingMatrix;
  14922. private updateCacheCalled;
  14923. private _correctPositionIfNotTrackPosition;
  14924. /**
  14925. * @hidden
  14926. * Updates the cached values of the camera
  14927. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14928. */ private _updateCache(ignoreParentClass?: boolean): void;
  14929. /**
  14930. * @hidden
  14931. * Get current device position in babylon world
  14932. */ private _computeDevicePosition(): void;
  14933. /**
  14934. * Updates the current device position and rotation in the babylon world
  14935. */
  14936. update(): void;
  14937. /**
  14938. * @hidden
  14939. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14940. * @returns an identity matrix
  14941. */ private _getViewMatrix(): Matrix;
  14942. private _tmpMatrix;
  14943. /**
  14944. * This function is called by the two RIG cameras.
  14945. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14946. * @hidden
  14947. */ private _getWebVRViewMatrix(): Matrix;
  14948. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14949. private _onGamepadConnectedObserver;
  14950. private _onGamepadDisconnectedObserver;
  14951. private _updateCacheWhenTrackingDisabledObserver;
  14952. /**
  14953. * Initializes the controllers and their meshes
  14954. */
  14955. initControllers(): void;
  14956. }
  14957. }
  14958. declare module BABYLON {
  14959. /**
  14960. * Size options for a post process
  14961. */
  14962. export type PostProcessOptions = {
  14963. width: number;
  14964. height: number;
  14965. };
  14966. /**
  14967. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14968. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14969. */
  14970. export class PostProcess {
  14971. /** Name of the PostProcess. */
  14972. name: string;
  14973. /**
  14974. * Gets or sets the unique id of the post process
  14975. */
  14976. uniqueId: number;
  14977. /**
  14978. * Width of the texture to apply the post process on
  14979. */
  14980. width: number;
  14981. /**
  14982. * Height of the texture to apply the post process on
  14983. */
  14984. height: number;
  14985. /**
  14986. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14987. * @hidden
  14988. */ private _outputTexture: Nullable<InternalTexture>;
  14989. /**
  14990. * Sampling mode used by the shader
  14991. * See https://doc.babylonjs.com/classes/3.1/texture
  14992. */
  14993. renderTargetSamplingMode: number;
  14994. /**
  14995. * Clear color to use when screen clearing
  14996. */
  14997. clearColor: Color4;
  14998. /**
  14999. * If the buffer needs to be cleared before applying the post process. (default: true)
  15000. * Should be set to false if shader will overwrite all previous pixels.
  15001. */
  15002. autoClear: boolean;
  15003. /**
  15004. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15005. */
  15006. alphaMode: number;
  15007. /**
  15008. * Sets the setAlphaBlendConstants of the babylon engine
  15009. */
  15010. alphaConstants: Color4;
  15011. /**
  15012. * Animations to be used for the post processing
  15013. */
  15014. animations: Animation[];
  15015. /**
  15016. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15017. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15018. */
  15019. enablePixelPerfectMode: boolean;
  15020. /**
  15021. * Force the postprocess to be applied without taking in account viewport
  15022. */
  15023. forceFullscreenViewport: boolean;
  15024. /**
  15025. * List of inspectable custom properties (used by the Inspector)
  15026. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15027. */
  15028. inspectableCustomProperties: IInspectable[];
  15029. /**
  15030. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15031. *
  15032. * | Value | Type | Description |
  15033. * | ----- | ----------------------------------- | ----------- |
  15034. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15035. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15036. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15037. *
  15038. */
  15039. scaleMode: number;
  15040. /**
  15041. * Force textures to be a power of two (default: false)
  15042. */
  15043. alwaysForcePOT: boolean;
  15044. private _samples;
  15045. /**
  15046. * Number of sample textures (default: 1)
  15047. */
  15048. samples: number;
  15049. /**
  15050. * Modify the scale of the post process to be the same as the viewport (default: false)
  15051. */
  15052. adaptScaleToCurrentViewport: boolean;
  15053. private _camera;
  15054. private _scene;
  15055. private _engine;
  15056. private _options;
  15057. private _reusable;
  15058. private _textureType;
  15059. /**
  15060. * Smart array of input and output textures for the post process.
  15061. * @hidden
  15062. */ private _textures: SmartArray<InternalTexture>;
  15063. /**
  15064. * The index in _textures that corresponds to the output texture.
  15065. * @hidden
  15066. */ private _currentRenderTextureInd: number;
  15067. private _effect;
  15068. private _samplers;
  15069. private _fragmentUrl;
  15070. private _vertexUrl;
  15071. private _parameters;
  15072. private _scaleRatio;
  15073. protected _indexParameters: any;
  15074. private _shareOutputWithPostProcess;
  15075. private _texelSize;
  15076. private _forcedOutputTexture;
  15077. /**
  15078. * Returns the fragment url or shader name used in the post process.
  15079. * @returns the fragment url or name in the shader store.
  15080. */
  15081. getEffectName(): string;
  15082. /**
  15083. * An event triggered when the postprocess is activated.
  15084. */
  15085. onActivateObservable: Observable<Camera>;
  15086. private _onActivateObserver;
  15087. /**
  15088. * A function that is added to the onActivateObservable
  15089. */
  15090. onActivate: Nullable<(camera: Camera) => void>;
  15091. /**
  15092. * An event triggered when the postprocess changes its size.
  15093. */
  15094. onSizeChangedObservable: Observable<PostProcess>;
  15095. private _onSizeChangedObserver;
  15096. /**
  15097. * A function that is added to the onSizeChangedObservable
  15098. */
  15099. onSizeChanged: (postProcess: PostProcess) => void;
  15100. /**
  15101. * An event triggered when the postprocess applies its effect.
  15102. */
  15103. onApplyObservable: Observable<Effect>;
  15104. private _onApplyObserver;
  15105. /**
  15106. * A function that is added to the onApplyObservable
  15107. */
  15108. onApply: (effect: Effect) => void;
  15109. /**
  15110. * An event triggered before rendering the postprocess
  15111. */
  15112. onBeforeRenderObservable: Observable<Effect>;
  15113. private _onBeforeRenderObserver;
  15114. /**
  15115. * A function that is added to the onBeforeRenderObservable
  15116. */
  15117. onBeforeRender: (effect: Effect) => void;
  15118. /**
  15119. * An event triggered after rendering the postprocess
  15120. */
  15121. onAfterRenderObservable: Observable<Effect>;
  15122. private _onAfterRenderObserver;
  15123. /**
  15124. * A function that is added to the onAfterRenderObservable
  15125. */
  15126. onAfterRender: (efect: Effect) => void;
  15127. /**
  15128. * 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
  15129. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15130. */
  15131. inputTexture: InternalTexture;
  15132. /**
  15133. * Gets the camera which post process is applied to.
  15134. * @returns The camera the post process is applied to.
  15135. */
  15136. getCamera(): Camera;
  15137. /**
  15138. * Gets the texel size of the postprocess.
  15139. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15140. */
  15141. readonly texelSize: Vector2;
  15142. /**
  15143. * Creates a new instance PostProcess
  15144. * @param name The name of the PostProcess.
  15145. * @param fragmentUrl The url of the fragment shader to be used.
  15146. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15147. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15148. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15149. * @param camera The camera to apply the render pass to.
  15150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15151. * @param engine The engine which the post process will be applied. (default: current engine)
  15152. * @param reusable If the post process can be reused on the same frame. (default: false)
  15153. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15154. * @param textureType Type of textures used when performing the post process. (default: 0)
  15155. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15156. * @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
  15157. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15158. */
  15159. constructor(
  15160. /** Name of the PostProcess. */
  15161. 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);
  15162. /**
  15163. * Gets a string idenfifying the name of the class
  15164. * @returns "PostProcess" string
  15165. */
  15166. getClassName(): string;
  15167. /**
  15168. * Gets the engine which this post process belongs to.
  15169. * @returns The engine the post process was enabled with.
  15170. */
  15171. getEngine(): Engine;
  15172. /**
  15173. * The effect that is created when initializing the post process.
  15174. * @returns The created effect corresponding the the postprocess.
  15175. */
  15176. getEffect(): Effect;
  15177. /**
  15178. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15179. * @param postProcess The post process to share the output with.
  15180. * @returns This post process.
  15181. */
  15182. shareOutputWith(postProcess: PostProcess): PostProcess;
  15183. /**
  15184. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15185. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15186. */
  15187. useOwnOutput(): void;
  15188. /**
  15189. * Updates the effect with the current post process compile time values and recompiles the shader.
  15190. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15191. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15192. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15193. * @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
  15194. * @param onCompiled Called when the shader has been compiled.
  15195. * @param onError Called if there is an error when compiling a shader.
  15196. */
  15197. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15198. /**
  15199. * The post process is reusable if it can be used multiple times within one frame.
  15200. * @returns If the post process is reusable
  15201. */
  15202. isReusable(): boolean;
  15203. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15204. markTextureDirty(): void;
  15205. /**
  15206. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15207. * 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.
  15208. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15209. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15210. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15211. * @returns The target texture that was bound to be written to.
  15212. */
  15213. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15214. /**
  15215. * If the post process is supported.
  15216. */
  15217. readonly isSupported: boolean;
  15218. /**
  15219. * The aspect ratio of the output texture.
  15220. */
  15221. readonly aspectRatio: number;
  15222. /**
  15223. * Get a value indicating if the post-process is ready to be used
  15224. * @returns true if the post-process is ready (shader is compiled)
  15225. */
  15226. isReady(): boolean;
  15227. /**
  15228. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15229. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15230. */
  15231. apply(): Nullable<Effect>;
  15232. private _disposeTextures;
  15233. /**
  15234. * Disposes the post process.
  15235. * @param camera The camera to dispose the post process on.
  15236. */
  15237. dispose(camera?: Camera): void;
  15238. }
  15239. }
  15240. declare module BABYLON {
  15241. /** @hidden */
  15242. export var kernelBlurVaryingDeclaration: {
  15243. name: string;
  15244. shader: string;
  15245. };
  15246. }
  15247. declare module BABYLON {
  15248. /** @hidden */
  15249. export var kernelBlurFragment: {
  15250. name: string;
  15251. shader: string;
  15252. };
  15253. }
  15254. declare module BABYLON {
  15255. /** @hidden */
  15256. export var kernelBlurFragment2: {
  15257. name: string;
  15258. shader: string;
  15259. };
  15260. }
  15261. declare module BABYLON {
  15262. /** @hidden */
  15263. export var kernelBlurPixelShader: {
  15264. name: string;
  15265. shader: string;
  15266. };
  15267. }
  15268. declare module BABYLON {
  15269. /** @hidden */
  15270. export var kernelBlurVertex: {
  15271. name: string;
  15272. shader: string;
  15273. };
  15274. }
  15275. declare module BABYLON {
  15276. /** @hidden */
  15277. export var kernelBlurVertexShader: {
  15278. name: string;
  15279. shader: string;
  15280. };
  15281. }
  15282. declare module BABYLON {
  15283. /**
  15284. * The Blur Post Process which blurs an image based on a kernel and direction.
  15285. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15286. */
  15287. export class BlurPostProcess extends PostProcess {
  15288. /** The direction in which to blur the image. */
  15289. direction: Vector2;
  15290. private blockCompilation;
  15291. protected _kernel: number;
  15292. protected _idealKernel: number;
  15293. protected _packedFloat: boolean;
  15294. private _staticDefines;
  15295. /**
  15296. * Sets the length in pixels of the blur sample region
  15297. */
  15298. /**
  15299. * Gets the length in pixels of the blur sample region
  15300. */
  15301. kernel: number;
  15302. /**
  15303. * Sets wether or not the blur needs to unpack/repack floats
  15304. */
  15305. /**
  15306. * Gets wether or not the blur is unpacking/repacking floats
  15307. */
  15308. packedFloat: boolean;
  15309. /**
  15310. * Creates a new instance BlurPostProcess
  15311. * @param name The name of the effect.
  15312. * @param direction The direction in which to blur the image.
  15313. * @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.
  15314. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15315. * @param camera The camera to apply the render pass to.
  15316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15317. * @param engine The engine which the post process will be applied. (default: current engine)
  15318. * @param reusable If the post process can be reused on the same frame. (default: false)
  15319. * @param textureType Type of textures used when performing the post process. (default: 0)
  15320. * @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)
  15321. */
  15322. constructor(name: string,
  15323. /** The direction in which to blur the image. */
  15324. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15325. /**
  15326. * Updates the effect with the current post process compile time values and recompiles the shader.
  15327. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15328. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15329. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15330. * @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
  15331. * @param onCompiled Called when the shader has been compiled.
  15332. * @param onError Called if there is an error when compiling a shader.
  15333. */
  15334. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15335. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15336. /**
  15337. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15338. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15339. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15340. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15341. * The gaps between physical kernels are compensated for in the weighting of the samples
  15342. * @param idealKernel Ideal blur kernel.
  15343. * @return Nearest best kernel.
  15344. */
  15345. protected _nearestBestKernel(idealKernel: number): number;
  15346. /**
  15347. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15348. * @param x The point on the Gaussian distribution to sample.
  15349. * @return the value of the Gaussian function at x.
  15350. */
  15351. protected _gaussianWeight(x: number): number;
  15352. /**
  15353. * Generates a string that can be used as a floating point number in GLSL.
  15354. * @param x Value to print.
  15355. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15356. * @return GLSL float string.
  15357. */
  15358. protected _glslFloat(x: number, decimalFigures?: number): string;
  15359. }
  15360. }
  15361. declare module BABYLON {
  15362. /**
  15363. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15364. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15365. * You can then easily use it as a reflectionTexture on a flat surface.
  15366. * In case the surface is not a plane, please consider relying on reflection probes.
  15367. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15368. */
  15369. export class MirrorTexture extends RenderTargetTexture {
  15370. private scene;
  15371. /**
  15372. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15373. * 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.
  15374. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15375. */
  15376. mirrorPlane: Plane;
  15377. /**
  15378. * Define the blur ratio used to blur the reflection if needed.
  15379. */
  15380. blurRatio: number;
  15381. /**
  15382. * Define the adaptive blur kernel used to blur the reflection if needed.
  15383. * This will autocompute the closest best match for the `blurKernel`
  15384. */
  15385. adaptiveBlurKernel: number;
  15386. /**
  15387. * Define the blur kernel used to blur the reflection if needed.
  15388. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15389. */
  15390. blurKernel: number;
  15391. /**
  15392. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15393. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15394. */
  15395. blurKernelX: number;
  15396. /**
  15397. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15398. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15399. */
  15400. blurKernelY: number;
  15401. private _autoComputeBlurKernel;
  15402. protected _onRatioRescale(): void;
  15403. private _updateGammaSpace;
  15404. private _imageProcessingConfigChangeObserver;
  15405. private _transformMatrix;
  15406. private _mirrorMatrix;
  15407. private _savedViewMatrix;
  15408. private _blurX;
  15409. private _blurY;
  15410. private _adaptiveBlurKernel;
  15411. private _blurKernelX;
  15412. private _blurKernelY;
  15413. private _blurRatio;
  15414. /**
  15415. * Instantiates a Mirror Texture.
  15416. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15417. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15418. * You can then easily use it as a reflectionTexture on a flat surface.
  15419. * In case the surface is not a plane, please consider relying on reflection probes.
  15420. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15421. * @param name
  15422. * @param size
  15423. * @param scene
  15424. * @param generateMipMaps
  15425. * @param type
  15426. * @param samplingMode
  15427. * @param generateDepthBuffer
  15428. */
  15429. constructor(name: string, size: number | {
  15430. width: number;
  15431. height: number;
  15432. } | {
  15433. ratio: number;
  15434. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15435. private _preparePostProcesses;
  15436. /**
  15437. * Clone the mirror texture.
  15438. * @returns the cloned texture
  15439. */
  15440. clone(): MirrorTexture;
  15441. /**
  15442. * Serialize the texture to a JSON representation you could use in Parse later on
  15443. * @returns the serialized JSON representation
  15444. */
  15445. serialize(): any;
  15446. /**
  15447. * Dispose the texture and release its associated resources.
  15448. */
  15449. dispose(): void;
  15450. }
  15451. }
  15452. declare module BABYLON {
  15453. /**
  15454. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15455. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15456. */
  15457. export class Texture extends BaseTexture {
  15458. /**
  15459. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15460. */
  15461. static SerializeBuffers: boolean;
  15462. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15463. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15464. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15465. /** nearest is mag = nearest and min = nearest and mip = linear */
  15466. static readonly NEAREST_SAMPLINGMODE: number;
  15467. /** nearest is mag = nearest and min = nearest and mip = linear */
  15468. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15469. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15470. static readonly BILINEAR_SAMPLINGMODE: number;
  15471. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15472. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15473. /** Trilinear is mag = linear and min = linear and mip = linear */
  15474. static readonly TRILINEAR_SAMPLINGMODE: number;
  15475. /** Trilinear is mag = linear and min = linear and mip = linear */
  15476. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15477. /** mag = nearest and min = nearest and mip = nearest */
  15478. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15479. /** mag = nearest and min = linear and mip = nearest */
  15480. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15481. /** mag = nearest and min = linear and mip = linear */
  15482. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15483. /** mag = nearest and min = linear and mip = none */
  15484. static readonly NEAREST_LINEAR: number;
  15485. /** mag = nearest and min = nearest and mip = none */
  15486. static readonly NEAREST_NEAREST: number;
  15487. /** mag = linear and min = nearest and mip = nearest */
  15488. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15489. /** mag = linear and min = nearest and mip = linear */
  15490. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15491. /** mag = linear and min = linear and mip = none */
  15492. static readonly LINEAR_LINEAR: number;
  15493. /** mag = linear and min = nearest and mip = none */
  15494. static readonly LINEAR_NEAREST: number;
  15495. /** Explicit coordinates mode */
  15496. static readonly EXPLICIT_MODE: number;
  15497. /** Spherical coordinates mode */
  15498. static readonly SPHERICAL_MODE: number;
  15499. /** Planar coordinates mode */
  15500. static readonly PLANAR_MODE: number;
  15501. /** Cubic coordinates mode */
  15502. static readonly CUBIC_MODE: number;
  15503. /** Projection coordinates mode */
  15504. static readonly PROJECTION_MODE: number;
  15505. /** Inverse Cubic coordinates mode */
  15506. static readonly SKYBOX_MODE: number;
  15507. /** Inverse Cubic coordinates mode */
  15508. static readonly INVCUBIC_MODE: number;
  15509. /** Equirectangular coordinates mode */
  15510. static readonly EQUIRECTANGULAR_MODE: number;
  15511. /** Equirectangular Fixed coordinates mode */
  15512. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15513. /** Equirectangular Fixed Mirrored coordinates mode */
  15514. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15515. /** Texture is not repeating outside of 0..1 UVs */
  15516. static readonly CLAMP_ADDRESSMODE: number;
  15517. /** Texture is repeating outside of 0..1 UVs */
  15518. static readonly WRAP_ADDRESSMODE: number;
  15519. /** Texture is repeating and mirrored */
  15520. static readonly MIRROR_ADDRESSMODE: number;
  15521. /**
  15522. * 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
  15523. */
  15524. static UseSerializedUrlIfAny: boolean;
  15525. /**
  15526. * Define the url of the texture.
  15527. */
  15528. url: Nullable<string>;
  15529. /**
  15530. * Define an offset on the texture to offset the u coordinates of the UVs
  15531. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15532. */
  15533. uOffset: number;
  15534. /**
  15535. * Define an offset on the texture to offset the v coordinates of the UVs
  15536. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15537. */
  15538. vOffset: number;
  15539. /**
  15540. * Define an offset on the texture to scale the u coordinates of the UVs
  15541. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15542. */
  15543. uScale: number;
  15544. /**
  15545. * Define an offset on the texture to scale the v coordinates of the UVs
  15546. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15547. */
  15548. vScale: number;
  15549. /**
  15550. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15551. * @see http://doc.babylonjs.com/how_to/more_materials
  15552. */
  15553. uAng: number;
  15554. /**
  15555. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15556. * @see http://doc.babylonjs.com/how_to/more_materials
  15557. */
  15558. vAng: number;
  15559. /**
  15560. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15561. * @see http://doc.babylonjs.com/how_to/more_materials
  15562. */
  15563. wAng: number;
  15564. /**
  15565. * Defines the center of rotation (U)
  15566. */
  15567. uRotationCenter: number;
  15568. /**
  15569. * Defines the center of rotation (V)
  15570. */
  15571. vRotationCenter: number;
  15572. /**
  15573. * Defines the center of rotation (W)
  15574. */
  15575. wRotationCenter: number;
  15576. /**
  15577. * Are mip maps generated for this texture or not.
  15578. */
  15579. readonly noMipmap: boolean;
  15580. /**
  15581. * List of inspectable custom properties (used by the Inspector)
  15582. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15583. */
  15584. inspectableCustomProperties: Nullable<IInspectable[]>;
  15585. private _noMipmap;
  15586. /** @hidden */ private _invertY: boolean;
  15587. private _rowGenerationMatrix;
  15588. private _cachedTextureMatrix;
  15589. private _projectionModeMatrix;
  15590. private _t0;
  15591. private _t1;
  15592. private _t2;
  15593. private _cachedUOffset;
  15594. private _cachedVOffset;
  15595. private _cachedUScale;
  15596. private _cachedVScale;
  15597. private _cachedUAng;
  15598. private _cachedVAng;
  15599. private _cachedWAng;
  15600. private _cachedProjectionMatrixId;
  15601. private _cachedCoordinatesMode;
  15602. /** @hidden */
  15603. protected _initialSamplingMode: number;
  15604. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15605. private _deleteBuffer;
  15606. protected _format: Nullable<number>;
  15607. private _delayedOnLoad;
  15608. private _delayedOnError;
  15609. private _mimeType?;
  15610. /**
  15611. * Observable triggered once the texture has been loaded.
  15612. */
  15613. onLoadObservable: Observable<Texture>;
  15614. protected _isBlocking: boolean;
  15615. /**
  15616. * Is the texture preventing material to render while loading.
  15617. * If false, a default texture will be used instead of the loading one during the preparation step.
  15618. */
  15619. isBlocking: boolean;
  15620. /**
  15621. * Get the current sampling mode associated with the texture.
  15622. */
  15623. readonly samplingMode: number;
  15624. /**
  15625. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15626. */
  15627. readonly invertY: boolean;
  15628. /**
  15629. * Instantiates a new texture.
  15630. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15631. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15632. * @param url defines the url of the picture to load as a texture
  15633. * @param scene defines the scene or engine the texture will belong to
  15634. * @param noMipmap defines if the texture will require mip maps or not
  15635. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15636. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15637. * @param onLoad defines a callback triggered when the texture has been loaded
  15638. * @param onError defines a callback triggered when an error occurred during the loading session
  15639. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15640. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15641. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15642. * @param mimeType defines an optional mime type information
  15643. */
  15644. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15645. /**
  15646. * Update the url (and optional buffer) of this texture if url was null during construction.
  15647. * @param url the url of the texture
  15648. * @param buffer the buffer of the texture (defaults to null)
  15649. * @param onLoad callback called when the texture is loaded (defaults to null)
  15650. */
  15651. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15652. /**
  15653. * Finish the loading sequence of a texture flagged as delayed load.
  15654. * @hidden
  15655. */
  15656. delayLoad(): void;
  15657. private _prepareRowForTextureGeneration;
  15658. /**
  15659. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15660. * @returns the transform matrix of the texture.
  15661. */
  15662. getTextureMatrix(): Matrix;
  15663. /**
  15664. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15665. * @returns The reflection texture transform
  15666. */
  15667. getReflectionTextureMatrix(): Matrix;
  15668. /**
  15669. * Clones the texture.
  15670. * @returns the cloned texture
  15671. */
  15672. clone(): Texture;
  15673. /**
  15674. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15675. * @returns The JSON representation of the texture
  15676. */
  15677. serialize(): any;
  15678. /**
  15679. * Get the current class name of the texture useful for serialization or dynamic coding.
  15680. * @returns "Texture"
  15681. */
  15682. getClassName(): string;
  15683. /**
  15684. * Dispose the texture and release its associated resources.
  15685. */
  15686. dispose(): void;
  15687. /**
  15688. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15689. * @param parsedTexture Define the JSON representation of the texture
  15690. * @param scene Define the scene the parsed texture should be instantiated in
  15691. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15692. * @returns The parsed texture if successful
  15693. */
  15694. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15695. /**
  15696. * Creates a texture from its base 64 representation.
  15697. * @param data Define the base64 payload without the data: prefix
  15698. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15699. * @param scene Define the scene the texture should belong to
  15700. * @param noMipmap Forces the texture to not create mip map information if true
  15701. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15702. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15703. * @param onLoad define a callback triggered when the texture has been loaded
  15704. * @param onError define a callback triggered when an error occurred during the loading session
  15705. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15706. * @returns the created texture
  15707. */
  15708. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15709. /**
  15710. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15711. * @param data Define the base64 payload without the data: prefix
  15712. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15713. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15714. * @param scene Define the scene the texture should belong to
  15715. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15716. * @param noMipmap Forces the texture to not create mip map information if true
  15717. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15718. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15719. * @param onLoad define a callback triggered when the texture has been loaded
  15720. * @param onError define a callback triggered when an error occurred during the loading session
  15721. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15722. * @returns the created texture
  15723. */
  15724. 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;
  15725. }
  15726. }
  15727. declare module BABYLON {
  15728. /**
  15729. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15730. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15731. */
  15732. export class PostProcessManager {
  15733. private _scene;
  15734. private _indexBuffer;
  15735. private _vertexBuffers;
  15736. /**
  15737. * Creates a new instance PostProcess
  15738. * @param scene The scene that the post process is associated with.
  15739. */
  15740. constructor(scene: Scene);
  15741. private _prepareBuffers;
  15742. private _buildIndexBuffer;
  15743. /**
  15744. * Rebuilds the vertex buffers of the manager.
  15745. * @hidden
  15746. */ private _rebuild(): void;
  15747. /**
  15748. * Prepares a frame to be run through a post process.
  15749. * @param sourceTexture The input texture to the post procesess. (default: null)
  15750. * @param postProcesses An array of post processes to be run. (default: null)
  15751. * @returns True if the post processes were able to be run.
  15752. * @hidden
  15753. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15754. /**
  15755. * Manually render a set of post processes to a texture.
  15756. * @param postProcesses An array of post processes to be run.
  15757. * @param targetTexture The target texture to render to.
  15758. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15759. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15760. * @param lodLevel defines which lod of the texture to render to
  15761. */
  15762. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15763. /**
  15764. * Finalize the result of the output of the postprocesses.
  15765. * @param doNotPresent If true the result will not be displayed to the screen.
  15766. * @param targetTexture The target texture to render to.
  15767. * @param faceIndex The index of the face to bind the target texture to.
  15768. * @param postProcesses The array of post processes to render.
  15769. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15770. * @hidden
  15771. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15772. /**
  15773. * Disposes of the post process manager.
  15774. */
  15775. dispose(): void;
  15776. }
  15777. }
  15778. declare module BABYLON {
  15779. /** Interface used by value gradients (color, factor, ...) */
  15780. export interface IValueGradient {
  15781. /**
  15782. * Gets or sets the gradient value (between 0 and 1)
  15783. */
  15784. gradient: number;
  15785. }
  15786. /** Class used to store color4 gradient */
  15787. export class ColorGradient implements IValueGradient {
  15788. /**
  15789. * Gets or sets the gradient value (between 0 and 1)
  15790. */
  15791. gradient: number;
  15792. /**
  15793. * Gets or sets first associated color
  15794. */
  15795. color1: Color4;
  15796. /**
  15797. * Gets or sets second associated color
  15798. */
  15799. color2?: Color4;
  15800. /**
  15801. * Will get a color picked randomly between color1 and color2.
  15802. * If color2 is undefined then color1 will be used
  15803. * @param result defines the target Color4 to store the result in
  15804. */
  15805. getColorToRef(result: Color4): void;
  15806. }
  15807. /** Class used to store color 3 gradient */
  15808. export class Color3Gradient implements IValueGradient {
  15809. /**
  15810. * Gets or sets the gradient value (between 0 and 1)
  15811. */
  15812. gradient: number;
  15813. /**
  15814. * Gets or sets the associated color
  15815. */
  15816. color: Color3;
  15817. }
  15818. /** Class used to store factor gradient */
  15819. export class FactorGradient implements IValueGradient {
  15820. /**
  15821. * Gets or sets the gradient value (between 0 and 1)
  15822. */
  15823. gradient: number;
  15824. /**
  15825. * Gets or sets first associated factor
  15826. */
  15827. factor1: number;
  15828. /**
  15829. * Gets or sets second associated factor
  15830. */
  15831. factor2?: number;
  15832. /**
  15833. * Will get a number picked randomly between factor1 and factor2.
  15834. * If factor2 is undefined then factor1 will be used
  15835. * @returns the picked number
  15836. */
  15837. getFactor(): number;
  15838. }
  15839. /**
  15840. * Helper used to simplify some generic gradient tasks
  15841. */
  15842. export class GradientHelper {
  15843. /**
  15844. * Gets the current gradient from an array of IValueGradient
  15845. * @param ratio defines the current ratio to get
  15846. * @param gradients defines the array of IValueGradient
  15847. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15848. */
  15849. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15850. }
  15851. }
  15852. declare module BABYLON {
  15853. interface ThinEngine {
  15854. /**
  15855. * Creates a dynamic texture
  15856. * @param width defines the width of the texture
  15857. * @param height defines the height of the texture
  15858. * @param generateMipMaps defines if the engine should generate the mip levels
  15859. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15860. * @returns the dynamic texture inside an InternalTexture
  15861. */
  15862. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15863. /**
  15864. * Update the content of a dynamic texture
  15865. * @param texture defines the texture to update
  15866. * @param canvas defines the canvas containing the source
  15867. * @param invertY defines if data must be stored with Y axis inverted
  15868. * @param premulAlpha defines if alpha is stored as premultiplied
  15869. * @param format defines the format of the data
  15870. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15871. */
  15872. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15873. }
  15874. }
  15875. declare module BABYLON {
  15876. /**
  15877. * Helper class used to generate a canvas to manipulate images
  15878. */
  15879. export class CanvasGenerator {
  15880. /**
  15881. * Create a new canvas (or offscreen canvas depending on the context)
  15882. * @param width defines the expected width
  15883. * @param height defines the expected height
  15884. * @return a new canvas or offscreen canvas
  15885. */
  15886. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  15887. }
  15888. }
  15889. declare module BABYLON {
  15890. /**
  15891. * A class extending Texture allowing drawing on a texture
  15892. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15893. */
  15894. export class DynamicTexture extends Texture {
  15895. private _generateMipMaps;
  15896. private _canvas;
  15897. private _context;
  15898. private _engine;
  15899. /**
  15900. * Creates a DynamicTexture
  15901. * @param name defines the name of the texture
  15902. * @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
  15903. * @param scene defines the scene where you want the texture
  15904. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15905. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15906. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15907. */
  15908. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15909. /**
  15910. * Get the current class name of the texture useful for serialization or dynamic coding.
  15911. * @returns "DynamicTexture"
  15912. */
  15913. getClassName(): string;
  15914. /**
  15915. * Gets the current state of canRescale
  15916. */
  15917. readonly canRescale: boolean;
  15918. private _recreate;
  15919. /**
  15920. * Scales the texture
  15921. * @param ratio the scale factor to apply to both width and height
  15922. */
  15923. scale(ratio: number): void;
  15924. /**
  15925. * Resizes the texture
  15926. * @param width the new width
  15927. * @param height the new height
  15928. */
  15929. scaleTo(width: number, height: number): void;
  15930. /**
  15931. * Gets the context of the canvas used by the texture
  15932. * @returns the canvas context of the dynamic texture
  15933. */
  15934. getContext(): CanvasRenderingContext2D;
  15935. /**
  15936. * Clears the texture
  15937. */
  15938. clear(): void;
  15939. /**
  15940. * Updates the texture
  15941. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15942. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15943. */
  15944. update(invertY?: boolean, premulAlpha?: boolean): void;
  15945. /**
  15946. * Draws text onto the texture
  15947. * @param text defines the text to be drawn
  15948. * @param x defines the placement of the text from the left
  15949. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  15950. * @param font defines the font to be used with font-style, font-size, font-name
  15951. * @param color defines the color used for the text
  15952. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  15953. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15954. * @param update defines whether texture is immediately update (default is true)
  15955. */
  15956. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  15957. /**
  15958. * Clones the texture
  15959. * @returns the clone of the texture.
  15960. */
  15961. clone(): DynamicTexture;
  15962. /**
  15963. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  15964. * @returns a serialized dynamic texture object
  15965. */
  15966. serialize(): any;
  15967. /** @hidden */ private _rebuild(): void;
  15968. }
  15969. }
  15970. declare module BABYLON {
  15971. interface AbstractScene {
  15972. /**
  15973. * The list of procedural textures added to the scene
  15974. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15975. */
  15976. proceduralTextures: Array<ProceduralTexture>;
  15977. }
  15978. /**
  15979. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15980. * in a given scene.
  15981. */
  15982. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15983. /**
  15984. * The component name helpfull to identify the component in the list of scene components.
  15985. */
  15986. readonly name: string;
  15987. /**
  15988. * The scene the component belongs to.
  15989. */
  15990. scene: Scene;
  15991. /**
  15992. * Creates a new instance of the component for the given scene
  15993. * @param scene Defines the scene to register the component in
  15994. */
  15995. constructor(scene: Scene);
  15996. /**
  15997. * Registers the component in a given scene
  15998. */
  15999. register(): void;
  16000. /**
  16001. * Rebuilds the elements related to this component in case of
  16002. * context lost for instance.
  16003. */
  16004. rebuild(): void;
  16005. /**
  16006. * Disposes the component and the associated ressources.
  16007. */
  16008. dispose(): void;
  16009. private _beforeClear;
  16010. }
  16011. }
  16012. declare module BABYLON {
  16013. interface ThinEngine {
  16014. /**
  16015. * Creates a new render target cube texture
  16016. * @param size defines the size of the texture
  16017. * @param options defines the options used to create the texture
  16018. * @returns a new render target cube texture stored in an InternalTexture
  16019. */
  16020. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16021. }
  16022. }
  16023. declare module BABYLON {
  16024. /** @hidden */
  16025. export var proceduralVertexShader: {
  16026. name: string;
  16027. shader: string;
  16028. };
  16029. }
  16030. declare module BABYLON {
  16031. /**
  16032. * 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.
  16033. * This is the base class of any Procedural texture and contains most of the shareable code.
  16034. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16035. */
  16036. export class ProceduralTexture extends Texture {
  16037. isCube: boolean;
  16038. /**
  16039. * Define if the texture is enabled or not (disabled texture will not render)
  16040. */
  16041. isEnabled: boolean;
  16042. /**
  16043. * Define if the texture must be cleared before rendering (default is true)
  16044. */
  16045. autoClear: boolean;
  16046. /**
  16047. * Callback called when the texture is generated
  16048. */
  16049. onGenerated: () => void;
  16050. /**
  16051. * Event raised when the texture is generated
  16052. */
  16053. onGeneratedObservable: Observable<ProceduralTexture>;
  16054. /** @hidden */ private _generateMipMaps: boolean;
  16055. /** @hidden **/ private _effect: Effect;
  16056. /** @hidden */ private _textures: {
  16057. [key: string]: Texture;
  16058. };
  16059. private _size;
  16060. private _currentRefreshId;
  16061. private _refreshRate;
  16062. private _vertexBuffers;
  16063. private _indexBuffer;
  16064. private _uniforms;
  16065. private _samplers;
  16066. private _fragment;
  16067. private _floats;
  16068. private _ints;
  16069. private _floatsArrays;
  16070. private _colors3;
  16071. private _colors4;
  16072. private _vectors2;
  16073. private _vectors3;
  16074. private _matrices;
  16075. private _fallbackTexture;
  16076. private _fallbackTextureUsed;
  16077. private _engine;
  16078. private _cachedDefines;
  16079. private _contentUpdateId;
  16080. private _contentData;
  16081. /**
  16082. * Instantiates a new procedural texture.
  16083. * 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.
  16084. * This is the base class of any Procedural texture and contains most of the shareable code.
  16085. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16086. * @param name Define the name of the texture
  16087. * @param size Define the size of the texture to create
  16088. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16089. * @param scene Define the scene the texture belongs to
  16090. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16091. * @param generateMipMaps Define if the texture should creates mip maps or not
  16092. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16093. */
  16094. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16095. /**
  16096. * The effect that is created when initializing the post process.
  16097. * @returns The created effect corresponding the the postprocess.
  16098. */
  16099. getEffect(): Effect;
  16100. /**
  16101. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16102. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16103. */
  16104. getContent(): Nullable<ArrayBufferView>;
  16105. private _createIndexBuffer;
  16106. /** @hidden */ private _rebuild(): void;
  16107. /**
  16108. * Resets the texture in order to recreate its associated resources.
  16109. * This can be called in case of context loss
  16110. */
  16111. reset(): void;
  16112. protected _getDefines(): string;
  16113. /**
  16114. * Is the texture ready to be used ? (rendered at least once)
  16115. * @returns true if ready, otherwise, false.
  16116. */
  16117. isReady(): boolean;
  16118. /**
  16119. * Resets the refresh counter of the texture and start bak from scratch.
  16120. * Could be useful to regenerate the texture if it is setup to render only once.
  16121. */
  16122. resetRefreshCounter(): void;
  16123. /**
  16124. * Set the fragment shader to use in order to render the texture.
  16125. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16126. */
  16127. setFragment(fragment: any): void;
  16128. /**
  16129. * Define the refresh rate of the texture or the rendering frequency.
  16130. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16131. */
  16132. refreshRate: number;
  16133. /** @hidden */ private _shouldRender(): boolean;
  16134. /**
  16135. * Get the size the texture is rendering at.
  16136. * @returns the size (texture is always squared)
  16137. */
  16138. getRenderSize(): number;
  16139. /**
  16140. * Resize the texture to new value.
  16141. * @param size Define the new size the texture should have
  16142. * @param generateMipMaps Define whether the new texture should create mip maps
  16143. */
  16144. resize(size: number, generateMipMaps: boolean): void;
  16145. private _checkUniform;
  16146. /**
  16147. * Set a texture in the shader program used to render.
  16148. * @param name Define the name of the uniform samplers as defined in the shader
  16149. * @param texture Define the texture to bind to this sampler
  16150. * @return the texture itself allowing "fluent" like uniform updates
  16151. */
  16152. setTexture(name: string, texture: Texture): ProceduralTexture;
  16153. /**
  16154. * Set a float in the shader.
  16155. * @param name Define the name of the uniform as defined in the shader
  16156. * @param value Define the value to give to the uniform
  16157. * @return the texture itself allowing "fluent" like uniform updates
  16158. */
  16159. setFloat(name: string, value: number): ProceduralTexture;
  16160. /**
  16161. * Set a int in the shader.
  16162. * @param name Define the name of the uniform as defined in the shader
  16163. * @param value Define the value to give to the uniform
  16164. * @return the texture itself allowing "fluent" like uniform updates
  16165. */
  16166. setInt(name: string, value: number): ProceduralTexture;
  16167. /**
  16168. * Set an array of floats in the shader.
  16169. * @param name Define the name of the uniform as defined in the shader
  16170. * @param value Define the value to give to the uniform
  16171. * @return the texture itself allowing "fluent" like uniform updates
  16172. */
  16173. setFloats(name: string, value: number[]): ProceduralTexture;
  16174. /**
  16175. * Set a vec3 in the shader from a Color3.
  16176. * @param name Define the name of the uniform as defined in the shader
  16177. * @param value Define the value to give to the uniform
  16178. * @return the texture itself allowing "fluent" like uniform updates
  16179. */
  16180. setColor3(name: string, value: Color3): ProceduralTexture;
  16181. /**
  16182. * Set a vec4 in the shader from a Color4.
  16183. * @param name Define the name of the uniform as defined in the shader
  16184. * @param value Define the value to give to the uniform
  16185. * @return the texture itself allowing "fluent" like uniform updates
  16186. */
  16187. setColor4(name: string, value: Color4): ProceduralTexture;
  16188. /**
  16189. * Set a vec2 in the shader from a Vector2.
  16190. * @param name Define the name of the uniform as defined in the shader
  16191. * @param value Define the value to give to the uniform
  16192. * @return the texture itself allowing "fluent" like uniform updates
  16193. */
  16194. setVector2(name: string, value: Vector2): ProceduralTexture;
  16195. /**
  16196. * Set a vec3 in the shader from a Vector3.
  16197. * @param name Define the name of the uniform as defined in the shader
  16198. * @param value Define the value to give to the uniform
  16199. * @return the texture itself allowing "fluent" like uniform updates
  16200. */
  16201. setVector3(name: string, value: Vector3): ProceduralTexture;
  16202. /**
  16203. * Set a mat4 in the shader from a MAtrix.
  16204. * @param name Define the name of the uniform as defined in the shader
  16205. * @param value Define the value to give to the uniform
  16206. * @return the texture itself allowing "fluent" like uniform updates
  16207. */
  16208. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16209. /**
  16210. * Render the texture to its associated render target.
  16211. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16212. */
  16213. render(useCameraPostProcess?: boolean): void;
  16214. /**
  16215. * Clone the texture.
  16216. * @returns the cloned texture
  16217. */
  16218. clone(): ProceduralTexture;
  16219. /**
  16220. * Dispose the texture and release its asoociated resources.
  16221. */
  16222. dispose(): void;
  16223. }
  16224. }
  16225. declare module BABYLON {
  16226. /**
  16227. * This represents the base class for particle system in Babylon.
  16228. * 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.
  16229. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16230. * @example https://doc.babylonjs.com/babylon101/particles
  16231. */
  16232. export class BaseParticleSystem {
  16233. /**
  16234. * Source color is added to the destination color without alpha affecting the result
  16235. */
  16236. static BLENDMODE_ONEONE: number;
  16237. /**
  16238. * Blend current color and particle color using particle’s alpha
  16239. */
  16240. static BLENDMODE_STANDARD: number;
  16241. /**
  16242. * Add current color and particle color multiplied by particle’s alpha
  16243. */
  16244. static BLENDMODE_ADD: number;
  16245. /**
  16246. * Multiply current color with particle color
  16247. */
  16248. static BLENDMODE_MULTIPLY: number;
  16249. /**
  16250. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16251. */
  16252. static BLENDMODE_MULTIPLYADD: number;
  16253. /**
  16254. * List of animations used by the particle system.
  16255. */
  16256. animations: Animation[];
  16257. /**
  16258. * The id of the Particle system.
  16259. */
  16260. id: string;
  16261. /**
  16262. * The friendly name of the Particle system.
  16263. */
  16264. name: string;
  16265. /**
  16266. * The rendering group used by the Particle system to chose when to render.
  16267. */
  16268. renderingGroupId: number;
  16269. /**
  16270. * The emitter represents the Mesh or position we are attaching the particle system to.
  16271. */
  16272. emitter: Nullable<AbstractMesh | Vector3>;
  16273. /**
  16274. * The maximum number of particles to emit per frame
  16275. */
  16276. emitRate: number;
  16277. /**
  16278. * If you want to launch only a few particles at once, that can be done, as well.
  16279. */
  16280. manualEmitCount: number;
  16281. /**
  16282. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16283. */
  16284. updateSpeed: number;
  16285. /**
  16286. * The amount of time the particle system is running (depends of the overall update speed).
  16287. */
  16288. targetStopDuration: number;
  16289. /**
  16290. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16291. */
  16292. disposeOnStop: boolean;
  16293. /**
  16294. * Minimum power of emitting particles.
  16295. */
  16296. minEmitPower: number;
  16297. /**
  16298. * Maximum power of emitting particles.
  16299. */
  16300. maxEmitPower: number;
  16301. /**
  16302. * Minimum life time of emitting particles.
  16303. */
  16304. minLifeTime: number;
  16305. /**
  16306. * Maximum life time of emitting particles.
  16307. */
  16308. maxLifeTime: number;
  16309. /**
  16310. * Minimum Size of emitting particles.
  16311. */
  16312. minSize: number;
  16313. /**
  16314. * Maximum Size of emitting particles.
  16315. */
  16316. maxSize: number;
  16317. /**
  16318. * Minimum scale of emitting particles on X axis.
  16319. */
  16320. minScaleX: number;
  16321. /**
  16322. * Maximum scale of emitting particles on X axis.
  16323. */
  16324. maxScaleX: number;
  16325. /**
  16326. * Minimum scale of emitting particles on Y axis.
  16327. */
  16328. minScaleY: number;
  16329. /**
  16330. * Maximum scale of emitting particles on Y axis.
  16331. */
  16332. maxScaleY: number;
  16333. /**
  16334. * Gets or sets the minimal initial rotation in radians.
  16335. */
  16336. minInitialRotation: number;
  16337. /**
  16338. * Gets or sets the maximal initial rotation in radians.
  16339. */
  16340. maxInitialRotation: number;
  16341. /**
  16342. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16343. */
  16344. minAngularSpeed: number;
  16345. /**
  16346. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16347. */
  16348. maxAngularSpeed: number;
  16349. /**
  16350. * The texture used to render each particle. (this can be a spritesheet)
  16351. */
  16352. particleTexture: Nullable<Texture>;
  16353. /**
  16354. * The layer mask we are rendering the particles through.
  16355. */
  16356. layerMask: number;
  16357. /**
  16358. * This can help using your own shader to render the particle system.
  16359. * The according effect will be created
  16360. */
  16361. customShader: any;
  16362. /**
  16363. * By default particle system starts as soon as they are created. This prevents the
  16364. * automatic start to happen and let you decide when to start emitting particles.
  16365. */
  16366. preventAutoStart: boolean;
  16367. private _noiseTexture;
  16368. /**
  16369. * Gets or sets a texture used to add random noise to particle positions
  16370. */
  16371. noiseTexture: Nullable<ProceduralTexture>;
  16372. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16373. noiseStrength: Vector3;
  16374. /**
  16375. * Callback triggered when the particle animation is ending.
  16376. */
  16377. onAnimationEnd: Nullable<() => void>;
  16378. /**
  16379. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16380. */
  16381. blendMode: number;
  16382. /**
  16383. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16384. * to override the particles.
  16385. */
  16386. forceDepthWrite: boolean;
  16387. /** 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 */
  16388. preWarmCycles: number;
  16389. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16390. preWarmStepOffset: number;
  16391. /**
  16392. * 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)
  16393. */
  16394. spriteCellChangeSpeed: number;
  16395. /**
  16396. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16397. */
  16398. startSpriteCellID: number;
  16399. /**
  16400. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16401. */
  16402. endSpriteCellID: number;
  16403. /**
  16404. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16405. */
  16406. spriteCellWidth: number;
  16407. /**
  16408. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16409. */
  16410. spriteCellHeight: number;
  16411. /**
  16412. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16413. */
  16414. spriteRandomStartCell: boolean;
  16415. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16416. translationPivot: Vector2;
  16417. /** @hidden */
  16418. protected _isAnimationSheetEnabled: boolean;
  16419. /**
  16420. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16421. */
  16422. beginAnimationOnStart: boolean;
  16423. /**
  16424. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16425. */
  16426. beginAnimationFrom: number;
  16427. /**
  16428. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16429. */
  16430. beginAnimationTo: number;
  16431. /**
  16432. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16433. */
  16434. beginAnimationLoop: boolean;
  16435. /**
  16436. * Gets or sets a world offset applied to all particles
  16437. */
  16438. worldOffset: Vector3;
  16439. /**
  16440. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16441. */
  16442. isAnimationSheetEnabled: boolean;
  16443. /**
  16444. * Get hosting scene
  16445. * @returns the scene
  16446. */
  16447. getScene(): Scene;
  16448. /**
  16449. * You can use gravity if you want to give an orientation to your particles.
  16450. */
  16451. gravity: Vector3;
  16452. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16453. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16454. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16455. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16456. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16457. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16458. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16459. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16460. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16461. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16462. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16463. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16464. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16465. /**
  16466. * Defines the delay in milliseconds before starting the system (0 by default)
  16467. */
  16468. startDelay: number;
  16469. /**
  16470. * Gets the current list of drag gradients.
  16471. * You must use addDragGradient and removeDragGradient to udpate this list
  16472. * @returns the list of drag gradients
  16473. */
  16474. getDragGradients(): Nullable<Array<FactorGradient>>;
  16475. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16476. limitVelocityDamping: number;
  16477. /**
  16478. * Gets the current list of limit velocity gradients.
  16479. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16480. * @returns the list of limit velocity gradients
  16481. */
  16482. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16483. /**
  16484. * Gets the current list of color gradients.
  16485. * You must use addColorGradient and removeColorGradient to udpate this list
  16486. * @returns the list of color gradients
  16487. */
  16488. getColorGradients(): Nullable<Array<ColorGradient>>;
  16489. /**
  16490. * Gets the current list of size gradients.
  16491. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16492. * @returns the list of size gradients
  16493. */
  16494. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16495. /**
  16496. * Gets the current list of color remap gradients.
  16497. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16498. * @returns the list of color remap gradients
  16499. */
  16500. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16501. /**
  16502. * Gets the current list of alpha remap gradients.
  16503. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16504. * @returns the list of alpha remap gradients
  16505. */
  16506. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16507. /**
  16508. * Gets the current list of life time gradients.
  16509. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16510. * @returns the list of life time gradients
  16511. */
  16512. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16513. /**
  16514. * Gets the current list of angular speed gradients.
  16515. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16516. * @returns the list of angular speed gradients
  16517. */
  16518. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16519. /**
  16520. * Gets the current list of velocity gradients.
  16521. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16522. * @returns the list of velocity gradients
  16523. */
  16524. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16525. /**
  16526. * Gets the current list of start size gradients.
  16527. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16528. * @returns the list of start size gradients
  16529. */
  16530. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16531. /**
  16532. * Gets the current list of emit rate gradients.
  16533. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16534. * @returns the list of emit rate gradients
  16535. */
  16536. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16537. /**
  16538. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16540. */
  16541. direction1: Vector3;
  16542. /**
  16543. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16544. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16545. */
  16546. direction2: Vector3;
  16547. /**
  16548. * 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.
  16549. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16550. */
  16551. minEmitBox: Vector3;
  16552. /**
  16553. * 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.
  16554. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16555. */
  16556. maxEmitBox: Vector3;
  16557. /**
  16558. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16559. */
  16560. color1: Color4;
  16561. /**
  16562. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16563. */
  16564. color2: Color4;
  16565. /**
  16566. * Color the particle will have at the end of its lifetime
  16567. */
  16568. colorDead: Color4;
  16569. /**
  16570. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16571. */
  16572. textureMask: Color4;
  16573. /**
  16574. * The particle emitter type defines the emitter used by the particle system.
  16575. * It can be for example box, sphere, or cone...
  16576. */
  16577. particleEmitterType: IParticleEmitterType;
  16578. /** @hidden */ private _isSubEmitter: boolean;
  16579. /**
  16580. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16581. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16582. */
  16583. billboardMode: number;
  16584. protected _isBillboardBased: boolean;
  16585. /**
  16586. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16587. */
  16588. isBillboardBased: boolean;
  16589. /**
  16590. * The scene the particle system belongs to.
  16591. */
  16592. protected _scene: Scene;
  16593. /**
  16594. * Local cache of defines for image processing.
  16595. */
  16596. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16597. /**
  16598. * Default configuration related to image processing available in the standard Material.
  16599. */
  16600. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16601. /**
  16602. * Gets the image processing configuration used either in this material.
  16603. */
  16604. /**
  16605. * Sets the Default image processing configuration used either in the this material.
  16606. *
  16607. * If sets to null, the scene one is in use.
  16608. */
  16609. imageProcessingConfiguration: ImageProcessingConfiguration;
  16610. /**
  16611. * Attaches a new image processing configuration to the Standard Material.
  16612. * @param configuration
  16613. */
  16614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16615. /** @hidden */
  16616. protected _reset(): void;
  16617. /** @hidden */
  16618. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16619. /**
  16620. * Instantiates a particle system.
  16621. * 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.
  16622. * @param name The name of the particle system
  16623. */
  16624. constructor(name: string);
  16625. /**
  16626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16629. * @returns the emitter
  16630. */
  16631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16632. /**
  16633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16634. * @param radius The radius of the hemisphere to emit from
  16635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16636. * @returns the emitter
  16637. */
  16638. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16639. /**
  16640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16641. * @param radius The radius of the sphere to emit from
  16642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16643. * @returns the emitter
  16644. */
  16645. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16646. /**
  16647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16648. * @param radius The radius of the sphere to emit from
  16649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16651. * @returns the emitter
  16652. */
  16653. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16654. /**
  16655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16656. * @param radius The radius of the emission cylinder
  16657. * @param height The height of the emission cylinder
  16658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16660. * @returns the emitter
  16661. */
  16662. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16663. /**
  16664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16665. * @param radius The radius of the cylinder to emit from
  16666. * @param height The height of the emission cylinder
  16667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16670. * @returns the emitter
  16671. */
  16672. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16673. /**
  16674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16675. * @param radius The radius of the cone to emit from
  16676. * @param angle The base angle of the cone
  16677. * @returns the emitter
  16678. */
  16679. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16680. /**
  16681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16686. * @returns the emitter
  16687. */
  16688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16689. }
  16690. }
  16691. declare module BABYLON {
  16692. /**
  16693. * Type of sub emitter
  16694. */
  16695. export enum SubEmitterType {
  16696. /**
  16697. * Attached to the particle over it's lifetime
  16698. */
  16699. ATTACHED = 0,
  16700. /**
  16701. * Created when the particle dies
  16702. */
  16703. END = 1
  16704. }
  16705. /**
  16706. * Sub emitter class used to emit particles from an existing particle
  16707. */
  16708. export class SubEmitter {
  16709. /**
  16710. * the particle system to be used by the sub emitter
  16711. */
  16712. particleSystem: ParticleSystem;
  16713. /**
  16714. * Type of the submitter (Default: END)
  16715. */
  16716. type: SubEmitterType;
  16717. /**
  16718. * 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)
  16719. * Note: This only is supported when using an emitter of type Mesh
  16720. */
  16721. inheritDirection: boolean;
  16722. /**
  16723. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16724. */
  16725. inheritedVelocityAmount: number;
  16726. /**
  16727. * Creates a sub emitter
  16728. * @param particleSystem the particle system to be used by the sub emitter
  16729. */
  16730. constructor(
  16731. /**
  16732. * the particle system to be used by the sub emitter
  16733. */
  16734. particleSystem: ParticleSystem);
  16735. /**
  16736. * Clones the sub emitter
  16737. * @returns the cloned sub emitter
  16738. */
  16739. clone(): SubEmitter;
  16740. /**
  16741. * Serialize current object to a JSON object
  16742. * @returns the serialized object
  16743. */
  16744. serialize(): any;
  16745. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16746. /**
  16747. * Creates a new SubEmitter from a serialized JSON version
  16748. * @param serializationObject defines the JSON object to read from
  16749. * @param scene defines the hosting scene
  16750. * @param rootUrl defines the rootUrl for data loading
  16751. * @returns a new SubEmitter
  16752. */
  16753. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16754. /** Release associated resources */
  16755. dispose(): void;
  16756. }
  16757. }
  16758. declare module BABYLON {
  16759. /** @hidden */
  16760. export var clipPlaneFragmentDeclaration: {
  16761. name: string;
  16762. shader: string;
  16763. };
  16764. }
  16765. declare module BABYLON {
  16766. /** @hidden */
  16767. export var imageProcessingDeclaration: {
  16768. name: string;
  16769. shader: string;
  16770. };
  16771. }
  16772. declare module BABYLON {
  16773. /** @hidden */
  16774. export var imageProcessingFunctions: {
  16775. name: string;
  16776. shader: string;
  16777. };
  16778. }
  16779. declare module BABYLON {
  16780. /** @hidden */
  16781. export var clipPlaneFragment: {
  16782. name: string;
  16783. shader: string;
  16784. };
  16785. }
  16786. declare module BABYLON {
  16787. /** @hidden */
  16788. export var particlesPixelShader: {
  16789. name: string;
  16790. shader: string;
  16791. };
  16792. }
  16793. declare module BABYLON {
  16794. /** @hidden */
  16795. export var clipPlaneVertexDeclaration: {
  16796. name: string;
  16797. shader: string;
  16798. };
  16799. }
  16800. declare module BABYLON {
  16801. /** @hidden */
  16802. export var clipPlaneVertex: {
  16803. name: string;
  16804. shader: string;
  16805. };
  16806. }
  16807. declare module BABYLON {
  16808. /** @hidden */
  16809. export var particlesVertexShader: {
  16810. name: string;
  16811. shader: string;
  16812. };
  16813. }
  16814. declare module BABYLON {
  16815. /**
  16816. * This represents a particle system in Babylon.
  16817. * 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.
  16818. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16819. * @example https://doc.babylonjs.com/babylon101/particles
  16820. */
  16821. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16822. /**
  16823. * Billboard mode will only apply to Y axis
  16824. */
  16825. static readonly BILLBOARDMODE_Y: number;
  16826. /**
  16827. * Billboard mode will apply to all axes
  16828. */
  16829. static readonly BILLBOARDMODE_ALL: number;
  16830. /**
  16831. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16832. */
  16833. static readonly BILLBOARDMODE_STRETCHED: number;
  16834. /**
  16835. * This function can be defined to provide custom update for active particles.
  16836. * This function will be called instead of regular update (age, position, color, etc.).
  16837. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16838. */
  16839. updateFunction: (particles: Particle[]) => void;
  16840. private _emitterWorldMatrix;
  16841. /**
  16842. * This function can be defined to specify initial direction for every new particle.
  16843. * It by default use the emitterType defined function
  16844. */
  16845. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16846. /**
  16847. * This function can be defined to specify initial position for every new particle.
  16848. * It by default use the emitterType defined function
  16849. */
  16850. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16851. /**
  16852. * @hidden
  16853. */ private _inheritedVelocityOffset: Vector3;
  16854. /**
  16855. * An event triggered when the system is disposed
  16856. */
  16857. onDisposeObservable: Observable<ParticleSystem>;
  16858. private _onDisposeObserver;
  16859. /**
  16860. * Sets a callback that will be triggered when the system is disposed
  16861. */
  16862. onDispose: () => void;
  16863. private _particles;
  16864. private _epsilon;
  16865. private _capacity;
  16866. private _stockParticles;
  16867. private _newPartsExcess;
  16868. private _vertexData;
  16869. private _vertexBuffer;
  16870. private _vertexBuffers;
  16871. private _spriteBuffer;
  16872. private _indexBuffer;
  16873. private _effect;
  16874. private _customEffect;
  16875. private _cachedDefines;
  16876. private _scaledColorStep;
  16877. private _colorDiff;
  16878. private _scaledDirection;
  16879. private _scaledGravity;
  16880. private _currentRenderId;
  16881. private _alive;
  16882. private _useInstancing;
  16883. private _started;
  16884. private _stopped;
  16885. private _actualFrame;
  16886. private _scaledUpdateSpeed;
  16887. private _vertexBufferSize;
  16888. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16889. /** @hidden */ private _currentEmitRate1: number;
  16890. /** @hidden */ private _currentEmitRate2: number;
  16891. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16892. /** @hidden */ private _currentStartSize1: number;
  16893. /** @hidden */ private _currentStartSize2: number;
  16894. private readonly _rawTextureWidth;
  16895. private _rampGradientsTexture;
  16896. private _useRampGradients;
  16897. /** Gets or sets a boolean indicating that ramp gradients must be used
  16898. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16899. */
  16900. useRampGradients: boolean;
  16901. /**
  16902. * 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.
  16903. * 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: [])
  16904. */
  16905. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16906. private _subEmitters;
  16907. /**
  16908. * @hidden
  16909. * If the particle systems emitter should be disposed when the particle system is disposed
  16910. */ private _disposeEmitterOnDispose: boolean;
  16911. /**
  16912. * The current active Sub-systems, this property is used by the root particle system only.
  16913. */
  16914. activeSubSystems: Array<ParticleSystem>;
  16915. private _rootParticleSystem;
  16916. /**
  16917. * Gets the current list of active particles
  16918. */
  16919. readonly particles: Particle[];
  16920. /**
  16921. * Returns the string "ParticleSystem"
  16922. * @returns a string containing the class name
  16923. */
  16924. getClassName(): string;
  16925. /**
  16926. * Instantiates a particle system.
  16927. * 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.
  16928. * @param name The name of the particle system
  16929. * @param capacity The max number of particles alive at the same time
  16930. * @param scene The scene the particle system belongs to
  16931. * @param customEffect a custom effect used to change the way particles are rendered by default
  16932. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16933. * @param epsilon Offset used to render the particles
  16934. */
  16935. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16936. private _addFactorGradient;
  16937. private _removeFactorGradient;
  16938. /**
  16939. * Adds a new life time gradient
  16940. * @param gradient defines the gradient to use (between 0 and 1)
  16941. * @param factor defines the life time factor to affect to the specified gradient
  16942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16943. * @returns the current particle system
  16944. */
  16945. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16946. /**
  16947. * Remove a specific life time gradient
  16948. * @param gradient defines the gradient to remove
  16949. * @returns the current particle system
  16950. */
  16951. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16952. /**
  16953. * Adds a new size gradient
  16954. * @param gradient defines the gradient to use (between 0 and 1)
  16955. * @param factor defines the size factor to affect to the specified gradient
  16956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16957. * @returns the current particle system
  16958. */
  16959. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16960. /**
  16961. * Remove a specific size gradient
  16962. * @param gradient defines the gradient to remove
  16963. * @returns the current particle system
  16964. */
  16965. removeSizeGradient(gradient: number): IParticleSystem;
  16966. /**
  16967. * Adds a new color remap gradient
  16968. * @param gradient defines the gradient to use (between 0 and 1)
  16969. * @param min defines the color remap minimal range
  16970. * @param max defines the color remap maximal range
  16971. * @returns the current particle system
  16972. */
  16973. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16974. /**
  16975. * Remove a specific color remap gradient
  16976. * @param gradient defines the gradient to remove
  16977. * @returns the current particle system
  16978. */
  16979. removeColorRemapGradient(gradient: number): IParticleSystem;
  16980. /**
  16981. * Adds a new alpha remap gradient
  16982. * @param gradient defines the gradient to use (between 0 and 1)
  16983. * @param min defines the alpha remap minimal range
  16984. * @param max defines the alpha remap maximal range
  16985. * @returns the current particle system
  16986. */
  16987. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16988. /**
  16989. * Remove a specific alpha remap gradient
  16990. * @param gradient defines the gradient to remove
  16991. * @returns the current particle system
  16992. */
  16993. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16994. /**
  16995. * Adds a new angular speed gradient
  16996. * @param gradient defines the gradient to use (between 0 and 1)
  16997. * @param factor defines the angular speed to affect to the specified gradient
  16998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16999. * @returns the current particle system
  17000. */
  17001. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17002. /**
  17003. * Remove a specific angular speed gradient
  17004. * @param gradient defines the gradient to remove
  17005. * @returns the current particle system
  17006. */
  17007. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17008. /**
  17009. * Adds a new velocity gradient
  17010. * @param gradient defines the gradient to use (between 0 and 1)
  17011. * @param factor defines the velocity to affect to the specified gradient
  17012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17013. * @returns the current particle system
  17014. */
  17015. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17016. /**
  17017. * Remove a specific velocity gradient
  17018. * @param gradient defines the gradient to remove
  17019. * @returns the current particle system
  17020. */
  17021. removeVelocityGradient(gradient: number): IParticleSystem;
  17022. /**
  17023. * Adds a new limit velocity gradient
  17024. * @param gradient defines the gradient to use (between 0 and 1)
  17025. * @param factor defines the limit velocity value to affect to the specified gradient
  17026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17027. * @returns the current particle system
  17028. */
  17029. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17030. /**
  17031. * Remove a specific limit velocity gradient
  17032. * @param gradient defines the gradient to remove
  17033. * @returns the current particle system
  17034. */
  17035. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17036. /**
  17037. * Adds a new drag gradient
  17038. * @param gradient defines the gradient to use (between 0 and 1)
  17039. * @param factor defines the drag value to affect to the specified gradient
  17040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17041. * @returns the current particle system
  17042. */
  17043. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17044. /**
  17045. * Remove a specific drag gradient
  17046. * @param gradient defines the gradient to remove
  17047. * @returns the current particle system
  17048. */
  17049. removeDragGradient(gradient: number): IParticleSystem;
  17050. /**
  17051. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17052. * @param gradient defines the gradient to use (between 0 and 1)
  17053. * @param factor defines the emit rate value to affect to the specified gradient
  17054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17055. * @returns the current particle system
  17056. */
  17057. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17058. /**
  17059. * Remove a specific emit rate gradient
  17060. * @param gradient defines the gradient to remove
  17061. * @returns the current particle system
  17062. */
  17063. removeEmitRateGradient(gradient: number): IParticleSystem;
  17064. /**
  17065. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17066. * @param gradient defines the gradient to use (between 0 and 1)
  17067. * @param factor defines the start size value to affect to the specified gradient
  17068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17069. * @returns the current particle system
  17070. */
  17071. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17072. /**
  17073. * Remove a specific start size gradient
  17074. * @param gradient defines the gradient to remove
  17075. * @returns the current particle system
  17076. */
  17077. removeStartSizeGradient(gradient: number): IParticleSystem;
  17078. private _createRampGradientTexture;
  17079. /**
  17080. * Gets the current list of ramp gradients.
  17081. * You must use addRampGradient and removeRampGradient to udpate this list
  17082. * @returns the list of ramp gradients
  17083. */
  17084. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17085. /**
  17086. * Adds a new ramp gradient used to remap particle colors
  17087. * @param gradient defines the gradient to use (between 0 and 1)
  17088. * @param color defines the color to affect to the specified gradient
  17089. * @returns the current particle system
  17090. */
  17091. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17092. /**
  17093. * Remove a specific ramp gradient
  17094. * @param gradient defines the gradient to remove
  17095. * @returns the current particle system
  17096. */
  17097. removeRampGradient(gradient: number): ParticleSystem;
  17098. /**
  17099. * Adds a new color gradient
  17100. * @param gradient defines the gradient to use (between 0 and 1)
  17101. * @param color1 defines the color to affect to the specified gradient
  17102. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17103. * @returns this particle system
  17104. */
  17105. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17106. /**
  17107. * Remove a specific color gradient
  17108. * @param gradient defines the gradient to remove
  17109. * @returns this particle system
  17110. */
  17111. removeColorGradient(gradient: number): IParticleSystem;
  17112. private _fetchR;
  17113. protected _reset(): void;
  17114. private _resetEffect;
  17115. private _createVertexBuffers;
  17116. private _createIndexBuffer;
  17117. /**
  17118. * Gets the maximum number of particles active at the same time.
  17119. * @returns The max number of active particles.
  17120. */
  17121. getCapacity(): number;
  17122. /**
  17123. * Gets whether there are still active particles in the system.
  17124. * @returns True if it is alive, otherwise false.
  17125. */
  17126. isAlive(): boolean;
  17127. /**
  17128. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17129. * @returns True if it has been started, otherwise false.
  17130. */
  17131. isStarted(): boolean;
  17132. private _prepareSubEmitterInternalArray;
  17133. /**
  17134. * Starts the particle system and begins to emit
  17135. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17136. */
  17137. start(delay?: number): void;
  17138. /**
  17139. * Stops the particle system.
  17140. * @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.
  17141. */
  17142. stop(stopSubEmitters?: boolean): void;
  17143. /**
  17144. * Remove all active particles
  17145. */
  17146. reset(): void;
  17147. /**
  17148. * @hidden (for internal use only)
  17149. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17150. /**
  17151. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17152. * Its lifetime will start back at 0.
  17153. */
  17154. recycleParticle: (particle: Particle) => void;
  17155. private _stopSubEmitters;
  17156. private _createParticle;
  17157. private _removeFromRoot;
  17158. private _emitFromParticle;
  17159. private _update;
  17160. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17161. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17162. /** @hidden */
  17163. private _getEffect;
  17164. /**
  17165. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17166. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17167. */
  17168. animate(preWarmOnly?: boolean): void;
  17169. private _appendParticleVertices;
  17170. /**
  17171. * Rebuilds the particle system.
  17172. */
  17173. rebuild(): void;
  17174. /**
  17175. * Is this system ready to be used/rendered
  17176. * @return true if the system is ready
  17177. */
  17178. isReady(): boolean;
  17179. private _render;
  17180. /**
  17181. * Renders the particle system in its current state.
  17182. * @returns the current number of particles
  17183. */
  17184. render(): number;
  17185. /**
  17186. * Disposes the particle system and free the associated resources
  17187. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17188. */
  17189. dispose(disposeTexture?: boolean): void;
  17190. /**
  17191. * Clones the particle system.
  17192. * @param name The name of the cloned object
  17193. * @param newEmitter The new emitter to use
  17194. * @returns the cloned particle system
  17195. */
  17196. clone(name: string, newEmitter: any): ParticleSystem;
  17197. /**
  17198. * Serializes the particle system to a JSON object.
  17199. * @returns the JSON object
  17200. */
  17201. serialize(): any;
  17202. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17203. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17204. /**
  17205. * Parses a JSON object to create a particle system.
  17206. * @param parsedParticleSystem The JSON object to parse
  17207. * @param scene The scene to create the particle system in
  17208. * @param rootUrl The root url to use to load external dependencies like texture
  17209. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17210. * @returns the Parsed particle system
  17211. */
  17212. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17213. }
  17214. }
  17215. declare module BABYLON {
  17216. /**
  17217. * A particle represents one of the element emitted by a particle system.
  17218. * This is mainly define by its coordinates, direction, velocity and age.
  17219. */
  17220. export class Particle {
  17221. /**
  17222. * The particle system the particle belongs to.
  17223. */
  17224. particleSystem: ParticleSystem;
  17225. private static _Count;
  17226. /**
  17227. * Unique ID of the particle
  17228. */
  17229. id: number;
  17230. /**
  17231. * The world position of the particle in the scene.
  17232. */
  17233. position: Vector3;
  17234. /**
  17235. * The world direction of the particle in the scene.
  17236. */
  17237. direction: Vector3;
  17238. /**
  17239. * The color of the particle.
  17240. */
  17241. color: Color4;
  17242. /**
  17243. * The color change of the particle per step.
  17244. */
  17245. colorStep: Color4;
  17246. /**
  17247. * Defines how long will the life of the particle be.
  17248. */
  17249. lifeTime: number;
  17250. /**
  17251. * The current age of the particle.
  17252. */
  17253. age: number;
  17254. /**
  17255. * The current size of the particle.
  17256. */
  17257. size: number;
  17258. /**
  17259. * The current scale of the particle.
  17260. */
  17261. scale: Vector2;
  17262. /**
  17263. * The current angle of the particle.
  17264. */
  17265. angle: number;
  17266. /**
  17267. * Defines how fast is the angle changing.
  17268. */
  17269. angularSpeed: number;
  17270. /**
  17271. * Defines the cell index used by the particle to be rendered from a sprite.
  17272. */
  17273. cellIndex: number;
  17274. /**
  17275. * The information required to support color remapping
  17276. */
  17277. remapData: Vector4;
  17278. /** @hidden */ private _randomCellOffset?: number;
  17279. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17280. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17281. /** @hidden */ private _initialStartSpriteCellID: number;
  17282. /** @hidden */ private _initialEndSpriteCellID: number;
  17283. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17284. /** @hidden */ private _currentColor1: Color4;
  17285. /** @hidden */ private _currentColor2: Color4;
  17286. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17287. /** @hidden */ private _currentSize1: number;
  17288. /** @hidden */ private _currentSize2: number;
  17289. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17290. /** @hidden */ private _currentAngularSpeed1: number;
  17291. /** @hidden */ private _currentAngularSpeed2: number;
  17292. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17293. /** @hidden */ private _currentVelocity1: number;
  17294. /** @hidden */ private _currentVelocity2: number;
  17295. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17296. /** @hidden */ private _currentLimitVelocity1: number;
  17297. /** @hidden */ private _currentLimitVelocity2: number;
  17298. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17299. /** @hidden */ private _currentDrag1: number;
  17300. /** @hidden */ private _currentDrag2: number;
  17301. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17302. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17303. /**
  17304. * Creates a new instance Particle
  17305. * @param particleSystem the particle system the particle belongs to
  17306. */
  17307. constructor(
  17308. /**
  17309. * The particle system the particle belongs to.
  17310. */
  17311. particleSystem: ParticleSystem);
  17312. private updateCellInfoFromSystem;
  17313. /**
  17314. * Defines how the sprite cell index is updated for the particle
  17315. */
  17316. updateCellIndex(): void;
  17317. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17318. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17319. /** @hidden */ private _reset(): void;
  17320. /**
  17321. * Copy the properties of particle to another one.
  17322. * @param other the particle to copy the information to.
  17323. */
  17324. copyTo(other: Particle): void;
  17325. }
  17326. }
  17327. declare module BABYLON {
  17328. /**
  17329. * Particle emitter represents a volume emitting particles.
  17330. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17331. */
  17332. export interface IParticleEmitterType {
  17333. /**
  17334. * Called by the particle System when the direction is computed for the created particle.
  17335. * @param worldMatrix is the world matrix of the particle system
  17336. * @param directionToUpdate is the direction vector to update with the result
  17337. * @param particle is the particle we are computed the direction for
  17338. */
  17339. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17340. /**
  17341. * Called by the particle System when the position is computed for the created particle.
  17342. * @param worldMatrix is the world matrix of the particle system
  17343. * @param positionToUpdate is the position vector to update with the result
  17344. * @param particle is the particle we are computed the position for
  17345. */
  17346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17347. /**
  17348. * Clones the current emitter and returns a copy of it
  17349. * @returns the new emitter
  17350. */
  17351. clone(): IParticleEmitterType;
  17352. /**
  17353. * Called by the GPUParticleSystem to setup the update shader
  17354. * @param effect defines the update shader
  17355. */
  17356. applyToShader(effect: Effect): void;
  17357. /**
  17358. * Returns a string to use to update the GPU particles update shader
  17359. * @returns the effect defines string
  17360. */
  17361. getEffectDefines(): string;
  17362. /**
  17363. * Returns a string representing the class name
  17364. * @returns a string containing the class name
  17365. */
  17366. getClassName(): string;
  17367. /**
  17368. * Serializes the particle system to a JSON object.
  17369. * @returns the JSON object
  17370. */
  17371. serialize(): any;
  17372. /**
  17373. * Parse properties from a JSON object
  17374. * @param serializationObject defines the JSON object
  17375. */
  17376. parse(serializationObject: any): void;
  17377. }
  17378. }
  17379. declare module BABYLON {
  17380. /**
  17381. * Particle emitter emitting particles from the inside of a box.
  17382. * It emits the particles randomly between 2 given directions.
  17383. */
  17384. export class BoxParticleEmitter implements IParticleEmitterType {
  17385. /**
  17386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17387. */
  17388. direction1: Vector3;
  17389. /**
  17390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17391. */
  17392. direction2: Vector3;
  17393. /**
  17394. * 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.
  17395. */
  17396. minEmitBox: Vector3;
  17397. /**
  17398. * 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.
  17399. */
  17400. maxEmitBox: Vector3;
  17401. /**
  17402. * Creates a new instance BoxParticleEmitter
  17403. */
  17404. constructor();
  17405. /**
  17406. * Called by the particle System when the direction is computed for the created particle.
  17407. * @param worldMatrix is the world matrix of the particle system
  17408. * @param directionToUpdate is the direction vector to update with the result
  17409. * @param particle is the particle we are computed the direction for
  17410. */
  17411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17412. /**
  17413. * Called by the particle System when the position is computed for the created particle.
  17414. * @param worldMatrix is the world matrix of the particle system
  17415. * @param positionToUpdate is the position vector to update with the result
  17416. * @param particle is the particle we are computed the position for
  17417. */
  17418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17419. /**
  17420. * Clones the current emitter and returns a copy of it
  17421. * @returns the new emitter
  17422. */
  17423. clone(): BoxParticleEmitter;
  17424. /**
  17425. * Called by the GPUParticleSystem to setup the update shader
  17426. * @param effect defines the update shader
  17427. */
  17428. applyToShader(effect: Effect): void;
  17429. /**
  17430. * Returns a string to use to update the GPU particles update shader
  17431. * @returns a string containng the defines string
  17432. */
  17433. getEffectDefines(): string;
  17434. /**
  17435. * Returns the string "BoxParticleEmitter"
  17436. * @returns a string containing the class name
  17437. */
  17438. getClassName(): string;
  17439. /**
  17440. * Serializes the particle system to a JSON object.
  17441. * @returns the JSON object
  17442. */
  17443. serialize(): any;
  17444. /**
  17445. * Parse properties from a JSON object
  17446. * @param serializationObject defines the JSON object
  17447. */
  17448. parse(serializationObject: any): void;
  17449. }
  17450. }
  17451. declare module BABYLON {
  17452. /**
  17453. * Particle emitter emitting particles from the inside of a cone.
  17454. * It emits the particles alongside the cone volume from the base to the particle.
  17455. * The emission direction might be randomized.
  17456. */
  17457. export class ConeParticleEmitter implements IParticleEmitterType {
  17458. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17459. directionRandomizer: number;
  17460. private _radius;
  17461. private _angle;
  17462. private _height;
  17463. /**
  17464. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17465. */
  17466. radiusRange: number;
  17467. /**
  17468. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17469. */
  17470. heightRange: number;
  17471. /**
  17472. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17473. */
  17474. emitFromSpawnPointOnly: boolean;
  17475. /**
  17476. * Gets or sets the radius of the emission cone
  17477. */
  17478. radius: number;
  17479. /**
  17480. * Gets or sets the angle of the emission cone
  17481. */
  17482. angle: number;
  17483. private _buildHeight;
  17484. /**
  17485. * Creates a new instance ConeParticleEmitter
  17486. * @param radius the radius of the emission cone (1 by default)
  17487. * @param angle the cone base angle (PI by default)
  17488. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17489. */
  17490. constructor(radius?: number, angle?: number,
  17491. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17492. directionRandomizer?: number);
  17493. /**
  17494. * Called by the particle System when the direction is computed for the created particle.
  17495. * @param worldMatrix is the world matrix of the particle system
  17496. * @param directionToUpdate is the direction vector to update with the result
  17497. * @param particle is the particle we are computed the direction for
  17498. */
  17499. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17500. /**
  17501. * Called by the particle System when the position is computed for the created particle.
  17502. * @param worldMatrix is the world matrix of the particle system
  17503. * @param positionToUpdate is the position vector to update with the result
  17504. * @param particle is the particle we are computed the position for
  17505. */
  17506. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17507. /**
  17508. * Clones the current emitter and returns a copy of it
  17509. * @returns the new emitter
  17510. */
  17511. clone(): ConeParticleEmitter;
  17512. /**
  17513. * Called by the GPUParticleSystem to setup the update shader
  17514. * @param effect defines the update shader
  17515. */
  17516. applyToShader(effect: Effect): void;
  17517. /**
  17518. * Returns a string to use to update the GPU particles update shader
  17519. * @returns a string containng the defines string
  17520. */
  17521. getEffectDefines(): string;
  17522. /**
  17523. * Returns the string "ConeParticleEmitter"
  17524. * @returns a string containing the class name
  17525. */
  17526. getClassName(): string;
  17527. /**
  17528. * Serializes the particle system to a JSON object.
  17529. * @returns the JSON object
  17530. */
  17531. serialize(): any;
  17532. /**
  17533. * Parse properties from a JSON object
  17534. * @param serializationObject defines the JSON object
  17535. */
  17536. parse(serializationObject: any): void;
  17537. }
  17538. }
  17539. declare module BABYLON {
  17540. /**
  17541. * Particle emitter emitting particles from the inside of a cylinder.
  17542. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17543. */
  17544. export class CylinderParticleEmitter implements IParticleEmitterType {
  17545. /**
  17546. * The radius of the emission cylinder.
  17547. */
  17548. radius: number;
  17549. /**
  17550. * The height of the emission cylinder.
  17551. */
  17552. height: number;
  17553. /**
  17554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17555. */
  17556. radiusRange: number;
  17557. /**
  17558. * How much to randomize the particle direction [0-1].
  17559. */
  17560. directionRandomizer: number;
  17561. /**
  17562. * Creates a new instance CylinderParticleEmitter
  17563. * @param radius the radius of the emission cylinder (1 by default)
  17564. * @param height the height of the emission cylinder (1 by default)
  17565. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17566. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17567. */
  17568. constructor(
  17569. /**
  17570. * The radius of the emission cylinder.
  17571. */
  17572. radius?: number,
  17573. /**
  17574. * The height of the emission cylinder.
  17575. */
  17576. height?: number,
  17577. /**
  17578. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17579. */
  17580. radiusRange?: number,
  17581. /**
  17582. * How much to randomize the particle direction [0-1].
  17583. */
  17584. directionRandomizer?: number);
  17585. /**
  17586. * Called by the particle System when the direction is computed for the created particle.
  17587. * @param worldMatrix is the world matrix of the particle system
  17588. * @param directionToUpdate is the direction vector to update with the result
  17589. * @param particle is the particle we are computed the direction for
  17590. */
  17591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17592. /**
  17593. * Called by the particle System when the position is computed for the created particle.
  17594. * @param worldMatrix is the world matrix of the particle system
  17595. * @param positionToUpdate is the position vector to update with the result
  17596. * @param particle is the particle we are computed the position for
  17597. */
  17598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17599. /**
  17600. * Clones the current emitter and returns a copy of it
  17601. * @returns the new emitter
  17602. */
  17603. clone(): CylinderParticleEmitter;
  17604. /**
  17605. * Called by the GPUParticleSystem to setup the update shader
  17606. * @param effect defines the update shader
  17607. */
  17608. applyToShader(effect: Effect): void;
  17609. /**
  17610. * Returns a string to use to update the GPU particles update shader
  17611. * @returns a string containng the defines string
  17612. */
  17613. getEffectDefines(): string;
  17614. /**
  17615. * Returns the string "CylinderParticleEmitter"
  17616. * @returns a string containing the class name
  17617. */
  17618. getClassName(): string;
  17619. /**
  17620. * Serializes the particle system to a JSON object.
  17621. * @returns the JSON object
  17622. */
  17623. serialize(): any;
  17624. /**
  17625. * Parse properties from a JSON object
  17626. * @param serializationObject defines the JSON object
  17627. */
  17628. parse(serializationObject: any): void;
  17629. }
  17630. /**
  17631. * Particle emitter emitting particles from the inside of a cylinder.
  17632. * It emits the particles randomly between two vectors.
  17633. */
  17634. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17635. /**
  17636. * The min limit of the emission direction.
  17637. */
  17638. direction1: Vector3;
  17639. /**
  17640. * The max limit of the emission direction.
  17641. */
  17642. direction2: Vector3;
  17643. /**
  17644. * Creates a new instance CylinderDirectedParticleEmitter
  17645. * @param radius the radius of the emission cylinder (1 by default)
  17646. * @param height the height of the emission cylinder (1 by default)
  17647. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17648. * @param direction1 the min limit of the emission direction (up vector by default)
  17649. * @param direction2 the max limit of the emission direction (up vector by default)
  17650. */
  17651. constructor(radius?: number, height?: number, radiusRange?: number,
  17652. /**
  17653. * The min limit of the emission direction.
  17654. */
  17655. direction1?: Vector3,
  17656. /**
  17657. * The max limit of the emission direction.
  17658. */
  17659. direction2?: Vector3);
  17660. /**
  17661. * Called by the particle System when the direction is computed for the created particle.
  17662. * @param worldMatrix is the world matrix of the particle system
  17663. * @param directionToUpdate is the direction vector to update with the result
  17664. * @param particle is the particle we are computed the direction for
  17665. */
  17666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17667. /**
  17668. * Clones the current emitter and returns a copy of it
  17669. * @returns the new emitter
  17670. */
  17671. clone(): CylinderDirectedParticleEmitter;
  17672. /**
  17673. * Called by the GPUParticleSystem to setup the update shader
  17674. * @param effect defines the update shader
  17675. */
  17676. applyToShader(effect: Effect): void;
  17677. /**
  17678. * Returns a string to use to update the GPU particles update shader
  17679. * @returns a string containng the defines string
  17680. */
  17681. getEffectDefines(): string;
  17682. /**
  17683. * Returns the string "CylinderDirectedParticleEmitter"
  17684. * @returns a string containing the class name
  17685. */
  17686. getClassName(): string;
  17687. /**
  17688. * Serializes the particle system to a JSON object.
  17689. * @returns the JSON object
  17690. */
  17691. serialize(): any;
  17692. /**
  17693. * Parse properties from a JSON object
  17694. * @param serializationObject defines the JSON object
  17695. */
  17696. parse(serializationObject: any): void;
  17697. }
  17698. }
  17699. declare module BABYLON {
  17700. /**
  17701. * Particle emitter emitting particles from the inside of a hemisphere.
  17702. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17703. */
  17704. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17705. /**
  17706. * The radius of the emission hemisphere.
  17707. */
  17708. radius: number;
  17709. /**
  17710. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17711. */
  17712. radiusRange: number;
  17713. /**
  17714. * How much to randomize the particle direction [0-1].
  17715. */
  17716. directionRandomizer: number;
  17717. /**
  17718. * Creates a new instance HemisphericParticleEmitter
  17719. * @param radius the radius of the emission hemisphere (1 by default)
  17720. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17721. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17722. */
  17723. constructor(
  17724. /**
  17725. * The radius of the emission hemisphere.
  17726. */
  17727. radius?: number,
  17728. /**
  17729. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17730. */
  17731. radiusRange?: number,
  17732. /**
  17733. * How much to randomize the particle direction [0-1].
  17734. */
  17735. directionRandomizer?: number);
  17736. /**
  17737. * Called by the particle System when the direction is computed for the created particle.
  17738. * @param worldMatrix is the world matrix of the particle system
  17739. * @param directionToUpdate is the direction vector to update with the result
  17740. * @param particle is the particle we are computed the direction for
  17741. */
  17742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17743. /**
  17744. * Called by the particle System when the position is computed for the created particle.
  17745. * @param worldMatrix is the world matrix of the particle system
  17746. * @param positionToUpdate is the position vector to update with the result
  17747. * @param particle is the particle we are computed the position for
  17748. */
  17749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17750. /**
  17751. * Clones the current emitter and returns a copy of it
  17752. * @returns the new emitter
  17753. */
  17754. clone(): HemisphericParticleEmitter;
  17755. /**
  17756. * Called by the GPUParticleSystem to setup the update shader
  17757. * @param effect defines the update shader
  17758. */
  17759. applyToShader(effect: Effect): void;
  17760. /**
  17761. * Returns a string to use to update the GPU particles update shader
  17762. * @returns a string containng the defines string
  17763. */
  17764. getEffectDefines(): string;
  17765. /**
  17766. * Returns the string "HemisphericParticleEmitter"
  17767. * @returns a string containing the class name
  17768. */
  17769. getClassName(): string;
  17770. /**
  17771. * Serializes the particle system to a JSON object.
  17772. * @returns the JSON object
  17773. */
  17774. serialize(): any;
  17775. /**
  17776. * Parse properties from a JSON object
  17777. * @param serializationObject defines the JSON object
  17778. */
  17779. parse(serializationObject: any): void;
  17780. }
  17781. }
  17782. declare module BABYLON {
  17783. /**
  17784. * Particle emitter emitting particles from a point.
  17785. * It emits the particles randomly between 2 given directions.
  17786. */
  17787. export class PointParticleEmitter implements IParticleEmitterType {
  17788. /**
  17789. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17790. */
  17791. direction1: Vector3;
  17792. /**
  17793. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17794. */
  17795. direction2: Vector3;
  17796. /**
  17797. * Creates a new instance PointParticleEmitter
  17798. */
  17799. constructor();
  17800. /**
  17801. * Called by the particle System when the direction is computed for the created particle.
  17802. * @param worldMatrix is the world matrix of the particle system
  17803. * @param directionToUpdate is the direction vector to update with the result
  17804. * @param particle is the particle we are computed the direction for
  17805. */
  17806. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17807. /**
  17808. * Called by the particle System when the position is computed for the created particle.
  17809. * @param worldMatrix is the world matrix of the particle system
  17810. * @param positionToUpdate is the position vector to update with the result
  17811. * @param particle is the particle we are computed the position for
  17812. */
  17813. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17814. /**
  17815. * Clones the current emitter and returns a copy of it
  17816. * @returns the new emitter
  17817. */
  17818. clone(): PointParticleEmitter;
  17819. /**
  17820. * Called by the GPUParticleSystem to setup the update shader
  17821. * @param effect defines the update shader
  17822. */
  17823. applyToShader(effect: Effect): void;
  17824. /**
  17825. * Returns a string to use to update the GPU particles update shader
  17826. * @returns a string containng the defines string
  17827. */
  17828. getEffectDefines(): string;
  17829. /**
  17830. * Returns the string "PointParticleEmitter"
  17831. * @returns a string containing the class name
  17832. */
  17833. getClassName(): string;
  17834. /**
  17835. * Serializes the particle system to a JSON object.
  17836. * @returns the JSON object
  17837. */
  17838. serialize(): any;
  17839. /**
  17840. * Parse properties from a JSON object
  17841. * @param serializationObject defines the JSON object
  17842. */
  17843. parse(serializationObject: any): void;
  17844. }
  17845. }
  17846. declare module BABYLON {
  17847. /**
  17848. * Particle emitter emitting particles from the inside of a sphere.
  17849. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17850. */
  17851. export class SphereParticleEmitter implements IParticleEmitterType {
  17852. /**
  17853. * The radius of the emission sphere.
  17854. */
  17855. radius: number;
  17856. /**
  17857. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17858. */
  17859. radiusRange: number;
  17860. /**
  17861. * How much to randomize the particle direction [0-1].
  17862. */
  17863. directionRandomizer: number;
  17864. /**
  17865. * Creates a new instance SphereParticleEmitter
  17866. * @param radius the radius of the emission sphere (1 by default)
  17867. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17868. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17869. */
  17870. constructor(
  17871. /**
  17872. * The radius of the emission sphere.
  17873. */
  17874. radius?: number,
  17875. /**
  17876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17877. */
  17878. radiusRange?: number,
  17879. /**
  17880. * How much to randomize the particle direction [0-1].
  17881. */
  17882. directionRandomizer?: number);
  17883. /**
  17884. * Called by the particle System when the direction is computed for the created particle.
  17885. * @param worldMatrix is the world matrix of the particle system
  17886. * @param directionToUpdate is the direction vector to update with the result
  17887. * @param particle is the particle we are computed the direction for
  17888. */
  17889. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17890. /**
  17891. * Called by the particle System when the position is computed for the created particle.
  17892. * @param worldMatrix is the world matrix of the particle system
  17893. * @param positionToUpdate is the position vector to update with the result
  17894. * @param particle is the particle we are computed the position for
  17895. */
  17896. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17897. /**
  17898. * Clones the current emitter and returns a copy of it
  17899. * @returns the new emitter
  17900. */
  17901. clone(): SphereParticleEmitter;
  17902. /**
  17903. * Called by the GPUParticleSystem to setup the update shader
  17904. * @param effect defines the update shader
  17905. */
  17906. applyToShader(effect: Effect): void;
  17907. /**
  17908. * Returns a string to use to update the GPU particles update shader
  17909. * @returns a string containng the defines string
  17910. */
  17911. getEffectDefines(): string;
  17912. /**
  17913. * Returns the string "SphereParticleEmitter"
  17914. * @returns a string containing the class name
  17915. */
  17916. getClassName(): string;
  17917. /**
  17918. * Serializes the particle system to a JSON object.
  17919. * @returns the JSON object
  17920. */
  17921. serialize(): any;
  17922. /**
  17923. * Parse properties from a JSON object
  17924. * @param serializationObject defines the JSON object
  17925. */
  17926. parse(serializationObject: any): void;
  17927. }
  17928. /**
  17929. * Particle emitter emitting particles from the inside of a sphere.
  17930. * It emits the particles randomly between two vectors.
  17931. */
  17932. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17933. /**
  17934. * The min limit of the emission direction.
  17935. */
  17936. direction1: Vector3;
  17937. /**
  17938. * The max limit of the emission direction.
  17939. */
  17940. direction2: Vector3;
  17941. /**
  17942. * Creates a new instance SphereDirectedParticleEmitter
  17943. * @param radius the radius of the emission sphere (1 by default)
  17944. * @param direction1 the min limit of the emission direction (up vector by default)
  17945. * @param direction2 the max limit of the emission direction (up vector by default)
  17946. */
  17947. constructor(radius?: number,
  17948. /**
  17949. * The min limit of the emission direction.
  17950. */
  17951. direction1?: Vector3,
  17952. /**
  17953. * The max limit of the emission direction.
  17954. */
  17955. direction2?: Vector3);
  17956. /**
  17957. * Called by the particle System when the direction is computed for the created particle.
  17958. * @param worldMatrix is the world matrix of the particle system
  17959. * @param directionToUpdate is the direction vector to update with the result
  17960. * @param particle is the particle we are computed the direction for
  17961. */
  17962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17963. /**
  17964. * Clones the current emitter and returns a copy of it
  17965. * @returns the new emitter
  17966. */
  17967. clone(): SphereDirectedParticleEmitter;
  17968. /**
  17969. * Called by the GPUParticleSystem to setup the update shader
  17970. * @param effect defines the update shader
  17971. */
  17972. applyToShader(effect: Effect): void;
  17973. /**
  17974. * Returns a string to use to update the GPU particles update shader
  17975. * @returns a string containng the defines string
  17976. */
  17977. getEffectDefines(): string;
  17978. /**
  17979. * Returns the string "SphereDirectedParticleEmitter"
  17980. * @returns a string containing the class name
  17981. */
  17982. getClassName(): string;
  17983. /**
  17984. * Serializes the particle system to a JSON object.
  17985. * @returns the JSON object
  17986. */
  17987. serialize(): any;
  17988. /**
  17989. * Parse properties from a JSON object
  17990. * @param serializationObject defines the JSON object
  17991. */
  17992. parse(serializationObject: any): void;
  17993. }
  17994. }
  17995. declare module BABYLON {
  17996. /**
  17997. * Interface representing a particle system in Babylon.js.
  17998. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17999. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18000. */
  18001. export interface IParticleSystem {
  18002. /**
  18003. * List of animations used by the particle system.
  18004. */
  18005. animations: Animation[];
  18006. /**
  18007. * The id of the Particle system.
  18008. */
  18009. id: string;
  18010. /**
  18011. * The name of the Particle system.
  18012. */
  18013. name: string;
  18014. /**
  18015. * The emitter represents the Mesh or position we are attaching the particle system to.
  18016. */
  18017. emitter: Nullable<AbstractMesh | Vector3>;
  18018. /**
  18019. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18020. */
  18021. isBillboardBased: boolean;
  18022. /**
  18023. * The rendering group used by the Particle system to chose when to render.
  18024. */
  18025. renderingGroupId: number;
  18026. /**
  18027. * The layer mask we are rendering the particles through.
  18028. */
  18029. layerMask: number;
  18030. /**
  18031. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18032. */
  18033. updateSpeed: number;
  18034. /**
  18035. * The amount of time the particle system is running (depends of the overall update speed).
  18036. */
  18037. targetStopDuration: number;
  18038. /**
  18039. * The texture used to render each particle. (this can be a spritesheet)
  18040. */
  18041. particleTexture: Nullable<Texture>;
  18042. /**
  18043. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18044. */
  18045. blendMode: number;
  18046. /**
  18047. * Minimum life time of emitting particles.
  18048. */
  18049. minLifeTime: number;
  18050. /**
  18051. * Maximum life time of emitting particles.
  18052. */
  18053. maxLifeTime: number;
  18054. /**
  18055. * Minimum Size of emitting particles.
  18056. */
  18057. minSize: number;
  18058. /**
  18059. * Maximum Size of emitting particles.
  18060. */
  18061. maxSize: number;
  18062. /**
  18063. * Minimum scale of emitting particles on X axis.
  18064. */
  18065. minScaleX: number;
  18066. /**
  18067. * Maximum scale of emitting particles on X axis.
  18068. */
  18069. maxScaleX: number;
  18070. /**
  18071. * Minimum scale of emitting particles on Y axis.
  18072. */
  18073. minScaleY: number;
  18074. /**
  18075. * Maximum scale of emitting particles on Y axis.
  18076. */
  18077. maxScaleY: number;
  18078. /**
  18079. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18080. */
  18081. color1: Color4;
  18082. /**
  18083. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18084. */
  18085. color2: Color4;
  18086. /**
  18087. * Color the particle will have at the end of its lifetime.
  18088. */
  18089. colorDead: Color4;
  18090. /**
  18091. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18092. */
  18093. emitRate: number;
  18094. /**
  18095. * You can use gravity if you want to give an orientation to your particles.
  18096. */
  18097. gravity: Vector3;
  18098. /**
  18099. * Minimum power of emitting particles.
  18100. */
  18101. minEmitPower: number;
  18102. /**
  18103. * Maximum power of emitting particles.
  18104. */
  18105. maxEmitPower: number;
  18106. /**
  18107. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18108. */
  18109. minAngularSpeed: number;
  18110. /**
  18111. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18112. */
  18113. maxAngularSpeed: number;
  18114. /**
  18115. * Gets or sets the minimal initial rotation in radians.
  18116. */
  18117. minInitialRotation: number;
  18118. /**
  18119. * Gets or sets the maximal initial rotation in radians.
  18120. */
  18121. maxInitialRotation: number;
  18122. /**
  18123. * The particle emitter type defines the emitter used by the particle system.
  18124. * It can be for example box, sphere, or cone...
  18125. */
  18126. particleEmitterType: Nullable<IParticleEmitterType>;
  18127. /**
  18128. * Defines the delay in milliseconds before starting the system (0 by default)
  18129. */
  18130. startDelay: number;
  18131. /**
  18132. * 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
  18133. */
  18134. preWarmCycles: number;
  18135. /**
  18136. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18137. */
  18138. preWarmStepOffset: number;
  18139. /**
  18140. * 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)
  18141. */
  18142. spriteCellChangeSpeed: number;
  18143. /**
  18144. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18145. */
  18146. startSpriteCellID: number;
  18147. /**
  18148. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18149. */
  18150. endSpriteCellID: number;
  18151. /**
  18152. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18153. */
  18154. spriteCellWidth: number;
  18155. /**
  18156. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18157. */
  18158. spriteCellHeight: number;
  18159. /**
  18160. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18161. */
  18162. spriteRandomStartCell: boolean;
  18163. /**
  18164. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18165. */
  18166. isAnimationSheetEnabled: boolean;
  18167. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18168. translationPivot: Vector2;
  18169. /**
  18170. * Gets or sets a texture used to add random noise to particle positions
  18171. */
  18172. noiseTexture: Nullable<BaseTexture>;
  18173. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18174. noiseStrength: Vector3;
  18175. /**
  18176. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18177. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18178. */
  18179. billboardMode: number;
  18180. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18181. limitVelocityDamping: number;
  18182. /**
  18183. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18184. */
  18185. beginAnimationOnStart: boolean;
  18186. /**
  18187. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18188. */
  18189. beginAnimationFrom: number;
  18190. /**
  18191. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18192. */
  18193. beginAnimationTo: number;
  18194. /**
  18195. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18196. */
  18197. beginAnimationLoop: boolean;
  18198. /**
  18199. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18200. */
  18201. disposeOnStop: boolean;
  18202. /**
  18203. * Gets the maximum number of particles active at the same time.
  18204. * @returns The max number of active particles.
  18205. */
  18206. getCapacity(): number;
  18207. /**
  18208. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18209. * @returns True if it has been started, otherwise false.
  18210. */
  18211. isStarted(): boolean;
  18212. /**
  18213. * Animates the particle system for this frame.
  18214. */
  18215. animate(): void;
  18216. /**
  18217. * Renders the particle system in its current state.
  18218. * @returns the current number of particles
  18219. */
  18220. render(): number;
  18221. /**
  18222. * Dispose the particle system and frees its associated resources.
  18223. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18224. */
  18225. dispose(disposeTexture?: boolean): void;
  18226. /**
  18227. * Clones the particle system.
  18228. * @param name The name of the cloned object
  18229. * @param newEmitter The new emitter to use
  18230. * @returns the cloned particle system
  18231. */
  18232. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18233. /**
  18234. * Serializes the particle system to a JSON object.
  18235. * @returns the JSON object
  18236. */
  18237. serialize(): any;
  18238. /**
  18239. * Rebuild the particle system
  18240. */
  18241. rebuild(): void;
  18242. /**
  18243. * Starts the particle system and begins to emit
  18244. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18245. */
  18246. start(delay?: number): void;
  18247. /**
  18248. * Stops the particle system.
  18249. */
  18250. stop(): void;
  18251. /**
  18252. * Remove all active particles
  18253. */
  18254. reset(): void;
  18255. /**
  18256. * Is this system ready to be used/rendered
  18257. * @return true if the system is ready
  18258. */
  18259. isReady(): boolean;
  18260. /**
  18261. * Adds a new color gradient
  18262. * @param gradient defines the gradient to use (between 0 and 1)
  18263. * @param color1 defines the color to affect to the specified gradient
  18264. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18265. * @returns the current particle system
  18266. */
  18267. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18268. /**
  18269. * Remove a specific color gradient
  18270. * @param gradient defines the gradient to remove
  18271. * @returns the current particle system
  18272. */
  18273. removeColorGradient(gradient: number): IParticleSystem;
  18274. /**
  18275. * Adds a new size gradient
  18276. * @param gradient defines the gradient to use (between 0 and 1)
  18277. * @param factor defines the size factor to affect to the specified gradient
  18278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18279. * @returns the current particle system
  18280. */
  18281. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18282. /**
  18283. * Remove a specific size gradient
  18284. * @param gradient defines the gradient to remove
  18285. * @returns the current particle system
  18286. */
  18287. removeSizeGradient(gradient: number): IParticleSystem;
  18288. /**
  18289. * Gets the current list of color gradients.
  18290. * You must use addColorGradient and removeColorGradient to udpate this list
  18291. * @returns the list of color gradients
  18292. */
  18293. getColorGradients(): Nullable<Array<ColorGradient>>;
  18294. /**
  18295. * Gets the current list of size gradients.
  18296. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18297. * @returns the list of size gradients
  18298. */
  18299. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18300. /**
  18301. * Gets the current list of angular speed gradients.
  18302. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18303. * @returns the list of angular speed gradients
  18304. */
  18305. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18306. /**
  18307. * Adds a new angular speed gradient
  18308. * @param gradient defines the gradient to use (between 0 and 1)
  18309. * @param factor defines the angular speed to affect to the specified gradient
  18310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18311. * @returns the current particle system
  18312. */
  18313. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18314. /**
  18315. * Remove a specific angular speed gradient
  18316. * @param gradient defines the gradient to remove
  18317. * @returns the current particle system
  18318. */
  18319. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18320. /**
  18321. * Gets the current list of velocity gradients.
  18322. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18323. * @returns the list of velocity gradients
  18324. */
  18325. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18326. /**
  18327. * Adds a new velocity gradient
  18328. * @param gradient defines the gradient to use (between 0 and 1)
  18329. * @param factor defines the velocity to affect to the specified gradient
  18330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18331. * @returns the current particle system
  18332. */
  18333. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18334. /**
  18335. * Remove a specific velocity gradient
  18336. * @param gradient defines the gradient to remove
  18337. * @returns the current particle system
  18338. */
  18339. removeVelocityGradient(gradient: number): IParticleSystem;
  18340. /**
  18341. * Gets the current list of limit velocity gradients.
  18342. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18343. * @returns the list of limit velocity gradients
  18344. */
  18345. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18346. /**
  18347. * Adds a new limit velocity gradient
  18348. * @param gradient defines the gradient to use (between 0 and 1)
  18349. * @param factor defines the limit velocity to affect to the specified gradient
  18350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18351. * @returns the current particle system
  18352. */
  18353. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18354. /**
  18355. * Remove a specific limit velocity gradient
  18356. * @param gradient defines the gradient to remove
  18357. * @returns the current particle system
  18358. */
  18359. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18360. /**
  18361. * Adds a new drag gradient
  18362. * @param gradient defines the gradient to use (between 0 and 1)
  18363. * @param factor defines the drag to affect to the specified gradient
  18364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18365. * @returns the current particle system
  18366. */
  18367. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18368. /**
  18369. * Remove a specific drag gradient
  18370. * @param gradient defines the gradient to remove
  18371. * @returns the current particle system
  18372. */
  18373. removeDragGradient(gradient: number): IParticleSystem;
  18374. /**
  18375. * Gets the current list of drag gradients.
  18376. * You must use addDragGradient and removeDragGradient to udpate this list
  18377. * @returns the list of drag gradients
  18378. */
  18379. getDragGradients(): Nullable<Array<FactorGradient>>;
  18380. /**
  18381. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18382. * @param gradient defines the gradient to use (between 0 and 1)
  18383. * @param factor defines the emit rate to affect to the specified gradient
  18384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18385. * @returns the current particle system
  18386. */
  18387. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18388. /**
  18389. * Remove a specific emit rate gradient
  18390. * @param gradient defines the gradient to remove
  18391. * @returns the current particle system
  18392. */
  18393. removeEmitRateGradient(gradient: number): IParticleSystem;
  18394. /**
  18395. * Gets the current list of emit rate gradients.
  18396. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18397. * @returns the list of emit rate gradients
  18398. */
  18399. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18400. /**
  18401. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18402. * @param gradient defines the gradient to use (between 0 and 1)
  18403. * @param factor defines the start size to affect to the specified gradient
  18404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18405. * @returns the current particle system
  18406. */
  18407. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18408. /**
  18409. * Remove a specific start size gradient
  18410. * @param gradient defines the gradient to remove
  18411. * @returns the current particle system
  18412. */
  18413. removeStartSizeGradient(gradient: number): IParticleSystem;
  18414. /**
  18415. * Gets the current list of start size gradients.
  18416. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18417. * @returns the list of start size gradients
  18418. */
  18419. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18420. /**
  18421. * Adds a new life time gradient
  18422. * @param gradient defines the gradient to use (between 0 and 1)
  18423. * @param factor defines the life time factor to affect to the specified gradient
  18424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18425. * @returns the current particle system
  18426. */
  18427. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18428. /**
  18429. * Remove a specific life time gradient
  18430. * @param gradient defines the gradient to remove
  18431. * @returns the current particle system
  18432. */
  18433. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18434. /**
  18435. * Gets the current list of life time gradients.
  18436. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18437. * @returns the list of life time gradients
  18438. */
  18439. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18440. /**
  18441. * Gets the current list of color gradients.
  18442. * You must use addColorGradient and removeColorGradient to udpate this list
  18443. * @returns the list of color gradients
  18444. */
  18445. getColorGradients(): Nullable<Array<ColorGradient>>;
  18446. /**
  18447. * Adds a new ramp gradient used to remap particle colors
  18448. * @param gradient defines the gradient to use (between 0 and 1)
  18449. * @param color defines the color to affect to the specified gradient
  18450. * @returns the current particle system
  18451. */
  18452. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18453. /**
  18454. * Gets the current list of ramp gradients.
  18455. * You must use addRampGradient and removeRampGradient to udpate this list
  18456. * @returns the list of ramp gradients
  18457. */
  18458. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18459. /** Gets or sets a boolean indicating that ramp gradients must be used
  18460. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18461. */
  18462. useRampGradients: boolean;
  18463. /**
  18464. * Adds a new color remap gradient
  18465. * @param gradient defines the gradient to use (between 0 and 1)
  18466. * @param min defines the color remap minimal range
  18467. * @param max defines the color remap maximal range
  18468. * @returns the current particle system
  18469. */
  18470. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18471. /**
  18472. * Gets the current list of color remap gradients.
  18473. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18474. * @returns the list of color remap gradients
  18475. */
  18476. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18477. /**
  18478. * Adds a new alpha remap gradient
  18479. * @param gradient defines the gradient to use (between 0 and 1)
  18480. * @param min defines the alpha remap minimal range
  18481. * @param max defines the alpha remap maximal range
  18482. * @returns the current particle system
  18483. */
  18484. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18485. /**
  18486. * Gets the current list of alpha remap gradients.
  18487. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18488. * @returns the list of alpha remap gradients
  18489. */
  18490. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18491. /**
  18492. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18495. * @returns the emitter
  18496. */
  18497. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18498. /**
  18499. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18500. * @param radius The radius of the hemisphere to emit from
  18501. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18502. * @returns the emitter
  18503. */
  18504. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18505. /**
  18506. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18507. * @param radius The radius of the sphere to emit from
  18508. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18509. * @returns the emitter
  18510. */
  18511. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18512. /**
  18513. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18514. * @param radius The radius of the sphere to emit from
  18515. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18516. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18517. * @returns the emitter
  18518. */
  18519. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18520. /**
  18521. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18522. * @param radius The radius of the emission cylinder
  18523. * @param height The height of the emission cylinder
  18524. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18525. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18526. * @returns the emitter
  18527. */
  18528. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18529. /**
  18530. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18531. * @param radius The radius of the cylinder to emit from
  18532. * @param height The height of the emission cylinder
  18533. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18536. * @returns the emitter
  18537. */
  18538. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18539. /**
  18540. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18541. * @param radius The radius of the cone to emit from
  18542. * @param angle The base angle of the cone
  18543. * @returns the emitter
  18544. */
  18545. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18546. /**
  18547. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18550. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18551. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18552. * @returns the emitter
  18553. */
  18554. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18555. /**
  18556. * Get hosting scene
  18557. * @returns the scene
  18558. */
  18559. getScene(): Scene;
  18560. }
  18561. }
  18562. declare module BABYLON {
  18563. /**
  18564. * Creates an instance based on a source mesh.
  18565. */
  18566. export class InstancedMesh extends AbstractMesh {
  18567. private _sourceMesh;
  18568. private _currentLOD;
  18569. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18570. constructor(name: string, source: Mesh);
  18571. /**
  18572. * Returns the string "InstancedMesh".
  18573. */
  18574. getClassName(): string;
  18575. /** Gets the list of lights affecting that mesh */
  18576. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18577. /**
  18578. * If the source mesh receives shadows
  18579. */
  18580. readonly receiveShadows: boolean;
  18581. /**
  18582. * The material of the source mesh
  18583. */
  18584. readonly material: Nullable<Material>;
  18585. /**
  18586. * Visibility of the source mesh
  18587. */
  18588. readonly visibility: number;
  18589. /**
  18590. * Skeleton of the source mesh
  18591. */
  18592. readonly skeleton: Nullable<Skeleton>;
  18593. /**
  18594. * Rendering ground id of the source mesh
  18595. */
  18596. renderingGroupId: number;
  18597. /**
  18598. * Returns the total number of vertices (integer).
  18599. */
  18600. getTotalVertices(): number;
  18601. /**
  18602. * Returns a positive integer : the total number of indices in this mesh geometry.
  18603. * @returns the numner of indices or zero if the mesh has no geometry.
  18604. */
  18605. getTotalIndices(): number;
  18606. /**
  18607. * The source mesh of the instance
  18608. */
  18609. readonly sourceMesh: Mesh;
  18610. /**
  18611. * Is this node ready to be used/rendered
  18612. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18613. * @return {boolean} is it ready
  18614. */
  18615. isReady(completeCheck?: boolean): boolean;
  18616. /**
  18617. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18618. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18619. * @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.
  18620. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18621. */
  18622. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18623. /**
  18624. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18625. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18626. * The `data` are either a numeric array either a Float32Array.
  18627. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18628. * 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).
  18629. * Note that a new underlying VertexBuffer object is created each call.
  18630. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18631. *
  18632. * Possible `kind` values :
  18633. * - VertexBuffer.PositionKind
  18634. * - VertexBuffer.UVKind
  18635. * - VertexBuffer.UV2Kind
  18636. * - VertexBuffer.UV3Kind
  18637. * - VertexBuffer.UV4Kind
  18638. * - VertexBuffer.UV5Kind
  18639. * - VertexBuffer.UV6Kind
  18640. * - VertexBuffer.ColorKind
  18641. * - VertexBuffer.MatricesIndicesKind
  18642. * - VertexBuffer.MatricesIndicesExtraKind
  18643. * - VertexBuffer.MatricesWeightsKind
  18644. * - VertexBuffer.MatricesWeightsExtraKind
  18645. *
  18646. * Returns the Mesh.
  18647. */
  18648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18649. /**
  18650. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18651. * If the mesh has no geometry, it is simply returned as it is.
  18652. * The `data` are either a numeric array either a Float32Array.
  18653. * No new underlying VertexBuffer object is created.
  18654. * 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.
  18655. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18656. *
  18657. * Possible `kind` values :
  18658. * - VertexBuffer.PositionKind
  18659. * - VertexBuffer.UVKind
  18660. * - VertexBuffer.UV2Kind
  18661. * - VertexBuffer.UV3Kind
  18662. * - VertexBuffer.UV4Kind
  18663. * - VertexBuffer.UV5Kind
  18664. * - VertexBuffer.UV6Kind
  18665. * - VertexBuffer.ColorKind
  18666. * - VertexBuffer.MatricesIndicesKind
  18667. * - VertexBuffer.MatricesIndicesExtraKind
  18668. * - VertexBuffer.MatricesWeightsKind
  18669. * - VertexBuffer.MatricesWeightsExtraKind
  18670. *
  18671. * Returns the Mesh.
  18672. */
  18673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18674. /**
  18675. * Sets the mesh indices.
  18676. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18677. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18678. * This method creates a new index buffer each call.
  18679. * Returns the Mesh.
  18680. */
  18681. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18682. /**
  18683. * Boolean : True if the mesh owns the requested kind of data.
  18684. */
  18685. isVerticesDataPresent(kind: string): boolean;
  18686. /**
  18687. * Returns an array of indices (IndicesArray).
  18688. */
  18689. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18690. /**
  18691. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18692. * This means the mesh underlying bounding box and sphere are recomputed.
  18693. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18694. * @returns the current mesh
  18695. */
  18696. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18697. /** @hidden */ private _preActivate(): InstancedMesh;
  18698. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18699. /** @hidden */ private _postActivate(): void;
  18700. getWorldMatrix(): Matrix;
  18701. readonly isAnInstance: boolean;
  18702. /**
  18703. * Returns the current associated LOD AbstractMesh.
  18704. */
  18705. getLOD(camera: Camera): AbstractMesh;
  18706. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18707. /** @hidden */ private _generatePointsArray(): boolean;
  18708. /**
  18709. * Creates a new InstancedMesh from the current mesh.
  18710. * - name (string) : the cloned mesh name
  18711. * - newParent (optional Node) : the optional Node to parent the clone to.
  18712. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18713. *
  18714. * Returns the clone.
  18715. */
  18716. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18717. /**
  18718. * Disposes the InstancedMesh.
  18719. * Returns nothing.
  18720. */
  18721. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18722. }
  18723. interface Mesh {
  18724. /**
  18725. * Register a custom buffer that will be instanced
  18726. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18727. * @param kind defines the buffer kind
  18728. * @param stride defines the stride in floats
  18729. */
  18730. registerInstancedBuffer(kind: string, stride: number): void;
  18731. /** @hidden */ private _userInstancedBuffersStorage: {
  18732. data: {
  18733. [key: string]: Float32Array;
  18734. };
  18735. sizes: {
  18736. [key: string]: number;
  18737. };
  18738. vertexBuffers: {
  18739. [key: string]: Nullable<VertexBuffer>;
  18740. };
  18741. strides: {
  18742. [key: string]: number;
  18743. };
  18744. };
  18745. }
  18746. interface AbstractMesh {
  18747. /**
  18748. * Object used to store instanced buffers defined by user
  18749. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18750. */
  18751. instancedBuffers: {
  18752. [key: string]: any;
  18753. };
  18754. }
  18755. }
  18756. declare module BABYLON {
  18757. /**
  18758. * Defines the options associated with the creation of a shader material.
  18759. */
  18760. export interface IShaderMaterialOptions {
  18761. /**
  18762. * Does the material work in alpha blend mode
  18763. */
  18764. needAlphaBlending: boolean;
  18765. /**
  18766. * Does the material work in alpha test mode
  18767. */
  18768. needAlphaTesting: boolean;
  18769. /**
  18770. * The list of attribute names used in the shader
  18771. */
  18772. attributes: string[];
  18773. /**
  18774. * The list of unifrom names used in the shader
  18775. */
  18776. uniforms: string[];
  18777. /**
  18778. * The list of UBO names used in the shader
  18779. */
  18780. uniformBuffers: string[];
  18781. /**
  18782. * The list of sampler names used in the shader
  18783. */
  18784. samplers: string[];
  18785. /**
  18786. * The list of defines used in the shader
  18787. */
  18788. defines: string[];
  18789. }
  18790. /**
  18791. * 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.
  18792. *
  18793. * This returned material effects how the mesh will look based on the code in the shaders.
  18794. *
  18795. * @see http://doc.babylonjs.com/how_to/shader_material
  18796. */
  18797. export class ShaderMaterial extends Material {
  18798. private _shaderPath;
  18799. private _options;
  18800. private _textures;
  18801. private _textureArrays;
  18802. private _floats;
  18803. private _ints;
  18804. private _floatsArrays;
  18805. private _colors3;
  18806. private _colors3Arrays;
  18807. private _colors4;
  18808. private _colors4Arrays;
  18809. private _vectors2;
  18810. private _vectors3;
  18811. private _vectors4;
  18812. private _matrices;
  18813. private _matrices3x3;
  18814. private _matrices2x2;
  18815. private _vectors2Arrays;
  18816. private _vectors3Arrays;
  18817. private _vectors4Arrays;
  18818. private _cachedWorldViewMatrix;
  18819. private _cachedWorldViewProjectionMatrix;
  18820. private _renderId;
  18821. /**
  18822. * Instantiate a new shader material.
  18823. * 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.
  18824. * This returned material effects how the mesh will look based on the code in the shaders.
  18825. * @see http://doc.babylonjs.com/how_to/shader_material
  18826. * @param name Define the name of the material in the scene
  18827. * @param scene Define the scene the material belongs to
  18828. * @param shaderPath Defines the route to the shader code in one of three ways:
  18829. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18830. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18831. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18832. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18833. * @param options Define the options used to create the shader
  18834. */
  18835. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18836. /**
  18837. * Gets the options used to compile the shader.
  18838. * They can be modified to trigger a new compilation
  18839. */
  18840. readonly options: IShaderMaterialOptions;
  18841. /**
  18842. * Gets the current class name of the material e.g. "ShaderMaterial"
  18843. * Mainly use in serialization.
  18844. * @returns the class name
  18845. */
  18846. getClassName(): string;
  18847. /**
  18848. * Specifies if the material will require alpha blending
  18849. * @returns a boolean specifying if alpha blending is needed
  18850. */
  18851. needAlphaBlending(): boolean;
  18852. /**
  18853. * Specifies if this material should be rendered in alpha test mode
  18854. * @returns a boolean specifying if an alpha test is needed.
  18855. */
  18856. needAlphaTesting(): boolean;
  18857. private _checkUniform;
  18858. /**
  18859. * Set a texture in the shader.
  18860. * @param name Define the name of the uniform samplers as defined in the shader
  18861. * @param texture Define the texture to bind to this sampler
  18862. * @return the material itself allowing "fluent" like uniform updates
  18863. */
  18864. setTexture(name: string, texture: Texture): ShaderMaterial;
  18865. /**
  18866. * Set a texture array in the shader.
  18867. * @param name Define the name of the uniform sampler array as defined in the shader
  18868. * @param textures Define the list of textures to bind to this sampler
  18869. * @return the material itself allowing "fluent" like uniform updates
  18870. */
  18871. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18872. /**
  18873. * Set a float in the shader.
  18874. * @param name Define the name of the uniform as defined in the shader
  18875. * @param value Define the value to give to the uniform
  18876. * @return the material itself allowing "fluent" like uniform updates
  18877. */
  18878. setFloat(name: string, value: number): ShaderMaterial;
  18879. /**
  18880. * Set a int in the shader.
  18881. * @param name Define the name of the uniform as defined in the shader
  18882. * @param value Define the value to give to the uniform
  18883. * @return the material itself allowing "fluent" like uniform updates
  18884. */
  18885. setInt(name: string, value: number): ShaderMaterial;
  18886. /**
  18887. * Set an array of floats in the shader.
  18888. * @param name Define the name of the uniform as defined in the shader
  18889. * @param value Define the value to give to the uniform
  18890. * @return the material itself allowing "fluent" like uniform updates
  18891. */
  18892. setFloats(name: string, value: number[]): ShaderMaterial;
  18893. /**
  18894. * Set a vec3 in the shader from a Color3.
  18895. * @param name Define the name of the uniform as defined in the shader
  18896. * @param value Define the value to give to the uniform
  18897. * @return the material itself allowing "fluent" like uniform updates
  18898. */
  18899. setColor3(name: string, value: Color3): ShaderMaterial;
  18900. /**
  18901. * Set a vec3 array in the shader from a Color3 array.
  18902. * @param name Define the name of the uniform as defined in the shader
  18903. * @param value Define the value to give to the uniform
  18904. * @return the material itself allowing "fluent" like uniform updates
  18905. */
  18906. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18907. /**
  18908. * Set a vec4 in the shader from a Color4.
  18909. * @param name Define the name of the uniform as defined in the shader
  18910. * @param value Define the value to give to the uniform
  18911. * @return the material itself allowing "fluent" like uniform updates
  18912. */
  18913. setColor4(name: string, value: Color4): ShaderMaterial;
  18914. /**
  18915. * Set a vec4 array in the shader from a Color4 array.
  18916. * @param name Define the name of the uniform as defined in the shader
  18917. * @param value Define the value to give to the uniform
  18918. * @return the material itself allowing "fluent" like uniform updates
  18919. */
  18920. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18921. /**
  18922. * Set a vec2 in the shader from a Vector2.
  18923. * @param name Define the name of the uniform as defined in the shader
  18924. * @param value Define the value to give to the uniform
  18925. * @return the material itself allowing "fluent" like uniform updates
  18926. */
  18927. setVector2(name: string, value: Vector2): ShaderMaterial;
  18928. /**
  18929. * Set a vec3 in the shader from a Vector3.
  18930. * @param name Define the name of the uniform as defined in the shader
  18931. * @param value Define the value to give to the uniform
  18932. * @return the material itself allowing "fluent" like uniform updates
  18933. */
  18934. setVector3(name: string, value: Vector3): ShaderMaterial;
  18935. /**
  18936. * Set a vec4 in the shader from a Vector4.
  18937. * @param name Define the name of the uniform as defined in the shader
  18938. * @param value Define the value to give to the uniform
  18939. * @return the material itself allowing "fluent" like uniform updates
  18940. */
  18941. setVector4(name: string, value: Vector4): ShaderMaterial;
  18942. /**
  18943. * Set a mat4 in the shader from a Matrix.
  18944. * @param name Define the name of the uniform as defined in the shader
  18945. * @param value Define the value to give to the uniform
  18946. * @return the material itself allowing "fluent" like uniform updates
  18947. */
  18948. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18949. /**
  18950. * Set a mat3 in the shader from a Float32Array.
  18951. * @param name Define the name of the uniform as defined in the shader
  18952. * @param value Define the value to give to the uniform
  18953. * @return the material itself allowing "fluent" like uniform updates
  18954. */
  18955. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18956. /**
  18957. * Set a mat2 in the shader from a Float32Array.
  18958. * @param name Define the name of the uniform as defined in the shader
  18959. * @param value Define the value to give to the uniform
  18960. * @return the material itself allowing "fluent" like uniform updates
  18961. */
  18962. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18963. /**
  18964. * Set a vec2 array in the shader from a number array.
  18965. * @param name Define the name of the uniform as defined in the shader
  18966. * @param value Define the value to give to the uniform
  18967. * @return the material itself allowing "fluent" like uniform updates
  18968. */
  18969. setArray2(name: string, value: number[]): ShaderMaterial;
  18970. /**
  18971. * Set a vec3 array in the shader from a number array.
  18972. * @param name Define the name of the uniform as defined in the shader
  18973. * @param value Define the value to give to the uniform
  18974. * @return the material itself allowing "fluent" like uniform updates
  18975. */
  18976. setArray3(name: string, value: number[]): ShaderMaterial;
  18977. /**
  18978. * Set a vec4 array in the shader from a number array.
  18979. * @param name Define the name of the uniform as defined in the shader
  18980. * @param value Define the value to give to the uniform
  18981. * @return the material itself allowing "fluent" like uniform updates
  18982. */
  18983. setArray4(name: string, value: number[]): ShaderMaterial;
  18984. private _checkCache;
  18985. /**
  18986. * Specifies that the submesh is ready to be used
  18987. * @param mesh defines the mesh to check
  18988. * @param subMesh defines which submesh to check
  18989. * @param useInstances specifies that instances should be used
  18990. * @returns a boolean indicating that the submesh is ready or not
  18991. */
  18992. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18993. /**
  18994. * Checks if the material is ready to render the requested mesh
  18995. * @param mesh Define the mesh to render
  18996. * @param useInstances Define whether or not the material is used with instances
  18997. * @returns true if ready, otherwise false
  18998. */
  18999. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19000. /**
  19001. * Binds the world matrix to the material
  19002. * @param world defines the world transformation matrix
  19003. */
  19004. bindOnlyWorldMatrix(world: Matrix): void;
  19005. /**
  19006. * Binds the material to the mesh
  19007. * @param world defines the world transformation matrix
  19008. * @param mesh defines the mesh to bind the material to
  19009. */
  19010. bind(world: Matrix, mesh?: Mesh): void;
  19011. /**
  19012. * Gets the active textures from the material
  19013. * @returns an array of textures
  19014. */
  19015. getActiveTextures(): BaseTexture[];
  19016. /**
  19017. * Specifies if the material uses a texture
  19018. * @param texture defines the texture to check against the material
  19019. * @returns a boolean specifying if the material uses the texture
  19020. */
  19021. hasTexture(texture: BaseTexture): boolean;
  19022. /**
  19023. * Makes a duplicate of the material, and gives it a new name
  19024. * @param name defines the new name for the duplicated material
  19025. * @returns the cloned material
  19026. */
  19027. clone(name: string): ShaderMaterial;
  19028. /**
  19029. * Disposes the material
  19030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19032. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19033. */
  19034. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19035. /**
  19036. * Serializes this material in a JSON representation
  19037. * @returns the serialized material object
  19038. */
  19039. serialize(): any;
  19040. /**
  19041. * Creates a shader material from parsed shader material data
  19042. * @param source defines the JSON represnetation of the material
  19043. * @param scene defines the hosting scene
  19044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19045. * @returns a new material
  19046. */
  19047. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19048. }
  19049. }
  19050. declare module BABYLON {
  19051. /** @hidden */
  19052. export var colorPixelShader: {
  19053. name: string;
  19054. shader: string;
  19055. };
  19056. }
  19057. declare module BABYLON {
  19058. /** @hidden */
  19059. export var colorVertexShader: {
  19060. name: string;
  19061. shader: string;
  19062. };
  19063. }
  19064. declare module BABYLON {
  19065. /**
  19066. * Line mesh
  19067. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19068. */
  19069. export class LinesMesh extends Mesh {
  19070. /**
  19071. * If vertex color should be applied to the mesh
  19072. */
  19073. readonly useVertexColor?: boolean | undefined;
  19074. /**
  19075. * If vertex alpha should be applied to the mesh
  19076. */
  19077. readonly useVertexAlpha?: boolean | undefined;
  19078. /**
  19079. * Color of the line (Default: White)
  19080. */
  19081. color: Color3;
  19082. /**
  19083. * Alpha of the line (Default: 1)
  19084. */
  19085. alpha: number;
  19086. /**
  19087. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19088. * This margin is expressed in world space coordinates, so its value may vary.
  19089. * Default value is 0.1
  19090. */
  19091. intersectionThreshold: number;
  19092. private _colorShader;
  19093. private color4;
  19094. /**
  19095. * Creates a new LinesMesh
  19096. * @param name defines the name
  19097. * @param scene defines the hosting scene
  19098. * @param parent defines the parent mesh if any
  19099. * @param source defines the optional source LinesMesh used to clone data from
  19100. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19101. * When false, achieved by calling a clone(), also passing False.
  19102. * This will make creation of children, recursive.
  19103. * @param useVertexColor defines if this LinesMesh supports vertex color
  19104. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19105. */
  19106. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19107. /**
  19108. * If vertex color should be applied to the mesh
  19109. */
  19110. useVertexColor?: boolean | undefined,
  19111. /**
  19112. * If vertex alpha should be applied to the mesh
  19113. */
  19114. useVertexAlpha?: boolean | undefined);
  19115. private _addClipPlaneDefine;
  19116. private _removeClipPlaneDefine;
  19117. isReady(): boolean;
  19118. /**
  19119. * Returns the string "LineMesh"
  19120. */
  19121. getClassName(): string;
  19122. /**
  19123. * @hidden
  19124. */
  19125. /**
  19126. * @hidden
  19127. */
  19128. material: Material;
  19129. /**
  19130. * @hidden
  19131. */
  19132. readonly checkCollisions: boolean;
  19133. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19134. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19135. /**
  19136. * Disposes of the line mesh
  19137. * @param doNotRecurse If children should be disposed
  19138. */
  19139. dispose(doNotRecurse?: boolean): void;
  19140. /**
  19141. * Returns a new LineMesh object cloned from the current one.
  19142. */
  19143. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19144. /**
  19145. * Creates a new InstancedLinesMesh object from the mesh model.
  19146. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19147. * @param name defines the name of the new instance
  19148. * @returns a new InstancedLinesMesh
  19149. */
  19150. createInstance(name: string): InstancedLinesMesh;
  19151. }
  19152. /**
  19153. * Creates an instance based on a source LinesMesh
  19154. */
  19155. export class InstancedLinesMesh extends InstancedMesh {
  19156. /**
  19157. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19158. * This margin is expressed in world space coordinates, so its value may vary.
  19159. * Initilized with the intersectionThreshold value of the source LinesMesh
  19160. */
  19161. intersectionThreshold: number;
  19162. constructor(name: string, source: LinesMesh);
  19163. /**
  19164. * Returns the string "InstancedLinesMesh".
  19165. */
  19166. getClassName(): string;
  19167. }
  19168. }
  19169. declare module BABYLON {
  19170. /** @hidden */
  19171. export var linePixelShader: {
  19172. name: string;
  19173. shader: string;
  19174. };
  19175. }
  19176. declare module BABYLON {
  19177. /** @hidden */
  19178. export var lineVertexShader: {
  19179. name: string;
  19180. shader: string;
  19181. };
  19182. }
  19183. declare module BABYLON {
  19184. interface AbstractMesh {
  19185. /**
  19186. * Gets the edgesRenderer associated with the mesh
  19187. */
  19188. edgesRenderer: Nullable<EdgesRenderer>;
  19189. }
  19190. interface LinesMesh {
  19191. /**
  19192. * Enables the edge rendering mode on the mesh.
  19193. * This mode makes the mesh edges visible
  19194. * @param epsilon defines the maximal distance between two angles to detect a face
  19195. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19196. * @returns the currentAbstractMesh
  19197. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19198. */
  19199. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19200. }
  19201. interface InstancedLinesMesh {
  19202. /**
  19203. * Enables the edge rendering mode on the mesh.
  19204. * This mode makes the mesh edges visible
  19205. * @param epsilon defines the maximal distance between two angles to detect a face
  19206. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19207. * @returns the current InstancedLinesMesh
  19208. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19209. */
  19210. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19211. }
  19212. /**
  19213. * Defines the minimum contract an Edges renderer should follow.
  19214. */
  19215. export interface IEdgesRenderer extends IDisposable {
  19216. /**
  19217. * Gets or sets a boolean indicating if the edgesRenderer is active
  19218. */
  19219. isEnabled: boolean;
  19220. /**
  19221. * Renders the edges of the attached mesh,
  19222. */
  19223. render(): void;
  19224. /**
  19225. * Checks wether or not the edges renderer is ready to render.
  19226. * @return true if ready, otherwise false.
  19227. */
  19228. isReady(): boolean;
  19229. }
  19230. /**
  19231. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19232. */
  19233. export class EdgesRenderer implements IEdgesRenderer {
  19234. /**
  19235. * Define the size of the edges with an orthographic camera
  19236. */
  19237. edgesWidthScalerForOrthographic: number;
  19238. /**
  19239. * Define the size of the edges with a perspective camera
  19240. */
  19241. edgesWidthScalerForPerspective: number;
  19242. protected _source: AbstractMesh;
  19243. protected _linesPositions: number[];
  19244. protected _linesNormals: number[];
  19245. protected _linesIndices: number[];
  19246. protected _epsilon: number;
  19247. protected _indicesCount: number;
  19248. protected _lineShader: ShaderMaterial;
  19249. protected _ib: DataBuffer;
  19250. protected _buffers: {
  19251. [key: string]: Nullable<VertexBuffer>;
  19252. };
  19253. protected _checkVerticesInsteadOfIndices: boolean;
  19254. private _meshRebuildObserver;
  19255. private _meshDisposeObserver;
  19256. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19257. isEnabled: boolean;
  19258. /**
  19259. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19260. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19261. * @param source Mesh used to create edges
  19262. * @param epsilon sum of angles in adjacency to check for edge
  19263. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19264. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19265. */
  19266. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19267. protected _prepareRessources(): void;
  19268. /** @hidden */ private _rebuild(): void;
  19269. /**
  19270. * Releases the required resources for the edges renderer
  19271. */
  19272. dispose(): void;
  19273. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19274. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19275. /**
  19276. * Checks if the pair of p0 and p1 is en edge
  19277. * @param faceIndex
  19278. * @param edge
  19279. * @param faceNormals
  19280. * @param p0
  19281. * @param p1
  19282. * @private
  19283. */
  19284. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19285. /**
  19286. * push line into the position, normal and index buffer
  19287. * @protected
  19288. */
  19289. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19290. /**
  19291. * Generates lines edges from adjacencjes
  19292. * @private
  19293. */ private _generateEdgesLines(): void;
  19294. /**
  19295. * Checks wether or not the edges renderer is ready to render.
  19296. * @return true if ready, otherwise false.
  19297. */
  19298. isReady(): boolean;
  19299. /**
  19300. * Renders the edges of the attached mesh,
  19301. */
  19302. render(): void;
  19303. }
  19304. /**
  19305. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19306. */
  19307. export class LineEdgesRenderer extends EdgesRenderer {
  19308. /**
  19309. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19310. * @param source LineMesh used to generate edges
  19311. * @param epsilon not important (specified angle for edge detection)
  19312. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19313. */
  19314. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19315. /**
  19316. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19317. */ private _generateEdgesLines(): void;
  19318. }
  19319. }
  19320. declare module BABYLON {
  19321. /**
  19322. * This represents the object necessary to create a rendering group.
  19323. * This is exclusively used and created by the rendering manager.
  19324. * To modify the behavior, you use the available helpers in your scene or meshes.
  19325. * @hidden
  19326. */
  19327. export class RenderingGroup {
  19328. index: number;
  19329. private static _zeroVector;
  19330. private _scene;
  19331. private _opaqueSubMeshes;
  19332. private _transparentSubMeshes;
  19333. private _alphaTestSubMeshes;
  19334. private _depthOnlySubMeshes;
  19335. private _particleSystems;
  19336. private _spriteManagers;
  19337. private _opaqueSortCompareFn;
  19338. private _alphaTestSortCompareFn;
  19339. private _transparentSortCompareFn;
  19340. private _renderOpaque;
  19341. private _renderAlphaTest;
  19342. private _renderTransparent;
  19343. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19344. onBeforeTransparentRendering: () => void;
  19345. /**
  19346. * Set the opaque sort comparison function.
  19347. * If null the sub meshes will be render in the order they were created
  19348. */
  19349. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19350. /**
  19351. * Set the alpha test sort comparison function.
  19352. * If null the sub meshes will be render in the order they were created
  19353. */
  19354. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19355. /**
  19356. * Set the transparent sort comparison function.
  19357. * If null the sub meshes will be render in the order they were created
  19358. */
  19359. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19360. /**
  19361. * Creates a new rendering group.
  19362. * @param index The rendering group index
  19363. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19364. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19365. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19366. */
  19367. 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>);
  19368. /**
  19369. * Render all the sub meshes contained in the group.
  19370. * @param customRenderFunction Used to override the default render behaviour of the group.
  19371. * @returns true if rendered some submeshes.
  19372. */
  19373. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19374. /**
  19375. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19376. * @param subMeshes The submeshes to render
  19377. */
  19378. private renderOpaqueSorted;
  19379. /**
  19380. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19381. * @param subMeshes The submeshes to render
  19382. */
  19383. private renderAlphaTestSorted;
  19384. /**
  19385. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19386. * @param subMeshes The submeshes to render
  19387. */
  19388. private renderTransparentSorted;
  19389. /**
  19390. * Renders the submeshes in a specified order.
  19391. * @param subMeshes The submeshes to sort before render
  19392. * @param sortCompareFn The comparison function use to sort
  19393. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19394. * @param transparent Specifies to activate blending if true
  19395. */
  19396. private static renderSorted;
  19397. /**
  19398. * Renders the submeshes in the order they were dispatched (no sort applied).
  19399. * @param subMeshes The submeshes to render
  19400. */
  19401. private static renderUnsorted;
  19402. /**
  19403. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19404. * are rendered back to front if in the same alpha index.
  19405. *
  19406. * @param a The first submesh
  19407. * @param b The second submesh
  19408. * @returns The result of the comparison
  19409. */
  19410. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19411. /**
  19412. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19413. * are rendered back to front.
  19414. *
  19415. * @param a The first submesh
  19416. * @param b The second submesh
  19417. * @returns The result of the comparison
  19418. */
  19419. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19420. /**
  19421. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19422. * are rendered front to back (prevent overdraw).
  19423. *
  19424. * @param a The first submesh
  19425. * @param b The second submesh
  19426. * @returns The result of the comparison
  19427. */
  19428. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19429. /**
  19430. * Resets the different lists of submeshes to prepare a new frame.
  19431. */
  19432. prepare(): void;
  19433. dispose(): void;
  19434. /**
  19435. * Inserts the submesh in its correct queue depending on its material.
  19436. * @param subMesh The submesh to dispatch
  19437. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19438. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19439. */
  19440. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19441. dispatchSprites(spriteManager: ISpriteManager): void;
  19442. dispatchParticles(particleSystem: IParticleSystem): void;
  19443. private _renderParticles;
  19444. private _renderSprites;
  19445. }
  19446. }
  19447. declare module BABYLON {
  19448. /**
  19449. * Interface describing the different options available in the rendering manager
  19450. * regarding Auto Clear between groups.
  19451. */
  19452. export interface IRenderingManagerAutoClearSetup {
  19453. /**
  19454. * Defines whether or not autoclear is enable.
  19455. */
  19456. autoClear: boolean;
  19457. /**
  19458. * Defines whether or not to autoclear the depth buffer.
  19459. */
  19460. depth: boolean;
  19461. /**
  19462. * Defines whether or not to autoclear the stencil buffer.
  19463. */
  19464. stencil: boolean;
  19465. }
  19466. /**
  19467. * This class is used by the onRenderingGroupObservable
  19468. */
  19469. export class RenderingGroupInfo {
  19470. /**
  19471. * The Scene that being rendered
  19472. */
  19473. scene: Scene;
  19474. /**
  19475. * The camera currently used for the rendering pass
  19476. */
  19477. camera: Nullable<Camera>;
  19478. /**
  19479. * The ID of the renderingGroup being processed
  19480. */
  19481. renderingGroupId: number;
  19482. }
  19483. /**
  19484. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19485. * It is enable to manage the different groups as well as the different necessary sort functions.
  19486. * This should not be used directly aside of the few static configurations
  19487. */
  19488. export class RenderingManager {
  19489. /**
  19490. * The max id used for rendering groups (not included)
  19491. */
  19492. static MAX_RENDERINGGROUPS: number;
  19493. /**
  19494. * The min id used for rendering groups (included)
  19495. */
  19496. static MIN_RENDERINGGROUPS: number;
  19497. /**
  19498. * Used to globally prevent autoclearing scenes.
  19499. */
  19500. static AUTOCLEAR: boolean;
  19501. /**
  19502. * @hidden
  19503. */ private _useSceneAutoClearSetup: boolean;
  19504. private _scene;
  19505. private _renderingGroups;
  19506. private _depthStencilBufferAlreadyCleaned;
  19507. private _autoClearDepthStencil;
  19508. private _customOpaqueSortCompareFn;
  19509. private _customAlphaTestSortCompareFn;
  19510. private _customTransparentSortCompareFn;
  19511. private _renderingGroupInfo;
  19512. /**
  19513. * Instantiates a new rendering group for a particular scene
  19514. * @param scene Defines the scene the groups belongs to
  19515. */
  19516. constructor(scene: Scene);
  19517. private _clearDepthStencilBuffer;
  19518. /**
  19519. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19520. * @hidden
  19521. */
  19522. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19523. /**
  19524. * Resets the different information of the group to prepare a new frame
  19525. * @hidden
  19526. */
  19527. reset(): void;
  19528. /**
  19529. * Dispose and release the group and its associated resources.
  19530. * @hidden
  19531. */
  19532. dispose(): void;
  19533. /**
  19534. * Clear the info related to rendering groups preventing retention points during dispose.
  19535. */
  19536. freeRenderingGroups(): void;
  19537. private _prepareRenderingGroup;
  19538. /**
  19539. * Add a sprite manager to the rendering manager in order to render it this frame.
  19540. * @param spriteManager Define the sprite manager to render
  19541. */
  19542. dispatchSprites(spriteManager: ISpriteManager): void;
  19543. /**
  19544. * Add a particle system to the rendering manager in order to render it this frame.
  19545. * @param particleSystem Define the particle system to render
  19546. */
  19547. dispatchParticles(particleSystem: IParticleSystem): void;
  19548. /**
  19549. * Add a submesh to the manager in order to render it this frame
  19550. * @param subMesh The submesh to dispatch
  19551. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19552. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19553. */
  19554. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19555. /**
  19556. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19557. * This allowed control for front to back rendering or reversly depending of the special needs.
  19558. *
  19559. * @param renderingGroupId The rendering group id corresponding to its index
  19560. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19561. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19562. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19563. */
  19564. 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;
  19565. /**
  19566. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19567. *
  19568. * @param renderingGroupId The rendering group id corresponding to its index
  19569. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19570. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19571. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19572. */
  19573. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19574. /**
  19575. * Gets the current auto clear configuration for one rendering group of the rendering
  19576. * manager.
  19577. * @param index the rendering group index to get the information for
  19578. * @returns The auto clear setup for the requested rendering group
  19579. */
  19580. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19581. }
  19582. }
  19583. declare module BABYLON {
  19584. /**
  19585. * This Helps creating a texture that will be created from a camera in your scene.
  19586. * It is basically a dynamic texture that could be used to create special effects for instance.
  19587. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19588. */
  19589. export class RenderTargetTexture extends Texture {
  19590. isCube: boolean;
  19591. /**
  19592. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19593. */
  19594. static readonly REFRESHRATE_RENDER_ONCE: number;
  19595. /**
  19596. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19597. */
  19598. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19599. /**
  19600. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19601. * the central point of your effect and can save a lot of performances.
  19602. */
  19603. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19604. /**
  19605. * Use this predicate to dynamically define the list of mesh you want to render.
  19606. * If set, the renderList property will be overwritten.
  19607. */
  19608. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19609. private _renderList;
  19610. /**
  19611. * Use this list to define the list of mesh you want to render.
  19612. */
  19613. renderList: Nullable<Array<AbstractMesh>>;
  19614. private _hookArray;
  19615. /**
  19616. * Define if particles should be rendered in your texture.
  19617. */
  19618. renderParticles: boolean;
  19619. /**
  19620. * Define if sprites should be rendered in your texture.
  19621. */
  19622. renderSprites: boolean;
  19623. /**
  19624. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19625. */
  19626. coordinatesMode: number;
  19627. /**
  19628. * Define the camera used to render the texture.
  19629. */
  19630. activeCamera: Nullable<Camera>;
  19631. /**
  19632. * Override the render function of the texture with your own one.
  19633. */
  19634. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19635. /**
  19636. * Define if camera post processes should be use while rendering the texture.
  19637. */
  19638. useCameraPostProcesses: boolean;
  19639. /**
  19640. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19641. */
  19642. ignoreCameraViewport: boolean;
  19643. private _postProcessManager;
  19644. private _postProcesses;
  19645. private _resizeObserver;
  19646. /**
  19647. * An event triggered when the texture is unbind.
  19648. */
  19649. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19650. /**
  19651. * An event triggered when the texture is unbind.
  19652. */
  19653. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19654. private _onAfterUnbindObserver;
  19655. /**
  19656. * Set a after unbind callback in the texture.
  19657. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19658. */
  19659. onAfterUnbind: () => void;
  19660. /**
  19661. * An event triggered before rendering the texture
  19662. */
  19663. onBeforeRenderObservable: Observable<number>;
  19664. private _onBeforeRenderObserver;
  19665. /**
  19666. * Set a before render callback in the texture.
  19667. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19668. */
  19669. onBeforeRender: (faceIndex: number) => void;
  19670. /**
  19671. * An event triggered after rendering the texture
  19672. */
  19673. onAfterRenderObservable: Observable<number>;
  19674. private _onAfterRenderObserver;
  19675. /**
  19676. * Set a after render callback in the texture.
  19677. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19678. */
  19679. onAfterRender: (faceIndex: number) => void;
  19680. /**
  19681. * An event triggered after the texture clear
  19682. */
  19683. onClearObservable: Observable<Engine>;
  19684. private _onClearObserver;
  19685. /**
  19686. * Set a clear callback in the texture.
  19687. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19688. */
  19689. onClear: (Engine: Engine) => void;
  19690. /**
  19691. * An event triggered when the texture is resized.
  19692. */
  19693. onResizeObservable: Observable<RenderTargetTexture>;
  19694. /**
  19695. * Define the clear color of the Render Target if it should be different from the scene.
  19696. */
  19697. clearColor: Color4;
  19698. protected _size: number | {
  19699. width: number;
  19700. height: number;
  19701. };
  19702. protected _initialSizeParameter: number | {
  19703. width: number;
  19704. height: number;
  19705. } | {
  19706. ratio: number;
  19707. };
  19708. protected _sizeRatio: Nullable<number>;
  19709. /** @hidden */ private _generateMipMaps: boolean;
  19710. protected _renderingManager: RenderingManager;
  19711. /** @hidden */ private _waitingRenderList: string[];
  19712. protected _doNotChangeAspectRatio: boolean;
  19713. protected _currentRefreshId: number;
  19714. protected _refreshRate: number;
  19715. protected _textureMatrix: Matrix;
  19716. protected _samples: number;
  19717. protected _renderTargetOptions: RenderTargetCreationOptions;
  19718. /**
  19719. * Gets render target creation options that were used.
  19720. */
  19721. readonly renderTargetOptions: RenderTargetCreationOptions;
  19722. protected _engine: Engine;
  19723. protected _onRatioRescale(): void;
  19724. /**
  19725. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19726. * It must define where the camera used to render the texture is set
  19727. */
  19728. boundingBoxPosition: Vector3;
  19729. private _boundingBoxSize;
  19730. /**
  19731. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19732. * When defined, the cubemap will switch to local mode
  19733. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19734. * @example https://www.babylonjs-playground.com/#RNASML
  19735. */
  19736. boundingBoxSize: Vector3;
  19737. /**
  19738. * In case the RTT has been created with a depth texture, get the associated
  19739. * depth texture.
  19740. * Otherwise, return null.
  19741. */
  19742. depthStencilTexture: Nullable<InternalTexture>;
  19743. /**
  19744. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19745. * or used a shadow, depth texture...
  19746. * @param name The friendly name of the texture
  19747. * @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)
  19748. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19749. * @param generateMipMaps True if mip maps need to be generated after render.
  19750. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19751. * @param type The type of the buffer in the RTT (int, half float, float...)
  19752. * @param isCube True if a cube texture needs to be created
  19753. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19754. * @param generateDepthBuffer True to generate a depth buffer
  19755. * @param generateStencilBuffer True to generate a stencil buffer
  19756. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19757. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19758. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19759. */
  19760. constructor(name: string, size: number | {
  19761. width: number;
  19762. height: number;
  19763. } | {
  19764. ratio: number;
  19765. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19766. /**
  19767. * Creates a depth stencil texture.
  19768. * This is only available in WebGL 2 or with the depth texture extension available.
  19769. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19770. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19771. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19772. */
  19773. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19774. private _processSizeParameter;
  19775. /**
  19776. * Define the number of samples to use in case of MSAA.
  19777. * It defaults to one meaning no MSAA has been enabled.
  19778. */
  19779. samples: number;
  19780. /**
  19781. * Resets the refresh counter of the texture and start bak from scratch.
  19782. * Could be useful to regenerate the texture if it is setup to render only once.
  19783. */
  19784. resetRefreshCounter(): void;
  19785. /**
  19786. * Define the refresh rate of the texture or the rendering frequency.
  19787. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19788. */
  19789. refreshRate: number;
  19790. /**
  19791. * Adds a post process to the render target rendering passes.
  19792. * @param postProcess define the post process to add
  19793. */
  19794. addPostProcess(postProcess: PostProcess): void;
  19795. /**
  19796. * Clear all the post processes attached to the render target
  19797. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19798. */
  19799. clearPostProcesses(dispose?: boolean): void;
  19800. /**
  19801. * Remove one of the post process from the list of attached post processes to the texture
  19802. * @param postProcess define the post process to remove from the list
  19803. */
  19804. removePostProcess(postProcess: PostProcess): void;
  19805. /** @hidden */ private _shouldRender(): boolean;
  19806. /**
  19807. * Gets the actual render size of the texture.
  19808. * @returns the width of the render size
  19809. */
  19810. getRenderSize(): number;
  19811. /**
  19812. * Gets the actual render width of the texture.
  19813. * @returns the width of the render size
  19814. */
  19815. getRenderWidth(): number;
  19816. /**
  19817. * Gets the actual render height of the texture.
  19818. * @returns the height of the render size
  19819. */
  19820. getRenderHeight(): number;
  19821. /**
  19822. * Get if the texture can be rescaled or not.
  19823. */
  19824. readonly canRescale: boolean;
  19825. /**
  19826. * Resize the texture using a ratio.
  19827. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19828. */
  19829. scale(ratio: number): void;
  19830. /**
  19831. * Get the texture reflection matrix used to rotate/transform the reflection.
  19832. * @returns the reflection matrix
  19833. */
  19834. getReflectionTextureMatrix(): Matrix;
  19835. /**
  19836. * Resize the texture to a new desired size.
  19837. * Be carrefull as it will recreate all the data in the new texture.
  19838. * @param size Define the new size. It can be:
  19839. * - a number for squared texture,
  19840. * - an object containing { width: number, height: number }
  19841. * - or an object containing a ratio { ratio: number }
  19842. */
  19843. resize(size: number | {
  19844. width: number;
  19845. height: number;
  19846. } | {
  19847. ratio: number;
  19848. }): void;
  19849. /**
  19850. * Renders all the objects from the render list into the texture.
  19851. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19852. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19853. */
  19854. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19855. private _bestReflectionRenderTargetDimension;
  19856. /**
  19857. * @hidden
  19858. * @param faceIndex face index to bind to if this is a cubetexture
  19859. */ private _bindFrameBuffer(faceIndex?: number): void;
  19860. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19861. private renderToTarget;
  19862. /**
  19863. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19864. * This allowed control for front to back rendering or reversly depending of the special needs.
  19865. *
  19866. * @param renderingGroupId The rendering group id corresponding to its index
  19867. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19868. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19869. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19870. */
  19871. 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;
  19872. /**
  19873. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19874. *
  19875. * @param renderingGroupId The rendering group id corresponding to its index
  19876. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19877. */
  19878. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19879. /**
  19880. * Clones the texture.
  19881. * @returns the cloned texture
  19882. */
  19883. clone(): RenderTargetTexture;
  19884. /**
  19885. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19886. * @returns The JSON representation of the texture
  19887. */
  19888. serialize(): any;
  19889. /**
  19890. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19891. */
  19892. disposeFramebufferObjects(): void;
  19893. /**
  19894. * Dispose the texture and release its associated resources.
  19895. */
  19896. dispose(): void;
  19897. /** @hidden */ private _rebuild(): void;
  19898. /**
  19899. * Clear the info related to rendering groups preventing retention point in material dispose.
  19900. */
  19901. freeRenderingGroups(): void;
  19902. /**
  19903. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19904. * @returns the view count
  19905. */
  19906. getViewCount(): number;
  19907. }
  19908. }
  19909. declare module BABYLON {
  19910. /**
  19911. * Options for compiling materials.
  19912. */
  19913. export interface IMaterialCompilationOptions {
  19914. /**
  19915. * Defines whether clip planes are enabled.
  19916. */
  19917. clipPlane: boolean;
  19918. /**
  19919. * Defines whether instances are enabled.
  19920. */
  19921. useInstances: boolean;
  19922. }
  19923. /**
  19924. * Base class for the main features of a material in Babylon.js
  19925. */
  19926. export class Material implements IAnimatable {
  19927. /**
  19928. * Returns the triangle fill mode
  19929. */
  19930. static readonly TriangleFillMode: number;
  19931. /**
  19932. * Returns the wireframe mode
  19933. */
  19934. static readonly WireFrameFillMode: number;
  19935. /**
  19936. * Returns the point fill mode
  19937. */
  19938. static readonly PointFillMode: number;
  19939. /**
  19940. * Returns the point list draw mode
  19941. */
  19942. static readonly PointListDrawMode: number;
  19943. /**
  19944. * Returns the line list draw mode
  19945. */
  19946. static readonly LineListDrawMode: number;
  19947. /**
  19948. * Returns the line loop draw mode
  19949. */
  19950. static readonly LineLoopDrawMode: number;
  19951. /**
  19952. * Returns the line strip draw mode
  19953. */
  19954. static readonly LineStripDrawMode: number;
  19955. /**
  19956. * Returns the triangle strip draw mode
  19957. */
  19958. static readonly TriangleStripDrawMode: number;
  19959. /**
  19960. * Returns the triangle fan draw mode
  19961. */
  19962. static readonly TriangleFanDrawMode: number;
  19963. /**
  19964. * Stores the clock-wise side orientation
  19965. */
  19966. static readonly ClockWiseSideOrientation: number;
  19967. /**
  19968. * Stores the counter clock-wise side orientation
  19969. */
  19970. static readonly CounterClockWiseSideOrientation: number;
  19971. /**
  19972. * The dirty texture flag value
  19973. */
  19974. static readonly TextureDirtyFlag: number;
  19975. /**
  19976. * The dirty light flag value
  19977. */
  19978. static readonly LightDirtyFlag: number;
  19979. /**
  19980. * The dirty fresnel flag value
  19981. */
  19982. static readonly FresnelDirtyFlag: number;
  19983. /**
  19984. * The dirty attribute flag value
  19985. */
  19986. static readonly AttributesDirtyFlag: number;
  19987. /**
  19988. * The dirty misc flag value
  19989. */
  19990. static readonly MiscDirtyFlag: number;
  19991. /**
  19992. * The all dirty flag value
  19993. */
  19994. static readonly AllDirtyFlag: number;
  19995. /**
  19996. * The ID of the material
  19997. */
  19998. id: string;
  19999. /**
  20000. * Gets or sets the unique id of the material
  20001. */
  20002. uniqueId: number;
  20003. /**
  20004. * The name of the material
  20005. */
  20006. name: string;
  20007. /**
  20008. * Gets or sets user defined metadata
  20009. */
  20010. metadata: any;
  20011. /**
  20012. * For internal use only. Please do not use.
  20013. */
  20014. reservedDataStore: any;
  20015. /**
  20016. * Specifies if the ready state should be checked on each call
  20017. */
  20018. checkReadyOnEveryCall: boolean;
  20019. /**
  20020. * Specifies if the ready state should be checked once
  20021. */
  20022. checkReadyOnlyOnce: boolean;
  20023. /**
  20024. * The state of the material
  20025. */
  20026. state: string;
  20027. /**
  20028. * The alpha value of the material
  20029. */
  20030. protected _alpha: number;
  20031. /**
  20032. * List of inspectable custom properties (used by the Inspector)
  20033. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20034. */
  20035. inspectableCustomProperties: IInspectable[];
  20036. /**
  20037. * Sets the alpha value of the material
  20038. */
  20039. /**
  20040. * Gets the alpha value of the material
  20041. */
  20042. alpha: number;
  20043. /**
  20044. * Specifies if back face culling is enabled
  20045. */
  20046. protected _backFaceCulling: boolean;
  20047. /**
  20048. * Sets the back-face culling state
  20049. */
  20050. /**
  20051. * Gets the back-face culling state
  20052. */
  20053. backFaceCulling: boolean;
  20054. /**
  20055. * Stores the value for side orientation
  20056. */
  20057. sideOrientation: number;
  20058. /**
  20059. * Callback triggered when the material is compiled
  20060. */
  20061. onCompiled: Nullable<(effect: Effect) => void>;
  20062. /**
  20063. * Callback triggered when an error occurs
  20064. */
  20065. onError: Nullable<(effect: Effect, errors: string) => void>;
  20066. /**
  20067. * Callback triggered to get the render target textures
  20068. */
  20069. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20070. /**
  20071. * Gets a boolean indicating that current material needs to register RTT
  20072. */
  20073. readonly hasRenderTargetTextures: boolean;
  20074. /**
  20075. * Specifies if the material should be serialized
  20076. */
  20077. doNotSerialize: boolean;
  20078. /**
  20079. * @hidden
  20080. */ private _storeEffectOnSubMeshes: boolean;
  20081. /**
  20082. * Stores the animations for the material
  20083. */
  20084. animations: Nullable<Array<Animation>>;
  20085. /**
  20086. * An event triggered when the material is disposed
  20087. */
  20088. onDisposeObservable: Observable<Material>;
  20089. /**
  20090. * An observer which watches for dispose events
  20091. */
  20092. private _onDisposeObserver;
  20093. private _onUnBindObservable;
  20094. /**
  20095. * Called during a dispose event
  20096. */
  20097. onDispose: () => void;
  20098. private _onBindObservable;
  20099. /**
  20100. * An event triggered when the material is bound
  20101. */
  20102. readonly onBindObservable: Observable<AbstractMesh>;
  20103. /**
  20104. * An observer which watches for bind events
  20105. */
  20106. private _onBindObserver;
  20107. /**
  20108. * Called during a bind event
  20109. */
  20110. onBind: (Mesh: AbstractMesh) => void;
  20111. /**
  20112. * An event triggered when the material is unbound
  20113. */
  20114. readonly onUnBindObservable: Observable<Material>;
  20115. /**
  20116. * Stores the value of the alpha mode
  20117. */
  20118. private _alphaMode;
  20119. /**
  20120. * Sets the value of the alpha mode.
  20121. *
  20122. * | Value | Type | Description |
  20123. * | --- | --- | --- |
  20124. * | 0 | ALPHA_DISABLE | |
  20125. * | 1 | ALPHA_ADD | |
  20126. * | 2 | ALPHA_COMBINE | |
  20127. * | 3 | ALPHA_SUBTRACT | |
  20128. * | 4 | ALPHA_MULTIPLY | |
  20129. * | 5 | ALPHA_MAXIMIZED | |
  20130. * | 6 | ALPHA_ONEONE | |
  20131. * | 7 | ALPHA_PREMULTIPLIED | |
  20132. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20133. * | 9 | ALPHA_INTERPOLATE | |
  20134. * | 10 | ALPHA_SCREENMODE | |
  20135. *
  20136. */
  20137. /**
  20138. * Gets the value of the alpha mode
  20139. */
  20140. alphaMode: number;
  20141. /**
  20142. * Stores the state of the need depth pre-pass value
  20143. */
  20144. private _needDepthPrePass;
  20145. /**
  20146. * Sets the need depth pre-pass value
  20147. */
  20148. /**
  20149. * Gets the depth pre-pass value
  20150. */
  20151. needDepthPrePass: boolean;
  20152. /**
  20153. * Specifies if depth writing should be disabled
  20154. */
  20155. disableDepthWrite: boolean;
  20156. /**
  20157. * Specifies if depth writing should be forced
  20158. */
  20159. forceDepthWrite: boolean;
  20160. /**
  20161. * Specifies if there should be a separate pass for culling
  20162. */
  20163. separateCullingPass: boolean;
  20164. /**
  20165. * Stores the state specifing if fog should be enabled
  20166. */
  20167. private _fogEnabled;
  20168. /**
  20169. * Sets the state for enabling fog
  20170. */
  20171. /**
  20172. * Gets the value of the fog enabled state
  20173. */
  20174. fogEnabled: boolean;
  20175. /**
  20176. * Stores the size of points
  20177. */
  20178. pointSize: number;
  20179. /**
  20180. * Stores the z offset value
  20181. */
  20182. zOffset: number;
  20183. /**
  20184. * Gets a value specifying if wireframe mode is enabled
  20185. */
  20186. /**
  20187. * Sets the state of wireframe mode
  20188. */
  20189. wireframe: boolean;
  20190. /**
  20191. * Gets the value specifying if point clouds are enabled
  20192. */
  20193. /**
  20194. * Sets the state of point cloud mode
  20195. */
  20196. pointsCloud: boolean;
  20197. /**
  20198. * Gets the material fill mode
  20199. */
  20200. /**
  20201. * Sets the material fill mode
  20202. */
  20203. fillMode: number;
  20204. /**
  20205. * @hidden
  20206. * Stores the effects for the material
  20207. */ private _effect: Nullable<Effect>;
  20208. /**
  20209. * @hidden
  20210. * Specifies if the material was previously ready
  20211. */ private _wasPreviouslyReady: boolean;
  20212. /**
  20213. * Specifies if uniform buffers should be used
  20214. */
  20215. private _useUBO;
  20216. /**
  20217. * Stores a reference to the scene
  20218. */
  20219. private _scene;
  20220. /**
  20221. * Stores the fill mode state
  20222. */
  20223. private _fillMode;
  20224. /**
  20225. * Specifies if the depth write state should be cached
  20226. */
  20227. private _cachedDepthWriteState;
  20228. /**
  20229. * Stores the uniform buffer
  20230. */
  20231. protected _uniformBuffer: UniformBuffer;
  20232. /** @hidden */ private _indexInSceneMaterialArray: number;
  20233. /** @hidden */
  20234. meshMap: Nullable<{
  20235. [id: string]: AbstractMesh | undefined;
  20236. }>;
  20237. /**
  20238. * Creates a material instance
  20239. * @param name defines the name of the material
  20240. * @param scene defines the scene to reference
  20241. * @param doNotAdd specifies if the material should be added to the scene
  20242. */
  20243. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20244. /**
  20245. * Returns a string representation of the current material
  20246. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20247. * @returns a string with material information
  20248. */
  20249. toString(fullDetails?: boolean): string;
  20250. /**
  20251. * Gets the class name of the material
  20252. * @returns a string with the class name of the material
  20253. */
  20254. getClassName(): string;
  20255. /**
  20256. * Specifies if updates for the material been locked
  20257. */
  20258. readonly isFrozen: boolean;
  20259. /**
  20260. * Locks updates for the material
  20261. */
  20262. freeze(): void;
  20263. /**
  20264. * Unlocks updates for the material
  20265. */
  20266. unfreeze(): void;
  20267. /**
  20268. * Specifies if the material is ready to be used
  20269. * @param mesh defines the mesh to check
  20270. * @param useInstances specifies if instances should be used
  20271. * @returns a boolean indicating if the material is ready to be used
  20272. */
  20273. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20274. /**
  20275. * Specifies that the submesh is ready to be used
  20276. * @param mesh defines the mesh to check
  20277. * @param subMesh defines which submesh to check
  20278. * @param useInstances specifies that instances should be used
  20279. * @returns a boolean indicating that the submesh is ready or not
  20280. */
  20281. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20282. /**
  20283. * Returns the material effect
  20284. * @returns the effect associated with the material
  20285. */
  20286. getEffect(): Nullable<Effect>;
  20287. /**
  20288. * Returns the current scene
  20289. * @returns a Scene
  20290. */
  20291. getScene(): Scene;
  20292. /**
  20293. * Specifies if the material will require alpha blending
  20294. * @returns a boolean specifying if alpha blending is needed
  20295. */
  20296. needAlphaBlending(): boolean;
  20297. /**
  20298. * Specifies if the mesh will require alpha blending
  20299. * @param mesh defines the mesh to check
  20300. * @returns a boolean specifying if alpha blending is needed for the mesh
  20301. */
  20302. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20303. /**
  20304. * Specifies if this material should be rendered in alpha test mode
  20305. * @returns a boolean specifying if an alpha test is needed.
  20306. */
  20307. needAlphaTesting(): boolean;
  20308. /**
  20309. * Gets the texture used for the alpha test
  20310. * @returns the texture to use for alpha testing
  20311. */
  20312. getAlphaTestTexture(): Nullable<BaseTexture>;
  20313. /**
  20314. * Marks the material to indicate that it needs to be re-calculated
  20315. */
  20316. markDirty(): void;
  20317. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20318. /**
  20319. * Binds the material to the mesh
  20320. * @param world defines the world transformation matrix
  20321. * @param mesh defines the mesh to bind the material to
  20322. */
  20323. bind(world: Matrix, mesh?: Mesh): void;
  20324. /**
  20325. * Binds the submesh to the material
  20326. * @param world defines the world transformation matrix
  20327. * @param mesh defines the mesh containing the submesh
  20328. * @param subMesh defines the submesh to bind the material to
  20329. */
  20330. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20331. /**
  20332. * Binds the world matrix to the material
  20333. * @param world defines the world transformation matrix
  20334. */
  20335. bindOnlyWorldMatrix(world: Matrix): void;
  20336. /**
  20337. * Binds the scene's uniform buffer to the effect.
  20338. * @param effect defines the effect to bind to the scene uniform buffer
  20339. * @param sceneUbo defines the uniform buffer storing scene data
  20340. */
  20341. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20342. /**
  20343. * Binds the view matrix to the effect
  20344. * @param effect defines the effect to bind the view matrix to
  20345. */
  20346. bindView(effect: Effect): void;
  20347. /**
  20348. * Binds the view projection matrix to the effect
  20349. * @param effect defines the effect to bind the view projection matrix to
  20350. */
  20351. bindViewProjection(effect: Effect): void;
  20352. /**
  20353. * Specifies if material alpha testing should be turned on for the mesh
  20354. * @param mesh defines the mesh to check
  20355. */
  20356. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20357. /**
  20358. * Processes to execute after binding the material to a mesh
  20359. * @param mesh defines the rendered mesh
  20360. */
  20361. protected _afterBind(mesh?: Mesh): void;
  20362. /**
  20363. * Unbinds the material from the mesh
  20364. */
  20365. unbind(): void;
  20366. /**
  20367. * Gets the active textures from the material
  20368. * @returns an array of textures
  20369. */
  20370. getActiveTextures(): BaseTexture[];
  20371. /**
  20372. * Specifies if the material uses a texture
  20373. * @param texture defines the texture to check against the material
  20374. * @returns a boolean specifying if the material uses the texture
  20375. */
  20376. hasTexture(texture: BaseTexture): boolean;
  20377. /**
  20378. * Makes a duplicate of the material, and gives it a new name
  20379. * @param name defines the new name for the duplicated material
  20380. * @returns the cloned material
  20381. */
  20382. clone(name: string): Nullable<Material>;
  20383. /**
  20384. * Gets the meshes bound to the material
  20385. * @returns an array of meshes bound to the material
  20386. */
  20387. getBindedMeshes(): AbstractMesh[];
  20388. /**
  20389. * Force shader compilation
  20390. * @param mesh defines the mesh associated with this material
  20391. * @param onCompiled defines a function to execute once the material is compiled
  20392. * @param options defines the options to configure the compilation
  20393. * @param onError defines a function to execute if the material fails compiling
  20394. */
  20395. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20396. /**
  20397. * Force shader compilation
  20398. * @param mesh defines the mesh that will use this material
  20399. * @param options defines additional options for compiling the shaders
  20400. * @returns a promise that resolves when the compilation completes
  20401. */
  20402. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20403. private static readonly _AllDirtyCallBack;
  20404. private static readonly _ImageProcessingDirtyCallBack;
  20405. private static readonly _TextureDirtyCallBack;
  20406. private static readonly _FresnelDirtyCallBack;
  20407. private static readonly _MiscDirtyCallBack;
  20408. private static readonly _LightsDirtyCallBack;
  20409. private static readonly _AttributeDirtyCallBack;
  20410. private static _FresnelAndMiscDirtyCallBack;
  20411. private static _TextureAndMiscDirtyCallBack;
  20412. private static readonly _DirtyCallbackArray;
  20413. private static readonly _RunDirtyCallBacks;
  20414. /**
  20415. * Marks a define in the material to indicate that it needs to be re-computed
  20416. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20417. */
  20418. markAsDirty(flag: number): void;
  20419. /**
  20420. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20421. * @param func defines a function which checks material defines against the submeshes
  20422. */
  20423. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20424. /**
  20425. * Indicates that we need to re-calculated for all submeshes
  20426. */
  20427. protected _markAllSubMeshesAsAllDirty(): void;
  20428. /**
  20429. * Indicates that image processing needs to be re-calculated for all submeshes
  20430. */
  20431. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20432. /**
  20433. * Indicates that textures need to be re-calculated for all submeshes
  20434. */
  20435. protected _markAllSubMeshesAsTexturesDirty(): void;
  20436. /**
  20437. * Indicates that fresnel needs to be re-calculated for all submeshes
  20438. */
  20439. protected _markAllSubMeshesAsFresnelDirty(): void;
  20440. /**
  20441. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20442. */
  20443. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20444. /**
  20445. * Indicates that lights need to be re-calculated for all submeshes
  20446. */
  20447. protected _markAllSubMeshesAsLightsDirty(): void;
  20448. /**
  20449. * Indicates that attributes need to be re-calculated for all submeshes
  20450. */
  20451. protected _markAllSubMeshesAsAttributesDirty(): void;
  20452. /**
  20453. * Indicates that misc needs to be re-calculated for all submeshes
  20454. */
  20455. protected _markAllSubMeshesAsMiscDirty(): void;
  20456. /**
  20457. * Indicates that textures and misc need to be re-calculated for all submeshes
  20458. */
  20459. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20460. /**
  20461. * Disposes the material
  20462. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20463. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20464. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20465. */
  20466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20467. /** @hidden */
  20468. private releaseVertexArrayObject;
  20469. /**
  20470. * Serializes this material
  20471. * @returns the serialized material object
  20472. */
  20473. serialize(): any;
  20474. /**
  20475. * Creates a material from parsed material data
  20476. * @param parsedMaterial defines parsed material data
  20477. * @param scene defines the hosting scene
  20478. * @param rootUrl defines the root URL to use to load textures
  20479. * @returns a new material
  20480. */
  20481. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20482. }
  20483. }
  20484. declare module BABYLON {
  20485. /**
  20486. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20487. * separate meshes. This can be use to improve performances.
  20488. * @see http://doc.babylonjs.com/how_to/multi_materials
  20489. */
  20490. export class MultiMaterial extends Material {
  20491. private _subMaterials;
  20492. /**
  20493. * Gets or Sets the list of Materials used within the multi material.
  20494. * They need to be ordered according to the submeshes order in the associated mesh
  20495. */
  20496. subMaterials: Nullable<Material>[];
  20497. /**
  20498. * Function used to align with Node.getChildren()
  20499. * @returns the list of Materials used within the multi material
  20500. */
  20501. getChildren(): Nullable<Material>[];
  20502. /**
  20503. * Instantiates a new Multi Material
  20504. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20505. * separate meshes. This can be use to improve performances.
  20506. * @see http://doc.babylonjs.com/how_to/multi_materials
  20507. * @param name Define the name in the scene
  20508. * @param scene Define the scene the material belongs to
  20509. */
  20510. constructor(name: string, scene: Scene);
  20511. private _hookArray;
  20512. /**
  20513. * Get one of the submaterial by its index in the submaterials array
  20514. * @param index The index to look the sub material at
  20515. * @returns The Material if the index has been defined
  20516. */
  20517. getSubMaterial(index: number): Nullable<Material>;
  20518. /**
  20519. * Get the list of active textures for the whole sub materials list.
  20520. * @returns All the textures that will be used during the rendering
  20521. */
  20522. getActiveTextures(): BaseTexture[];
  20523. /**
  20524. * Gets the current class name of the material e.g. "MultiMaterial"
  20525. * Mainly use in serialization.
  20526. * @returns the class name
  20527. */
  20528. getClassName(): string;
  20529. /**
  20530. * Checks if the material is ready to render the requested sub mesh
  20531. * @param mesh Define the mesh the submesh belongs to
  20532. * @param subMesh Define the sub mesh to look readyness for
  20533. * @param useInstances Define whether or not the material is used with instances
  20534. * @returns true if ready, otherwise false
  20535. */
  20536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20537. /**
  20538. * Clones the current material and its related sub materials
  20539. * @param name Define the name of the newly cloned material
  20540. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20541. * @returns the cloned material
  20542. */
  20543. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20544. /**
  20545. * Serializes the materials into a JSON representation.
  20546. * @returns the JSON representation
  20547. */
  20548. serialize(): any;
  20549. /**
  20550. * Dispose the material and release its associated resources
  20551. * @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)
  20552. * @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)
  20553. * @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)
  20554. */
  20555. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20556. /**
  20557. * Creates a MultiMaterial from parsed MultiMaterial data.
  20558. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20559. * @param scene defines the hosting scene
  20560. * @returns a new MultiMaterial
  20561. */
  20562. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20563. }
  20564. }
  20565. declare module BABYLON {
  20566. /**
  20567. * Base class for submeshes
  20568. */
  20569. export class BaseSubMesh {
  20570. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20571. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20572. /**
  20573. * Gets associated effect
  20574. */
  20575. readonly effect: Nullable<Effect>;
  20576. /**
  20577. * Sets associated effect (effect used to render this submesh)
  20578. * @param effect defines the effect to associate with
  20579. * @param defines defines the set of defines used to compile this effect
  20580. */
  20581. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20582. }
  20583. /**
  20584. * Defines a subdivision inside a mesh
  20585. */
  20586. export class SubMesh extends BaseSubMesh implements ICullable {
  20587. /** the material index to use */
  20588. materialIndex: number;
  20589. /** vertex index start */
  20590. verticesStart: number;
  20591. /** vertices count */
  20592. verticesCount: number;
  20593. /** index start */
  20594. indexStart: number;
  20595. /** indices count */
  20596. indexCount: number;
  20597. /** @hidden */ private _linesIndexCount: number;
  20598. private _mesh;
  20599. private _renderingMesh;
  20600. private _boundingInfo;
  20601. private _linesIndexBuffer;
  20602. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20603. /** @hidden */ private _trianglePlanes: Plane[];
  20604. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20605. /** @hidden */ private _renderId: number;
  20606. /** @hidden */ private _alphaIndex: number;
  20607. /** @hidden */ private _distanceToCamera: number;
  20608. /** @hidden */ private _id: number;
  20609. private _currentMaterial;
  20610. /**
  20611. * Add a new submesh to a mesh
  20612. * @param materialIndex defines the material index to use
  20613. * @param verticesStart defines vertex index start
  20614. * @param verticesCount defines vertices count
  20615. * @param indexStart defines index start
  20616. * @param indexCount defines indices count
  20617. * @param mesh defines the parent mesh
  20618. * @param renderingMesh defines an optional rendering mesh
  20619. * @param createBoundingBox defines if bounding box should be created for this submesh
  20620. * @returns the new submesh
  20621. */
  20622. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20623. /**
  20624. * Creates a new submesh
  20625. * @param materialIndex defines the material index to use
  20626. * @param verticesStart defines vertex index start
  20627. * @param verticesCount defines vertices count
  20628. * @param indexStart defines index start
  20629. * @param indexCount defines indices count
  20630. * @param mesh defines the parent mesh
  20631. * @param renderingMesh defines an optional rendering mesh
  20632. * @param createBoundingBox defines if bounding box should be created for this submesh
  20633. */
  20634. constructor(
  20635. /** the material index to use */
  20636. materialIndex: number,
  20637. /** vertex index start */
  20638. verticesStart: number,
  20639. /** vertices count */
  20640. verticesCount: number,
  20641. /** index start */
  20642. indexStart: number,
  20643. /** indices count */
  20644. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20645. /**
  20646. * Returns true if this submesh covers the entire parent mesh
  20647. * @ignorenaming
  20648. */
  20649. readonly IsGlobal: boolean;
  20650. /**
  20651. * Returns the submesh BoudingInfo object
  20652. * @returns current bounding info (or mesh's one if the submesh is global)
  20653. */
  20654. getBoundingInfo(): BoundingInfo;
  20655. /**
  20656. * Sets the submesh BoundingInfo
  20657. * @param boundingInfo defines the new bounding info to use
  20658. * @returns the SubMesh
  20659. */
  20660. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20661. /**
  20662. * Returns the mesh of the current submesh
  20663. * @return the parent mesh
  20664. */
  20665. getMesh(): AbstractMesh;
  20666. /**
  20667. * Returns the rendering mesh of the submesh
  20668. * @returns the rendering mesh (could be different from parent mesh)
  20669. */
  20670. getRenderingMesh(): Mesh;
  20671. /**
  20672. * Returns the submesh material
  20673. * @returns null or the current material
  20674. */
  20675. getMaterial(): Nullable<Material>;
  20676. /**
  20677. * Sets a new updated BoundingInfo object to the submesh
  20678. * @param data defines an optional position array to use to determine the bounding info
  20679. * @returns the SubMesh
  20680. */
  20681. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20682. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20683. /**
  20684. * Updates the submesh BoundingInfo
  20685. * @param world defines the world matrix to use to update the bounding info
  20686. * @returns the submesh
  20687. */
  20688. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20689. /**
  20690. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20691. * @param frustumPlanes defines the frustum planes
  20692. * @returns true if the submesh is intersecting with the frustum
  20693. */
  20694. isInFrustum(frustumPlanes: Plane[]): boolean;
  20695. /**
  20696. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20697. * @param frustumPlanes defines the frustum planes
  20698. * @returns true if the submesh is inside the frustum
  20699. */
  20700. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20701. /**
  20702. * Renders the submesh
  20703. * @param enableAlphaMode defines if alpha needs to be used
  20704. * @returns the submesh
  20705. */
  20706. render(enableAlphaMode: boolean): SubMesh;
  20707. /**
  20708. * @hidden
  20709. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20710. /**
  20711. * Checks if the submesh intersects with a ray
  20712. * @param ray defines the ray to test
  20713. * @returns true is the passed ray intersects the submesh bounding box
  20714. */
  20715. canIntersects(ray: Ray): boolean;
  20716. /**
  20717. * Intersects current submesh with a ray
  20718. * @param ray defines the ray to test
  20719. * @param positions defines mesh's positions array
  20720. * @param indices defines mesh's indices array
  20721. * @param fastCheck defines if only bounding info should be used
  20722. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20723. * @returns intersection info or null if no intersection
  20724. */
  20725. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20726. /** @hidden */
  20727. private _intersectLines;
  20728. /** @hidden */
  20729. private _intersectUnIndexedLines;
  20730. /** @hidden */
  20731. private _intersectTriangles;
  20732. /** @hidden */
  20733. private _intersectUnIndexedTriangles;
  20734. /** @hidden */ private _rebuild(): void;
  20735. /**
  20736. * Creates a new submesh from the passed mesh
  20737. * @param newMesh defines the new hosting mesh
  20738. * @param newRenderingMesh defines an optional rendering mesh
  20739. * @returns the new submesh
  20740. */
  20741. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20742. /**
  20743. * Release associated resources
  20744. */
  20745. dispose(): void;
  20746. /**
  20747. * Gets the class name
  20748. * @returns the string "SubMesh".
  20749. */
  20750. getClassName(): string;
  20751. /**
  20752. * Creates a new submesh from indices data
  20753. * @param materialIndex the index of the main mesh material
  20754. * @param startIndex the index where to start the copy in the mesh indices array
  20755. * @param indexCount the number of indices to copy then from the startIndex
  20756. * @param mesh the main mesh to create the submesh from
  20757. * @param renderingMesh the optional rendering mesh
  20758. * @returns a new submesh
  20759. */
  20760. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20761. }
  20762. }
  20763. declare module BABYLON {
  20764. /**
  20765. * Class used to represent data loading progression
  20766. */
  20767. export class SceneLoaderFlags {
  20768. private static _ForceFullSceneLoadingForIncremental;
  20769. private static _ShowLoadingScreen;
  20770. private static _CleanBoneMatrixWeights;
  20771. private static _loggingLevel;
  20772. /**
  20773. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20774. */
  20775. static ForceFullSceneLoadingForIncremental: boolean;
  20776. /**
  20777. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20778. */
  20779. static ShowLoadingScreen: boolean;
  20780. /**
  20781. * Defines the current logging level (while loading the scene)
  20782. * @ignorenaming
  20783. */
  20784. static loggingLevel: number;
  20785. /**
  20786. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20787. */
  20788. static CleanBoneMatrixWeights: boolean;
  20789. }
  20790. }
  20791. declare module BABYLON {
  20792. /**
  20793. * Class used to store geometry data (vertex buffers + index buffer)
  20794. */
  20795. export class Geometry implements IGetSetVerticesData {
  20796. /**
  20797. * Gets or sets the ID of the geometry
  20798. */
  20799. id: string;
  20800. /**
  20801. * Gets or sets the unique ID of the geometry
  20802. */
  20803. uniqueId: number;
  20804. /**
  20805. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20806. */
  20807. delayLoadState: number;
  20808. /**
  20809. * Gets the file containing the data to load when running in delay load state
  20810. */
  20811. delayLoadingFile: Nullable<string>;
  20812. /**
  20813. * Callback called when the geometry is updated
  20814. */
  20815. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20816. private _scene;
  20817. private _engine;
  20818. private _meshes;
  20819. private _totalVertices;
  20820. /** @hidden */ private _indices: IndicesArray;
  20821. /** @hidden */ private _vertexBuffers: {
  20822. [key: string]: VertexBuffer;
  20823. };
  20824. private _isDisposed;
  20825. private _extend;
  20826. private _boundingBias;
  20827. /** @hidden */ private _delayInfo: Array<string>;
  20828. private _indexBuffer;
  20829. private _indexBufferIsUpdatable;
  20830. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20831. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20832. /** @hidden */ private _softwareSkinningFrameId: number;
  20833. private _vertexArrayObjects;
  20834. private _updatable;
  20835. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20836. /**
  20837. * 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
  20838. */
  20839. /**
  20840. * 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
  20841. */
  20842. boundingBias: Vector2;
  20843. /**
  20844. * Static function used to attach a new empty geometry to a mesh
  20845. * @param mesh defines the mesh to attach the geometry to
  20846. * @returns the new Geometry
  20847. */
  20848. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20849. /**
  20850. * Creates a new geometry
  20851. * @param id defines the unique ID
  20852. * @param scene defines the hosting scene
  20853. * @param vertexData defines the VertexData used to get geometry data
  20854. * @param updatable defines if geometry must be updatable (false by default)
  20855. * @param mesh defines the mesh that will be associated with the geometry
  20856. */
  20857. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20858. /**
  20859. * Gets the current extend of the geometry
  20860. */
  20861. readonly extend: {
  20862. minimum: Vector3;
  20863. maximum: Vector3;
  20864. };
  20865. /**
  20866. * Gets the hosting scene
  20867. * @returns the hosting Scene
  20868. */
  20869. getScene(): Scene;
  20870. /**
  20871. * Gets the hosting engine
  20872. * @returns the hosting Engine
  20873. */
  20874. getEngine(): Engine;
  20875. /**
  20876. * Defines if the geometry is ready to use
  20877. * @returns true if the geometry is ready to be used
  20878. */
  20879. isReady(): boolean;
  20880. /**
  20881. * Gets a value indicating that the geometry should not be serialized
  20882. */
  20883. readonly doNotSerialize: boolean;
  20884. /** @hidden */ private _rebuild(): void;
  20885. /**
  20886. * Affects all geometry data in one call
  20887. * @param vertexData defines the geometry data
  20888. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20889. */
  20890. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20891. /**
  20892. * Set specific vertex data
  20893. * @param kind defines the data kind (Position, normal, etc...)
  20894. * @param data defines the vertex data to use
  20895. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20896. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20897. */
  20898. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20899. /**
  20900. * Removes a specific vertex data
  20901. * @param kind defines the data kind (Position, normal, etc...)
  20902. */
  20903. removeVerticesData(kind: string): void;
  20904. /**
  20905. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20906. * @param buffer defines the vertex buffer to use
  20907. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20908. */
  20909. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20910. /**
  20911. * Update a specific vertex buffer
  20912. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20913. * It will do nothing if the buffer is not updatable
  20914. * @param kind defines the data kind (Position, normal, etc...)
  20915. * @param data defines the data to use
  20916. * @param offset defines the offset in the target buffer where to store the data
  20917. * @param useBytes set to true if the offset is in bytes
  20918. */
  20919. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20920. /**
  20921. * Update a specific vertex buffer
  20922. * This function will create a new buffer if the current one is not updatable
  20923. * @param kind defines the data kind (Position, normal, etc...)
  20924. * @param data defines the data to use
  20925. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20926. */
  20927. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20928. private _updateBoundingInfo;
  20929. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20930. /**
  20931. * Gets total number of vertices
  20932. * @returns the total number of vertices
  20933. */
  20934. getTotalVertices(): number;
  20935. /**
  20936. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20937. * @param kind defines the data kind (Position, normal, etc...)
  20938. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20940. * @returns a float array containing vertex data
  20941. */
  20942. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20943. /**
  20944. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20945. * @param kind defines the data kind (Position, normal, etc...)
  20946. * @returns true if the vertex buffer with the specified kind is updatable
  20947. */
  20948. isVertexBufferUpdatable(kind: string): boolean;
  20949. /**
  20950. * Gets a specific vertex buffer
  20951. * @param kind defines the data kind (Position, normal, etc...)
  20952. * @returns a VertexBuffer
  20953. */
  20954. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20955. /**
  20956. * Returns all vertex buffers
  20957. * @return an object holding all vertex buffers indexed by kind
  20958. */
  20959. getVertexBuffers(): Nullable<{
  20960. [key: string]: VertexBuffer;
  20961. }>;
  20962. /**
  20963. * Gets a boolean indicating if specific vertex buffer is present
  20964. * @param kind defines the data kind (Position, normal, etc...)
  20965. * @returns true if data is present
  20966. */
  20967. isVerticesDataPresent(kind: string): boolean;
  20968. /**
  20969. * Gets a list of all attached data kinds (Position, normal, etc...)
  20970. * @returns a list of string containing all kinds
  20971. */
  20972. getVerticesDataKinds(): string[];
  20973. /**
  20974. * Update index buffer
  20975. * @param indices defines the indices to store in the index buffer
  20976. * @param offset defines the offset in the target buffer where to store the data
  20977. * @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)
  20978. */
  20979. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20980. /**
  20981. * Creates a new index buffer
  20982. * @param indices defines the indices to store in the index buffer
  20983. * @param totalVertices defines the total number of vertices (could be null)
  20984. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20985. */
  20986. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20987. /**
  20988. * Return the total number of indices
  20989. * @returns the total number of indices
  20990. */
  20991. getTotalIndices(): number;
  20992. /**
  20993. * Gets the index buffer array
  20994. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20996. * @returns the index buffer array
  20997. */
  20998. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20999. /**
  21000. * Gets the index buffer
  21001. * @return the index buffer
  21002. */
  21003. getIndexBuffer(): Nullable<DataBuffer>;
  21004. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21005. /**
  21006. * Release the associated resources for a specific mesh
  21007. * @param mesh defines the source mesh
  21008. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21009. */
  21010. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21011. /**
  21012. * Apply current geometry to a given mesh
  21013. * @param mesh defines the mesh to apply geometry to
  21014. */
  21015. applyToMesh(mesh: Mesh): void;
  21016. private _updateExtend;
  21017. private _applyToMesh;
  21018. private notifyUpdate;
  21019. /**
  21020. * Load the geometry if it was flagged as delay loaded
  21021. * @param scene defines the hosting scene
  21022. * @param onLoaded defines a callback called when the geometry is loaded
  21023. */
  21024. load(scene: Scene, onLoaded?: () => void): void;
  21025. private _queueLoad;
  21026. /**
  21027. * Invert the geometry to move from a right handed system to a left handed one.
  21028. */
  21029. toLeftHanded(): void;
  21030. /** @hidden */ private _resetPointsArrayCache(): void;
  21031. /** @hidden */ private _generatePointsArray(): boolean;
  21032. /**
  21033. * Gets a value indicating if the geometry is disposed
  21034. * @returns true if the geometry was disposed
  21035. */
  21036. isDisposed(): boolean;
  21037. private _disposeVertexArrayObjects;
  21038. /**
  21039. * Free all associated resources
  21040. */
  21041. dispose(): void;
  21042. /**
  21043. * Clone the current geometry into a new geometry
  21044. * @param id defines the unique ID of the new geometry
  21045. * @returns a new geometry object
  21046. */
  21047. copy(id: string): Geometry;
  21048. /**
  21049. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21050. * @return a JSON representation of the current geometry data (without the vertices data)
  21051. */
  21052. serialize(): any;
  21053. private toNumberArray;
  21054. /**
  21055. * Serialize all vertices data into a JSON oject
  21056. * @returns a JSON representation of the current geometry data
  21057. */
  21058. serializeVerticeData(): any;
  21059. /**
  21060. * Extracts a clone of a mesh geometry
  21061. * @param mesh defines the source mesh
  21062. * @param id defines the unique ID of the new geometry object
  21063. * @returns the new geometry object
  21064. */
  21065. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21066. /**
  21067. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21068. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21069. * Be aware Math.random() could cause collisions, but:
  21070. * "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"
  21071. * @returns a string containing a new GUID
  21072. */
  21073. static RandomId(): string;
  21074. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21075. private static _CleanMatricesWeights;
  21076. /**
  21077. * Create a new geometry from persisted data (Using .babylon file format)
  21078. * @param parsedVertexData defines the persisted data
  21079. * @param scene defines the hosting scene
  21080. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21081. * @returns the new geometry object
  21082. */
  21083. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21084. }
  21085. }
  21086. declare module BABYLON {
  21087. /**
  21088. * Define an interface for all classes that will get and set the data on vertices
  21089. */
  21090. export interface IGetSetVerticesData {
  21091. /**
  21092. * Gets a boolean indicating if specific vertex data is present
  21093. * @param kind defines the vertex data kind to use
  21094. * @returns true is data kind is present
  21095. */
  21096. isVerticesDataPresent(kind: string): boolean;
  21097. /**
  21098. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21099. * @param kind defines the data kind (Position, normal, etc...)
  21100. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21101. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21102. * @returns a float array containing vertex data
  21103. */
  21104. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21105. /**
  21106. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21107. * @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.
  21108. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21109. * @returns the indices array or an empty array if the mesh has no geometry
  21110. */
  21111. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21112. /**
  21113. * Set specific vertex data
  21114. * @param kind defines the data kind (Position, normal, etc...)
  21115. * @param data defines the vertex data to use
  21116. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21117. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21118. */
  21119. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21120. /**
  21121. * Update a specific associated vertex buffer
  21122. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21123. * - VertexBuffer.PositionKind
  21124. * - VertexBuffer.UVKind
  21125. * - VertexBuffer.UV2Kind
  21126. * - VertexBuffer.UV3Kind
  21127. * - VertexBuffer.UV4Kind
  21128. * - VertexBuffer.UV5Kind
  21129. * - VertexBuffer.UV6Kind
  21130. * - VertexBuffer.ColorKind
  21131. * - VertexBuffer.MatricesIndicesKind
  21132. * - VertexBuffer.MatricesIndicesExtraKind
  21133. * - VertexBuffer.MatricesWeightsKind
  21134. * - VertexBuffer.MatricesWeightsExtraKind
  21135. * @param data defines the data source
  21136. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21137. * @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)
  21138. */
  21139. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21140. /**
  21141. * Creates a new index buffer
  21142. * @param indices defines the indices to store in the index buffer
  21143. * @param totalVertices defines the total number of vertices (could be null)
  21144. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21145. */
  21146. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21147. }
  21148. /**
  21149. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21150. */
  21151. export class VertexData {
  21152. /**
  21153. * Mesh side orientation : usually the external or front surface
  21154. */
  21155. static readonly FRONTSIDE: number;
  21156. /**
  21157. * Mesh side orientation : usually the internal or back surface
  21158. */
  21159. static readonly BACKSIDE: number;
  21160. /**
  21161. * Mesh side orientation : both internal and external or front and back surfaces
  21162. */
  21163. static readonly DOUBLESIDE: number;
  21164. /**
  21165. * Mesh side orientation : by default, `FRONTSIDE`
  21166. */
  21167. static readonly DEFAULTSIDE: number;
  21168. /**
  21169. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21170. */
  21171. positions: Nullable<FloatArray>;
  21172. /**
  21173. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21174. */
  21175. normals: Nullable<FloatArray>;
  21176. /**
  21177. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21178. */
  21179. tangents: Nullable<FloatArray>;
  21180. /**
  21181. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21182. */
  21183. uvs: Nullable<FloatArray>;
  21184. /**
  21185. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21186. */
  21187. uvs2: Nullable<FloatArray>;
  21188. /**
  21189. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21190. */
  21191. uvs3: Nullable<FloatArray>;
  21192. /**
  21193. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21194. */
  21195. uvs4: Nullable<FloatArray>;
  21196. /**
  21197. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21198. */
  21199. uvs5: Nullable<FloatArray>;
  21200. /**
  21201. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21202. */
  21203. uvs6: Nullable<FloatArray>;
  21204. /**
  21205. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21206. */
  21207. colors: Nullable<FloatArray>;
  21208. /**
  21209. * 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).
  21210. */
  21211. matricesIndices: Nullable<FloatArray>;
  21212. /**
  21213. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21214. */
  21215. matricesWeights: Nullable<FloatArray>;
  21216. /**
  21217. * An array extending the number of possible indices
  21218. */
  21219. matricesIndicesExtra: Nullable<FloatArray>;
  21220. /**
  21221. * An array extending the number of possible weights when the number of indices is extended
  21222. */
  21223. matricesWeightsExtra: Nullable<FloatArray>;
  21224. /**
  21225. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21226. */
  21227. indices: Nullable<IndicesArray>;
  21228. /**
  21229. * Uses the passed data array to set the set the values for the specified kind of data
  21230. * @param data a linear array of floating numbers
  21231. * @param kind the type of data that is being set, eg positions, colors etc
  21232. */
  21233. set(data: FloatArray, kind: string): void;
  21234. /**
  21235. * Associates the vertexData to the passed Mesh.
  21236. * Sets it as updatable or not (default `false`)
  21237. * @param mesh the mesh the vertexData is applied to
  21238. * @param updatable when used and having the value true allows new data to update the vertexData
  21239. * @returns the VertexData
  21240. */
  21241. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21242. /**
  21243. * Associates the vertexData to the passed Geometry.
  21244. * Sets it as updatable or not (default `false`)
  21245. * @param geometry the geometry the vertexData is applied to
  21246. * @param updatable when used and having the value true allows new data to update the vertexData
  21247. * @returns VertexData
  21248. */
  21249. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21250. /**
  21251. * Updates the associated mesh
  21252. * @param mesh the mesh to be updated
  21253. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21254. * @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
  21255. * @returns VertexData
  21256. */
  21257. updateMesh(mesh: Mesh): VertexData;
  21258. /**
  21259. * Updates the associated geometry
  21260. * @param geometry the geometry to be updated
  21261. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21262. * @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
  21263. * @returns VertexData.
  21264. */
  21265. updateGeometry(geometry: Geometry): VertexData;
  21266. private _applyTo;
  21267. private _update;
  21268. /**
  21269. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21270. * @param matrix the transforming matrix
  21271. * @returns the VertexData
  21272. */
  21273. transform(matrix: Matrix): VertexData;
  21274. /**
  21275. * Merges the passed VertexData into the current one
  21276. * @param other the VertexData to be merged into the current one
  21277. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21278. * @returns the modified VertexData
  21279. */
  21280. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21281. private _mergeElement;
  21282. private _validate;
  21283. /**
  21284. * Serializes the VertexData
  21285. * @returns a serialized object
  21286. */
  21287. serialize(): any;
  21288. /**
  21289. * Extracts the vertexData from a mesh
  21290. * @param mesh the mesh from which to extract the VertexData
  21291. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21292. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21293. * @returns the object VertexData associated to the passed mesh
  21294. */
  21295. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21296. /**
  21297. * Extracts the vertexData from the geometry
  21298. * @param geometry the geometry from which to extract the VertexData
  21299. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21300. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21301. * @returns the object VertexData associated to the passed mesh
  21302. */
  21303. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21304. private static _ExtractFrom;
  21305. /**
  21306. * Creates the VertexData for a Ribbon
  21307. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21308. * * pathArray array of paths, each of which an array of successive Vector3
  21309. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21310. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21311. * * 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
  21312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21313. * * 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)
  21314. * * 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)
  21315. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21316. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21317. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21318. * @returns the VertexData of the ribbon
  21319. */
  21320. static CreateRibbon(options: {
  21321. pathArray: Vector3[][];
  21322. closeArray?: boolean;
  21323. closePath?: boolean;
  21324. offset?: number;
  21325. sideOrientation?: number;
  21326. frontUVs?: Vector4;
  21327. backUVs?: Vector4;
  21328. invertUV?: boolean;
  21329. uvs?: Vector2[];
  21330. colors?: Color4[];
  21331. }): VertexData;
  21332. /**
  21333. * Creates the VertexData for a box
  21334. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21335. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21336. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21337. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21338. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21339. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21340. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21342. * * 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)
  21343. * * 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)
  21344. * @returns the VertexData of the box
  21345. */
  21346. static CreateBox(options: {
  21347. size?: number;
  21348. width?: number;
  21349. height?: number;
  21350. depth?: number;
  21351. faceUV?: Vector4[];
  21352. faceColors?: Color4[];
  21353. sideOrientation?: number;
  21354. frontUVs?: Vector4;
  21355. backUVs?: Vector4;
  21356. }): VertexData;
  21357. /**
  21358. * Creates the VertexData for a tiled box
  21359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21360. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21361. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21362. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21363. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21364. * @returns the VertexData of the box
  21365. */
  21366. static CreateTiledBox(options: {
  21367. pattern?: number;
  21368. width?: number;
  21369. height?: number;
  21370. depth?: number;
  21371. tileSize?: number;
  21372. tileWidth?: number;
  21373. tileHeight?: number;
  21374. alignHorizontal?: number;
  21375. alignVertical?: number;
  21376. faceUV?: Vector4[];
  21377. faceColors?: Color4[];
  21378. sideOrientation?: number;
  21379. }): VertexData;
  21380. /**
  21381. * Creates the VertexData for a tiled plane
  21382. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21383. * * pattern a limited pattern arrangement depending on the number
  21384. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21385. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21386. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21388. * * 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)
  21389. * * 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)
  21390. * @returns the VertexData of the tiled plane
  21391. */
  21392. static CreateTiledPlane(options: {
  21393. pattern?: number;
  21394. tileSize?: number;
  21395. tileWidth?: number;
  21396. tileHeight?: number;
  21397. size?: number;
  21398. width?: number;
  21399. height?: number;
  21400. alignHorizontal?: number;
  21401. alignVertical?: number;
  21402. sideOrientation?: number;
  21403. frontUVs?: Vector4;
  21404. backUVs?: Vector4;
  21405. }): VertexData;
  21406. /**
  21407. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21408. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21409. * * segments sets the number of horizontal strips optional, default 32
  21410. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21411. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21412. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21413. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21414. * * 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
  21415. * * 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
  21416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21417. * * 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)
  21418. * * 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)
  21419. * @returns the VertexData of the ellipsoid
  21420. */
  21421. static CreateSphere(options: {
  21422. segments?: number;
  21423. diameter?: number;
  21424. diameterX?: number;
  21425. diameterY?: number;
  21426. diameterZ?: number;
  21427. arc?: number;
  21428. slice?: number;
  21429. sideOrientation?: number;
  21430. frontUVs?: Vector4;
  21431. backUVs?: Vector4;
  21432. }): VertexData;
  21433. /**
  21434. * Creates the VertexData for a cylinder, cone or prism
  21435. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21436. * * height sets the height (y direction) of the cylinder, optional, default 2
  21437. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21438. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21439. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21440. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21441. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21442. * * 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
  21443. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21444. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21445. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21446. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21448. * * 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)
  21449. * * 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)
  21450. * @returns the VertexData of the cylinder, cone or prism
  21451. */
  21452. static CreateCylinder(options: {
  21453. height?: number;
  21454. diameterTop?: number;
  21455. diameterBottom?: number;
  21456. diameter?: number;
  21457. tessellation?: number;
  21458. subdivisions?: number;
  21459. arc?: number;
  21460. faceColors?: Color4[];
  21461. faceUV?: Vector4[];
  21462. hasRings?: boolean;
  21463. enclose?: boolean;
  21464. sideOrientation?: number;
  21465. frontUVs?: Vector4;
  21466. backUVs?: Vector4;
  21467. }): VertexData;
  21468. /**
  21469. * Creates the VertexData for a torus
  21470. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21471. * * diameter the diameter of the torus, optional default 1
  21472. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21473. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21475. * * 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)
  21476. * * 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)
  21477. * @returns the VertexData of the torus
  21478. */
  21479. static CreateTorus(options: {
  21480. diameter?: number;
  21481. thickness?: number;
  21482. tessellation?: number;
  21483. sideOrientation?: number;
  21484. frontUVs?: Vector4;
  21485. backUVs?: Vector4;
  21486. }): VertexData;
  21487. /**
  21488. * Creates the VertexData of the LineSystem
  21489. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21490. * - lines an array of lines, each line being an array of successive Vector3
  21491. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21492. * @returns the VertexData of the LineSystem
  21493. */
  21494. static CreateLineSystem(options: {
  21495. lines: Vector3[][];
  21496. colors?: Nullable<Color4[][]>;
  21497. }): VertexData;
  21498. /**
  21499. * Create the VertexData for a DashedLines
  21500. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21501. * - points an array successive Vector3
  21502. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21503. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21504. * - dashNb the intended total number of dashes, optional, default 200
  21505. * @returns the VertexData for the DashedLines
  21506. */
  21507. static CreateDashedLines(options: {
  21508. points: Vector3[];
  21509. dashSize?: number;
  21510. gapSize?: number;
  21511. dashNb?: number;
  21512. }): VertexData;
  21513. /**
  21514. * Creates the VertexData for a Ground
  21515. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21516. * - width the width (x direction) of the ground, optional, default 1
  21517. * - height the height (z direction) of the ground, optional, default 1
  21518. * - subdivisions the number of subdivisions per side, optional, default 1
  21519. * @returns the VertexData of the Ground
  21520. */
  21521. static CreateGround(options: {
  21522. width?: number;
  21523. height?: number;
  21524. subdivisions?: number;
  21525. subdivisionsX?: number;
  21526. subdivisionsY?: number;
  21527. }): VertexData;
  21528. /**
  21529. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21530. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21531. * * xmin the ground minimum X coordinate, optional, default -1
  21532. * * zmin the ground minimum Z coordinate, optional, default -1
  21533. * * xmax the ground maximum X coordinate, optional, default 1
  21534. * * zmax the ground maximum Z coordinate, optional, default 1
  21535. * * 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}
  21536. * * 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}
  21537. * @returns the VertexData of the TiledGround
  21538. */
  21539. static CreateTiledGround(options: {
  21540. xmin: number;
  21541. zmin: number;
  21542. xmax: number;
  21543. zmax: number;
  21544. subdivisions?: {
  21545. w: number;
  21546. h: number;
  21547. };
  21548. precision?: {
  21549. w: number;
  21550. h: number;
  21551. };
  21552. }): VertexData;
  21553. /**
  21554. * Creates the VertexData of the Ground designed from a heightmap
  21555. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21556. * * width the width (x direction) of the ground
  21557. * * height the height (z direction) of the ground
  21558. * * subdivisions the number of subdivisions per side
  21559. * * minHeight the minimum altitude on the ground, optional, default 0
  21560. * * maxHeight the maximum altitude on the ground, optional default 1
  21561. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21562. * * buffer the array holding the image color data
  21563. * * bufferWidth the width of image
  21564. * * bufferHeight the height of image
  21565. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21566. * @returns the VertexData of the Ground designed from a heightmap
  21567. */
  21568. static CreateGroundFromHeightMap(options: {
  21569. width: number;
  21570. height: number;
  21571. subdivisions: number;
  21572. minHeight: number;
  21573. maxHeight: number;
  21574. colorFilter: Color3;
  21575. buffer: Uint8Array;
  21576. bufferWidth: number;
  21577. bufferHeight: number;
  21578. alphaFilter: number;
  21579. }): VertexData;
  21580. /**
  21581. * Creates the VertexData for a Plane
  21582. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21583. * * size sets the width and height of the plane to the value of size, optional default 1
  21584. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21585. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21587. * * 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)
  21588. * * 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)
  21589. * @returns the VertexData of the box
  21590. */
  21591. static CreatePlane(options: {
  21592. size?: number;
  21593. width?: number;
  21594. height?: number;
  21595. sideOrientation?: number;
  21596. frontUVs?: Vector4;
  21597. backUVs?: Vector4;
  21598. }): VertexData;
  21599. /**
  21600. * Creates the VertexData of the Disc or regular Polygon
  21601. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21602. * * radius the radius of the disc, optional default 0.5
  21603. * * tessellation the number of polygon sides, optional, default 64
  21604. * * 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
  21605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21606. * * 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)
  21607. * * 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)
  21608. * @returns the VertexData of the box
  21609. */
  21610. static CreateDisc(options: {
  21611. radius?: number;
  21612. tessellation?: number;
  21613. arc?: number;
  21614. sideOrientation?: number;
  21615. frontUVs?: Vector4;
  21616. backUVs?: Vector4;
  21617. }): VertexData;
  21618. /**
  21619. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21620. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21621. * @param polygon a mesh built from polygonTriangulation.build()
  21622. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21623. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21624. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21625. * @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)
  21626. * @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)
  21627. * @returns the VertexData of the Polygon
  21628. */
  21629. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21630. /**
  21631. * Creates the VertexData of the IcoSphere
  21632. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21633. * * radius the radius of the IcoSphere, optional default 1
  21634. * * radiusX allows stretching in the x direction, optional, default radius
  21635. * * radiusY allows stretching in the y direction, optional, default radius
  21636. * * radiusZ allows stretching in the z direction, optional, default radius
  21637. * * flat when true creates a flat shaded mesh, optional, default true
  21638. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21640. * * 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)
  21641. * * 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)
  21642. * @returns the VertexData of the IcoSphere
  21643. */
  21644. static CreateIcoSphere(options: {
  21645. radius?: number;
  21646. radiusX?: number;
  21647. radiusY?: number;
  21648. radiusZ?: number;
  21649. flat?: boolean;
  21650. subdivisions?: number;
  21651. sideOrientation?: number;
  21652. frontUVs?: Vector4;
  21653. backUVs?: Vector4;
  21654. }): VertexData;
  21655. /**
  21656. * Creates the VertexData for a Polyhedron
  21657. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21658. * * type provided types are:
  21659. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21660. * * 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)
  21661. * * size the size of the IcoSphere, optional default 1
  21662. * * sizeX allows stretching in the x direction, optional, default size
  21663. * * sizeY allows stretching in the y direction, optional, default size
  21664. * * sizeZ allows stretching in the z direction, optional, default size
  21665. * * 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
  21666. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21667. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21668. * * flat when true creates a flat shaded mesh, optional, default true
  21669. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21670. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21671. * * 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)
  21672. * * 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)
  21673. * @returns the VertexData of the Polyhedron
  21674. */
  21675. static CreatePolyhedron(options: {
  21676. type?: number;
  21677. size?: number;
  21678. sizeX?: number;
  21679. sizeY?: number;
  21680. sizeZ?: number;
  21681. custom?: any;
  21682. faceUV?: Vector4[];
  21683. faceColors?: Color4[];
  21684. flat?: boolean;
  21685. sideOrientation?: number;
  21686. frontUVs?: Vector4;
  21687. backUVs?: Vector4;
  21688. }): VertexData;
  21689. /**
  21690. * Creates the VertexData for a TorusKnot
  21691. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21692. * * radius the radius of the torus knot, optional, default 2
  21693. * * tube the thickness of the tube, optional, default 0.5
  21694. * * radialSegments the number of sides on each tube segments, optional, default 32
  21695. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21696. * * p the number of windings around the z axis, optional, default 2
  21697. * * q the number of windings around the x axis, optional, default 3
  21698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21699. * * 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)
  21700. * * 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)
  21701. * @returns the VertexData of the Torus Knot
  21702. */
  21703. static CreateTorusKnot(options: {
  21704. radius?: number;
  21705. tube?: number;
  21706. radialSegments?: number;
  21707. tubularSegments?: number;
  21708. p?: number;
  21709. q?: number;
  21710. sideOrientation?: number;
  21711. frontUVs?: Vector4;
  21712. backUVs?: Vector4;
  21713. }): VertexData;
  21714. /**
  21715. * Compute normals for given positions and indices
  21716. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21717. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21718. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21719. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21720. * * facetNormals : optional array of facet normals (vector3)
  21721. * * facetPositions : optional array of facet positions (vector3)
  21722. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21723. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21724. * * bInfo : optional bounding info, required for facetPartitioning computation
  21725. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21726. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21727. * * useRightHandedSystem: optional boolean to for right handed system computation
  21728. * * depthSort : optional boolean to enable the facet depth sort computation
  21729. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21730. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21731. */
  21732. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21733. facetNormals?: any;
  21734. facetPositions?: any;
  21735. facetPartitioning?: any;
  21736. ratio?: number;
  21737. bInfo?: any;
  21738. bbSize?: Vector3;
  21739. subDiv?: any;
  21740. useRightHandedSystem?: boolean;
  21741. depthSort?: boolean;
  21742. distanceTo?: Vector3;
  21743. depthSortedFacets?: any;
  21744. }): void;
  21745. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21746. /**
  21747. * Applies VertexData created from the imported parameters to the geometry
  21748. * @param parsedVertexData the parsed data from an imported file
  21749. * @param geometry the geometry to apply the VertexData to
  21750. */
  21751. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21752. }
  21753. }
  21754. declare module BABYLON {
  21755. /**
  21756. * Defines a target to use with MorphTargetManager
  21757. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21758. */
  21759. export class MorphTarget implements IAnimatable {
  21760. /** defines the name of the target */
  21761. name: string;
  21762. /**
  21763. * Gets or sets the list of animations
  21764. */
  21765. animations: Animation[];
  21766. private _scene;
  21767. private _positions;
  21768. private _normals;
  21769. private _tangents;
  21770. private _uvs;
  21771. private _influence;
  21772. private _uniqueId;
  21773. /**
  21774. * Observable raised when the influence changes
  21775. */
  21776. onInfluenceChanged: Observable<boolean>;
  21777. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21778. /**
  21779. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21780. */
  21781. influence: number;
  21782. /**
  21783. * Gets or sets the id of the morph Target
  21784. */
  21785. id: string;
  21786. private _animationPropertiesOverride;
  21787. /**
  21788. * Gets or sets the animation properties override
  21789. */
  21790. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21791. /**
  21792. * Creates a new MorphTarget
  21793. * @param name defines the name of the target
  21794. * @param influence defines the influence to use
  21795. * @param scene defines the scene the morphtarget belongs to
  21796. */
  21797. constructor(
  21798. /** defines the name of the target */
  21799. name: string, influence?: number, scene?: Nullable<Scene>);
  21800. /**
  21801. * Gets the unique ID of this manager
  21802. */
  21803. readonly uniqueId: number;
  21804. /**
  21805. * Gets a boolean defining if the target contains position data
  21806. */
  21807. readonly hasPositions: boolean;
  21808. /**
  21809. * Gets a boolean defining if the target contains normal data
  21810. */
  21811. readonly hasNormals: boolean;
  21812. /**
  21813. * Gets a boolean defining if the target contains tangent data
  21814. */
  21815. readonly hasTangents: boolean;
  21816. /**
  21817. * Gets a boolean defining if the target contains texture coordinates data
  21818. */
  21819. readonly hasUVs: boolean;
  21820. /**
  21821. * Affects position data to this target
  21822. * @param data defines the position data to use
  21823. */
  21824. setPositions(data: Nullable<FloatArray>): void;
  21825. /**
  21826. * Gets the position data stored in this target
  21827. * @returns a FloatArray containing the position data (or null if not present)
  21828. */
  21829. getPositions(): Nullable<FloatArray>;
  21830. /**
  21831. * Affects normal data to this target
  21832. * @param data defines the normal data to use
  21833. */
  21834. setNormals(data: Nullable<FloatArray>): void;
  21835. /**
  21836. * Gets the normal data stored in this target
  21837. * @returns a FloatArray containing the normal data (or null if not present)
  21838. */
  21839. getNormals(): Nullable<FloatArray>;
  21840. /**
  21841. * Affects tangent data to this target
  21842. * @param data defines the tangent data to use
  21843. */
  21844. setTangents(data: Nullable<FloatArray>): void;
  21845. /**
  21846. * Gets the tangent data stored in this target
  21847. * @returns a FloatArray containing the tangent data (or null if not present)
  21848. */
  21849. getTangents(): Nullable<FloatArray>;
  21850. /**
  21851. * Affects texture coordinates data to this target
  21852. * @param data defines the texture coordinates data to use
  21853. */
  21854. setUVs(data: Nullable<FloatArray>): void;
  21855. /**
  21856. * Gets the texture coordinates data stored in this target
  21857. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21858. */
  21859. getUVs(): Nullable<FloatArray>;
  21860. /**
  21861. * Clone the current target
  21862. * @returns a new MorphTarget
  21863. */
  21864. clone(): MorphTarget;
  21865. /**
  21866. * Serializes the current target into a Serialization object
  21867. * @returns the serialized object
  21868. */
  21869. serialize(): any;
  21870. /**
  21871. * Returns the string "MorphTarget"
  21872. * @returns "MorphTarget"
  21873. */
  21874. getClassName(): string;
  21875. /**
  21876. * Creates a new target from serialized data
  21877. * @param serializationObject defines the serialized data to use
  21878. * @returns a new MorphTarget
  21879. */
  21880. static Parse(serializationObject: any): MorphTarget;
  21881. /**
  21882. * Creates a MorphTarget from mesh data
  21883. * @param mesh defines the source mesh
  21884. * @param name defines the name to use for the new target
  21885. * @param influence defines the influence to attach to the target
  21886. * @returns a new MorphTarget
  21887. */
  21888. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21889. }
  21890. }
  21891. declare module BABYLON {
  21892. /**
  21893. * This class is used to deform meshes using morphing between different targets
  21894. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21895. */
  21896. export class MorphTargetManager {
  21897. private _targets;
  21898. private _targetInfluenceChangedObservers;
  21899. private _targetDataLayoutChangedObservers;
  21900. private _activeTargets;
  21901. private _scene;
  21902. private _influences;
  21903. private _supportsNormals;
  21904. private _supportsTangents;
  21905. private _supportsUVs;
  21906. private _vertexCount;
  21907. private _uniqueId;
  21908. private _tempInfluences;
  21909. /**
  21910. * Gets or sets a boolean indicating if normals must be morphed
  21911. */
  21912. enableNormalMorphing: boolean;
  21913. /**
  21914. * Gets or sets a boolean indicating if tangents must be morphed
  21915. */
  21916. enableTangentMorphing: boolean;
  21917. /**
  21918. * Gets or sets a boolean indicating if UV must be morphed
  21919. */
  21920. enableUVMorphing: boolean;
  21921. /**
  21922. * Creates a new MorphTargetManager
  21923. * @param scene defines the current scene
  21924. */
  21925. constructor(scene?: Nullable<Scene>);
  21926. /**
  21927. * Gets the unique ID of this manager
  21928. */
  21929. readonly uniqueId: number;
  21930. /**
  21931. * Gets the number of vertices handled by this manager
  21932. */
  21933. readonly vertexCount: number;
  21934. /**
  21935. * Gets a boolean indicating if this manager supports morphing of normals
  21936. */
  21937. readonly supportsNormals: boolean;
  21938. /**
  21939. * Gets a boolean indicating if this manager supports morphing of tangents
  21940. */
  21941. readonly supportsTangents: boolean;
  21942. /**
  21943. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21944. */
  21945. readonly supportsUVs: boolean;
  21946. /**
  21947. * Gets the number of targets stored in this manager
  21948. */
  21949. readonly numTargets: number;
  21950. /**
  21951. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21952. */
  21953. readonly numInfluencers: number;
  21954. /**
  21955. * Gets the list of influences (one per target)
  21956. */
  21957. readonly influences: Float32Array;
  21958. /**
  21959. * Gets the active target at specified index. An active target is a target with an influence > 0
  21960. * @param index defines the index to check
  21961. * @returns the requested target
  21962. */
  21963. getActiveTarget(index: number): MorphTarget;
  21964. /**
  21965. * Gets the target at specified index
  21966. * @param index defines the index to check
  21967. * @returns the requested target
  21968. */
  21969. getTarget(index: number): MorphTarget;
  21970. /**
  21971. * Add a new target to this manager
  21972. * @param target defines the target to add
  21973. */
  21974. addTarget(target: MorphTarget): void;
  21975. /**
  21976. * Removes a target from the manager
  21977. * @param target defines the target to remove
  21978. */
  21979. removeTarget(target: MorphTarget): void;
  21980. /**
  21981. * Clone the current manager
  21982. * @returns a new MorphTargetManager
  21983. */
  21984. clone(): MorphTargetManager;
  21985. /**
  21986. * Serializes the current manager into a Serialization object
  21987. * @returns the serialized object
  21988. */
  21989. serialize(): any;
  21990. private _syncActiveTargets;
  21991. /**
  21992. * Syncrhonize the targets with all the meshes using this morph target manager
  21993. */
  21994. synchronize(): void;
  21995. /**
  21996. * Creates a new MorphTargetManager from serialized data
  21997. * @param serializationObject defines the serialized data
  21998. * @param scene defines the hosting scene
  21999. * @returns the new MorphTargetManager
  22000. */
  22001. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22002. }
  22003. }
  22004. declare module BABYLON {
  22005. /**
  22006. * Class used to represent a specific level of detail of a mesh
  22007. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22008. */
  22009. export class MeshLODLevel {
  22010. /** Defines the distance where this level should start being displayed */
  22011. distance: number;
  22012. /** Defines the mesh to use to render this level */
  22013. mesh: Nullable<Mesh>;
  22014. /**
  22015. * Creates a new LOD level
  22016. * @param distance defines the distance where this level should star being displayed
  22017. * @param mesh defines the mesh to use to render this level
  22018. */
  22019. constructor(
  22020. /** Defines the distance where this level should start being displayed */
  22021. distance: number,
  22022. /** Defines the mesh to use to render this level */
  22023. mesh: Nullable<Mesh>);
  22024. }
  22025. }
  22026. declare module BABYLON {
  22027. /**
  22028. * Mesh representing the gorund
  22029. */
  22030. export class GroundMesh extends Mesh {
  22031. /** If octree should be generated */
  22032. generateOctree: boolean;
  22033. private _heightQuads;
  22034. /** @hidden */ private _subdivisionsX: number;
  22035. /** @hidden */ private _subdivisionsY: number;
  22036. /** @hidden */ private _width: number;
  22037. /** @hidden */ private _height: number;
  22038. /** @hidden */ private _minX: number;
  22039. /** @hidden */ private _maxX: number;
  22040. /** @hidden */ private _minZ: number;
  22041. /** @hidden */ private _maxZ: number;
  22042. constructor(name: string, scene: Scene);
  22043. /**
  22044. * "GroundMesh"
  22045. * @returns "GroundMesh"
  22046. */
  22047. getClassName(): string;
  22048. /**
  22049. * The minimum of x and y subdivisions
  22050. */
  22051. readonly subdivisions: number;
  22052. /**
  22053. * X subdivisions
  22054. */
  22055. readonly subdivisionsX: number;
  22056. /**
  22057. * Y subdivisions
  22058. */
  22059. readonly subdivisionsY: number;
  22060. /**
  22061. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22062. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22063. * @param chunksCount the number of subdivisions for x and y
  22064. * @param octreeBlocksSize (Default: 32)
  22065. */
  22066. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22067. /**
  22068. * Returns a height (y) value in the Worl system :
  22069. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22070. * @param x x coordinate
  22071. * @param z z coordinate
  22072. * @returns the ground y position if (x, z) are outside the ground surface.
  22073. */
  22074. getHeightAtCoordinates(x: number, z: number): number;
  22075. /**
  22076. * Returns a normalized vector (Vector3) orthogonal to the ground
  22077. * at the ground coordinates (x, z) expressed in the World system.
  22078. * @param x x coordinate
  22079. * @param z z coordinate
  22080. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22081. */
  22082. getNormalAtCoordinates(x: number, z: number): Vector3;
  22083. /**
  22084. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22085. * at the ground coordinates (x, z) expressed in the World system.
  22086. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22087. * @param x x coordinate
  22088. * @param z z coordinate
  22089. * @param ref vector to store the result
  22090. * @returns the GroundMesh.
  22091. */
  22092. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22093. /**
  22094. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22095. * if the ground has been updated.
  22096. * This can be used in the render loop.
  22097. * @returns the GroundMesh.
  22098. */
  22099. updateCoordinateHeights(): GroundMesh;
  22100. private _getFacetAt;
  22101. private _initHeightQuads;
  22102. private _computeHeightQuads;
  22103. /**
  22104. * Serializes this ground mesh
  22105. * @param serializationObject object to write serialization to
  22106. */
  22107. serialize(serializationObject: any): void;
  22108. /**
  22109. * Parses a serialized ground mesh
  22110. * @param parsedMesh the serialized mesh
  22111. * @param scene the scene to create the ground mesh in
  22112. * @returns the created ground mesh
  22113. */
  22114. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22115. }
  22116. }
  22117. declare module BABYLON {
  22118. /**
  22119. * Interface for Physics-Joint data
  22120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22121. */
  22122. export interface PhysicsJointData {
  22123. /**
  22124. * The main pivot of the joint
  22125. */
  22126. mainPivot?: Vector3;
  22127. /**
  22128. * The connected pivot of the joint
  22129. */
  22130. connectedPivot?: Vector3;
  22131. /**
  22132. * The main axis of the joint
  22133. */
  22134. mainAxis?: Vector3;
  22135. /**
  22136. * The connected axis of the joint
  22137. */
  22138. connectedAxis?: Vector3;
  22139. /**
  22140. * The collision of the joint
  22141. */
  22142. collision?: boolean;
  22143. /**
  22144. * Native Oimo/Cannon/Energy data
  22145. */
  22146. nativeParams?: any;
  22147. }
  22148. /**
  22149. * This is a holder class for the physics joint created by the physics plugin
  22150. * It holds a set of functions to control the underlying joint
  22151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22152. */
  22153. export class PhysicsJoint {
  22154. /**
  22155. * The type of the physics joint
  22156. */
  22157. type: number;
  22158. /**
  22159. * The data for the physics joint
  22160. */
  22161. jointData: PhysicsJointData;
  22162. private _physicsJoint;
  22163. protected _physicsPlugin: IPhysicsEnginePlugin;
  22164. /**
  22165. * Initializes the physics joint
  22166. * @param type The type of the physics joint
  22167. * @param jointData The data for the physics joint
  22168. */
  22169. constructor(
  22170. /**
  22171. * The type of the physics joint
  22172. */
  22173. type: number,
  22174. /**
  22175. * The data for the physics joint
  22176. */
  22177. jointData: PhysicsJointData);
  22178. /**
  22179. * Gets the physics joint
  22180. */
  22181. /**
  22182. * Sets the physics joint
  22183. */
  22184. physicsJoint: any;
  22185. /**
  22186. * Sets the physics plugin
  22187. */
  22188. physicsPlugin: IPhysicsEnginePlugin;
  22189. /**
  22190. * Execute a function that is physics-plugin specific.
  22191. * @param {Function} func the function that will be executed.
  22192. * It accepts two parameters: the physics world and the physics joint
  22193. */
  22194. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22195. /**
  22196. * Distance-Joint type
  22197. */
  22198. static DistanceJoint: number;
  22199. /**
  22200. * Hinge-Joint type
  22201. */
  22202. static HingeJoint: number;
  22203. /**
  22204. * Ball-and-Socket joint type
  22205. */
  22206. static BallAndSocketJoint: number;
  22207. /**
  22208. * Wheel-Joint type
  22209. */
  22210. static WheelJoint: number;
  22211. /**
  22212. * Slider-Joint type
  22213. */
  22214. static SliderJoint: number;
  22215. /**
  22216. * Prismatic-Joint type
  22217. */
  22218. static PrismaticJoint: number;
  22219. /**
  22220. * Universal-Joint type
  22221. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22222. */
  22223. static UniversalJoint: number;
  22224. /**
  22225. * Hinge-Joint 2 type
  22226. */
  22227. static Hinge2Joint: number;
  22228. /**
  22229. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22230. */
  22231. static PointToPointJoint: number;
  22232. /**
  22233. * Spring-Joint type
  22234. */
  22235. static SpringJoint: number;
  22236. /**
  22237. * Lock-Joint type
  22238. */
  22239. static LockJoint: number;
  22240. }
  22241. /**
  22242. * A class representing a physics distance joint
  22243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22244. */
  22245. export class DistanceJoint extends PhysicsJoint {
  22246. /**
  22247. *
  22248. * @param jointData The data for the Distance-Joint
  22249. */
  22250. constructor(jointData: DistanceJointData);
  22251. /**
  22252. * Update the predefined distance.
  22253. * @param maxDistance The maximum preferred distance
  22254. * @param minDistance The minimum preferred distance
  22255. */
  22256. updateDistance(maxDistance: number, minDistance?: number): void;
  22257. }
  22258. /**
  22259. * Represents a Motor-Enabled Joint
  22260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22261. */
  22262. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22263. /**
  22264. * Initializes the Motor-Enabled Joint
  22265. * @param type The type of the joint
  22266. * @param jointData The physica joint data for the joint
  22267. */
  22268. constructor(type: number, jointData: PhysicsJointData);
  22269. /**
  22270. * Set the motor values.
  22271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22272. * @param force the force to apply
  22273. * @param maxForce max force for this motor.
  22274. */
  22275. setMotor(force?: number, maxForce?: number): void;
  22276. /**
  22277. * Set the motor's limits.
  22278. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22279. * @param upperLimit The upper limit of the motor
  22280. * @param lowerLimit The lower limit of the motor
  22281. */
  22282. setLimit(upperLimit: number, lowerLimit?: number): void;
  22283. }
  22284. /**
  22285. * This class represents a single physics Hinge-Joint
  22286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22287. */
  22288. export class HingeJoint extends MotorEnabledJoint {
  22289. /**
  22290. * Initializes the Hinge-Joint
  22291. * @param jointData The joint data for the Hinge-Joint
  22292. */
  22293. constructor(jointData: PhysicsJointData);
  22294. /**
  22295. * Set the motor values.
  22296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22297. * @param {number} force the force to apply
  22298. * @param {number} maxForce max force for this motor.
  22299. */
  22300. setMotor(force?: number, maxForce?: number): void;
  22301. /**
  22302. * Set the motor's limits.
  22303. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22304. * @param upperLimit The upper limit of the motor
  22305. * @param lowerLimit The lower limit of the motor
  22306. */
  22307. setLimit(upperLimit: number, lowerLimit?: number): void;
  22308. }
  22309. /**
  22310. * This class represents a dual hinge physics joint (same as wheel joint)
  22311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22312. */
  22313. export class Hinge2Joint extends MotorEnabledJoint {
  22314. /**
  22315. * Initializes the Hinge2-Joint
  22316. * @param jointData The joint data for the Hinge2-Joint
  22317. */
  22318. constructor(jointData: PhysicsJointData);
  22319. /**
  22320. * Set the motor values.
  22321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22322. * @param {number} targetSpeed the speed the motor is to reach
  22323. * @param {number} maxForce max force for this motor.
  22324. * @param {motorIndex} the motor's index, 0 or 1.
  22325. */
  22326. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22327. /**
  22328. * Set the motor limits.
  22329. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22330. * @param {number} upperLimit the upper limit
  22331. * @param {number} lowerLimit lower limit
  22332. * @param {motorIndex} the motor's index, 0 or 1.
  22333. */
  22334. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22335. }
  22336. /**
  22337. * Interface for a motor enabled joint
  22338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22339. */
  22340. export interface IMotorEnabledJoint {
  22341. /**
  22342. * Physics joint
  22343. */
  22344. physicsJoint: any;
  22345. /**
  22346. * Sets the motor of the motor-enabled joint
  22347. * @param force The force of the motor
  22348. * @param maxForce The maximum force of the motor
  22349. * @param motorIndex The index of the motor
  22350. */
  22351. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22352. /**
  22353. * Sets the limit of the motor
  22354. * @param upperLimit The upper limit of the motor
  22355. * @param lowerLimit The lower limit of the motor
  22356. * @param motorIndex The index of the motor
  22357. */
  22358. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22359. }
  22360. /**
  22361. * Joint data for a Distance-Joint
  22362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22363. */
  22364. export interface DistanceJointData extends PhysicsJointData {
  22365. /**
  22366. * Max distance the 2 joint objects can be apart
  22367. */
  22368. maxDistance: number;
  22369. }
  22370. /**
  22371. * Joint data from a spring joint
  22372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22373. */
  22374. export interface SpringJointData extends PhysicsJointData {
  22375. /**
  22376. * Length of the spring
  22377. */
  22378. length: number;
  22379. /**
  22380. * Stiffness of the spring
  22381. */
  22382. stiffness: number;
  22383. /**
  22384. * Damping of the spring
  22385. */
  22386. damping: number;
  22387. /** this callback will be called when applying the force to the impostors. */
  22388. forceApplicationCallback: () => void;
  22389. }
  22390. }
  22391. declare module BABYLON {
  22392. /**
  22393. * Holds the data for the raycast result
  22394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22395. */
  22396. export class PhysicsRaycastResult {
  22397. private _hasHit;
  22398. private _hitDistance;
  22399. private _hitNormalWorld;
  22400. private _hitPointWorld;
  22401. private _rayFromWorld;
  22402. private _rayToWorld;
  22403. /**
  22404. * Gets if there was a hit
  22405. */
  22406. readonly hasHit: boolean;
  22407. /**
  22408. * Gets the distance from the hit
  22409. */
  22410. readonly hitDistance: number;
  22411. /**
  22412. * Gets the hit normal/direction in the world
  22413. */
  22414. readonly hitNormalWorld: Vector3;
  22415. /**
  22416. * Gets the hit point in the world
  22417. */
  22418. readonly hitPointWorld: Vector3;
  22419. /**
  22420. * Gets the ray "start point" of the ray in the world
  22421. */
  22422. readonly rayFromWorld: Vector3;
  22423. /**
  22424. * Gets the ray "end point" of the ray in the world
  22425. */
  22426. readonly rayToWorld: Vector3;
  22427. /**
  22428. * Sets the hit data (normal & point in world space)
  22429. * @param hitNormalWorld defines the normal in world space
  22430. * @param hitPointWorld defines the point in world space
  22431. */
  22432. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22433. /**
  22434. * Sets the distance from the start point to the hit point
  22435. * @param distance
  22436. */
  22437. setHitDistance(distance: number): void;
  22438. /**
  22439. * Calculates the distance manually
  22440. */
  22441. calculateHitDistance(): void;
  22442. /**
  22443. * Resets all the values to default
  22444. * @param from The from point on world space
  22445. * @param to The to point on world space
  22446. */
  22447. reset(from?: Vector3, to?: Vector3): void;
  22448. }
  22449. /**
  22450. * Interface for the size containing width and height
  22451. */
  22452. interface IXYZ {
  22453. /**
  22454. * X
  22455. */
  22456. x: number;
  22457. /**
  22458. * Y
  22459. */
  22460. y: number;
  22461. /**
  22462. * Z
  22463. */
  22464. z: number;
  22465. }
  22466. }
  22467. declare module BABYLON {
  22468. /**
  22469. * Interface used to describe a physics joint
  22470. */
  22471. export interface PhysicsImpostorJoint {
  22472. /** Defines the main impostor to which the joint is linked */
  22473. mainImpostor: PhysicsImpostor;
  22474. /** Defines the impostor that is connected to the main impostor using this joint */
  22475. connectedImpostor: PhysicsImpostor;
  22476. /** Defines the joint itself */
  22477. joint: PhysicsJoint;
  22478. }
  22479. /** @hidden */
  22480. export interface IPhysicsEnginePlugin {
  22481. world: any;
  22482. name: string;
  22483. setGravity(gravity: Vector3): void;
  22484. setTimeStep(timeStep: number): void;
  22485. getTimeStep(): number;
  22486. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22487. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22488. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22489. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22490. removePhysicsBody(impostor: PhysicsImpostor): void;
  22491. generateJoint(joint: PhysicsImpostorJoint): void;
  22492. removeJoint(joint: PhysicsImpostorJoint): void;
  22493. isSupported(): boolean;
  22494. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22495. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22496. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22497. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22498. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22499. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22500. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22501. getBodyMass(impostor: PhysicsImpostor): number;
  22502. getBodyFriction(impostor: PhysicsImpostor): number;
  22503. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22504. getBodyRestitution(impostor: PhysicsImpostor): number;
  22505. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22506. getBodyPressure?(impostor: PhysicsImpostor): number;
  22507. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22508. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22509. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22510. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22511. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22512. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22513. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22514. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22515. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22516. sleepBody(impostor: PhysicsImpostor): void;
  22517. wakeUpBody(impostor: PhysicsImpostor): void;
  22518. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22519. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22520. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22521. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22522. getRadius(impostor: PhysicsImpostor): number;
  22523. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22524. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22525. dispose(): void;
  22526. }
  22527. /**
  22528. * Interface used to define a physics engine
  22529. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22530. */
  22531. export interface IPhysicsEngine {
  22532. /**
  22533. * Gets the gravity vector used by the simulation
  22534. */
  22535. gravity: Vector3;
  22536. /**
  22537. * Sets the gravity vector used by the simulation
  22538. * @param gravity defines the gravity vector to use
  22539. */
  22540. setGravity(gravity: Vector3): void;
  22541. /**
  22542. * Set the time step of the physics engine.
  22543. * Default is 1/60.
  22544. * To slow it down, enter 1/600 for example.
  22545. * To speed it up, 1/30
  22546. * @param newTimeStep the new timestep to apply to this world.
  22547. */
  22548. setTimeStep(newTimeStep: number): void;
  22549. /**
  22550. * Get the time step of the physics engine.
  22551. * @returns the current time step
  22552. */
  22553. getTimeStep(): number;
  22554. /**
  22555. * Release all resources
  22556. */
  22557. dispose(): void;
  22558. /**
  22559. * Gets the name of the current physics plugin
  22560. * @returns the name of the plugin
  22561. */
  22562. getPhysicsPluginName(): string;
  22563. /**
  22564. * Adding a new impostor for the impostor tracking.
  22565. * This will be done by the impostor itself.
  22566. * @param impostor the impostor to add
  22567. */
  22568. addImpostor(impostor: PhysicsImpostor): void;
  22569. /**
  22570. * Remove an impostor from the engine.
  22571. * This impostor and its mesh will not longer be updated by the physics engine.
  22572. * @param impostor the impostor to remove
  22573. */
  22574. removeImpostor(impostor: PhysicsImpostor): void;
  22575. /**
  22576. * Add a joint to the physics engine
  22577. * @param mainImpostor defines the main impostor to which the joint is added.
  22578. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22579. * @param joint defines the joint that will connect both impostors.
  22580. */
  22581. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22582. /**
  22583. * Removes a joint from the simulation
  22584. * @param mainImpostor defines the impostor used with the joint
  22585. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22586. * @param joint defines the joint to remove
  22587. */
  22588. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22589. /**
  22590. * Gets the current plugin used to run the simulation
  22591. * @returns current plugin
  22592. */
  22593. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22594. /**
  22595. * Gets the list of physic impostors
  22596. * @returns an array of PhysicsImpostor
  22597. */
  22598. getImpostors(): Array<PhysicsImpostor>;
  22599. /**
  22600. * Gets the impostor for a physics enabled object
  22601. * @param object defines the object impersonated by the impostor
  22602. * @returns the PhysicsImpostor or null if not found
  22603. */
  22604. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22605. /**
  22606. * Gets the impostor for a physics body object
  22607. * @param body defines physics body used by the impostor
  22608. * @returns the PhysicsImpostor or null if not found
  22609. */
  22610. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22611. /**
  22612. * Does a raycast in the physics world
  22613. * @param from when should the ray start?
  22614. * @param to when should the ray end?
  22615. * @returns PhysicsRaycastResult
  22616. */
  22617. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22618. /**
  22619. * Called by the scene. No need to call it.
  22620. * @param delta defines the timespam between frames
  22621. */ private _step(delta: number): void;
  22622. }
  22623. }
  22624. declare module BABYLON {
  22625. /**
  22626. * The interface for the physics imposter parameters
  22627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22628. */
  22629. export interface PhysicsImpostorParameters {
  22630. /**
  22631. * The mass of the physics imposter
  22632. */
  22633. mass: number;
  22634. /**
  22635. * The friction of the physics imposter
  22636. */
  22637. friction?: number;
  22638. /**
  22639. * The coefficient of restitution of the physics imposter
  22640. */
  22641. restitution?: number;
  22642. /**
  22643. * The native options of the physics imposter
  22644. */
  22645. nativeOptions?: any;
  22646. /**
  22647. * Specifies if the parent should be ignored
  22648. */
  22649. ignoreParent?: boolean;
  22650. /**
  22651. * Specifies if bi-directional transformations should be disabled
  22652. */
  22653. disableBidirectionalTransformation?: boolean;
  22654. /**
  22655. * The pressure inside the physics imposter, soft object only
  22656. */
  22657. pressure?: number;
  22658. /**
  22659. * The stiffness the physics imposter, soft object only
  22660. */
  22661. stiffness?: number;
  22662. /**
  22663. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22664. */
  22665. velocityIterations?: number;
  22666. /**
  22667. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22668. */
  22669. positionIterations?: number;
  22670. /**
  22671. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22672. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22673. * Add to fix multiple points
  22674. */
  22675. fixedPoints?: number;
  22676. /**
  22677. * The collision margin around a soft object
  22678. */
  22679. margin?: number;
  22680. /**
  22681. * The collision margin around a soft object
  22682. */
  22683. damping?: number;
  22684. /**
  22685. * The path for a rope based on an extrusion
  22686. */
  22687. path?: any;
  22688. /**
  22689. * The shape of an extrusion used for a rope based on an extrusion
  22690. */
  22691. shape?: any;
  22692. }
  22693. /**
  22694. * Interface for a physics-enabled object
  22695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22696. */
  22697. export interface IPhysicsEnabledObject {
  22698. /**
  22699. * The position of the physics-enabled object
  22700. */
  22701. position: Vector3;
  22702. /**
  22703. * The rotation of the physics-enabled object
  22704. */
  22705. rotationQuaternion: Nullable<Quaternion>;
  22706. /**
  22707. * The scale of the physics-enabled object
  22708. */
  22709. scaling: Vector3;
  22710. /**
  22711. * The rotation of the physics-enabled object
  22712. */
  22713. rotation?: Vector3;
  22714. /**
  22715. * The parent of the physics-enabled object
  22716. */
  22717. parent?: any;
  22718. /**
  22719. * The bounding info of the physics-enabled object
  22720. * @returns The bounding info of the physics-enabled object
  22721. */
  22722. getBoundingInfo(): BoundingInfo;
  22723. /**
  22724. * Computes the world matrix
  22725. * @param force Specifies if the world matrix should be computed by force
  22726. * @returns A world matrix
  22727. */
  22728. computeWorldMatrix(force: boolean): Matrix;
  22729. /**
  22730. * Gets the world matrix
  22731. * @returns A world matrix
  22732. */
  22733. getWorldMatrix?(): Matrix;
  22734. /**
  22735. * Gets the child meshes
  22736. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22737. * @returns An array of abstract meshes
  22738. */
  22739. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22740. /**
  22741. * Gets the vertex data
  22742. * @param kind The type of vertex data
  22743. * @returns A nullable array of numbers, or a float32 array
  22744. */
  22745. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22746. /**
  22747. * Gets the indices from the mesh
  22748. * @returns A nullable array of index arrays
  22749. */
  22750. getIndices?(): Nullable<IndicesArray>;
  22751. /**
  22752. * Gets the scene from the mesh
  22753. * @returns the indices array or null
  22754. */
  22755. getScene?(): Scene;
  22756. /**
  22757. * Gets the absolute position from the mesh
  22758. * @returns the absolute position
  22759. */
  22760. getAbsolutePosition(): Vector3;
  22761. /**
  22762. * Gets the absolute pivot point from the mesh
  22763. * @returns the absolute pivot point
  22764. */
  22765. getAbsolutePivotPoint(): Vector3;
  22766. /**
  22767. * Rotates the mesh
  22768. * @param axis The axis of rotation
  22769. * @param amount The amount of rotation
  22770. * @param space The space of the rotation
  22771. * @returns The rotation transform node
  22772. */
  22773. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22774. /**
  22775. * Translates the mesh
  22776. * @param axis The axis of translation
  22777. * @param distance The distance of translation
  22778. * @param space The space of the translation
  22779. * @returns The transform node
  22780. */
  22781. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22782. /**
  22783. * Sets the absolute position of the mesh
  22784. * @param absolutePosition The absolute position of the mesh
  22785. * @returns The transform node
  22786. */
  22787. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22788. /**
  22789. * Gets the class name of the mesh
  22790. * @returns The class name
  22791. */
  22792. getClassName(): string;
  22793. }
  22794. /**
  22795. * Represents a physics imposter
  22796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22797. */
  22798. export class PhysicsImpostor {
  22799. /**
  22800. * The physics-enabled object used as the physics imposter
  22801. */
  22802. object: IPhysicsEnabledObject;
  22803. /**
  22804. * The type of the physics imposter
  22805. */
  22806. type: number;
  22807. private _options;
  22808. private _scene?;
  22809. /**
  22810. * The default object size of the imposter
  22811. */
  22812. static DEFAULT_OBJECT_SIZE: Vector3;
  22813. /**
  22814. * The identity quaternion of the imposter
  22815. */
  22816. static IDENTITY_QUATERNION: Quaternion;
  22817. /** @hidden */ private _pluginData: any;
  22818. private _physicsEngine;
  22819. private _physicsBody;
  22820. private _bodyUpdateRequired;
  22821. private _onBeforePhysicsStepCallbacks;
  22822. private _onAfterPhysicsStepCallbacks;
  22823. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22824. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22825. otherImpostors: Array<PhysicsImpostor>;
  22826. }>;
  22827. private _deltaPosition;
  22828. private _deltaRotation;
  22829. private _deltaRotationConjugated;
  22830. /** @hidden */ private _isFromLine: boolean;
  22831. private _parent;
  22832. private _isDisposed;
  22833. private static _tmpVecs;
  22834. private static _tmpQuat;
  22835. /**
  22836. * Specifies if the physics imposter is disposed
  22837. */
  22838. readonly isDisposed: boolean;
  22839. /**
  22840. * Gets the mass of the physics imposter
  22841. */
  22842. mass: number;
  22843. /**
  22844. * Gets the coefficient of friction
  22845. */
  22846. /**
  22847. * Sets the coefficient of friction
  22848. */
  22849. friction: number;
  22850. /**
  22851. * Gets the coefficient of restitution
  22852. */
  22853. /**
  22854. * Sets the coefficient of restitution
  22855. */
  22856. restitution: number;
  22857. /**
  22858. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22859. */
  22860. /**
  22861. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22862. */
  22863. pressure: number;
  22864. /**
  22865. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22866. */
  22867. /**
  22868. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22869. */
  22870. stiffness: number;
  22871. /**
  22872. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22873. */
  22874. /**
  22875. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22876. */
  22877. velocityIterations: number;
  22878. /**
  22879. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22880. */
  22881. /**
  22882. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22883. */
  22884. positionIterations: number;
  22885. /**
  22886. * The unique id of the physics imposter
  22887. * set by the physics engine when adding this impostor to the array
  22888. */
  22889. uniqueId: number;
  22890. /**
  22891. * @hidden
  22892. */
  22893. soft: boolean;
  22894. /**
  22895. * @hidden
  22896. */
  22897. segments: number;
  22898. private _joints;
  22899. /**
  22900. * Initializes the physics imposter
  22901. * @param object The physics-enabled object used as the physics imposter
  22902. * @param type The type of the physics imposter
  22903. * @param _options The options for the physics imposter
  22904. * @param _scene The Babylon scene
  22905. */
  22906. constructor(
  22907. /**
  22908. * The physics-enabled object used as the physics imposter
  22909. */
  22910. object: IPhysicsEnabledObject,
  22911. /**
  22912. * The type of the physics imposter
  22913. */
  22914. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22915. /**
  22916. * This function will completly initialize this impostor.
  22917. * It will create a new body - but only if this mesh has no parent.
  22918. * If it has, this impostor will not be used other than to define the impostor
  22919. * of the child mesh.
  22920. * @hidden
  22921. */ private _init(): void;
  22922. private _getPhysicsParent;
  22923. /**
  22924. * Should a new body be generated.
  22925. * @returns boolean specifying if body initialization is required
  22926. */
  22927. isBodyInitRequired(): boolean;
  22928. /**
  22929. * Sets the updated scaling
  22930. * @param updated Specifies if the scaling is updated
  22931. */
  22932. setScalingUpdated(): void;
  22933. /**
  22934. * Force a regeneration of this or the parent's impostor's body.
  22935. * Use under cautious - This will remove all joints already implemented.
  22936. */
  22937. forceUpdate(): void;
  22938. /**
  22939. * Gets the body that holds this impostor. Either its own, or its parent.
  22940. */
  22941. /**
  22942. * Set the physics body. Used mainly by the physics engine/plugin
  22943. */
  22944. physicsBody: any;
  22945. /**
  22946. * Get the parent of the physics imposter
  22947. * @returns Physics imposter or null
  22948. */
  22949. /**
  22950. * Sets the parent of the physics imposter
  22951. */
  22952. parent: Nullable<PhysicsImpostor>;
  22953. /**
  22954. * Resets the update flags
  22955. */
  22956. resetUpdateFlags(): void;
  22957. /**
  22958. * Gets the object extend size
  22959. * @returns the object extend size
  22960. */
  22961. getObjectExtendSize(): Vector3;
  22962. /**
  22963. * Gets the object center
  22964. * @returns The object center
  22965. */
  22966. getObjectCenter(): Vector3;
  22967. /**
  22968. * Get a specific parametes from the options parameter
  22969. * @param paramName The object parameter name
  22970. * @returns The object parameter
  22971. */
  22972. getParam(paramName: string): any;
  22973. /**
  22974. * Sets a specific parameter in the options given to the physics plugin
  22975. * @param paramName The parameter name
  22976. * @param value The value of the parameter
  22977. */
  22978. setParam(paramName: string, value: number): void;
  22979. /**
  22980. * Specifically change the body's mass option. Won't recreate the physics body object
  22981. * @param mass The mass of the physics imposter
  22982. */
  22983. setMass(mass: number): void;
  22984. /**
  22985. * Gets the linear velocity
  22986. * @returns linear velocity or null
  22987. */
  22988. getLinearVelocity(): Nullable<Vector3>;
  22989. /**
  22990. * Sets the linear velocity
  22991. * @param velocity linear velocity or null
  22992. */
  22993. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22994. /**
  22995. * Gets the angular velocity
  22996. * @returns angular velocity or null
  22997. */
  22998. getAngularVelocity(): Nullable<Vector3>;
  22999. /**
  23000. * Sets the angular velocity
  23001. * @param velocity The velocity or null
  23002. */
  23003. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23004. /**
  23005. * Execute a function with the physics plugin native code
  23006. * Provide a function the will have two variables - the world object and the physics body object
  23007. * @param func The function to execute with the physics plugin native code
  23008. */
  23009. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23010. /**
  23011. * Register a function that will be executed before the physics world is stepping forward
  23012. * @param func The function to execute before the physics world is stepped forward
  23013. */
  23014. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23015. /**
  23016. * Unregister a function that will be executed before the physics world is stepping forward
  23017. * @param func The function to execute before the physics world is stepped forward
  23018. */
  23019. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23020. /**
  23021. * Register a function that will be executed after the physics step
  23022. * @param func The function to execute after physics step
  23023. */
  23024. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23025. /**
  23026. * Unregisters a function that will be executed after the physics step
  23027. * @param func The function to execute after physics step
  23028. */
  23029. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23030. /**
  23031. * register a function that will be executed when this impostor collides against a different body
  23032. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23033. * @param func Callback that is executed on collision
  23034. */
  23035. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23036. /**
  23037. * Unregisters the physics imposter on contact
  23038. * @param collideAgainst The physics object to collide against
  23039. * @param func Callback to execute on collision
  23040. */
  23041. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23042. private _tmpQuat;
  23043. private _tmpQuat2;
  23044. /**
  23045. * Get the parent rotation
  23046. * @returns The parent rotation
  23047. */
  23048. getParentsRotation(): Quaternion;
  23049. /**
  23050. * this function is executed by the physics engine.
  23051. */
  23052. beforeStep: () => void;
  23053. /**
  23054. * this function is executed by the physics engine
  23055. */
  23056. afterStep: () => void;
  23057. /**
  23058. * Legacy collision detection event support
  23059. */
  23060. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23061. /**
  23062. * event and body object due to cannon's event-based architecture.
  23063. */
  23064. onCollide: (e: {
  23065. body: any;
  23066. }) => void;
  23067. /**
  23068. * Apply a force
  23069. * @param force The force to apply
  23070. * @param contactPoint The contact point for the force
  23071. * @returns The physics imposter
  23072. */
  23073. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23074. /**
  23075. * Apply an impulse
  23076. * @param force The impulse force
  23077. * @param contactPoint The contact point for the impulse force
  23078. * @returns The physics imposter
  23079. */
  23080. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23081. /**
  23082. * A help function to create a joint
  23083. * @param otherImpostor A physics imposter used to create a joint
  23084. * @param jointType The type of joint
  23085. * @param jointData The data for the joint
  23086. * @returns The physics imposter
  23087. */
  23088. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23089. /**
  23090. * Add a joint to this impostor with a different impostor
  23091. * @param otherImpostor A physics imposter used to add a joint
  23092. * @param joint The joint to add
  23093. * @returns The physics imposter
  23094. */
  23095. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23096. /**
  23097. * Add an anchor to a cloth impostor
  23098. * @param otherImpostor rigid impostor to anchor to
  23099. * @param width ratio across width from 0 to 1
  23100. * @param height ratio up height from 0 to 1
  23101. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23102. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23103. * @returns impostor the soft imposter
  23104. */
  23105. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23106. /**
  23107. * Add a hook to a rope impostor
  23108. * @param otherImpostor rigid impostor to anchor to
  23109. * @param length ratio across rope from 0 to 1
  23110. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23111. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23112. * @returns impostor the rope imposter
  23113. */
  23114. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23115. /**
  23116. * Will keep this body still, in a sleep mode.
  23117. * @returns the physics imposter
  23118. */
  23119. sleep(): PhysicsImpostor;
  23120. /**
  23121. * Wake the body up.
  23122. * @returns The physics imposter
  23123. */
  23124. wakeUp(): PhysicsImpostor;
  23125. /**
  23126. * Clones the physics imposter
  23127. * @param newObject The physics imposter clones to this physics-enabled object
  23128. * @returns A nullable physics imposter
  23129. */
  23130. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23131. /**
  23132. * Disposes the physics imposter
  23133. */
  23134. dispose(): void;
  23135. /**
  23136. * Sets the delta position
  23137. * @param position The delta position amount
  23138. */
  23139. setDeltaPosition(position: Vector3): void;
  23140. /**
  23141. * Sets the delta rotation
  23142. * @param rotation The delta rotation amount
  23143. */
  23144. setDeltaRotation(rotation: Quaternion): void;
  23145. /**
  23146. * Gets the box size of the physics imposter and stores the result in the input parameter
  23147. * @param result Stores the box size
  23148. * @returns The physics imposter
  23149. */
  23150. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23151. /**
  23152. * Gets the radius of the physics imposter
  23153. * @returns Radius of the physics imposter
  23154. */
  23155. getRadius(): number;
  23156. /**
  23157. * Sync a bone with this impostor
  23158. * @param bone The bone to sync to the impostor.
  23159. * @param boneMesh The mesh that the bone is influencing.
  23160. * @param jointPivot The pivot of the joint / bone in local space.
  23161. * @param distToJoint Optional distance from the impostor to the joint.
  23162. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23163. */
  23164. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23165. /**
  23166. * Sync impostor to a bone
  23167. * @param bone The bone that the impostor will be synced to.
  23168. * @param boneMesh The mesh that the bone is influencing.
  23169. * @param jointPivot The pivot of the joint / bone in local space.
  23170. * @param distToJoint Optional distance from the impostor to the joint.
  23171. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23172. * @param boneAxis Optional vector3 axis the bone is aligned with
  23173. */
  23174. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23175. /**
  23176. * No-Imposter type
  23177. */
  23178. static NoImpostor: number;
  23179. /**
  23180. * Sphere-Imposter type
  23181. */
  23182. static SphereImpostor: number;
  23183. /**
  23184. * Box-Imposter type
  23185. */
  23186. static BoxImpostor: number;
  23187. /**
  23188. * Plane-Imposter type
  23189. */
  23190. static PlaneImpostor: number;
  23191. /**
  23192. * Mesh-imposter type
  23193. */
  23194. static MeshImpostor: number;
  23195. /**
  23196. * Capsule-Impostor type (Ammo.js plugin only)
  23197. */
  23198. static CapsuleImpostor: number;
  23199. /**
  23200. * Cylinder-Imposter type
  23201. */
  23202. static CylinderImpostor: number;
  23203. /**
  23204. * Particle-Imposter type
  23205. */
  23206. static ParticleImpostor: number;
  23207. /**
  23208. * Heightmap-Imposter type
  23209. */
  23210. static HeightmapImpostor: number;
  23211. /**
  23212. * ConvexHull-Impostor type (Ammo.js plugin only)
  23213. */
  23214. static ConvexHullImpostor: number;
  23215. /**
  23216. * Rope-Imposter type
  23217. */
  23218. static RopeImpostor: number;
  23219. /**
  23220. * Cloth-Imposter type
  23221. */
  23222. static ClothImpostor: number;
  23223. /**
  23224. * Softbody-Imposter type
  23225. */
  23226. static SoftbodyImpostor: number;
  23227. }
  23228. }
  23229. declare module BABYLON {
  23230. /**
  23231. * @hidden
  23232. **/
  23233. export class _CreationDataStorage {
  23234. closePath?: boolean;
  23235. closeArray?: boolean;
  23236. idx: number[];
  23237. dashSize: number;
  23238. gapSize: number;
  23239. path3D: Path3D;
  23240. pathArray: Vector3[][];
  23241. arc: number;
  23242. radius: number;
  23243. cap: number;
  23244. tessellation: number;
  23245. }
  23246. /**
  23247. * @hidden
  23248. **/ private class _InstanceDataStorage {
  23249. visibleInstances: any;
  23250. batchCache: _InstancesBatch;
  23251. instancesBufferSize: number;
  23252. instancesBuffer: Nullable<Buffer>;
  23253. instancesData: Float32Array;
  23254. overridenInstanceCount: number;
  23255. isFrozen: boolean;
  23256. previousBatch: Nullable<_InstancesBatch>;
  23257. hardwareInstancedRendering: boolean;
  23258. sideOrientation: number;
  23259. }
  23260. /**
  23261. * @hidden
  23262. **/
  23263. export class _InstancesBatch {
  23264. mustReturn: boolean;
  23265. visibleInstances: Nullable<InstancedMesh[]>[];
  23266. renderSelf: boolean[];
  23267. hardwareInstancedRendering: boolean[];
  23268. }
  23269. /**
  23270. * Class used to represent renderable models
  23271. */
  23272. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23273. /**
  23274. * Mesh side orientation : usually the external or front surface
  23275. */
  23276. static readonly FRONTSIDE: number;
  23277. /**
  23278. * Mesh side orientation : usually the internal or back surface
  23279. */
  23280. static readonly BACKSIDE: number;
  23281. /**
  23282. * Mesh side orientation : both internal and external or front and back surfaces
  23283. */
  23284. static readonly DOUBLESIDE: number;
  23285. /**
  23286. * Mesh side orientation : by default, `FRONTSIDE`
  23287. */
  23288. static readonly DEFAULTSIDE: number;
  23289. /**
  23290. * Mesh cap setting : no cap
  23291. */
  23292. static readonly NO_CAP: number;
  23293. /**
  23294. * Mesh cap setting : one cap at the beginning of the mesh
  23295. */
  23296. static readonly CAP_START: number;
  23297. /**
  23298. * Mesh cap setting : one cap at the end of the mesh
  23299. */
  23300. static readonly CAP_END: number;
  23301. /**
  23302. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23303. */
  23304. static readonly CAP_ALL: number;
  23305. /**
  23306. * Mesh pattern setting : no flip or rotate
  23307. */
  23308. static readonly NO_FLIP: number;
  23309. /**
  23310. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23311. */
  23312. static readonly FLIP_TILE: number;
  23313. /**
  23314. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23315. */
  23316. static readonly ROTATE_TILE: number;
  23317. /**
  23318. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23319. */
  23320. static readonly FLIP_ROW: number;
  23321. /**
  23322. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23323. */
  23324. static readonly ROTATE_ROW: number;
  23325. /**
  23326. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23327. */
  23328. static readonly FLIP_N_ROTATE_TILE: number;
  23329. /**
  23330. * Mesh pattern setting : rotate pattern and rotate
  23331. */
  23332. static readonly FLIP_N_ROTATE_ROW: number;
  23333. /**
  23334. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23335. */
  23336. static readonly CENTER: number;
  23337. /**
  23338. * Mesh tile positioning : part tiles on left
  23339. */
  23340. static readonly LEFT: number;
  23341. /**
  23342. * Mesh tile positioning : part tiles on right
  23343. */
  23344. static readonly RIGHT: number;
  23345. /**
  23346. * Mesh tile positioning : part tiles on top
  23347. */
  23348. static readonly TOP: number;
  23349. /**
  23350. * Mesh tile positioning : part tiles on bottom
  23351. */
  23352. static readonly BOTTOM: number;
  23353. /**
  23354. * Gets the default side orientation.
  23355. * @param orientation the orientation to value to attempt to get
  23356. * @returns the default orientation
  23357. * @hidden
  23358. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23359. private _internalMeshDataInfo;
  23360. /**
  23361. * An event triggered before rendering the mesh
  23362. */
  23363. readonly onBeforeRenderObservable: Observable<Mesh>;
  23364. /**
  23365. * An event triggered before binding the mesh
  23366. */
  23367. readonly onBeforeBindObservable: Observable<Mesh>;
  23368. /**
  23369. * An event triggered after rendering the mesh
  23370. */
  23371. readonly onAfterRenderObservable: Observable<Mesh>;
  23372. /**
  23373. * An event triggered before drawing the mesh
  23374. */
  23375. readonly onBeforeDrawObservable: Observable<Mesh>;
  23376. private _onBeforeDrawObserver;
  23377. /**
  23378. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23379. */
  23380. onBeforeDraw: () => void;
  23381. readonly hasInstances: boolean;
  23382. /**
  23383. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23384. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23385. */
  23386. delayLoadState: number;
  23387. /**
  23388. * Gets the list of instances created from this mesh
  23389. * it is not supposed to be modified manually.
  23390. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23391. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23392. */
  23393. instances: InstancedMesh[];
  23394. /**
  23395. * Gets the file containing delay loading data for this mesh
  23396. */
  23397. delayLoadingFile: string;
  23398. /** @hidden */ private _binaryInfo: any;
  23399. /**
  23400. * User defined function used to change how LOD level selection is done
  23401. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23402. */
  23403. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23404. /**
  23405. * Gets or sets the morph target manager
  23406. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23407. */
  23408. morphTargetManager: Nullable<MorphTargetManager>;
  23409. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23410. /** @hidden */ private _geometry: Nullable<Geometry>;
  23411. /** @hidden */ private _delayInfo: Array<string>;
  23412. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23413. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23414. private _effectiveMaterial;
  23415. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23416. /** @hidden */ private _originalBuilderSideOrientation: number;
  23417. /**
  23418. * Use this property to change the original side orientation defined at construction time
  23419. */
  23420. overrideMaterialSideOrientation: Nullable<number>;
  23421. /**
  23422. * Gets the source mesh (the one used to clone this one from)
  23423. */
  23424. readonly source: Nullable<Mesh>;
  23425. /**
  23426. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23427. */
  23428. isUnIndexed: boolean;
  23429. /**
  23430. * @constructor
  23431. * @param name The value used by scene.getMeshByName() to do a lookup.
  23432. * @param scene The scene to add this mesh to.
  23433. * @param parent The parent of this mesh, if it has one
  23434. * @param source An optional Mesh from which geometry is shared, cloned.
  23435. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23436. * When false, achieved by calling a clone(), also passing False.
  23437. * This will make creation of children, recursive.
  23438. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23439. */
  23440. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23441. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  23442. doNotInstantiate: boolean;
  23443. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  23444. /**
  23445. * Gets the class name
  23446. * @returns the string "Mesh".
  23447. */
  23448. getClassName(): string;
  23449. /** @hidden */ protected readonly _isMesh: boolean;
  23450. /**
  23451. * Returns a description of this mesh
  23452. * @param fullDetails define if full details about this mesh must be used
  23453. * @returns a descriptive string representing this mesh
  23454. */
  23455. toString(fullDetails?: boolean): string;
  23456. /** @hidden */ private _unBindEffect(): void;
  23457. /**
  23458. * Gets a boolean indicating if this mesh has LOD
  23459. */
  23460. readonly hasLODLevels: boolean;
  23461. /**
  23462. * Gets the list of MeshLODLevel associated with the current mesh
  23463. * @returns an array of MeshLODLevel
  23464. */
  23465. getLODLevels(): MeshLODLevel[];
  23466. private _sortLODLevels;
  23467. /**
  23468. * Add a mesh as LOD level triggered at the given distance.
  23469. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23470. * @param distance The distance from the center of the object to show this level
  23471. * @param mesh The mesh to be added as LOD level (can be null)
  23472. * @return This mesh (for chaining)
  23473. */
  23474. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23475. /**
  23476. * Returns the LOD level mesh at the passed distance or null if not found.
  23477. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23478. * @param distance The distance from the center of the object to show this level
  23479. * @returns a Mesh or `null`
  23480. */
  23481. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23482. /**
  23483. * Remove a mesh from the LOD array
  23484. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23485. * @param mesh defines the mesh to be removed
  23486. * @return This mesh (for chaining)
  23487. */
  23488. removeLODLevel(mesh: Mesh): Mesh;
  23489. /**
  23490. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23491. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23492. * @param camera defines the camera to use to compute distance
  23493. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23494. * @return This mesh (for chaining)
  23495. */
  23496. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23497. /**
  23498. * Gets the mesh internal Geometry object
  23499. */
  23500. readonly geometry: Nullable<Geometry>;
  23501. /**
  23502. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23503. * @returns the total number of vertices
  23504. */
  23505. getTotalVertices(): number;
  23506. /**
  23507. * Returns the content of an associated vertex buffer
  23508. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23509. * - VertexBuffer.PositionKind
  23510. * - VertexBuffer.UVKind
  23511. * - VertexBuffer.UV2Kind
  23512. * - VertexBuffer.UV3Kind
  23513. * - VertexBuffer.UV4Kind
  23514. * - VertexBuffer.UV5Kind
  23515. * - VertexBuffer.UV6Kind
  23516. * - VertexBuffer.ColorKind
  23517. * - VertexBuffer.MatricesIndicesKind
  23518. * - VertexBuffer.MatricesIndicesExtraKind
  23519. * - VertexBuffer.MatricesWeightsKind
  23520. * - VertexBuffer.MatricesWeightsExtraKind
  23521. * @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
  23522. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23523. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23524. */
  23525. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23526. /**
  23527. * Returns the mesh VertexBuffer object from the requested `kind`
  23528. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23529. * - VertexBuffer.PositionKind
  23530. * - VertexBuffer.NormalKind
  23531. * - VertexBuffer.UVKind
  23532. * - VertexBuffer.UV2Kind
  23533. * - VertexBuffer.UV3Kind
  23534. * - VertexBuffer.UV4Kind
  23535. * - VertexBuffer.UV5Kind
  23536. * - VertexBuffer.UV6Kind
  23537. * - VertexBuffer.ColorKind
  23538. * - VertexBuffer.MatricesIndicesKind
  23539. * - VertexBuffer.MatricesIndicesExtraKind
  23540. * - VertexBuffer.MatricesWeightsKind
  23541. * - VertexBuffer.MatricesWeightsExtraKind
  23542. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23543. */
  23544. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23545. /**
  23546. * Tests if a specific vertex buffer is associated with this mesh
  23547. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23548. * - VertexBuffer.PositionKind
  23549. * - VertexBuffer.NormalKind
  23550. * - VertexBuffer.UVKind
  23551. * - VertexBuffer.UV2Kind
  23552. * - VertexBuffer.UV3Kind
  23553. * - VertexBuffer.UV4Kind
  23554. * - VertexBuffer.UV5Kind
  23555. * - VertexBuffer.UV6Kind
  23556. * - VertexBuffer.ColorKind
  23557. * - VertexBuffer.MatricesIndicesKind
  23558. * - VertexBuffer.MatricesIndicesExtraKind
  23559. * - VertexBuffer.MatricesWeightsKind
  23560. * - VertexBuffer.MatricesWeightsExtraKind
  23561. * @returns a boolean
  23562. */
  23563. isVerticesDataPresent(kind: string): boolean;
  23564. /**
  23565. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23566. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23567. * - VertexBuffer.PositionKind
  23568. * - VertexBuffer.UVKind
  23569. * - VertexBuffer.UV2Kind
  23570. * - VertexBuffer.UV3Kind
  23571. * - VertexBuffer.UV4Kind
  23572. * - VertexBuffer.UV5Kind
  23573. * - VertexBuffer.UV6Kind
  23574. * - VertexBuffer.ColorKind
  23575. * - VertexBuffer.MatricesIndicesKind
  23576. * - VertexBuffer.MatricesIndicesExtraKind
  23577. * - VertexBuffer.MatricesWeightsKind
  23578. * - VertexBuffer.MatricesWeightsExtraKind
  23579. * @returns a boolean
  23580. */
  23581. isVertexBufferUpdatable(kind: string): boolean;
  23582. /**
  23583. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23584. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23585. * - VertexBuffer.PositionKind
  23586. * - VertexBuffer.NormalKind
  23587. * - VertexBuffer.UVKind
  23588. * - VertexBuffer.UV2Kind
  23589. * - VertexBuffer.UV3Kind
  23590. * - VertexBuffer.UV4Kind
  23591. * - VertexBuffer.UV5Kind
  23592. * - VertexBuffer.UV6Kind
  23593. * - VertexBuffer.ColorKind
  23594. * - VertexBuffer.MatricesIndicesKind
  23595. * - VertexBuffer.MatricesIndicesExtraKind
  23596. * - VertexBuffer.MatricesWeightsKind
  23597. * - VertexBuffer.MatricesWeightsExtraKind
  23598. * @returns an array of strings
  23599. */
  23600. getVerticesDataKinds(): string[];
  23601. /**
  23602. * Returns a positive integer : the total number of indices in this mesh geometry.
  23603. * @returns the numner of indices or zero if the mesh has no geometry.
  23604. */
  23605. getTotalIndices(): number;
  23606. /**
  23607. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23608. * @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.
  23609. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23610. * @returns the indices array or an empty array if the mesh has no geometry
  23611. */
  23612. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23613. readonly isBlocked: boolean;
  23614. /**
  23615. * Determine if the current mesh is ready to be rendered
  23616. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23617. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23618. * @returns true if all associated assets are ready (material, textures, shaders)
  23619. */
  23620. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23621. /**
  23622. * 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.
  23623. */
  23624. readonly areNormalsFrozen: boolean;
  23625. /**
  23626. * 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.
  23627. * @returns the current mesh
  23628. */
  23629. freezeNormals(): Mesh;
  23630. /**
  23631. * 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
  23632. * @returns the current mesh
  23633. */
  23634. unfreezeNormals(): Mesh;
  23635. /**
  23636. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23637. */
  23638. overridenInstanceCount: number;
  23639. /** @hidden */ private _preActivate(): Mesh;
  23640. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23641. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23642. /**
  23643. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23644. * This means the mesh underlying bounding box and sphere are recomputed.
  23645. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23646. * @returns the current mesh
  23647. */
  23648. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23649. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23650. /**
  23651. * This function will subdivide the mesh into multiple submeshes
  23652. * @param count defines the expected number of submeshes
  23653. */
  23654. subdivide(count: number): void;
  23655. /**
  23656. * Copy a FloatArray into a specific associated vertex buffer
  23657. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23658. * - VertexBuffer.PositionKind
  23659. * - VertexBuffer.UVKind
  23660. * - VertexBuffer.UV2Kind
  23661. * - VertexBuffer.UV3Kind
  23662. * - VertexBuffer.UV4Kind
  23663. * - VertexBuffer.UV5Kind
  23664. * - VertexBuffer.UV6Kind
  23665. * - VertexBuffer.ColorKind
  23666. * - VertexBuffer.MatricesIndicesKind
  23667. * - VertexBuffer.MatricesIndicesExtraKind
  23668. * - VertexBuffer.MatricesWeightsKind
  23669. * - VertexBuffer.MatricesWeightsExtraKind
  23670. * @param data defines the data source
  23671. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23672. * @param stride defines the data stride size (can be null)
  23673. * @returns the current mesh
  23674. */
  23675. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23676. /**
  23677. * Delete a vertex buffer associated with this mesh
  23678. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  23679. * - VertexBuffer.PositionKind
  23680. * - VertexBuffer.UVKind
  23681. * - VertexBuffer.UV2Kind
  23682. * - VertexBuffer.UV3Kind
  23683. * - VertexBuffer.UV4Kind
  23684. * - VertexBuffer.UV5Kind
  23685. * - VertexBuffer.UV6Kind
  23686. * - VertexBuffer.ColorKind
  23687. * - VertexBuffer.MatricesIndicesKind
  23688. * - VertexBuffer.MatricesIndicesExtraKind
  23689. * - VertexBuffer.MatricesWeightsKind
  23690. * - VertexBuffer.MatricesWeightsExtraKind
  23691. */
  23692. removeVerticesData(kind: string): void;
  23693. /**
  23694. * Flags an associated vertex buffer as updatable
  23695. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23696. * - VertexBuffer.PositionKind
  23697. * - VertexBuffer.UVKind
  23698. * - VertexBuffer.UV2Kind
  23699. * - VertexBuffer.UV3Kind
  23700. * - VertexBuffer.UV4Kind
  23701. * - VertexBuffer.UV5Kind
  23702. * - VertexBuffer.UV6Kind
  23703. * - VertexBuffer.ColorKind
  23704. * - VertexBuffer.MatricesIndicesKind
  23705. * - VertexBuffer.MatricesIndicesExtraKind
  23706. * - VertexBuffer.MatricesWeightsKind
  23707. * - VertexBuffer.MatricesWeightsExtraKind
  23708. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23709. */
  23710. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23711. /**
  23712. * Sets the mesh global Vertex Buffer
  23713. * @param buffer defines the buffer to use
  23714. * @returns the current mesh
  23715. */
  23716. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23717. /**
  23718. * Update a specific associated vertex buffer
  23719. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23720. * - VertexBuffer.PositionKind
  23721. * - VertexBuffer.UVKind
  23722. * - VertexBuffer.UV2Kind
  23723. * - VertexBuffer.UV3Kind
  23724. * - VertexBuffer.UV4Kind
  23725. * - VertexBuffer.UV5Kind
  23726. * - VertexBuffer.UV6Kind
  23727. * - VertexBuffer.ColorKind
  23728. * - VertexBuffer.MatricesIndicesKind
  23729. * - VertexBuffer.MatricesIndicesExtraKind
  23730. * - VertexBuffer.MatricesWeightsKind
  23731. * - VertexBuffer.MatricesWeightsExtraKind
  23732. * @param data defines the data source
  23733. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23734. * @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)
  23735. * @returns the current mesh
  23736. */
  23737. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23738. /**
  23739. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23740. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23741. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23742. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23743. * @returns the current mesh
  23744. */
  23745. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23746. /**
  23747. * Creates a un-shared specific occurence of the geometry for the mesh.
  23748. * @returns the current mesh
  23749. */
  23750. makeGeometryUnique(): Mesh;
  23751. /**
  23752. * Set the index buffer of this mesh
  23753. * @param indices defines the source data
  23754. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23755. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23756. * @returns the current mesh
  23757. */
  23758. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23759. /**
  23760. * Update the current index buffer
  23761. * @param indices defines the source data
  23762. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23763. * @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)
  23764. * @returns the current mesh
  23765. */
  23766. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23767. /**
  23768. * Invert the geometry to move from a right handed system to a left handed one.
  23769. * @returns the current mesh
  23770. */
  23771. toLeftHanded(): Mesh;
  23772. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23773. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23774. /**
  23775. * Registers for this mesh a javascript function called just before the rendering process
  23776. * @param func defines the function to call before rendering this mesh
  23777. * @returns the current mesh
  23778. */
  23779. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23780. /**
  23781. * Disposes a previously registered javascript function called before the rendering
  23782. * @param func defines the function to remove
  23783. * @returns the current mesh
  23784. */
  23785. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23786. /**
  23787. * Registers for this mesh a javascript function called just after the rendering is complete
  23788. * @param func defines the function to call after rendering this mesh
  23789. * @returns the current mesh
  23790. */
  23791. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23792. /**
  23793. * Disposes a previously registered javascript function called after the rendering.
  23794. * @param func defines the function to remove
  23795. * @returns the current mesh
  23796. */
  23797. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23798. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23799. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23800. /** @hidden */ private _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  23801. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23802. /** @hidden */ private _rebuild(): void;
  23803. /** @hidden */ private _freeze(): void;
  23804. /** @hidden */ private _unFreeze(): void;
  23805. /**
  23806. * 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
  23807. * @param subMesh defines the subMesh to render
  23808. * @param enableAlphaMode defines if alpha mode can be changed
  23809. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  23810. * @returns the current mesh
  23811. */
  23812. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  23813. private _onBeforeDraw;
  23814. /**
  23815. * Renormalize the mesh and patch it up if there are no weights
  23816. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23817. * However in the case of zero weights then we set just a single influence to 1.
  23818. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23819. */
  23820. cleanMatrixWeights(): void;
  23821. private normalizeSkinFourWeights;
  23822. private normalizeSkinWeightsAndExtra;
  23823. /**
  23824. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23825. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23826. * the user know there was an issue with importing the mesh
  23827. * @returns a validation object with skinned, valid and report string
  23828. */
  23829. validateSkinning(): {
  23830. skinned: boolean;
  23831. valid: boolean;
  23832. report: string;
  23833. };
  23834. /** @hidden */ private _checkDelayState(): Mesh;
  23835. private _queueLoad;
  23836. /**
  23837. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23838. * A mesh is in the frustum if its bounding box intersects the frustum
  23839. * @param frustumPlanes defines the frustum to test
  23840. * @returns true if the mesh is in the frustum planes
  23841. */
  23842. isInFrustum(frustumPlanes: Plane[]): boolean;
  23843. /**
  23844. * Sets the mesh material by the material or multiMaterial `id` property
  23845. * @param id is a string identifying the material or the multiMaterial
  23846. * @returns the current mesh
  23847. */
  23848. setMaterialByID(id: string): Mesh;
  23849. /**
  23850. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23851. * @returns an array of IAnimatable
  23852. */
  23853. getAnimatables(): IAnimatable[];
  23854. /**
  23855. * Modifies the mesh geometry according to the passed transformation matrix.
  23856. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23857. * The mesh normals are modified using the same transformation.
  23858. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23859. * @param transform defines the transform matrix to use
  23860. * @see http://doc.babylonjs.com/resources/baking_transformations
  23861. * @returns the current mesh
  23862. */
  23863. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23864. /**
  23865. * Modifies the mesh geometry according to its own current World Matrix.
  23866. * The mesh World Matrix is then reset.
  23867. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23868. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23869. * @see http://doc.babylonjs.com/resources/baking_transformations
  23870. * @returns the current mesh
  23871. */
  23872. bakeCurrentTransformIntoVertices(): Mesh;
  23873. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23874. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23875. /** @hidden */ private _generatePointsArray(): boolean;
  23876. /**
  23877. * Returns a new Mesh object generated from the current mesh properties.
  23878. * This method must not get confused with createInstance()
  23879. * @param name is a string, the name given to the new mesh
  23880. * @param newParent can be any Node object (default `null`)
  23881. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23882. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23883. * @returns a new mesh
  23884. */
  23885. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23886. /**
  23887. * Releases resources associated with this mesh.
  23888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23890. */
  23891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23892. /** @hidden */ private _disposeInstanceSpecificData(): void;
  23893. /**
  23894. * Modifies the mesh geometry according to a displacement map.
  23895. * 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.
  23896. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23897. * @param url is a string, the URL from the image file is to be downloaded.
  23898. * @param minHeight is the lower limit of the displacement.
  23899. * @param maxHeight is the upper limit of the displacement.
  23900. * @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.
  23901. * @param uvOffset is an optional vector2 used to offset UV.
  23902. * @param uvScale is an optional vector2 used to scale UV.
  23903. * @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.
  23904. * @returns the Mesh.
  23905. */
  23906. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23907. /**
  23908. * Modifies the mesh geometry according to a displacementMap buffer.
  23909. * 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.
  23910. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23911. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23912. * @param heightMapWidth is the width of the buffer image.
  23913. * @param heightMapHeight is the height of the buffer image.
  23914. * @param minHeight is the lower limit of the displacement.
  23915. * @param maxHeight is the upper limit of the displacement.
  23916. * @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.
  23917. * @param uvOffset is an optional vector2 used to offset UV.
  23918. * @param uvScale is an optional vector2 used to scale UV.
  23919. * @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.
  23920. * @returns the Mesh.
  23921. */
  23922. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23923. /**
  23924. * Modify the mesh to get a flat shading rendering.
  23925. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23926. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23927. * @returns current mesh
  23928. */
  23929. convertToFlatShadedMesh(): Mesh;
  23930. /**
  23931. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23932. * In other words, more vertices, no more indices and a single bigger VBO.
  23933. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23934. * @returns current mesh
  23935. */
  23936. convertToUnIndexedMesh(): Mesh;
  23937. /**
  23938. * Inverses facet orientations.
  23939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23940. * @param flipNormals will also inverts the normals
  23941. * @returns current mesh
  23942. */
  23943. flipFaces(flipNormals?: boolean): Mesh;
  23944. /**
  23945. * Increase the number of facets and hence vertices in a mesh
  23946. * Vertex normals are interpolated from existing vertex normals
  23947. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23948. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23949. */
  23950. increaseVertices(numberPerEdge: number): void;
  23951. /**
  23952. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23953. * This will undo any application of covertToFlatShadedMesh
  23954. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23955. */
  23956. forceSharedVertices(): void;
  23957. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23958. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23959. /**
  23960. * Creates a new InstancedMesh object from the mesh model.
  23961. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23962. * @param name defines the name of the new instance
  23963. * @returns a new InstancedMesh
  23964. */
  23965. createInstance(name: string): InstancedMesh;
  23966. /**
  23967. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23968. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23969. * @returns the current mesh
  23970. */
  23971. synchronizeInstances(): Mesh;
  23972. /**
  23973. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23974. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23975. * This should be used together with the simplification to avoid disappearing triangles.
  23976. * @param successCallback an optional success callback to be called after the optimization finished.
  23977. * @returns the current mesh
  23978. */
  23979. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23980. /**
  23981. * Serialize current mesh
  23982. * @param serializationObject defines the object which will receive the serialization data
  23983. */
  23984. serialize(serializationObject: any): void;
  23985. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23986. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23987. /**
  23988. * Returns a new Mesh object parsed from the source provided.
  23989. * @param parsedMesh is the source
  23990. * @param scene defines the hosting scene
  23991. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23992. * @returns a new Mesh
  23993. */
  23994. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23995. /**
  23996. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23997. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23998. * @param name defines the name of the mesh to create
  23999. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24000. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24001. * @param closePath creates a seam between the first and the last points of each path of the path array
  24002. * @param offset is taken in account only if the `pathArray` is containing a single path
  24003. * @param scene defines the hosting scene
  24004. * @param updatable defines if the mesh must be flagged as updatable
  24005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24006. * @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)
  24007. * @returns a new Mesh
  24008. */
  24009. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24010. /**
  24011. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24012. * @param name defines the name of the mesh to create
  24013. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24014. * @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
  24015. * @param scene defines the hosting scene
  24016. * @param updatable defines if the mesh must be flagged as updatable
  24017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24018. * @returns a new Mesh
  24019. */
  24020. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24021. /**
  24022. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24023. * @param name defines the name of the mesh to create
  24024. * @param size sets the size (float) of each box side (default 1)
  24025. * @param scene defines the hosting scene
  24026. * @param updatable defines if the mesh must be flagged as updatable
  24027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24028. * @returns a new Mesh
  24029. */
  24030. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24031. /**
  24032. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24033. * @param name defines the name of the mesh to create
  24034. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24035. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24036. * @param scene defines the hosting scene
  24037. * @param updatable defines if the mesh must be flagged as updatable
  24038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24039. * @returns a new Mesh
  24040. */
  24041. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24042. /**
  24043. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24044. * @param name defines the name of the mesh to create
  24045. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24046. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24047. * @param scene defines the hosting scene
  24048. * @returns a new Mesh
  24049. */
  24050. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24051. /**
  24052. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24053. * @param name defines the name of the mesh to create
  24054. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24055. * @param diameterTop set the top cap diameter (floats, default 1)
  24056. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24057. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24058. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24059. * @param scene defines the hosting scene
  24060. * @param updatable defines if the mesh must be flagged as updatable
  24061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24062. * @returns a new Mesh
  24063. */
  24064. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24065. /**
  24066. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24067. * @param name defines the name of the mesh to create
  24068. * @param diameter sets the diameter size (float) of the torus (default 1)
  24069. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24070. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24071. * @param scene defines the hosting scene
  24072. * @param updatable defines if the mesh must be flagged as updatable
  24073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24074. * @returns a new Mesh
  24075. */
  24076. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24077. /**
  24078. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24079. * @param name defines the name of the mesh to create
  24080. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24081. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24082. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24083. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24084. * @param p the number of windings on X axis (positive integers, default 2)
  24085. * @param q the number of windings on Y axis (positive integers, default 3)
  24086. * @param scene defines the hosting scene
  24087. * @param updatable defines if the mesh must be flagged as updatable
  24088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24089. * @returns a new Mesh
  24090. */
  24091. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24092. /**
  24093. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24094. * @param name defines the name of the mesh to create
  24095. * @param points is an array successive Vector3
  24096. * @param scene defines the hosting scene
  24097. * @param updatable defines if the mesh must be flagged as updatable
  24098. * @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).
  24099. * @returns a new Mesh
  24100. */
  24101. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24102. /**
  24103. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24104. * @param name defines the name of the mesh to create
  24105. * @param points is an array successive Vector3
  24106. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24107. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24108. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24109. * @param scene defines the hosting scene
  24110. * @param updatable defines if the mesh must be flagged as updatable
  24111. * @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)
  24112. * @returns a new Mesh
  24113. */
  24114. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24115. /**
  24116. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24117. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24118. * 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.
  24119. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24120. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24121. * Remember you can only change the shape positions, not their number when updating a polygon.
  24122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24123. * @param name defines the name of the mesh to create
  24124. * @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
  24125. * @param scene defines the hosting scene
  24126. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24127. * @param updatable defines if the mesh must be flagged as updatable
  24128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24129. * @param earcutInjection can be used to inject your own earcut reference
  24130. * @returns a new Mesh
  24131. */
  24132. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24133. /**
  24134. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24135. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24136. * @param name defines the name of the mesh to create
  24137. * @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
  24138. * @param depth defines the height of extrusion
  24139. * @param scene defines the hosting scene
  24140. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24141. * @param updatable defines if the mesh must be flagged as updatable
  24142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24143. * @param earcutInjection can be used to inject your own earcut reference
  24144. * @returns a new Mesh
  24145. */
  24146. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24147. /**
  24148. * Creates an extruded shape mesh.
  24149. * 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
  24150. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24151. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24152. * @param name defines the name of the mesh to create
  24153. * @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
  24154. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24155. * @param scale is the value to scale the shape
  24156. * @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
  24157. * @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
  24158. * @param scene defines the hosting scene
  24159. * @param updatable defines if the mesh must be flagged as updatable
  24160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24161. * @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)
  24162. * @returns a new Mesh
  24163. */
  24164. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24165. /**
  24166. * Creates an custom extruded shape mesh.
  24167. * The custom extrusion is a parametric shape.
  24168. * It has no predefined shape. Its final shape will depend on the input parameters.
  24169. * Please consider using the same method from the MeshBuilder class instead
  24170. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24171. * @param name defines the name of the mesh to create
  24172. * @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
  24173. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24174. * @param scaleFunction is a custom Javascript function called on each path point
  24175. * @param rotationFunction is a custom Javascript function called on each path point
  24176. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24177. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24178. * @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
  24179. * @param scene defines the hosting scene
  24180. * @param updatable defines if the mesh must be flagged as updatable
  24181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24182. * @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)
  24183. * @returns a new Mesh
  24184. */
  24185. 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;
  24186. /**
  24187. * Creates lathe mesh.
  24188. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24189. * Please consider using the same method from the MeshBuilder class instead
  24190. * @param name defines the name of the mesh to create
  24191. * @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
  24192. * @param radius is the radius value of the lathe
  24193. * @param tessellation is the side number of the lathe.
  24194. * @param scene defines the hosting scene
  24195. * @param updatable defines if the mesh must be flagged as updatable
  24196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24197. * @returns a new Mesh
  24198. */
  24199. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24200. /**
  24201. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24202. * @param name defines the name of the mesh to create
  24203. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24204. * @param scene defines the hosting scene
  24205. * @param updatable defines if the mesh must be flagged as updatable
  24206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24207. * @returns a new Mesh
  24208. */
  24209. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24210. /**
  24211. * Creates a ground mesh.
  24212. * Please consider using the same method from the MeshBuilder class instead
  24213. * @param name defines the name of the mesh to create
  24214. * @param width set the width of the ground
  24215. * @param height set the height of the ground
  24216. * @param subdivisions sets the number of subdivisions per side
  24217. * @param scene defines the hosting scene
  24218. * @param updatable defines if the mesh must be flagged as updatable
  24219. * @returns a new Mesh
  24220. */
  24221. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24222. /**
  24223. * Creates a tiled ground mesh.
  24224. * Please consider using the same method from the MeshBuilder class instead
  24225. * @param name defines the name of the mesh to create
  24226. * @param xmin set the ground minimum X coordinate
  24227. * @param zmin set the ground minimum Y coordinate
  24228. * @param xmax set the ground maximum X coordinate
  24229. * @param zmax set the ground maximum Z coordinate
  24230. * @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
  24231. * @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
  24232. * @param scene defines the hosting scene
  24233. * @param updatable defines if the mesh must be flagged as updatable
  24234. * @returns a new Mesh
  24235. */
  24236. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24237. w: number;
  24238. h: number;
  24239. }, precision: {
  24240. w: number;
  24241. h: number;
  24242. }, scene: Scene, updatable?: boolean): Mesh;
  24243. /**
  24244. * Creates a ground mesh from a height map.
  24245. * Please consider using the same method from the MeshBuilder class instead
  24246. * @see http://doc.babylonjs.com/babylon101/height_map
  24247. * @param name defines the name of the mesh to create
  24248. * @param url sets the URL of the height map image resource
  24249. * @param width set the ground width size
  24250. * @param height set the ground height size
  24251. * @param subdivisions sets the number of subdivision per side
  24252. * @param minHeight is the minimum altitude on the ground
  24253. * @param maxHeight is the maximum altitude on the ground
  24254. * @param scene defines the hosting scene
  24255. * @param updatable defines if the mesh must be flagged as updatable
  24256. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24257. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24258. * @returns a new Mesh
  24259. */
  24260. 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;
  24261. /**
  24262. * Creates a tube mesh.
  24263. * The tube is a parametric shape.
  24264. * It has no predefined shape. Its final shape will depend on the input parameters.
  24265. * Please consider using the same method from the MeshBuilder class instead
  24266. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24267. * @param name defines the name of the mesh to create
  24268. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24269. * @param radius sets the tube radius size
  24270. * @param tessellation is the number of sides on the tubular surface
  24271. * @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
  24272. * @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
  24273. * @param scene defines the hosting scene
  24274. * @param updatable defines if the mesh must be flagged as updatable
  24275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24276. * @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)
  24277. * @returns a new Mesh
  24278. */
  24279. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24280. (i: number, distance: number): number;
  24281. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24282. /**
  24283. * Creates a polyhedron mesh.
  24284. * Please consider using the same method from the MeshBuilder class instead.
  24285. * * 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
  24286. * * The parameter `size` (positive float, default 1) sets the polygon size
  24287. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24288. * * 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`
  24289. * * 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
  24290. * * 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)`)
  24291. * * 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
  24292. * * 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
  24293. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24294. * * 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
  24295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24296. * @param name defines the name of the mesh to create
  24297. * @param options defines the options used to create the mesh
  24298. * @param scene defines the hosting scene
  24299. * @returns a new Mesh
  24300. */
  24301. static CreatePolyhedron(name: string, options: {
  24302. type?: number;
  24303. size?: number;
  24304. sizeX?: number;
  24305. sizeY?: number;
  24306. sizeZ?: number;
  24307. custom?: any;
  24308. faceUV?: Vector4[];
  24309. faceColors?: Color4[];
  24310. updatable?: boolean;
  24311. sideOrientation?: number;
  24312. }, scene: Scene): Mesh;
  24313. /**
  24314. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24315. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24316. * * 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`)
  24317. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24318. * * 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
  24319. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24320. * * 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
  24321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24322. * @param name defines the name of the mesh
  24323. * @param options defines the options used to create the mesh
  24324. * @param scene defines the hosting scene
  24325. * @returns a new Mesh
  24326. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24327. */
  24328. static CreateIcoSphere(name: string, options: {
  24329. radius?: number;
  24330. flat?: boolean;
  24331. subdivisions?: number;
  24332. sideOrientation?: number;
  24333. updatable?: boolean;
  24334. }, scene: Scene): Mesh;
  24335. /**
  24336. * Creates a decal mesh.
  24337. * Please consider using the same method from the MeshBuilder class instead.
  24338. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24339. * @param name defines the name of the mesh
  24340. * @param sourceMesh defines the mesh receiving the decal
  24341. * @param position sets the position of the decal in world coordinates
  24342. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24343. * @param size sets the decal scaling
  24344. * @param angle sets the angle to rotate the decal
  24345. * @returns a new Mesh
  24346. */
  24347. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24348. /**
  24349. * Prepare internal position array for software CPU skinning
  24350. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24351. */
  24352. setPositionsForCPUSkinning(): Float32Array;
  24353. /**
  24354. * Prepare internal normal array for software CPU skinning
  24355. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24356. */
  24357. setNormalsForCPUSkinning(): Float32Array;
  24358. /**
  24359. * Updates the vertex buffer by applying transformation from the bones
  24360. * @param skeleton defines the skeleton to apply to current mesh
  24361. * @returns the current mesh
  24362. */
  24363. applySkeleton(skeleton: Skeleton): Mesh;
  24364. /**
  24365. * 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
  24366. * @param meshes defines the list of meshes to scan
  24367. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24368. */
  24369. static MinMax(meshes: AbstractMesh[]): {
  24370. min: Vector3;
  24371. max: Vector3;
  24372. };
  24373. /**
  24374. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24375. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24376. * @returns a vector3
  24377. */
  24378. static Center(meshesOrMinMaxVector: {
  24379. min: Vector3;
  24380. max: Vector3;
  24381. } | AbstractMesh[]): Vector3;
  24382. /**
  24383. * Merge the array of meshes into a single mesh for performance reasons.
  24384. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24385. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24386. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24387. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24388. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24389. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24390. * @returns a new mesh
  24391. */
  24392. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24393. /** @hidden */
  24394. addInstance(instance: InstancedMesh): void;
  24395. /** @hidden */
  24396. removeInstance(instance: InstancedMesh): void;
  24397. }
  24398. }
  24399. declare module BABYLON {
  24400. /**
  24401. * This is the base class of all the camera used in the application.
  24402. * @see http://doc.babylonjs.com/features/cameras
  24403. */
  24404. export class Camera extends Node {
  24405. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24406. /**
  24407. * This is the default projection mode used by the cameras.
  24408. * It helps recreating a feeling of perspective and better appreciate depth.
  24409. * This is the best way to simulate real life cameras.
  24410. */
  24411. static readonly PERSPECTIVE_CAMERA: number;
  24412. /**
  24413. * This helps creating camera with an orthographic mode.
  24414. * 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.
  24415. */
  24416. static readonly ORTHOGRAPHIC_CAMERA: number;
  24417. /**
  24418. * This is the default FOV mode for perspective cameras.
  24419. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24420. */
  24421. static readonly FOVMODE_VERTICAL_FIXED: number;
  24422. /**
  24423. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24424. */
  24425. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24426. /**
  24427. * This specifies ther is no need for a camera rig.
  24428. * Basically only one eye is rendered corresponding to the camera.
  24429. */
  24430. static readonly RIG_MODE_NONE: number;
  24431. /**
  24432. * Simulates a camera Rig with one blue eye and one red eye.
  24433. * This can be use with 3d blue and red glasses.
  24434. */
  24435. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24436. /**
  24437. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24438. */
  24439. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24440. /**
  24441. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24442. */
  24443. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24444. /**
  24445. * Defines that both eyes of the camera will be rendered over under each other.
  24446. */
  24447. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24448. /**
  24449. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24450. */
  24451. static readonly RIG_MODE_VR: number;
  24452. /**
  24453. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24454. */
  24455. static readonly RIG_MODE_WEBVR: number;
  24456. /**
  24457. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24458. */
  24459. static readonly RIG_MODE_CUSTOM: number;
  24460. /**
  24461. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24462. */
  24463. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24464. /**
  24465. * Define the input manager associated with the camera.
  24466. */
  24467. inputs: CameraInputsManager<Camera>;
  24468. /** @hidden */ private _position: Vector3;
  24469. /**
  24470. * Define the current local position of the camera in the scene
  24471. */
  24472. position: Vector3;
  24473. /**
  24474. * The vector the camera should consider as up.
  24475. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24476. */
  24477. upVector: Vector3;
  24478. /**
  24479. * Define the current limit on the left side for an orthographic camera
  24480. * In scene unit
  24481. */
  24482. orthoLeft: Nullable<number>;
  24483. /**
  24484. * Define the current limit on the right side for an orthographic camera
  24485. * In scene unit
  24486. */
  24487. orthoRight: Nullable<number>;
  24488. /**
  24489. * Define the current limit on the bottom side for an orthographic camera
  24490. * In scene unit
  24491. */
  24492. orthoBottom: Nullable<number>;
  24493. /**
  24494. * Define the current limit on the top side for an orthographic camera
  24495. * In scene unit
  24496. */
  24497. orthoTop: Nullable<number>;
  24498. /**
  24499. * Field Of View is set in Radians. (default is 0.8)
  24500. */
  24501. fov: number;
  24502. /**
  24503. * Define the minimum distance the camera can see from.
  24504. * This is important to note that the depth buffer are not infinite and the closer it starts
  24505. * the more your scene might encounter depth fighting issue.
  24506. */
  24507. minZ: number;
  24508. /**
  24509. * Define the maximum distance the camera can see to.
  24510. * This is important to note that the depth buffer are not infinite and the further it end
  24511. * the more your scene might encounter depth fighting issue.
  24512. */
  24513. maxZ: number;
  24514. /**
  24515. * Define the default inertia of the camera.
  24516. * This helps giving a smooth feeling to the camera movement.
  24517. */
  24518. inertia: number;
  24519. /**
  24520. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24521. */
  24522. mode: number;
  24523. /**
  24524. * Define wether the camera is intermediate.
  24525. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24526. */
  24527. isIntermediate: boolean;
  24528. /**
  24529. * Define the viewport of the camera.
  24530. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24531. */
  24532. viewport: Viewport;
  24533. /**
  24534. * Restricts the camera to viewing objects with the same layerMask.
  24535. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24536. */
  24537. layerMask: number;
  24538. /**
  24539. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24540. */
  24541. fovMode: number;
  24542. /**
  24543. * Rig mode of the camera.
  24544. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24545. * This is normally controlled byt the camera themselves as internal use.
  24546. */
  24547. cameraRigMode: number;
  24548. /**
  24549. * Defines the distance between both "eyes" in case of a RIG
  24550. */
  24551. interaxialDistance: number;
  24552. /**
  24553. * Defines if stereoscopic rendering is done side by side or over under.
  24554. */
  24555. isStereoscopicSideBySide: boolean;
  24556. /**
  24557. * 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
  24558. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24559. * else in the scene. (Eg. security camera)
  24560. *
  24561. * 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)
  24562. */
  24563. customRenderTargets: RenderTargetTexture[];
  24564. /**
  24565. * When set, the camera will render to this render target instead of the default canvas
  24566. *
  24567. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24568. */
  24569. outputRenderTarget: Nullable<RenderTargetTexture>;
  24570. /**
  24571. * Observable triggered when the camera view matrix has changed.
  24572. */
  24573. onViewMatrixChangedObservable: Observable<Camera>;
  24574. /**
  24575. * Observable triggered when the camera Projection matrix has changed.
  24576. */
  24577. onProjectionMatrixChangedObservable: Observable<Camera>;
  24578. /**
  24579. * Observable triggered when the inputs have been processed.
  24580. */
  24581. onAfterCheckInputsObservable: Observable<Camera>;
  24582. /**
  24583. * Observable triggered when reset has been called and applied to the camera.
  24584. */
  24585. onRestoreStateObservable: Observable<Camera>;
  24586. /** @hidden */ private _cameraRigParams: any;
  24587. /** @hidden */ private _rigCameras: Camera[];
  24588. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24589. protected _webvrViewMatrix: Matrix;
  24590. /** @hidden */ private _skipRendering: boolean;
  24591. /** @hidden */ private _projectionMatrix: Matrix;
  24592. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24593. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24594. protected _globalPosition: Vector3;
  24595. /** @hidden */ private _computedViewMatrix: Matrix;
  24596. private _doNotComputeProjectionMatrix;
  24597. private _transformMatrix;
  24598. private _frustumPlanes;
  24599. private _refreshFrustumPlanes;
  24600. private _storedFov;
  24601. private _stateStored;
  24602. /**
  24603. * Instantiates a new camera object.
  24604. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24605. * @see http://doc.babylonjs.com/features/cameras
  24606. * @param name Defines the name of the camera in the scene
  24607. * @param position Defines the position of the camera
  24608. * @param scene Defines the scene the camera belongs too
  24609. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24610. */
  24611. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24612. /**
  24613. * Store current camera state (fov, position, etc..)
  24614. * @returns the camera
  24615. */
  24616. storeState(): Camera;
  24617. /**
  24618. * Restores the camera state values if it has been stored. You must call storeState() first
  24619. */
  24620. protected _restoreStateValues(): boolean;
  24621. /**
  24622. * Restored camera state. You must call storeState() first.
  24623. * @returns true if restored and false otherwise
  24624. */
  24625. restoreState(): boolean;
  24626. /**
  24627. * Gets the class name of the camera.
  24628. * @returns the class name
  24629. */
  24630. getClassName(): string;
  24631. /** @hidden */ protected readonly _isCamera: boolean;
  24632. /**
  24633. * Gets a string representation of the camera useful for debug purpose.
  24634. * @param fullDetails Defines that a more verboe level of logging is required
  24635. * @returns the string representation
  24636. */
  24637. toString(fullDetails?: boolean): string;
  24638. /**
  24639. * Gets the current world space position of the camera.
  24640. */
  24641. readonly globalPosition: Vector3;
  24642. /**
  24643. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24644. * @returns the active meshe list
  24645. */
  24646. getActiveMeshes(): SmartArray<AbstractMesh>;
  24647. /**
  24648. * Check wether a mesh is part of the current active mesh list of the camera
  24649. * @param mesh Defines the mesh to check
  24650. * @returns true if active, false otherwise
  24651. */
  24652. isActiveMesh(mesh: Mesh): boolean;
  24653. /**
  24654. * Is this camera ready to be used/rendered
  24655. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24656. * @return true if the camera is ready
  24657. */
  24658. isReady(completeCheck?: boolean): boolean;
  24659. /** @hidden */ private _initCache(): void;
  24660. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24661. /** @hidden */ private _isSynchronized(): boolean;
  24662. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24663. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24664. /**
  24665. * Attach the input controls to a specific dom element to get the input from.
  24666. * @param element Defines the element the controls should be listened from
  24667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24668. */
  24669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24670. /**
  24671. * Detach the current controls from the specified dom element.
  24672. * @param element Defines the element to stop listening the inputs from
  24673. */
  24674. detachControl(element: HTMLElement): void;
  24675. /**
  24676. * Update the camera state according to the different inputs gathered during the frame.
  24677. */
  24678. update(): void;
  24679. /** @hidden */ private _checkInputs(): void;
  24680. /** @hidden */
  24681. readonly rigCameras: Camera[];
  24682. /**
  24683. * Gets the post process used by the rig cameras
  24684. */
  24685. readonly rigPostProcess: Nullable<PostProcess>;
  24686. /**
  24687. * Internal, gets the first post proces.
  24688. * @returns the first post process to be run on this camera.
  24689. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24690. private _cascadePostProcessesToRigCams;
  24691. /**
  24692. * Attach a post process to the camera.
  24693. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24694. * @param postProcess The post process to attach to the camera
  24695. * @param insertAt The position of the post process in case several of them are in use in the scene
  24696. * @returns the position the post process has been inserted at
  24697. */
  24698. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24699. /**
  24700. * Detach a post process to the camera.
  24701. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24702. * @param postProcess The post process to detach from the camera
  24703. */
  24704. detachPostProcess(postProcess: PostProcess): void;
  24705. /**
  24706. * Gets the current world matrix of the camera
  24707. */
  24708. getWorldMatrix(): Matrix;
  24709. /** @hidden */ private _getViewMatrix(): Matrix;
  24710. /**
  24711. * Gets the current view matrix of the camera.
  24712. * @param force forces the camera to recompute the matrix without looking at the cached state
  24713. * @returns the view matrix
  24714. */
  24715. getViewMatrix(force?: boolean): Matrix;
  24716. /**
  24717. * Freeze the projection matrix.
  24718. * It will prevent the cache check of the camera projection compute and can speed up perf
  24719. * if no parameter of the camera are meant to change
  24720. * @param projection Defines manually a projection if necessary
  24721. */
  24722. freezeProjectionMatrix(projection?: Matrix): void;
  24723. /**
  24724. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24725. */
  24726. unfreezeProjectionMatrix(): void;
  24727. /**
  24728. * Gets the current projection matrix of the camera.
  24729. * @param force forces the camera to recompute the matrix without looking at the cached state
  24730. * @returns the projection matrix
  24731. */
  24732. getProjectionMatrix(force?: boolean): Matrix;
  24733. /**
  24734. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24735. * @returns a Matrix
  24736. */
  24737. getTransformationMatrix(): Matrix;
  24738. private _updateFrustumPlanes;
  24739. /**
  24740. * Checks if a cullable object (mesh...) is in the camera frustum
  24741. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24742. * @param target The object to check
  24743. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24744. * @returns true if the object is in frustum otherwise false
  24745. */
  24746. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24747. /**
  24748. * Checks if a cullable object (mesh...) is in the camera frustum
  24749. * Unlike isInFrustum this cheks the full bounding box
  24750. * @param target The object to check
  24751. * @returns true if the object is in frustum otherwise false
  24752. */
  24753. isCompletelyInFrustum(target: ICullable): boolean;
  24754. /**
  24755. * Gets a ray in the forward direction from the camera.
  24756. * @param length Defines the length of the ray to create
  24757. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24758. * @param origin Defines the start point of the ray which defaults to the camera position
  24759. * @returns the forward ray
  24760. */
  24761. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24762. /**
  24763. * Releases resources associated with this node.
  24764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24766. */
  24767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24768. /** @hidden */ private _isLeftCamera: boolean;
  24769. /**
  24770. * Gets the left camera of a rig setup in case of Rigged Camera
  24771. */
  24772. readonly isLeftCamera: boolean;
  24773. /** @hidden */ private _isRightCamera: boolean;
  24774. /**
  24775. * Gets the right camera of a rig setup in case of Rigged Camera
  24776. */
  24777. readonly isRightCamera: boolean;
  24778. /**
  24779. * Gets the left camera of a rig setup in case of Rigged Camera
  24780. */
  24781. readonly leftCamera: Nullable<FreeCamera>;
  24782. /**
  24783. * Gets the right camera of a rig setup in case of Rigged Camera
  24784. */
  24785. readonly rightCamera: Nullable<FreeCamera>;
  24786. /**
  24787. * Gets the left camera target of a rig setup in case of Rigged Camera
  24788. * @returns the target position
  24789. */
  24790. getLeftTarget(): Nullable<Vector3>;
  24791. /**
  24792. * Gets the right camera target of a rig setup in case of Rigged Camera
  24793. * @returns the target position
  24794. */
  24795. getRightTarget(): Nullable<Vector3>;
  24796. /**
  24797. * @hidden
  24798. */
  24799. setCameraRigMode(mode: number, rigParams: any): void;
  24800. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24801. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24802. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24803. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24804. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24805. protected _updateCameraRotationMatrix(): void;
  24806. protected _updateWebVRCameraRotationMatrix(): void;
  24807. /**
  24808. * This function MUST be overwritten by the different WebVR cameras available.
  24809. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24810. * @hidden
  24811. */ private _getWebVRProjectionMatrix(): Matrix;
  24812. /**
  24813. * This function MUST be overwritten by the different WebVR cameras available.
  24814. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24815. * @hidden
  24816. */ private _getWebVRViewMatrix(): Matrix;
  24817. /** @hidden */
  24818. setCameraRigParameter(name: string, value: any): void;
  24819. /**
  24820. * needs to be overridden by children so sub has required properties to be copied
  24821. * @hidden
  24822. */
  24823. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24824. /**
  24825. * May need to be overridden by children
  24826. * @hidden
  24827. */ private _updateRigCameras(): void;
  24828. /** @hidden */ private _setupInputs(): void;
  24829. /**
  24830. * Serialiaze the camera setup to a json represention
  24831. * @returns the JSON representation
  24832. */
  24833. serialize(): any;
  24834. /**
  24835. * Clones the current camera.
  24836. * @param name The cloned camera name
  24837. * @returns the cloned camera
  24838. */
  24839. clone(name: string): Camera;
  24840. /**
  24841. * Gets the direction of the camera relative to a given local axis.
  24842. * @param localAxis Defines the reference axis to provide a relative direction.
  24843. * @return the direction
  24844. */
  24845. getDirection(localAxis: Vector3): Vector3;
  24846. /**
  24847. * Returns the current camera absolute rotation
  24848. */
  24849. readonly absoluteRotation: Quaternion;
  24850. /**
  24851. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24852. * @param localAxis Defines the reference axis to provide a relative direction.
  24853. * @param result Defines the vector to store the result in
  24854. */
  24855. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24856. /**
  24857. * Gets a camera constructor for a given camera type
  24858. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24859. * @param name The name of the camera the result will be able to instantiate
  24860. * @param scene The scene the result will construct the camera in
  24861. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24862. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24863. * @returns a factory method to construc the camera
  24864. */
  24865. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24866. /**
  24867. * Compute the world matrix of the camera.
  24868. * @returns the camera world matrix
  24869. */
  24870. computeWorldMatrix(): Matrix;
  24871. /**
  24872. * Parse a JSON and creates the camera from the parsed information
  24873. * @param parsedCamera The JSON to parse
  24874. * @param scene The scene to instantiate the camera in
  24875. * @returns the newly constructed camera
  24876. */
  24877. static Parse(parsedCamera: any, scene: Scene): Camera;
  24878. }
  24879. }
  24880. declare module BABYLON {
  24881. /**
  24882. * Class containing static functions to help procedurally build meshes
  24883. */
  24884. export class DiscBuilder {
  24885. /**
  24886. * Creates a plane polygonal mesh. By default, this is a disc
  24887. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24888. * * 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
  24889. * * 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
  24890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24891. * * 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
  24892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24893. * @param name defines the name of the mesh
  24894. * @param options defines the options used to create the mesh
  24895. * @param scene defines the hosting scene
  24896. * @returns the plane polygonal mesh
  24897. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24898. */
  24899. static CreateDisc(name: string, options: {
  24900. radius?: number;
  24901. tessellation?: number;
  24902. arc?: number;
  24903. updatable?: boolean;
  24904. sideOrientation?: number;
  24905. frontUVs?: Vector4;
  24906. backUVs?: Vector4;
  24907. }, scene?: Nullable<Scene>): Mesh;
  24908. }
  24909. }
  24910. declare module BABYLON {
  24911. /**
  24912. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24913. *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.
  24914. * The SPS is also a particle system. It provides some methods to manage the particles.
  24915. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24916. *
  24917. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24918. */
  24919. export class SolidParticleSystem implements IDisposable {
  24920. /**
  24921. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24922. * Example : var p = SPS.particles[i];
  24923. */
  24924. particles: SolidParticle[];
  24925. /**
  24926. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24927. */
  24928. nbParticles: number;
  24929. /**
  24930. * If the particles must ever face the camera (default false). Useful for planar particles.
  24931. */
  24932. billboard: boolean;
  24933. /**
  24934. * Recompute normals when adding a shape
  24935. */
  24936. recomputeNormals: boolean;
  24937. /**
  24938. * This a counter ofr your own usage. It's not set by any SPS functions.
  24939. */
  24940. counter: number;
  24941. /**
  24942. * The SPS name. This name is also given to the underlying mesh.
  24943. */
  24944. name: string;
  24945. /**
  24946. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24947. */
  24948. mesh: Mesh;
  24949. /**
  24950. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24951. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24952. */
  24953. vars: any;
  24954. /**
  24955. * This array is populated when the SPS is set as 'pickable'.
  24956. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24957. * Each element of this array is an object `{idx: int, faceId: int}`.
  24958. * `idx` is the picked particle index in the `SPS.particles` array
  24959. * `faceId` is the picked face index counted within this particle.
  24960. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24961. */
  24962. pickedParticles: {
  24963. idx: number;
  24964. faceId: number;
  24965. }[];
  24966. /**
  24967. * This array is populated when `enableDepthSort` is set to true.
  24968. * Each element of this array is an instance of the class DepthSortedParticle.
  24969. */
  24970. depthSortedParticles: DepthSortedParticle[];
  24971. /**
  24972. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24973. * @hidden
  24974. */ private _bSphereOnly: boolean;
  24975. /**
  24976. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24977. * @hidden
  24978. */ private _bSphereRadiusFactor: number;
  24979. private _scene;
  24980. private _positions;
  24981. private _indices;
  24982. private _normals;
  24983. private _colors;
  24984. private _uvs;
  24985. private _indices32;
  24986. private _positions32;
  24987. private _normals32;
  24988. private _fixedNormal32;
  24989. private _colors32;
  24990. private _uvs32;
  24991. private _index;
  24992. private _updatable;
  24993. private _pickable;
  24994. private _isVisibilityBoxLocked;
  24995. private _alwaysVisible;
  24996. private _depthSort;
  24997. private _expandable;
  24998. private _shapeCounter;
  24999. private _copy;
  25000. private _color;
  25001. private _computeParticleColor;
  25002. private _computeParticleTexture;
  25003. private _computeParticleRotation;
  25004. private _computeParticleVertex;
  25005. private _computeBoundingBox;
  25006. private _depthSortParticles;
  25007. private _camera;
  25008. private _mustUnrotateFixedNormals;
  25009. private _particlesIntersect;
  25010. private _needs32Bits;
  25011. private _isNotBuilt;
  25012. /**
  25013. * Creates a SPS (Solid Particle System) object.
  25014. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25015. * @param scene (Scene) is the scene in which the SPS is added.
  25016. * @param options defines the options of the sps e.g.
  25017. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25018. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25019. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25020. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25021. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25022. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25023. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25024. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25025. */
  25026. constructor(name: string, scene: Scene, options?: {
  25027. updatable?: boolean;
  25028. isPickable?: boolean;
  25029. enableDepthSort?: boolean;
  25030. particleIntersection?: boolean;
  25031. boundingSphereOnly?: boolean;
  25032. bSphereRadiusFactor?: number;
  25033. expandable?: boolean;
  25034. });
  25035. /**
  25036. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25037. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25038. * @returns the created mesh
  25039. */
  25040. buildMesh(): Mesh;
  25041. /**
  25042. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25043. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25044. * Thus the particles generated from `digest()` have their property `position` set yet.
  25045. * @param mesh ( Mesh ) is the mesh to be digested
  25046. * @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
  25047. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25048. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25049. * @returns the current SPS
  25050. */
  25051. digest(mesh: Mesh, options?: {
  25052. facetNb?: number;
  25053. number?: number;
  25054. delta?: number;
  25055. }): SolidParticleSystem;
  25056. private _unrotateFixedNormals;
  25057. private _resetCopy;
  25058. private _meshBuilder;
  25059. private _posToShape;
  25060. private _uvsToShapeUV;
  25061. private _addParticle;
  25062. /**
  25063. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25064. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25065. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25066. * @param nb (positive integer) the number of particles to be created from this model
  25067. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25068. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25069. * @returns the number of shapes in the system
  25070. */
  25071. addShape(mesh: Mesh, nb: number, options?: {
  25072. positionFunction?: any;
  25073. vertexFunction?: any;
  25074. }): number;
  25075. private _rebuildParticle;
  25076. /**
  25077. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25078. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25079. * @returns the SPS.
  25080. */
  25081. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25082. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25083. * Returns an array with the removed particles.
  25084. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25085. * The SPS can't be empty so at least one particle needs to remain in place.
  25086. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25087. * @param start index of the first particle to remove
  25088. * @param end index of the last particle to remove (included)
  25089. * @returns an array populated with the removed particles
  25090. */
  25091. removeParticles(start: number, end: number): SolidParticle[];
  25092. /**
  25093. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25094. * This method calls `updateParticle()` for each particle of the SPS.
  25095. * For an animated SPS, it is usually called within the render loop.
  25096. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25097. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25098. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25099. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25100. * @returns the SPS.
  25101. */
  25102. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25103. /**
  25104. * Disposes the SPS.
  25105. */
  25106. dispose(): void;
  25107. /**
  25108. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25109. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25110. * @returns the SPS.
  25111. */
  25112. refreshVisibleSize(): SolidParticleSystem;
  25113. /**
  25114. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25115. * @param size the size (float) of the visibility box
  25116. * note : this doesn't lock the SPS mesh bounding box.
  25117. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25118. */
  25119. setVisibilityBox(size: number): void;
  25120. /**
  25121. * Gets whether the SPS as always visible or not
  25122. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25123. */
  25124. /**
  25125. * Sets the SPS as always visible or not
  25126. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25127. */
  25128. isAlwaysVisible: boolean;
  25129. /**
  25130. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25131. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25132. */
  25133. /**
  25134. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25136. */
  25137. isVisibilityBoxLocked: boolean;
  25138. /**
  25139. * Tells to `setParticles()` to compute the particle rotations or not.
  25140. * Default value : true. The SPS is faster when it's set to false.
  25141. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25142. */
  25143. /**
  25144. * Gets if `setParticles()` computes the particle rotations or not.
  25145. * Default value : true. The SPS is faster when it's set to false.
  25146. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25147. */
  25148. computeParticleRotation: boolean;
  25149. /**
  25150. * Tells to `setParticles()` to compute the particle colors or not.
  25151. * Default value : true. The SPS is faster when it's set to false.
  25152. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25153. */
  25154. /**
  25155. * Gets if `setParticles()` computes the particle colors or not.
  25156. * Default value : true. The SPS is faster when it's set to false.
  25157. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25158. */
  25159. computeParticleColor: boolean;
  25160. /**
  25161. * Gets if `setParticles()` computes the particle textures or not.
  25162. * Default value : true. The SPS is faster when it's set to false.
  25163. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25164. */
  25165. computeParticleTexture: boolean;
  25166. /**
  25167. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25168. * Default value : false. The SPS is faster when it's set to false.
  25169. * Note : the particle custom vertex positions aren't stored values.
  25170. */
  25171. /**
  25172. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25173. * Default value : false. The SPS is faster when it's set to false.
  25174. * Note : the particle custom vertex positions aren't stored values.
  25175. */
  25176. computeParticleVertex: boolean;
  25177. /**
  25178. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25179. */
  25180. /**
  25181. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25182. */
  25183. computeBoundingBox: boolean;
  25184. /**
  25185. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25186. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25187. * Default : `true`
  25188. */
  25189. /**
  25190. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25191. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25192. * Default : `true`
  25193. */
  25194. depthSortParticles: boolean;
  25195. /**
  25196. * Gets if the SPS is created as expandable at construction time.
  25197. * Default : `false`
  25198. */
  25199. readonly expandable: boolean;
  25200. /**
  25201. * This function does nothing. It may be overwritten to set all the particle first values.
  25202. * The SPS doesn't call this function, you may have to call it by your own.
  25203. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25204. */
  25205. initParticles(): void;
  25206. /**
  25207. * This function does nothing. It may be overwritten to recycle a particle.
  25208. * The SPS doesn't call this function, you may have to call it by your own.
  25209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25210. * @param particle The particle to recycle
  25211. * @returns the recycled particle
  25212. */
  25213. recycleParticle(particle: SolidParticle): SolidParticle;
  25214. /**
  25215. * Updates a particle : this function should be overwritten by the user.
  25216. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25217. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25218. * @example : just set a particle position or velocity and recycle conditions
  25219. * @param particle The particle to update
  25220. * @returns the updated particle
  25221. */
  25222. updateParticle(particle: SolidParticle): SolidParticle;
  25223. /**
  25224. * Updates a vertex of a particle : it can be overwritten by the user.
  25225. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25226. * @param particle the current particle
  25227. * @param vertex the current index of the current particle
  25228. * @param pt the index of the current vertex in the particle shape
  25229. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25230. * @example : just set a vertex particle position
  25231. * @returns the updated vertex
  25232. */
  25233. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25234. /**
  25235. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25236. * This does nothing and may be overwritten by the user.
  25237. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25238. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25239. * @param update the boolean update value actually passed to setParticles()
  25240. */
  25241. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25242. /**
  25243. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25244. * This will be passed three parameters.
  25245. * This does nothing and may be overwritten by the user.
  25246. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25247. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25248. * @param update the boolean update value actually passed to setParticles()
  25249. */
  25250. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25251. }
  25252. }
  25253. declare module BABYLON {
  25254. /**
  25255. * Represents one particle of a solid particle system.
  25256. */
  25257. export class SolidParticle {
  25258. /**
  25259. * particle global index
  25260. */
  25261. idx: number;
  25262. /**
  25263. * The color of the particle
  25264. */
  25265. color: Nullable<Color4>;
  25266. /**
  25267. * The world space position of the particle.
  25268. */
  25269. position: Vector3;
  25270. /**
  25271. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25272. */
  25273. rotation: Vector3;
  25274. /**
  25275. * The world space rotation quaternion of the particle.
  25276. */
  25277. rotationQuaternion: Nullable<Quaternion>;
  25278. /**
  25279. * The scaling of the particle.
  25280. */
  25281. scaling: Vector3;
  25282. /**
  25283. * The uvs of the particle.
  25284. */
  25285. uvs: Vector4;
  25286. /**
  25287. * The current speed of the particle.
  25288. */
  25289. velocity: Vector3;
  25290. /**
  25291. * The pivot point in the particle local space.
  25292. */
  25293. pivot: Vector3;
  25294. /**
  25295. * Must the particle be translated from its pivot point in its local space ?
  25296. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25297. * Default : false
  25298. */
  25299. translateFromPivot: boolean;
  25300. /**
  25301. * Is the particle active or not ?
  25302. */
  25303. alive: boolean;
  25304. /**
  25305. * Is the particle visible or not ?
  25306. */
  25307. isVisible: boolean;
  25308. /**
  25309. * Index of this particle in the global "positions" array (Internal use)
  25310. * @hidden
  25311. */ private _pos: number;
  25312. /**
  25313. * @hidden Index of this particle in the global "indices" array (Internal use)
  25314. */ private _ind: number;
  25315. /**
  25316. * @hidden ModelShape of this particle (Internal use)
  25317. */ private _model: ModelShape;
  25318. /**
  25319. * ModelShape id of this particle
  25320. */
  25321. shapeId: number;
  25322. /**
  25323. * Index of the particle in its shape id
  25324. */
  25325. idxInShape: number;
  25326. /**
  25327. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25328. */ private _modelBoundingInfo: BoundingInfo;
  25329. /**
  25330. * @hidden Particle BoundingInfo object (Internal use)
  25331. */ private _boundingInfo: BoundingInfo;
  25332. /**
  25333. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25334. */ private _sps: SolidParticleSystem;
  25335. /**
  25336. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25337. */ private _stillInvisible: boolean;
  25338. /**
  25339. * @hidden Last computed particle rotation matrix
  25340. */ private _rotationMatrix: number[];
  25341. /**
  25342. * Parent particle Id, if any.
  25343. * Default null.
  25344. */
  25345. parentId: Nullable<number>;
  25346. /**
  25347. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25348. * The possible values are :
  25349. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25350. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25352. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25353. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25354. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25355. * */
  25356. cullingStrategy: number;
  25357. /**
  25358. * @hidden Internal global position in the SPS.
  25359. */ private _globalPosition: Vector3;
  25360. /**
  25361. * Creates a Solid Particle object.
  25362. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25363. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25364. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25365. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25366. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25367. * @param shapeId (integer) is the model shape identifier in the SPS.
  25368. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25369. * @param sps defines the sps it is associated to
  25370. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25371. */
  25372. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25373. /**
  25374. * Legacy support, changed scale to scaling
  25375. */
  25376. /**
  25377. * Legacy support, changed scale to scaling
  25378. */
  25379. scale: Vector3;
  25380. /**
  25381. * Legacy support, changed quaternion to rotationQuaternion
  25382. */
  25383. /**
  25384. * Legacy support, changed quaternion to rotationQuaternion
  25385. */
  25386. quaternion: Nullable<Quaternion>;
  25387. /**
  25388. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25389. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25390. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25391. * @returns true if it intersects
  25392. */
  25393. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25394. /**
  25395. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25396. * A particle is in the frustum if its bounding box intersects the frustum
  25397. * @param frustumPlanes defines the frustum to test
  25398. * @returns true if the particle is in the frustum planes
  25399. */
  25400. isInFrustum(frustumPlanes: Plane[]): boolean;
  25401. /**
  25402. * get the rotation matrix of the particle
  25403. * @hidden
  25404. */
  25405. getRotationMatrix(m: Matrix): void;
  25406. }
  25407. /**
  25408. * Represents the shape of the model used by one particle of a solid particle system.
  25409. * SPS internal tool, don't use it manually.
  25410. */
  25411. export class ModelShape {
  25412. /**
  25413. * The shape id
  25414. * @hidden
  25415. */
  25416. shapeID: number;
  25417. /**
  25418. * flat array of model positions (internal use)
  25419. * @hidden
  25420. */ private _shape: Vector3[];
  25421. /**
  25422. * flat array of model UVs (internal use)
  25423. * @hidden
  25424. */ private _shapeUV: number[];
  25425. /**
  25426. * color array of the model
  25427. * @hidden
  25428. */ private _shapeColors: number[];
  25429. /**
  25430. * indices array of the model
  25431. * @hidden
  25432. */ private _indices: number[];
  25433. /**
  25434. * normals array of the model
  25435. * @hidden
  25436. */ private _normals: number[];
  25437. /**
  25438. * length of the shape in the model indices array (internal use)
  25439. * @hidden
  25440. */ private _indicesLength: number;
  25441. /**
  25442. * Custom position function (internal use)
  25443. * @hidden
  25444. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25445. /**
  25446. * Custom vertex function (internal use)
  25447. * @hidden
  25448. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25449. /**
  25450. * 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.
  25451. * SPS internal tool, don't use it manually.
  25452. * @hidden
  25453. */
  25454. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25455. }
  25456. /**
  25457. * Represents a Depth Sorted Particle in the solid particle system.
  25458. */
  25459. export class DepthSortedParticle {
  25460. /**
  25461. * Index of the particle in the "indices" array
  25462. */
  25463. ind: number;
  25464. /**
  25465. * Length of the particle shape in the "indices" array
  25466. */
  25467. indicesLength: number;
  25468. /**
  25469. * Squared distance from the particle to the camera
  25470. */
  25471. sqDistance: number;
  25472. }
  25473. }
  25474. declare module BABYLON {
  25475. /**
  25476. * @hidden
  25477. */
  25478. 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>>;
  25479. }
  25480. }
  25481. declare module BABYLON {
  25482. /** @hidden */ private class _FacetDataStorage {
  25483. facetPositions: Vector3[];
  25484. facetNormals: Vector3[];
  25485. facetPartitioning: number[][];
  25486. facetNb: number;
  25487. partitioningSubdivisions: number;
  25488. partitioningBBoxRatio: number;
  25489. facetDataEnabled: boolean;
  25490. facetParameters: any;
  25491. bbSize: Vector3;
  25492. subDiv: {
  25493. max: number;
  25494. X: number;
  25495. Y: number;
  25496. Z: number;
  25497. };
  25498. facetDepthSort: boolean;
  25499. facetDepthSortEnabled: boolean;
  25500. depthSortedIndices: IndicesArray;
  25501. depthSortedFacets: {
  25502. ind: number;
  25503. sqDistance: number;
  25504. }[];
  25505. facetDepthSortFunction: (f1: {
  25506. ind: number;
  25507. sqDistance: number;
  25508. }, f2: {
  25509. ind: number;
  25510. sqDistance: number;
  25511. }) => number;
  25512. facetDepthSortFrom: Vector3;
  25513. facetDepthSortOrigin: Vector3;
  25514. invertedMatrix: Matrix;
  25515. }
  25516. /**
  25517. * @hidden
  25518. **/ 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; private _actAsRegularMesh: boolean;
  25519. }
  25520. /**
  25521. * Class used to store all common mesh properties
  25522. */
  25523. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25524. /** No occlusion */
  25525. static OCCLUSION_TYPE_NONE: number;
  25526. /** Occlusion set to optimisitic */
  25527. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25528. /** Occlusion set to strict */
  25529. static OCCLUSION_TYPE_STRICT: number;
  25530. /** Use an accurante occlusion algorithm */
  25531. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25532. /** Use a conservative occlusion algorithm */
  25533. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25534. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25535. * Test order :
  25536. * Is the bounding sphere outside the frustum ?
  25537. * If not, are the bounding box vertices outside the frustum ?
  25538. * It not, then the cullable object is in the frustum.
  25539. */
  25540. static readonly CULLINGSTRATEGY_STANDARD: number;
  25541. /** Culling strategy : Bounding Sphere Only.
  25542. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25543. * It's also less accurate than the standard because some not visible objects can still be selected.
  25544. * Test : is the bounding sphere outside the frustum ?
  25545. * If not, then the cullable object is in the frustum.
  25546. */
  25547. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25548. /** Culling strategy : Optimistic Inclusion.
  25549. * This in an inclusion test first, then the standard exclusion test.
  25550. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25551. * 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.
  25552. * Anyway, it's as accurate as the standard strategy.
  25553. * Test :
  25554. * Is the cullable object bounding sphere center in the frustum ?
  25555. * If not, apply the default culling strategy.
  25556. */
  25557. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25558. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25559. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25560. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25561. * 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.
  25562. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25563. * Test :
  25564. * Is the cullable object bounding sphere center in the frustum ?
  25565. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25566. */
  25567. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25568. /**
  25569. * No billboard
  25570. */
  25571. static readonly BILLBOARDMODE_NONE: number;
  25572. /** Billboard on X axis */
  25573. static readonly BILLBOARDMODE_X: number;
  25574. /** Billboard on Y axis */
  25575. static readonly BILLBOARDMODE_Y: number;
  25576. /** Billboard on Z axis */
  25577. static readonly BILLBOARDMODE_Z: number;
  25578. /** Billboard on all axes */
  25579. static readonly BILLBOARDMODE_ALL: number;
  25580. /** Billboard on using position instead of orientation */
  25581. static readonly BILLBOARDMODE_USE_POSITION: number;
  25582. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25583. /**
  25584. * The culling strategy to use to check whether the mesh must be rendered or not.
  25585. * This value can be changed at any time and will be used on the next render mesh selection.
  25586. * The possible values are :
  25587. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25588. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25589. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25590. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25591. * Please read each static variable documentation to get details about the culling process.
  25592. * */
  25593. cullingStrategy: number;
  25594. /**
  25595. * Gets the number of facets in the mesh
  25596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25597. */
  25598. readonly facetNb: number;
  25599. /**
  25600. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25602. */
  25603. partitioningSubdivisions: number;
  25604. /**
  25605. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25606. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25608. */
  25609. partitioningBBoxRatio: number;
  25610. /**
  25611. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25612. * Works only for updatable meshes.
  25613. * Doesn't work with multi-materials
  25614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25615. */
  25616. mustDepthSortFacets: boolean;
  25617. /**
  25618. * The location (Vector3) where the facet depth sort must be computed from.
  25619. * By default, the active camera position.
  25620. * Used only when facet depth sort is enabled
  25621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25622. */
  25623. facetDepthSortFrom: Vector3;
  25624. /**
  25625. * gets a boolean indicating if facetData is enabled
  25626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25627. */
  25628. readonly isFacetDataEnabled: boolean;
  25629. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25630. /**
  25631. * An event triggered when this mesh collides with another one
  25632. */
  25633. onCollideObservable: Observable<AbstractMesh>;
  25634. /** Set a function to call when this mesh collides with another one */
  25635. onCollide: () => void;
  25636. /**
  25637. * An event triggered when the collision's position changes
  25638. */
  25639. onCollisionPositionChangeObservable: Observable<Vector3>;
  25640. /** Set a function to call when the collision's position changes */
  25641. onCollisionPositionChange: () => void;
  25642. /**
  25643. * An event triggered when material is changed
  25644. */
  25645. onMaterialChangedObservable: Observable<AbstractMesh>;
  25646. /**
  25647. * Gets or sets the orientation for POV movement & rotation
  25648. */
  25649. definedFacingForward: boolean;
  25650. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25651. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25652. /**
  25653. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25654. */
  25655. /**
  25656. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25657. */
  25658. visibility: number;
  25659. /** Gets or sets the alpha index used to sort transparent meshes
  25660. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25661. */
  25662. alphaIndex: number;
  25663. /**
  25664. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25665. */
  25666. isVisible: boolean;
  25667. /**
  25668. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25669. */
  25670. isPickable: boolean;
  25671. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25672. showSubMeshesBoundingBox: boolean;
  25673. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25674. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25675. */
  25676. isBlocker: boolean;
  25677. /**
  25678. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25679. */
  25680. enablePointerMoveEvents: boolean;
  25681. /**
  25682. * Specifies the rendering group id for this mesh (0 by default)
  25683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25684. */
  25685. renderingGroupId: number;
  25686. private _material;
  25687. /** Gets or sets current material */
  25688. material: Nullable<Material>;
  25689. /**
  25690. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25691. * @see http://doc.babylonjs.com/babylon101/shadows
  25692. */
  25693. receiveShadows: boolean;
  25694. /** Defines color to use when rendering outline */
  25695. outlineColor: Color3;
  25696. /** Define width to use when rendering outline */
  25697. outlineWidth: number;
  25698. /** Defines color to use when rendering overlay */
  25699. overlayColor: Color3;
  25700. /** Defines alpha to use when rendering overlay */
  25701. overlayAlpha: number;
  25702. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25703. hasVertexAlpha: boolean;
  25704. /** 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) */
  25705. useVertexColors: boolean;
  25706. /**
  25707. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25708. */
  25709. computeBonesUsingShaders: boolean;
  25710. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25711. numBoneInfluencers: number;
  25712. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25713. applyFog: boolean;
  25714. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25715. useOctreeForRenderingSelection: boolean;
  25716. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25717. useOctreeForPicking: boolean;
  25718. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25719. useOctreeForCollisions: boolean;
  25720. /**
  25721. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25722. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25723. */
  25724. layerMask: number;
  25725. /**
  25726. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25727. */
  25728. alwaysSelectAsActiveMesh: boolean;
  25729. /**
  25730. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25731. */
  25732. doNotSyncBoundingInfo: boolean;
  25733. /**
  25734. * Gets or sets the current action manager
  25735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25736. */
  25737. actionManager: Nullable<AbstractActionManager>;
  25738. private _meshCollisionData;
  25739. /**
  25740. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25742. */
  25743. ellipsoid: Vector3;
  25744. /**
  25745. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25747. */
  25748. ellipsoidOffset: Vector3;
  25749. /**
  25750. * Gets or sets a collision mask used to mask collisions (default is -1).
  25751. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25752. */
  25753. collisionMask: number;
  25754. /**
  25755. * Gets or sets the current collision group mask (-1 by default).
  25756. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25757. */
  25758. collisionGroup: number;
  25759. /**
  25760. * Defines edge width used when edgesRenderer is enabled
  25761. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25762. */
  25763. edgesWidth: number;
  25764. /**
  25765. * Defines edge color used when edgesRenderer is enabled
  25766. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25767. */
  25768. edgesColor: Color4;
  25769. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25770. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25771. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25772. /** @hidden */ private _renderId: number;
  25773. /**
  25774. * Gets or sets the list of subMeshes
  25775. * @see http://doc.babylonjs.com/how_to/multi_materials
  25776. */
  25777. subMeshes: SubMesh[];
  25778. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25779. /** @hidden */ private _unIndexed: boolean;
  25780. /** @hidden */ private _lightSources: Light[];
  25781. /** Gets the list of lights affecting that mesh */
  25782. readonly lightSources: Light[];
  25783. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25784. /** @hidden */ private _waitingData: {
  25785. lods: Nullable<any>;
  25786. actions: Nullable<any>;
  25787. freezeWorldMatrix: Nullable<boolean>;
  25788. };
  25789. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25790. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25791. /**
  25792. * Gets or sets a skeleton to apply skining transformations
  25793. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25794. */
  25795. skeleton: Nullable<Skeleton>;
  25796. /**
  25797. * An event triggered when the mesh is rebuilt.
  25798. */
  25799. onRebuildObservable: Observable<AbstractMesh>;
  25800. /**
  25801. * Creates a new AbstractMesh
  25802. * @param name defines the name of the mesh
  25803. * @param scene defines the hosting scene
  25804. */
  25805. constructor(name: string, scene?: Nullable<Scene>);
  25806. /**
  25807. * Returns the string "AbstractMesh"
  25808. * @returns "AbstractMesh"
  25809. */
  25810. getClassName(): string;
  25811. /**
  25812. * Gets a string representation of the current mesh
  25813. * @param fullDetails defines a boolean indicating if full details must be included
  25814. * @returns a string representation of the current mesh
  25815. */
  25816. toString(fullDetails?: boolean): string;
  25817. /**
  25818. * @hidden
  25819. */
  25820. protected _getEffectiveParent(): Nullable<Node>;
  25821. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25822. /** @hidden */ private _rebuild(): void;
  25823. /** @hidden */ private _resyncLightSources(): void;
  25824. /** @hidden */ private _resyncLighSource(light: Light): void;
  25825. /** @hidden */ private _unBindEffect(): void;
  25826. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25827. private _markSubMeshesAsDirty;
  25828. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25829. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25830. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25831. /**
  25832. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25833. */
  25834. scaling: Vector3;
  25835. /**
  25836. * Returns true if the mesh is blocked. Implemented by child classes
  25837. */
  25838. readonly isBlocked: boolean;
  25839. /**
  25840. * Returns the mesh itself by default. Implemented by child classes
  25841. * @param camera defines the camera to use to pick the right LOD level
  25842. * @returns the currentAbstractMesh
  25843. */
  25844. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25845. /**
  25846. * Returns 0 by default. Implemented by child classes
  25847. * @returns an integer
  25848. */
  25849. getTotalVertices(): number;
  25850. /**
  25851. * Returns a positive integer : the total number of indices in this mesh geometry.
  25852. * @returns the numner of indices or zero if the mesh has no geometry.
  25853. */
  25854. getTotalIndices(): number;
  25855. /**
  25856. * Returns null by default. Implemented by child classes
  25857. * @returns null
  25858. */
  25859. getIndices(): Nullable<IndicesArray>;
  25860. /**
  25861. * Returns the array of the requested vertex data kind. Implemented by child classes
  25862. * @param kind defines the vertex data kind to use
  25863. * @returns null
  25864. */
  25865. getVerticesData(kind: string): Nullable<FloatArray>;
  25866. /**
  25867. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25868. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25869. * Note that a new underlying VertexBuffer object is created each call.
  25870. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25871. * @param kind defines vertex data kind:
  25872. * * VertexBuffer.PositionKind
  25873. * * VertexBuffer.UVKind
  25874. * * VertexBuffer.UV2Kind
  25875. * * VertexBuffer.UV3Kind
  25876. * * VertexBuffer.UV4Kind
  25877. * * VertexBuffer.UV5Kind
  25878. * * VertexBuffer.UV6Kind
  25879. * * VertexBuffer.ColorKind
  25880. * * VertexBuffer.MatricesIndicesKind
  25881. * * VertexBuffer.MatricesIndicesExtraKind
  25882. * * VertexBuffer.MatricesWeightsKind
  25883. * * VertexBuffer.MatricesWeightsExtraKind
  25884. * @param data defines the data source
  25885. * @param updatable defines if the data must be flagged as updatable (or static)
  25886. * @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
  25887. * @returns the current mesh
  25888. */
  25889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25890. /**
  25891. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25892. * If the mesh has no geometry, it is simply returned as it is.
  25893. * @param kind defines vertex data kind:
  25894. * * VertexBuffer.PositionKind
  25895. * * VertexBuffer.UVKind
  25896. * * VertexBuffer.UV2Kind
  25897. * * VertexBuffer.UV3Kind
  25898. * * VertexBuffer.UV4Kind
  25899. * * VertexBuffer.UV5Kind
  25900. * * VertexBuffer.UV6Kind
  25901. * * VertexBuffer.ColorKind
  25902. * * VertexBuffer.MatricesIndicesKind
  25903. * * VertexBuffer.MatricesIndicesExtraKind
  25904. * * VertexBuffer.MatricesWeightsKind
  25905. * * VertexBuffer.MatricesWeightsExtraKind
  25906. * @param data defines the data source
  25907. * @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
  25908. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25909. * @returns the current mesh
  25910. */
  25911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25912. /**
  25913. * Sets the mesh indices,
  25914. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25915. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25916. * @param totalVertices Defines the total number of vertices
  25917. * @returns the current mesh
  25918. */
  25919. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25920. /**
  25921. * Gets a boolean indicating if specific vertex data is present
  25922. * @param kind defines the vertex data kind to use
  25923. * @returns true is data kind is present
  25924. */
  25925. isVerticesDataPresent(kind: string): boolean;
  25926. /**
  25927. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25928. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25929. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25930. * @returns a BoundingInfo
  25931. */
  25932. getBoundingInfo(): BoundingInfo;
  25933. /**
  25934. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25935. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25936. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25937. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25938. * @returns the current mesh
  25939. */
  25940. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25941. /**
  25942. * Overwrite the current bounding info
  25943. * @param boundingInfo defines the new bounding info
  25944. * @returns the current mesh
  25945. */
  25946. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25947. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25948. readonly useBones: boolean;
  25949. /** @hidden */ private _preActivate(): void;
  25950. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25951. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25952. /** @hidden */ private _postActivate(): void;
  25953. /** @hidden */ private _freeze(): void;
  25954. /** @hidden */ private _unFreeze(): void;
  25955. /**
  25956. * Gets the current world matrix
  25957. * @returns a Matrix
  25958. */
  25959. getWorldMatrix(): Matrix;
  25960. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25961. /**
  25962. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25963. */
  25964. readonly isAnInstance: boolean;
  25965. /**
  25966. * Gets a boolean indicating if this mesh has instances
  25967. */
  25968. readonly hasInstances: boolean;
  25969. /**
  25970. * Perform relative position change from the point of view of behind the front of the mesh.
  25971. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25972. * Supports definition of mesh facing forward or backward
  25973. * @param amountRight defines the distance on the right axis
  25974. * @param amountUp defines the distance on the up axis
  25975. * @param amountForward defines the distance on the forward axis
  25976. * @returns the current mesh
  25977. */
  25978. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25979. /**
  25980. * Calculate relative position change from the point of view of behind the front of the mesh.
  25981. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25982. * Supports definition of mesh facing forward or backward
  25983. * @param amountRight defines the distance on the right axis
  25984. * @param amountUp defines the distance on the up axis
  25985. * @param amountForward defines the distance on the forward axis
  25986. * @returns the new displacement vector
  25987. */
  25988. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25989. /**
  25990. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25991. * Supports definition of mesh facing forward or backward
  25992. * @param flipBack defines the flip
  25993. * @param twirlClockwise defines the twirl
  25994. * @param tiltRight defines the tilt
  25995. * @returns the current mesh
  25996. */
  25997. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25998. /**
  25999. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26000. * Supports definition of mesh facing forward or backward.
  26001. * @param flipBack defines the flip
  26002. * @param twirlClockwise defines the twirl
  26003. * @param tiltRight defines the tilt
  26004. * @returns the new rotation vector
  26005. */
  26006. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26007. /**
  26008. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26009. * This means the mesh underlying bounding box and sphere are recomputed.
  26010. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26011. * @returns the current mesh
  26012. */
  26013. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26014. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26015. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26016. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  26017. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26018. /** @hidden */
  26019. protected _afterComputeWorldMatrix(): void;
  26020. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  26021. /**
  26022. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26023. * A mesh is in the frustum if its bounding box intersects the frustum
  26024. * @param frustumPlanes defines the frustum to test
  26025. * @returns true if the mesh is in the frustum planes
  26026. */
  26027. isInFrustum(frustumPlanes: Plane[]): boolean;
  26028. /**
  26029. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26030. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26031. * @param frustumPlanes defines the frustum to test
  26032. * @returns true if the mesh is completely in the frustum planes
  26033. */
  26034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26035. /**
  26036. * True if the mesh intersects another mesh or a SolidParticle object
  26037. * @param mesh defines a target mesh or SolidParticle to test
  26038. * @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)
  26039. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26040. * @returns true if there is an intersection
  26041. */
  26042. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26043. /**
  26044. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26045. * @param point defines the point to test
  26046. * @returns true if there is an intersection
  26047. */
  26048. intersectsPoint(point: Vector3): boolean;
  26049. /**
  26050. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26051. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26052. */
  26053. checkCollisions: boolean;
  26054. /**
  26055. * Gets Collider object used to compute collisions (not physics)
  26056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26057. */
  26058. readonly collider: Nullable<Collider>;
  26059. /**
  26060. * Move the mesh using collision engine
  26061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26062. * @param displacement defines the requested displacement vector
  26063. * @returns the current mesh
  26064. */
  26065. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26066. private _onCollisionPositionChange;
  26067. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26068. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26069. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  26070. /** @hidden */ private _generatePointsArray(): boolean;
  26071. /**
  26072. * Checks if the passed Ray intersects with the mesh
  26073. * @param ray defines the ray to use
  26074. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26075. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26076. * @returns the picking info
  26077. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26078. */
  26079. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26080. /**
  26081. * Clones the current mesh
  26082. * @param name defines the mesh name
  26083. * @param newParent defines the new mesh parent
  26084. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26085. * @returns the new mesh
  26086. */
  26087. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26088. /**
  26089. * Disposes all the submeshes of the current meshnp
  26090. * @returns the current mesh
  26091. */
  26092. releaseSubMeshes(): AbstractMesh;
  26093. /**
  26094. * Releases resources associated with this abstract mesh.
  26095. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26096. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26097. */
  26098. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26099. /**
  26100. * Adds the passed mesh as a child to the current mesh
  26101. * @param mesh defines the child mesh
  26102. * @returns the current mesh
  26103. */
  26104. addChild(mesh: AbstractMesh): AbstractMesh;
  26105. /**
  26106. * Removes the passed mesh from the current mesh children list
  26107. * @param mesh defines the child mesh
  26108. * @returns the current mesh
  26109. */
  26110. removeChild(mesh: AbstractMesh): AbstractMesh;
  26111. /** @hidden */
  26112. private _initFacetData;
  26113. /**
  26114. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26115. * This method can be called within the render loop.
  26116. * 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
  26117. * @returns the current mesh
  26118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26119. */
  26120. updateFacetData(): AbstractMesh;
  26121. /**
  26122. * Returns the facetLocalNormals array.
  26123. * The normals are expressed in the mesh local spac
  26124. * @returns an array of Vector3
  26125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26126. */
  26127. getFacetLocalNormals(): Vector3[];
  26128. /**
  26129. * Returns the facetLocalPositions array.
  26130. * The facet positions are expressed in the mesh local space
  26131. * @returns an array of Vector3
  26132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26133. */
  26134. getFacetLocalPositions(): Vector3[];
  26135. /**
  26136. * Returns the facetLocalPartioning array
  26137. * @returns an array of array of numbers
  26138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26139. */
  26140. getFacetLocalPartitioning(): number[][];
  26141. /**
  26142. * Returns the i-th facet position in the world system.
  26143. * This method allocates a new Vector3 per call
  26144. * @param i defines the facet index
  26145. * @returns a new Vector3
  26146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26147. */
  26148. getFacetPosition(i: number): Vector3;
  26149. /**
  26150. * Sets the reference Vector3 with the i-th facet position in the world system
  26151. * @param i defines the facet index
  26152. * @param ref defines the target vector
  26153. * @returns the current mesh
  26154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26155. */
  26156. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26157. /**
  26158. * Returns the i-th facet normal in the world system.
  26159. * This method allocates a new Vector3 per call
  26160. * @param i defines the facet index
  26161. * @returns a new Vector3
  26162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26163. */
  26164. getFacetNormal(i: number): Vector3;
  26165. /**
  26166. * Sets the reference Vector3 with the i-th facet normal in the world system
  26167. * @param i defines the facet index
  26168. * @param ref defines the target vector
  26169. * @returns the current mesh
  26170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26171. */
  26172. getFacetNormalToRef(i: number, ref: Vector3): this;
  26173. /**
  26174. * 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)
  26175. * @param x defines x coordinate
  26176. * @param y defines y coordinate
  26177. * @param z defines z coordinate
  26178. * @returns the array of facet indexes
  26179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26180. */
  26181. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26182. /**
  26183. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26184. * @param projected sets as the (x,y,z) world projection on the facet
  26185. * @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
  26186. * @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
  26187. * @param x defines x coordinate
  26188. * @param y defines y coordinate
  26189. * @param z defines z coordinate
  26190. * @returns the face index if found (or null instead)
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26192. */
  26193. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26194. /**
  26195. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26196. * @param projected sets as the (x,y,z) local projection on the facet
  26197. * @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
  26198. * @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
  26199. * @param x defines x coordinate
  26200. * @param y defines y coordinate
  26201. * @param z defines z coordinate
  26202. * @returns the face index if found (or null instead)
  26203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26204. */
  26205. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26206. /**
  26207. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26208. * @returns the parameters
  26209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26210. */
  26211. getFacetDataParameters(): any;
  26212. /**
  26213. * Disables the feature FacetData and frees the related memory
  26214. * @returns the current mesh
  26215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26216. */
  26217. disableFacetData(): AbstractMesh;
  26218. /**
  26219. * Updates the AbstractMesh indices array
  26220. * @param indices defines the data source
  26221. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26222. * @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)
  26223. * @returns the current mesh
  26224. */
  26225. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26226. /**
  26227. * Creates new normals data for the mesh
  26228. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26229. * @returns the current mesh
  26230. */
  26231. createNormals(updatable: boolean): AbstractMesh;
  26232. /**
  26233. * Align the mesh with a normal
  26234. * @param normal defines the normal to use
  26235. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26236. * @returns the current mesh
  26237. */
  26238. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26239. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26240. /**
  26241. * Disables the mesh edge rendering mode
  26242. * @returns the currentAbstractMesh
  26243. */
  26244. disableEdgesRendering(): AbstractMesh;
  26245. /**
  26246. * Enables the edge rendering mode on the mesh.
  26247. * This mode makes the mesh edges visible
  26248. * @param epsilon defines the maximal distance between two angles to detect a face
  26249. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26250. * @returns the currentAbstractMesh
  26251. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26252. */
  26253. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26254. }
  26255. }
  26256. declare module BABYLON {
  26257. /**
  26258. * Interface used to define ActionEvent
  26259. */
  26260. export interface IActionEvent {
  26261. /** The mesh or sprite that triggered the action */
  26262. source: any;
  26263. /** The X mouse cursor position at the time of the event */
  26264. pointerX: number;
  26265. /** The Y mouse cursor position at the time of the event */
  26266. pointerY: number;
  26267. /** The mesh that is currently pointed at (can be null) */
  26268. meshUnderPointer: Nullable<AbstractMesh>;
  26269. /** the original (browser) event that triggered the ActionEvent */
  26270. sourceEvent?: any;
  26271. /** additional data for the event */
  26272. additionalData?: any;
  26273. }
  26274. /**
  26275. * ActionEvent is the event being sent when an action is triggered.
  26276. */
  26277. export class ActionEvent implements IActionEvent {
  26278. /** The mesh or sprite that triggered the action */
  26279. source: any;
  26280. /** The X mouse cursor position at the time of the event */
  26281. pointerX: number;
  26282. /** The Y mouse cursor position at the time of the event */
  26283. pointerY: number;
  26284. /** The mesh that is currently pointed at (can be null) */
  26285. meshUnderPointer: Nullable<AbstractMesh>;
  26286. /** the original (browser) event that triggered the ActionEvent */
  26287. sourceEvent?: any;
  26288. /** additional data for the event */
  26289. additionalData?: any;
  26290. /**
  26291. * Creates a new ActionEvent
  26292. * @param source The mesh or sprite that triggered the action
  26293. * @param pointerX The X mouse cursor position at the time of the event
  26294. * @param pointerY The Y mouse cursor position at the time of the event
  26295. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26296. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26297. * @param additionalData additional data for the event
  26298. */
  26299. constructor(
  26300. /** The mesh or sprite that triggered the action */
  26301. source: any,
  26302. /** The X mouse cursor position at the time of the event */
  26303. pointerX: number,
  26304. /** The Y mouse cursor position at the time of the event */
  26305. pointerY: number,
  26306. /** The mesh that is currently pointed at (can be null) */
  26307. meshUnderPointer: Nullable<AbstractMesh>,
  26308. /** the original (browser) event that triggered the ActionEvent */
  26309. sourceEvent?: any,
  26310. /** additional data for the event */
  26311. additionalData?: any);
  26312. /**
  26313. * Helper function to auto-create an ActionEvent from a source mesh.
  26314. * @param source The source mesh that triggered the event
  26315. * @param evt The original (browser) event
  26316. * @param additionalData additional data for the event
  26317. * @returns the new ActionEvent
  26318. */
  26319. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26320. /**
  26321. * Helper function to auto-create an ActionEvent from a source sprite
  26322. * @param source The source sprite that triggered the event
  26323. * @param scene Scene associated with the sprite
  26324. * @param evt The original (browser) event
  26325. * @param additionalData additional data for the event
  26326. * @returns the new ActionEvent
  26327. */
  26328. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26329. /**
  26330. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26331. * @param scene the scene where the event occurred
  26332. * @param evt The original (browser) event
  26333. * @returns the new ActionEvent
  26334. */
  26335. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26336. /**
  26337. * Helper function to auto-create an ActionEvent from a primitive
  26338. * @param prim defines the target primitive
  26339. * @param pointerPos defines the pointer position
  26340. * @param evt The original (browser) event
  26341. * @param additionalData additional data for the event
  26342. * @returns the new ActionEvent
  26343. */
  26344. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26345. }
  26346. }
  26347. declare module BABYLON {
  26348. /**
  26349. * Abstract class used to decouple action Manager from scene and meshes.
  26350. * Do not instantiate.
  26351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26352. */
  26353. export abstract class AbstractActionManager implements IDisposable {
  26354. /** Gets the list of active triggers */
  26355. static Triggers: {
  26356. [key: string]: number;
  26357. };
  26358. /** Gets the cursor to use when hovering items */
  26359. hoverCursor: string;
  26360. /** Gets the list of actions */
  26361. actions: IAction[];
  26362. /**
  26363. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26364. */
  26365. isRecursive: boolean;
  26366. /**
  26367. * Releases all associated resources
  26368. */
  26369. abstract dispose(): void;
  26370. /**
  26371. * Does this action manager has pointer triggers
  26372. */
  26373. abstract readonly hasPointerTriggers: boolean;
  26374. /**
  26375. * Does this action manager has pick triggers
  26376. */
  26377. abstract readonly hasPickTriggers: boolean;
  26378. /**
  26379. * Process a specific trigger
  26380. * @param trigger defines the trigger to process
  26381. * @param evt defines the event details to be processed
  26382. */
  26383. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26384. /**
  26385. * Does this action manager handles actions of any of the given triggers
  26386. * @param triggers defines the triggers to be tested
  26387. * @return a boolean indicating whether one (or more) of the triggers is handled
  26388. */
  26389. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26390. /**
  26391. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26392. * speed.
  26393. * @param triggerA defines the trigger to be tested
  26394. * @param triggerB defines the trigger to be tested
  26395. * @return a boolean indicating whether one (or more) of the triggers is handled
  26396. */
  26397. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26398. /**
  26399. * Does this action manager handles actions of a given trigger
  26400. * @param trigger defines the trigger to be tested
  26401. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26402. * @return whether the trigger is handled
  26403. */
  26404. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26405. /**
  26406. * Serialize this manager to a JSON object
  26407. * @param name defines the property name to store this manager
  26408. * @returns a JSON representation of this manager
  26409. */
  26410. abstract serialize(name: string): any;
  26411. /**
  26412. * Registers an action to this action manager
  26413. * @param action defines the action to be registered
  26414. * @return the action amended (prepared) after registration
  26415. */
  26416. abstract registerAction(action: IAction): Nullable<IAction>;
  26417. /**
  26418. * Unregisters an action to this action manager
  26419. * @param action defines the action to be unregistered
  26420. * @return a boolean indicating whether the action has been unregistered
  26421. */
  26422. abstract unregisterAction(action: IAction): Boolean;
  26423. /**
  26424. * Does exist one action manager with at least one trigger
  26425. **/
  26426. static readonly HasTriggers: boolean;
  26427. /**
  26428. * Does exist one action manager with at least one pick trigger
  26429. **/
  26430. static readonly HasPickTriggers: boolean;
  26431. /**
  26432. * Does exist one action manager that handles actions of a given trigger
  26433. * @param trigger defines the trigger to be tested
  26434. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26435. **/
  26436. static HasSpecificTrigger(trigger: number): boolean;
  26437. }
  26438. }
  26439. declare module BABYLON {
  26440. /**
  26441. * Defines how a node can be built from a string name.
  26442. */
  26443. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26444. /**
  26445. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26446. */
  26447. export class Node implements IBehaviorAware<Node> {
  26448. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26449. private static _NodeConstructors;
  26450. /**
  26451. * Add a new node constructor
  26452. * @param type defines the type name of the node to construct
  26453. * @param constructorFunc defines the constructor function
  26454. */
  26455. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26456. /**
  26457. * Returns a node constructor based on type name
  26458. * @param type defines the type name
  26459. * @param name defines the new node name
  26460. * @param scene defines the hosting scene
  26461. * @param options defines optional options to transmit to constructors
  26462. * @returns the new constructor or null
  26463. */
  26464. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26465. /**
  26466. * Gets or sets the name of the node
  26467. */
  26468. name: string;
  26469. /**
  26470. * Gets or sets the id of the node
  26471. */
  26472. id: string;
  26473. /**
  26474. * Gets or sets the unique id of the node
  26475. */
  26476. uniqueId: number;
  26477. /**
  26478. * Gets or sets a string used to store user defined state for the node
  26479. */
  26480. state: string;
  26481. /**
  26482. * Gets or sets an object used to store user defined information for the node
  26483. */
  26484. metadata: any;
  26485. /**
  26486. * For internal use only. Please do not use.
  26487. */
  26488. reservedDataStore: any;
  26489. /**
  26490. * List of inspectable custom properties (used by the Inspector)
  26491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26492. */
  26493. inspectableCustomProperties: IInspectable[];
  26494. private _doNotSerialize;
  26495. /**
  26496. * Gets or sets a boolean used to define if the node must be serialized
  26497. */
  26498. doNotSerialize: boolean;
  26499. /** @hidden */ private _isDisposed: boolean;
  26500. /**
  26501. * Gets a list of Animations associated with the node
  26502. */
  26503. animations: Animation[];
  26504. protected _ranges: {
  26505. [name: string]: Nullable<AnimationRange>;
  26506. };
  26507. /**
  26508. * Callback raised when the node is ready to be used
  26509. */
  26510. onReady: Nullable<(node: Node) => void>;
  26511. private _isEnabled;
  26512. private _isParentEnabled;
  26513. private _isReady;
  26514. /** @hidden */ private _currentRenderId: number;
  26515. private _parentUpdateId;
  26516. /** @hidden */ private _childUpdateId: number;
  26517. /** @hidden */ private _waitingParentId: Nullable<string>;
  26518. /** @hidden */ private _scene: Scene;
  26519. /** @hidden */ private _cache: any;
  26520. private _parentNode;
  26521. private _children;
  26522. /** @hidden */ private _worldMatrix: Matrix;
  26523. /** @hidden */ private _worldMatrixDeterminant: number;
  26524. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26525. /** @hidden */
  26526. private _sceneRootNodesIndex;
  26527. /**
  26528. * Gets a boolean indicating if the node has been disposed
  26529. * @returns true if the node was disposed
  26530. */
  26531. isDisposed(): boolean;
  26532. /**
  26533. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26534. * @see https://doc.babylonjs.com/how_to/parenting
  26535. */
  26536. parent: Nullable<Node>;
  26537. /** @hidden */ private _addToSceneRootNodes(): void;
  26538. /** @hidden */ private _removeFromSceneRootNodes(): void;
  26539. private _animationPropertiesOverride;
  26540. /**
  26541. * Gets or sets the animation properties override
  26542. */
  26543. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26544. /**
  26545. * Gets a string idenfifying the name of the class
  26546. * @returns "Node" string
  26547. */
  26548. getClassName(): string;
  26549. /** @hidden */ protected readonly _isNode: boolean;
  26550. /**
  26551. * An event triggered when the mesh is disposed
  26552. */
  26553. onDisposeObservable: Observable<Node>;
  26554. private _onDisposeObserver;
  26555. /**
  26556. * Sets a callback that will be raised when the node will be disposed
  26557. */
  26558. onDispose: () => void;
  26559. /**
  26560. * Creates a new Node
  26561. * @param name the name and id to be given to this node
  26562. * @param scene the scene this node will be added to
  26563. */
  26564. constructor(name: string, scene?: Nullable<Scene>);
  26565. /**
  26566. * Gets the scene of the node
  26567. * @returns a scene
  26568. */
  26569. getScene(): Scene;
  26570. /**
  26571. * Gets the engine of the node
  26572. * @returns a Engine
  26573. */
  26574. getEngine(): Engine;
  26575. private _behaviors;
  26576. /**
  26577. * Attach a behavior to the node
  26578. * @see http://doc.babylonjs.com/features/behaviour
  26579. * @param behavior defines the behavior to attach
  26580. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26581. * @returns the current Node
  26582. */
  26583. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26584. /**
  26585. * Remove an attached behavior
  26586. * @see http://doc.babylonjs.com/features/behaviour
  26587. * @param behavior defines the behavior to attach
  26588. * @returns the current Node
  26589. */
  26590. removeBehavior(behavior: Behavior<Node>): Node;
  26591. /**
  26592. * Gets the list of attached behaviors
  26593. * @see http://doc.babylonjs.com/features/behaviour
  26594. */
  26595. readonly behaviors: Behavior<Node>[];
  26596. /**
  26597. * Gets an attached behavior by name
  26598. * @param name defines the name of the behavior to look for
  26599. * @see http://doc.babylonjs.com/features/behaviour
  26600. * @returns null if behavior was not found else the requested behavior
  26601. */
  26602. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26603. /**
  26604. * Returns the latest update of the World matrix
  26605. * @returns a Matrix
  26606. */
  26607. getWorldMatrix(): Matrix;
  26608. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26609. /**
  26610. * Returns directly the latest state of the mesh World matrix.
  26611. * A Matrix is returned.
  26612. */
  26613. readonly worldMatrixFromCache: Matrix;
  26614. /** @hidden */ private _initCache(): void;
  26615. /** @hidden */
  26616. updateCache(force?: boolean): void;
  26617. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26618. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26619. /** @hidden */ private _isSynchronized(): boolean;
  26620. /** @hidden */ private _markSyncedWithParent(): void;
  26621. /** @hidden */
  26622. isSynchronizedWithParent(): boolean;
  26623. /** @hidden */
  26624. isSynchronized(): boolean;
  26625. /**
  26626. * Is this node ready to be used/rendered
  26627. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26628. * @return true if the node is ready
  26629. */
  26630. isReady(completeCheck?: boolean): boolean;
  26631. /**
  26632. * Is this node enabled?
  26633. * 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
  26634. * @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
  26635. * @return whether this node (and its parent) is enabled
  26636. */
  26637. isEnabled(checkAncestors?: boolean): boolean;
  26638. /** @hidden */
  26639. protected _syncParentEnabledState(): void;
  26640. /**
  26641. * Set the enabled state of this node
  26642. * @param value defines the new enabled state
  26643. */
  26644. setEnabled(value: boolean): void;
  26645. /**
  26646. * Is this node a descendant of the given node?
  26647. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26648. * @param ancestor defines the parent node to inspect
  26649. * @returns a boolean indicating if this node is a descendant of the given node
  26650. */
  26651. isDescendantOf(ancestor: Node): boolean;
  26652. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26653. /**
  26654. * Will return all nodes that have this node as ascendant
  26655. * @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
  26656. * @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
  26657. * @return all children nodes of all types
  26658. */
  26659. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26660. /**
  26661. * Get all child-meshes of this node
  26662. * @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)
  26663. * @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
  26664. * @returns an array of AbstractMesh
  26665. */
  26666. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26667. /**
  26668. * Get all direct children of this node
  26669. * @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
  26670. * @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)
  26671. * @returns an array of Node
  26672. */
  26673. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26674. /** @hidden */ private _setReady(state: boolean): void;
  26675. /**
  26676. * Get an animation by name
  26677. * @param name defines the name of the animation to look for
  26678. * @returns null if not found else the requested animation
  26679. */
  26680. getAnimationByName(name: string): Nullable<Animation>;
  26681. /**
  26682. * Creates an animation range for this node
  26683. * @param name defines the name of the range
  26684. * @param from defines the starting key
  26685. * @param to defines the end key
  26686. */
  26687. createAnimationRange(name: string, from: number, to: number): void;
  26688. /**
  26689. * Delete a specific animation range
  26690. * @param name defines the name of the range to delete
  26691. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26692. */
  26693. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26694. /**
  26695. * Get an animation range by name
  26696. * @param name defines the name of the animation range to look for
  26697. * @returns null if not found else the requested animation range
  26698. */
  26699. getAnimationRange(name: string): Nullable<AnimationRange>;
  26700. /**
  26701. * Gets the list of all animation ranges defined on this node
  26702. * @returns an array
  26703. */
  26704. getAnimationRanges(): Nullable<AnimationRange>[];
  26705. /**
  26706. * Will start the animation sequence
  26707. * @param name defines the range frames for animation sequence
  26708. * @param loop defines if the animation should loop (false by default)
  26709. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26710. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26711. * @returns the object created for this animation. If range does not exist, it will return null
  26712. */
  26713. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26714. /**
  26715. * Serialize animation ranges into a JSON compatible object
  26716. * @returns serialization object
  26717. */
  26718. serializeAnimationRanges(): any;
  26719. /**
  26720. * Computes the world matrix of the node
  26721. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26722. * @returns the world matrix
  26723. */
  26724. computeWorldMatrix(force?: boolean): Matrix;
  26725. /**
  26726. * Releases resources associated with this node.
  26727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26729. */
  26730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26731. /**
  26732. * Parse animation range data from a serialization object and store them into a given node
  26733. * @param node defines where to store the animation ranges
  26734. * @param parsedNode defines the serialization object to read data from
  26735. * @param scene defines the hosting scene
  26736. */
  26737. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26738. /**
  26739. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26740. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26741. * @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
  26742. * @returns the new bounding vectors
  26743. */
  26744. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26745. min: Vector3;
  26746. max: Vector3;
  26747. };
  26748. }
  26749. }
  26750. declare module BABYLON {
  26751. /**
  26752. * @hidden
  26753. */
  26754. export class _IAnimationState {
  26755. key: number;
  26756. repeatCount: number;
  26757. workValue?: any;
  26758. loopMode?: number;
  26759. offsetValue?: any;
  26760. highLimitValue?: any;
  26761. }
  26762. /**
  26763. * Class used to store any kind of animation
  26764. */
  26765. export class Animation {
  26766. /**Name of the animation */
  26767. name: string;
  26768. /**Property to animate */
  26769. targetProperty: string;
  26770. /**The frames per second of the animation */
  26771. framePerSecond: number;
  26772. /**The data type of the animation */
  26773. dataType: number;
  26774. /**The loop mode of the animation */
  26775. loopMode?: number | undefined;
  26776. /**Specifies if blending should be enabled */
  26777. enableBlending?: boolean | undefined;
  26778. /**
  26779. * Use matrix interpolation instead of using direct key value when animating matrices
  26780. */
  26781. static AllowMatricesInterpolation: boolean;
  26782. /**
  26783. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26784. */
  26785. static AllowMatrixDecomposeForInterpolation: boolean;
  26786. /**
  26787. * Stores the key frames of the animation
  26788. */
  26789. private _keys;
  26790. /**
  26791. * Stores the easing function of the animation
  26792. */
  26793. private _easingFunction;
  26794. /**
  26795. * @hidden Internal use only
  26796. */ private _runtimeAnimations: RuntimeAnimation[];
  26797. /**
  26798. * The set of event that will be linked to this animation
  26799. */
  26800. private _events;
  26801. /**
  26802. * Stores an array of target property paths
  26803. */
  26804. targetPropertyPath: string[];
  26805. /**
  26806. * Stores the blending speed of the animation
  26807. */
  26808. blendingSpeed: number;
  26809. /**
  26810. * Stores the animation ranges for the animation
  26811. */
  26812. private _ranges;
  26813. /**
  26814. * @hidden Internal use
  26815. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26816. /**
  26817. * Sets up an animation
  26818. * @param property The property to animate
  26819. * @param animationType The animation type to apply
  26820. * @param framePerSecond The frames per second of the animation
  26821. * @param easingFunction The easing function used in the animation
  26822. * @returns The created animation
  26823. */
  26824. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26825. /**
  26826. * Create and start an animation on a node
  26827. * @param name defines the name of the global animation that will be run on all nodes
  26828. * @param node defines the root node where the animation will take place
  26829. * @param targetProperty defines property to animate
  26830. * @param framePerSecond defines the number of frame per second yo use
  26831. * @param totalFrame defines the number of frames in total
  26832. * @param from defines the initial value
  26833. * @param to defines the final value
  26834. * @param loopMode defines which loop mode you want to use (off by default)
  26835. * @param easingFunction defines the easing function to use (linear by default)
  26836. * @param onAnimationEnd defines the callback to call when animation end
  26837. * @returns the animatable created for this animation
  26838. */
  26839. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26840. /**
  26841. * Create and start an animation on a node and its descendants
  26842. * @param name defines the name of the global animation that will be run on all nodes
  26843. * @param node defines the root node where the animation will take place
  26844. * @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
  26845. * @param targetProperty defines property to animate
  26846. * @param framePerSecond defines the number of frame per second to use
  26847. * @param totalFrame defines the number of frames in total
  26848. * @param from defines the initial value
  26849. * @param to defines the final value
  26850. * @param loopMode defines which loop mode you want to use (off by default)
  26851. * @param easingFunction defines the easing function to use (linear by default)
  26852. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26853. * @returns the list of animatables created for all nodes
  26854. * @example https://www.babylonjs-playground.com/#MH0VLI
  26855. */
  26856. 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[]>;
  26857. /**
  26858. * Creates a new animation, merges it with the existing animations and starts it
  26859. * @param name Name of the animation
  26860. * @param node Node which contains the scene that begins the animations
  26861. * @param targetProperty Specifies which property to animate
  26862. * @param framePerSecond The frames per second of the animation
  26863. * @param totalFrame The total number of frames
  26864. * @param from The frame at the beginning of the animation
  26865. * @param to The frame at the end of the animation
  26866. * @param loopMode Specifies the loop mode of the animation
  26867. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26868. * @param onAnimationEnd Callback to run once the animation is complete
  26869. * @returns Nullable animation
  26870. */
  26871. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26872. /**
  26873. * Transition property of an host to the target Value
  26874. * @param property The property to transition
  26875. * @param targetValue The target Value of the property
  26876. * @param host The object where the property to animate belongs
  26877. * @param scene Scene used to run the animation
  26878. * @param frameRate Framerate (in frame/s) to use
  26879. * @param transition The transition type we want to use
  26880. * @param duration The duration of the animation, in milliseconds
  26881. * @param onAnimationEnd Callback trigger at the end of the animation
  26882. * @returns Nullable animation
  26883. */
  26884. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26885. /**
  26886. * Return the array of runtime animations currently using this animation
  26887. */
  26888. readonly runtimeAnimations: RuntimeAnimation[];
  26889. /**
  26890. * Specifies if any of the runtime animations are currently running
  26891. */
  26892. readonly hasRunningRuntimeAnimations: boolean;
  26893. /**
  26894. * Initializes the animation
  26895. * @param name Name of the animation
  26896. * @param targetProperty Property to animate
  26897. * @param framePerSecond The frames per second of the animation
  26898. * @param dataType The data type of the animation
  26899. * @param loopMode The loop mode of the animation
  26900. * @param enableBlending Specifies if blending should be enabled
  26901. */
  26902. constructor(
  26903. /**Name of the animation */
  26904. name: string,
  26905. /**Property to animate */
  26906. targetProperty: string,
  26907. /**The frames per second of the animation */
  26908. framePerSecond: number,
  26909. /**The data type of the animation */
  26910. dataType: number,
  26911. /**The loop mode of the animation */
  26912. loopMode?: number | undefined,
  26913. /**Specifies if blending should be enabled */
  26914. enableBlending?: boolean | undefined);
  26915. /**
  26916. * Converts the animation to a string
  26917. * @param fullDetails support for multiple levels of logging within scene loading
  26918. * @returns String form of the animation
  26919. */
  26920. toString(fullDetails?: boolean): string;
  26921. /**
  26922. * Add an event to this animation
  26923. * @param event Event to add
  26924. */
  26925. addEvent(event: AnimationEvent): void;
  26926. /**
  26927. * Remove all events found at the given frame
  26928. * @param frame The frame to remove events from
  26929. */
  26930. removeEvents(frame: number): void;
  26931. /**
  26932. * Retrieves all the events from the animation
  26933. * @returns Events from the animation
  26934. */
  26935. getEvents(): AnimationEvent[];
  26936. /**
  26937. * Creates an animation range
  26938. * @param name Name of the animation range
  26939. * @param from Starting frame of the animation range
  26940. * @param to Ending frame of the animation
  26941. */
  26942. createRange(name: string, from: number, to: number): void;
  26943. /**
  26944. * Deletes an animation range by name
  26945. * @param name Name of the animation range to delete
  26946. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26947. */
  26948. deleteRange(name: string, deleteFrames?: boolean): void;
  26949. /**
  26950. * Gets the animation range by name, or null if not defined
  26951. * @param name Name of the animation range
  26952. * @returns Nullable animation range
  26953. */
  26954. getRange(name: string): Nullable<AnimationRange>;
  26955. /**
  26956. * Gets the key frames from the animation
  26957. * @returns The key frames of the animation
  26958. */
  26959. getKeys(): Array<IAnimationKey>;
  26960. /**
  26961. * Gets the highest frame rate of the animation
  26962. * @returns Highest frame rate of the animation
  26963. */
  26964. getHighestFrame(): number;
  26965. /**
  26966. * Gets the easing function of the animation
  26967. * @returns Easing function of the animation
  26968. */
  26969. getEasingFunction(): IEasingFunction;
  26970. /**
  26971. * Sets the easing function of the animation
  26972. * @param easingFunction A custom mathematical formula for animation
  26973. */
  26974. setEasingFunction(easingFunction: EasingFunction): void;
  26975. /**
  26976. * Interpolates a scalar linearly
  26977. * @param startValue Start value of the animation curve
  26978. * @param endValue End value of the animation curve
  26979. * @param gradient Scalar amount to interpolate
  26980. * @returns Interpolated scalar value
  26981. */
  26982. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26983. /**
  26984. * Interpolates a scalar cubically
  26985. * @param startValue Start value of the animation curve
  26986. * @param outTangent End tangent of the animation
  26987. * @param endValue End value of the animation curve
  26988. * @param inTangent Start tangent of the animation curve
  26989. * @param gradient Scalar amount to interpolate
  26990. * @returns Interpolated scalar value
  26991. */
  26992. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26993. /**
  26994. * Interpolates a quaternion using a spherical linear interpolation
  26995. * @param startValue Start value of the animation curve
  26996. * @param endValue End value of the animation curve
  26997. * @param gradient Scalar amount to interpolate
  26998. * @returns Interpolated quaternion value
  26999. */
  27000. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27001. /**
  27002. * Interpolates a quaternion cubically
  27003. * @param startValue Start value of the animation curve
  27004. * @param outTangent End tangent of the animation curve
  27005. * @param endValue End value of the animation curve
  27006. * @param inTangent Start tangent of the animation curve
  27007. * @param gradient Scalar amount to interpolate
  27008. * @returns Interpolated quaternion value
  27009. */
  27010. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27011. /**
  27012. * Interpolates a Vector3 linearl
  27013. * @param startValue Start value of the animation curve
  27014. * @param endValue End value of the animation curve
  27015. * @param gradient Scalar amount to interpolate
  27016. * @returns Interpolated scalar value
  27017. */
  27018. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27019. /**
  27020. * Interpolates a Vector3 cubically
  27021. * @param startValue Start value of the animation curve
  27022. * @param outTangent End tangent of the animation
  27023. * @param endValue End value of the animation curve
  27024. * @param inTangent Start tangent of the animation curve
  27025. * @param gradient Scalar amount to interpolate
  27026. * @returns InterpolatedVector3 value
  27027. */
  27028. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27029. /**
  27030. * Interpolates a Vector2 linearly
  27031. * @param startValue Start value of the animation curve
  27032. * @param endValue End value of the animation curve
  27033. * @param gradient Scalar amount to interpolate
  27034. * @returns Interpolated Vector2 value
  27035. */
  27036. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27037. /**
  27038. * Interpolates a Vector2 cubically
  27039. * @param startValue Start value of the animation curve
  27040. * @param outTangent End tangent of the animation
  27041. * @param endValue End value of the animation curve
  27042. * @param inTangent Start tangent of the animation curve
  27043. * @param gradient Scalar amount to interpolate
  27044. * @returns Interpolated Vector2 value
  27045. */
  27046. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27047. /**
  27048. * Interpolates a size linearly
  27049. * @param startValue Start value of the animation curve
  27050. * @param endValue End value of the animation curve
  27051. * @param gradient Scalar amount to interpolate
  27052. * @returns Interpolated Size value
  27053. */
  27054. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27055. /**
  27056. * Interpolates a Color3 linearly
  27057. * @param startValue Start value of the animation curve
  27058. * @param endValue End value of the animation curve
  27059. * @param gradient Scalar amount to interpolate
  27060. * @returns Interpolated Color3 value
  27061. */
  27062. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27063. /**
  27064. * Interpolates a Color4 linearly
  27065. * @param startValue Start value of the animation curve
  27066. * @param endValue End value of the animation curve
  27067. * @param gradient Scalar amount to interpolate
  27068. * @returns Interpolated Color3 value
  27069. */
  27070. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27071. /**
  27072. * @hidden Internal use only
  27073. */ private _getKeyValue(value: any): any;
  27074. /**
  27075. * @hidden Internal use only
  27076. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  27077. /**
  27078. * Defines the function to use to interpolate matrices
  27079. * @param startValue defines the start matrix
  27080. * @param endValue defines the end matrix
  27081. * @param gradient defines the gradient between both matrices
  27082. * @param result defines an optional target matrix where to store the interpolation
  27083. * @returns the interpolated matrix
  27084. */
  27085. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27086. /**
  27087. * Makes a copy of the animation
  27088. * @returns Cloned animation
  27089. */
  27090. clone(): Animation;
  27091. /**
  27092. * Sets the key frames of the animation
  27093. * @param values The animation key frames to set
  27094. */
  27095. setKeys(values: Array<IAnimationKey>): void;
  27096. /**
  27097. * Serializes the animation to an object
  27098. * @returns Serialized object
  27099. */
  27100. serialize(): any;
  27101. /**
  27102. * Float animation type
  27103. */
  27104. static readonly ANIMATIONTYPE_FLOAT: number;
  27105. /**
  27106. * Vector3 animation type
  27107. */
  27108. static readonly ANIMATIONTYPE_VECTOR3: number;
  27109. /**
  27110. * Quaternion animation type
  27111. */
  27112. static readonly ANIMATIONTYPE_QUATERNION: number;
  27113. /**
  27114. * Matrix animation type
  27115. */
  27116. static readonly ANIMATIONTYPE_MATRIX: number;
  27117. /**
  27118. * Color3 animation type
  27119. */
  27120. static readonly ANIMATIONTYPE_COLOR3: number;
  27121. /**
  27122. * Color3 animation type
  27123. */
  27124. static readonly ANIMATIONTYPE_COLOR4: number;
  27125. /**
  27126. * Vector2 animation type
  27127. */
  27128. static readonly ANIMATIONTYPE_VECTOR2: number;
  27129. /**
  27130. * Size animation type
  27131. */
  27132. static readonly ANIMATIONTYPE_SIZE: number;
  27133. /**
  27134. * Relative Loop Mode
  27135. */
  27136. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27137. /**
  27138. * Cycle Loop Mode
  27139. */
  27140. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27141. /**
  27142. * Constant Loop Mode
  27143. */
  27144. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27145. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  27146. /**
  27147. * Parses an animation object and creates an animation
  27148. * @param parsedAnimation Parsed animation object
  27149. * @returns Animation object
  27150. */
  27151. static Parse(parsedAnimation: any): Animation;
  27152. /**
  27153. * Appends the serialized animations from the source animations
  27154. * @param source Source containing the animations
  27155. * @param destination Target to store the animations
  27156. */
  27157. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27158. }
  27159. }
  27160. declare module BABYLON {
  27161. /**
  27162. * Interface containing an array of animations
  27163. */
  27164. export interface IAnimatable {
  27165. /**
  27166. * Array of animations
  27167. */
  27168. animations: Nullable<Array<Animation>>;
  27169. }
  27170. }
  27171. declare module BABYLON {
  27172. /**
  27173. * This represents all the required information to add a fresnel effect on a material:
  27174. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27175. */
  27176. export class FresnelParameters {
  27177. private _isEnabled;
  27178. /**
  27179. * Define if the fresnel effect is enable or not.
  27180. */
  27181. isEnabled: boolean;
  27182. /**
  27183. * Define the color used on edges (grazing angle)
  27184. */
  27185. leftColor: Color3;
  27186. /**
  27187. * Define the color used on center
  27188. */
  27189. rightColor: Color3;
  27190. /**
  27191. * Define bias applied to computed fresnel term
  27192. */
  27193. bias: number;
  27194. /**
  27195. * Defined the power exponent applied to fresnel term
  27196. */
  27197. power: number;
  27198. /**
  27199. * Clones the current fresnel and its valuues
  27200. * @returns a clone fresnel configuration
  27201. */
  27202. clone(): FresnelParameters;
  27203. /**
  27204. * Serializes the current fresnel parameters to a JSON representation.
  27205. * @return the JSON serialization
  27206. */
  27207. serialize(): any;
  27208. /**
  27209. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27210. * @param parsedFresnelParameters Define the JSON representation
  27211. * @returns the parsed parameters
  27212. */
  27213. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27214. }
  27215. }
  27216. declare module BABYLON {
  27217. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27218. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27219. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27220. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27221. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27222. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27223. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27224. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27225. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27226. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27227. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27228. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27229. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27230. /**
  27231. * Decorator used to define property that can be serialized as reference to a camera
  27232. * @param sourceName defines the name of the property to decorate
  27233. */
  27234. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27235. /**
  27236. * Class used to help serialization objects
  27237. */
  27238. export class SerializationHelper {
  27239. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27240. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27241. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27242. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27243. /**
  27244. * Appends the serialized animations from the source animations
  27245. * @param source Source containing the animations
  27246. * @param destination Target to store the animations
  27247. */
  27248. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27249. /**
  27250. * Static function used to serialized a specific entity
  27251. * @param entity defines the entity to serialize
  27252. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27253. * @returns a JSON compatible object representing the serialization of the entity
  27254. */
  27255. static Serialize<T>(entity: T, serializationObject?: any): any;
  27256. /**
  27257. * Creates a new entity from a serialization data object
  27258. * @param creationFunction defines a function used to instanciated the new entity
  27259. * @param source defines the source serialization data
  27260. * @param scene defines the hosting scene
  27261. * @param rootUrl defines the root url for resources
  27262. * @returns a new entity
  27263. */
  27264. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27265. /**
  27266. * Clones an object
  27267. * @param creationFunction defines the function used to instanciate the new object
  27268. * @param source defines the source object
  27269. * @returns the cloned object
  27270. */
  27271. static Clone<T>(creationFunction: () => T, source: T): T;
  27272. /**
  27273. * Instanciates a new object based on a source one (some data will be shared between both object)
  27274. * @param creationFunction defines the function used to instanciate the new object
  27275. * @param source defines the source object
  27276. * @returns the new object
  27277. */
  27278. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27279. }
  27280. }
  27281. declare module BABYLON {
  27282. /**
  27283. * Class used to manipulate GUIDs
  27284. */
  27285. export class GUID {
  27286. /**
  27287. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27288. * Be aware Math.random() could cause collisions, but:
  27289. * "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"
  27290. * @returns a pseudo random id
  27291. */
  27292. static RandomId(): string;
  27293. }
  27294. }
  27295. declare module BABYLON {
  27296. /**
  27297. * Base class of all the textures in babylon.
  27298. * It groups all the common properties the materials, post process, lights... might need
  27299. * in order to make a correct use of the texture.
  27300. */
  27301. export class BaseTexture implements IAnimatable {
  27302. /**
  27303. * Default anisotropic filtering level for the application.
  27304. * It is set to 4 as a good tradeoff between perf and quality.
  27305. */
  27306. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27307. /**
  27308. * Gets or sets the unique id of the texture
  27309. */
  27310. uniqueId: number;
  27311. /**
  27312. * Define the name of the texture.
  27313. */
  27314. name: string;
  27315. /**
  27316. * Gets or sets an object used to store user defined information.
  27317. */
  27318. metadata: any;
  27319. /**
  27320. * For internal use only. Please do not use.
  27321. */
  27322. reservedDataStore: any;
  27323. private _hasAlpha;
  27324. /**
  27325. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27326. */
  27327. hasAlpha: boolean;
  27328. /**
  27329. * Defines if the alpha value should be determined via the rgb values.
  27330. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27331. */
  27332. getAlphaFromRGB: boolean;
  27333. /**
  27334. * Intensity or strength of the texture.
  27335. * It is commonly used by materials to fine tune the intensity of the texture
  27336. */
  27337. level: number;
  27338. /**
  27339. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27340. * This is part of the texture as textures usually maps to one uv set.
  27341. */
  27342. coordinatesIndex: number;
  27343. private _coordinatesMode;
  27344. /**
  27345. * How a texture is mapped.
  27346. *
  27347. * | Value | Type | Description |
  27348. * | ----- | ----------------------------------- | ----------- |
  27349. * | 0 | EXPLICIT_MODE | |
  27350. * | 1 | SPHERICAL_MODE | |
  27351. * | 2 | PLANAR_MODE | |
  27352. * | 3 | CUBIC_MODE | |
  27353. * | 4 | PROJECTION_MODE | |
  27354. * | 5 | SKYBOX_MODE | |
  27355. * | 6 | INVCUBIC_MODE | |
  27356. * | 7 | EQUIRECTANGULAR_MODE | |
  27357. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27358. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27359. */
  27360. coordinatesMode: number;
  27361. /**
  27362. * | Value | Type | Description |
  27363. * | ----- | ------------------ | ----------- |
  27364. * | 0 | CLAMP_ADDRESSMODE | |
  27365. * | 1 | WRAP_ADDRESSMODE | |
  27366. * | 2 | MIRROR_ADDRESSMODE | |
  27367. */
  27368. wrapU: number;
  27369. /**
  27370. * | Value | Type | Description |
  27371. * | ----- | ------------------ | ----------- |
  27372. * | 0 | CLAMP_ADDRESSMODE | |
  27373. * | 1 | WRAP_ADDRESSMODE | |
  27374. * | 2 | MIRROR_ADDRESSMODE | |
  27375. */
  27376. wrapV: number;
  27377. /**
  27378. * | Value | Type | Description |
  27379. * | ----- | ------------------ | ----------- |
  27380. * | 0 | CLAMP_ADDRESSMODE | |
  27381. * | 1 | WRAP_ADDRESSMODE | |
  27382. * | 2 | MIRROR_ADDRESSMODE | |
  27383. */
  27384. wrapR: number;
  27385. /**
  27386. * With compliant hardware and browser (supporting anisotropic filtering)
  27387. * this defines the level of anisotropic filtering in the texture.
  27388. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27389. */
  27390. anisotropicFilteringLevel: number;
  27391. /**
  27392. * Define if the texture is a cube texture or if false a 2d texture.
  27393. */
  27394. isCube: boolean;
  27395. /**
  27396. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27397. */
  27398. is3D: boolean;
  27399. /**
  27400. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27401. * HDR texture are usually stored in linear space.
  27402. * This only impacts the PBR and Background materials
  27403. */
  27404. gammaSpace: boolean;
  27405. /**
  27406. * Gets or sets whether or not the texture contains RGBD data.
  27407. */
  27408. isRGBD: boolean;
  27409. /**
  27410. * Is Z inverted in the texture (useful in a cube texture).
  27411. */
  27412. invertZ: boolean;
  27413. /**
  27414. * Are mip maps generated for this texture or not.
  27415. */
  27416. readonly noMipmap: boolean;
  27417. /**
  27418. * @hidden
  27419. */
  27420. lodLevelInAlpha: boolean;
  27421. /**
  27422. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27423. */
  27424. lodGenerationOffset: number;
  27425. /**
  27426. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27427. */
  27428. lodGenerationScale: number;
  27429. /**
  27430. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27431. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27432. * average roughness values.
  27433. */
  27434. linearSpecularLOD: boolean;
  27435. /**
  27436. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27437. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27438. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27439. */
  27440. irradianceTexture: Nullable<BaseTexture>;
  27441. /**
  27442. * Define if the texture is a render target.
  27443. */
  27444. isRenderTarget: boolean;
  27445. /**
  27446. * Define the unique id of the texture in the scene.
  27447. */
  27448. readonly uid: string;
  27449. /**
  27450. * Return a string representation of the texture.
  27451. * @returns the texture as a string
  27452. */
  27453. toString(): string;
  27454. /**
  27455. * Get the class name of the texture.
  27456. * @returns "BaseTexture"
  27457. */
  27458. getClassName(): string;
  27459. /**
  27460. * Define the list of animation attached to the texture.
  27461. */
  27462. animations: Animation[];
  27463. /**
  27464. * An event triggered when the texture is disposed.
  27465. */
  27466. onDisposeObservable: Observable<BaseTexture>;
  27467. private _onDisposeObserver;
  27468. /**
  27469. * Callback triggered when the texture has been disposed.
  27470. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27471. */
  27472. onDispose: () => void;
  27473. /**
  27474. * Define the current state of the loading sequence when in delayed load mode.
  27475. */
  27476. delayLoadState: number;
  27477. private _scene;
  27478. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27479. private _uid;
  27480. /**
  27481. * Define if the texture is preventinga material to render or not.
  27482. * If not and the texture is not ready, the engine will use a default black texture instead.
  27483. */
  27484. readonly isBlocking: boolean;
  27485. /**
  27486. * Instantiates a new BaseTexture.
  27487. * Base class of all the textures in babylon.
  27488. * It groups all the common properties the materials, post process, lights... might need
  27489. * in order to make a correct use of the texture.
  27490. * @param scene Define the scene the texture blongs to
  27491. */
  27492. constructor(scene: Nullable<Scene>);
  27493. /**
  27494. * Get the scene the texture belongs to.
  27495. * @returns the scene or null if undefined
  27496. */
  27497. getScene(): Nullable<Scene>;
  27498. /**
  27499. * Get the texture transform matrix used to offset tile the texture for istance.
  27500. * @returns the transformation matrix
  27501. */
  27502. getTextureMatrix(): Matrix;
  27503. /**
  27504. * Get the texture reflection matrix used to rotate/transform the reflection.
  27505. * @returns the reflection matrix
  27506. */
  27507. getReflectionTextureMatrix(): Matrix;
  27508. /**
  27509. * Get the underlying lower level texture from Babylon.
  27510. * @returns the insternal texture
  27511. */
  27512. getInternalTexture(): Nullable<InternalTexture>;
  27513. /**
  27514. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27515. * @returns true if ready or not blocking
  27516. */
  27517. isReadyOrNotBlocking(): boolean;
  27518. /**
  27519. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27520. * @returns true if fully ready
  27521. */
  27522. isReady(): boolean;
  27523. private _cachedSize;
  27524. /**
  27525. * Get the size of the texture.
  27526. * @returns the texture size.
  27527. */
  27528. getSize(): ISize;
  27529. /**
  27530. * Get the base size of the texture.
  27531. * It can be different from the size if the texture has been resized for POT for instance
  27532. * @returns the base size
  27533. */
  27534. getBaseSize(): ISize;
  27535. /**
  27536. * Update the sampling mode of the texture.
  27537. * Default is Trilinear mode.
  27538. *
  27539. * | Value | Type | Description |
  27540. * | ----- | ------------------ | ----------- |
  27541. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27542. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27543. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27544. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27545. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27546. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27547. * | 7 | NEAREST_LINEAR | |
  27548. * | 8 | NEAREST_NEAREST | |
  27549. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27550. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27551. * | 11 | LINEAR_LINEAR | |
  27552. * | 12 | LINEAR_NEAREST | |
  27553. *
  27554. * > _mag_: magnification filter (close to the viewer)
  27555. * > _min_: minification filter (far from the viewer)
  27556. * > _mip_: filter used between mip map levels
  27557. *@param samplingMode Define the new sampling mode of the texture
  27558. */
  27559. updateSamplingMode(samplingMode: number): void;
  27560. /**
  27561. * Scales the texture if is `canRescale()`
  27562. * @param ratio the resize factor we want to use to rescale
  27563. */
  27564. scale(ratio: number): void;
  27565. /**
  27566. * Get if the texture can rescale.
  27567. */
  27568. readonly canRescale: boolean;
  27569. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27570. /** @hidden */ private _rebuild(): void;
  27571. /**
  27572. * Triggers the load sequence in delayed load mode.
  27573. */
  27574. delayLoad(): void;
  27575. /**
  27576. * Clones the texture.
  27577. * @returns the cloned texture
  27578. */
  27579. clone(): Nullable<BaseTexture>;
  27580. /**
  27581. * Get the texture underlying type (INT, FLOAT...)
  27582. */
  27583. readonly textureType: number;
  27584. /**
  27585. * Get the texture underlying format (RGB, RGBA...)
  27586. */
  27587. readonly textureFormat: number;
  27588. /**
  27589. * Indicates that textures need to be re-calculated for all materials
  27590. */
  27591. protected _markAllSubMeshesAsTexturesDirty(): void;
  27592. /**
  27593. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27594. * This will returns an RGBA array buffer containing either in values (0-255) or
  27595. * float values (0-1) depending of the underlying buffer type.
  27596. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27597. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27598. * @param buffer defines a user defined buffer to fill with data (can be null)
  27599. * @returns The Array buffer containing the pixels data.
  27600. */
  27601. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27602. /**
  27603. * Release and destroy the underlying lower level texture aka internalTexture.
  27604. */
  27605. releaseInternalTexture(): void;
  27606. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27607. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27608. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27609. /**
  27610. * Dispose the texture and release its associated resources.
  27611. */
  27612. dispose(): void;
  27613. /**
  27614. * Serialize the texture into a JSON representation that can be parsed later on.
  27615. * @returns the JSON representation of the texture
  27616. */
  27617. serialize(): any;
  27618. /**
  27619. * Helper function to be called back once a list of texture contains only ready textures.
  27620. * @param textures Define the list of textures to wait for
  27621. * @param callback Define the callback triggered once the entire list will be ready
  27622. */
  27623. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27624. }
  27625. }
  27626. declare module BABYLON {
  27627. /**
  27628. * Options to be used when creating an effect.
  27629. */
  27630. export interface IEffectCreationOptions {
  27631. /**
  27632. * Atrributes that will be used in the shader.
  27633. */
  27634. attributes: string[];
  27635. /**
  27636. * Uniform varible names that will be set in the shader.
  27637. */
  27638. uniformsNames: string[];
  27639. /**
  27640. * Uniform buffer varible names that will be set in the shader.
  27641. */
  27642. uniformBuffersNames: string[];
  27643. /**
  27644. * Sampler texture variable names that will be set in the shader.
  27645. */
  27646. samplers: string[];
  27647. /**
  27648. * Define statements that will be set in the shader.
  27649. */
  27650. defines: any;
  27651. /**
  27652. * Possible fallbacks for this effect to improve performance when needed.
  27653. */
  27654. fallbacks: Nullable<IEffectFallbacks>;
  27655. /**
  27656. * Callback that will be called when the shader is compiled.
  27657. */
  27658. onCompiled: Nullable<(effect: Effect) => void>;
  27659. /**
  27660. * Callback that will be called if an error occurs during shader compilation.
  27661. */
  27662. onError: Nullable<(effect: Effect, errors: string) => void>;
  27663. /**
  27664. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27665. */
  27666. indexParameters?: any;
  27667. /**
  27668. * Max number of lights that can be used in the shader.
  27669. */
  27670. maxSimultaneousLights?: number;
  27671. /**
  27672. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27673. */
  27674. transformFeedbackVaryings?: Nullable<string[]>;
  27675. }
  27676. /**
  27677. * Effect containing vertex and fragment shader that can be executed on an object.
  27678. */
  27679. export class Effect implements IDisposable {
  27680. /**
  27681. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27682. */
  27683. static ShadersRepository: string;
  27684. /**
  27685. * Name of the effect.
  27686. */
  27687. name: any;
  27688. /**
  27689. * String container all the define statements that should be set on the shader.
  27690. */
  27691. defines: string;
  27692. /**
  27693. * Callback that will be called when the shader is compiled.
  27694. */
  27695. onCompiled: Nullable<(effect: Effect) => void>;
  27696. /**
  27697. * Callback that will be called if an error occurs during shader compilation.
  27698. */
  27699. onError: Nullable<(effect: Effect, errors: string) => void>;
  27700. /**
  27701. * Callback that will be called when effect is bound.
  27702. */
  27703. onBind: Nullable<(effect: Effect) => void>;
  27704. /**
  27705. * Unique ID of the effect.
  27706. */
  27707. uniqueId: number;
  27708. /**
  27709. * Observable that will be called when the shader is compiled.
  27710. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27711. */
  27712. onCompileObservable: Observable<Effect>;
  27713. /**
  27714. * Observable that will be called if an error occurs during shader compilation.
  27715. */
  27716. onErrorObservable: Observable<Effect>;
  27717. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27718. /**
  27719. * Observable that will be called when effect is bound.
  27720. */
  27721. readonly onBindObservable: Observable<Effect>;
  27722. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27723. private static _uniqueIdSeed;
  27724. private _engine;
  27725. private _uniformBuffersNames;
  27726. private _uniformsNames;
  27727. private _samplerList;
  27728. private _samplers;
  27729. private _isReady;
  27730. private _compilationError;
  27731. private _allFallbacksProcessed;
  27732. private _attributesNames;
  27733. private _attributes;
  27734. private _uniforms;
  27735. /**
  27736. * Key for the effect.
  27737. * @hidden
  27738. */ private _key: string;
  27739. private _indexParameters;
  27740. private _fallbacks;
  27741. private _vertexSourceCode;
  27742. private _fragmentSourceCode;
  27743. private _vertexSourceCodeOverride;
  27744. private _fragmentSourceCodeOverride;
  27745. private _transformFeedbackVaryings;
  27746. /**
  27747. * Compiled shader to webGL program.
  27748. * @hidden
  27749. */ private _pipelineContext: Nullable<IPipelineContext>;
  27750. private _valueCache;
  27751. private static _baseCache;
  27752. /**
  27753. * Instantiates an effect.
  27754. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27755. * @param baseName Name of the effect.
  27756. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27757. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27758. * @param samplers List of sampler variables that will be passed to the shader.
  27759. * @param engine Engine to be used to render the effect
  27760. * @param defines Define statements to be added to the shader.
  27761. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27762. * @param onCompiled Callback that will be called when the shader is compiled.
  27763. * @param onError Callback that will be called if an error occurs during shader compilation.
  27764. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27765. */
  27766. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27767. private _useFinalCode;
  27768. /**
  27769. * Unique key for this effect
  27770. */
  27771. readonly key: string;
  27772. /**
  27773. * If the effect has been compiled and prepared.
  27774. * @returns if the effect is compiled and prepared.
  27775. */
  27776. isReady(): boolean;
  27777. private _isReadyInternal;
  27778. /**
  27779. * The engine the effect was initialized with.
  27780. * @returns the engine.
  27781. */
  27782. getEngine(): Engine;
  27783. /**
  27784. * The pipeline context for this effect
  27785. * @returns the associated pipeline context
  27786. */
  27787. getPipelineContext(): Nullable<IPipelineContext>;
  27788. /**
  27789. * The set of names of attribute variables for the shader.
  27790. * @returns An array of attribute names.
  27791. */
  27792. getAttributesNames(): string[];
  27793. /**
  27794. * Returns the attribute at the given index.
  27795. * @param index The index of the attribute.
  27796. * @returns The location of the attribute.
  27797. */
  27798. getAttributeLocation(index: number): number;
  27799. /**
  27800. * Returns the attribute based on the name of the variable.
  27801. * @param name of the attribute to look up.
  27802. * @returns the attribute location.
  27803. */
  27804. getAttributeLocationByName(name: string): number;
  27805. /**
  27806. * The number of attributes.
  27807. * @returns the numnber of attributes.
  27808. */
  27809. getAttributesCount(): number;
  27810. /**
  27811. * Gets the index of a uniform variable.
  27812. * @param uniformName of the uniform to look up.
  27813. * @returns the index.
  27814. */
  27815. getUniformIndex(uniformName: string): number;
  27816. /**
  27817. * Returns the attribute based on the name of the variable.
  27818. * @param uniformName of the uniform to look up.
  27819. * @returns the location of the uniform.
  27820. */
  27821. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27822. /**
  27823. * Returns an array of sampler variable names
  27824. * @returns The array of sampler variable neames.
  27825. */
  27826. getSamplers(): string[];
  27827. /**
  27828. * The error from the last compilation.
  27829. * @returns the error string.
  27830. */
  27831. getCompilationError(): string;
  27832. /**
  27833. * Gets a boolean indicating that all fallbacks were used during compilation
  27834. * @returns true if all fallbacks were used
  27835. */
  27836. allFallbacksProcessed(): boolean;
  27837. /**
  27838. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27839. * @param func The callback to be used.
  27840. */
  27841. executeWhenCompiled(func: (effect: Effect) => void): void;
  27842. private _checkIsReady;
  27843. private _loadShader;
  27844. /**
  27845. * Recompiles the webGL program
  27846. * @param vertexSourceCode The source code for the vertex shader.
  27847. * @param fragmentSourceCode The source code for the fragment shader.
  27848. * @param onCompiled Callback called when completed.
  27849. * @param onError Callback called on error.
  27850. * @hidden
  27851. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27852. /**
  27853. * Prepares the effect
  27854. * @hidden
  27855. */ private _prepareEffect(): void;
  27856. private _processCompilationErrors;
  27857. /**
  27858. * Checks if the effect is supported. (Must be called after compilation)
  27859. */
  27860. readonly isSupported: boolean;
  27861. /**
  27862. * Binds a texture to the engine to be used as output of the shader.
  27863. * @param channel Name of the output variable.
  27864. * @param texture Texture to bind.
  27865. * @hidden
  27866. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27867. /**
  27868. * Sets a texture on the engine to be used in the shader.
  27869. * @param channel Name of the sampler variable.
  27870. * @param texture Texture to set.
  27871. */
  27872. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27873. /**
  27874. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27875. * @param channel Name of the sampler variable.
  27876. * @param texture Texture to set.
  27877. */
  27878. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27879. /**
  27880. * Sets an array of textures on the engine to be used in the shader.
  27881. * @param channel Name of the variable.
  27882. * @param textures Textures to set.
  27883. */
  27884. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27885. /**
  27886. * 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)
  27887. * @param channel Name of the sampler variable.
  27888. * @param postProcess Post process to get the input texture from.
  27889. */
  27890. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27891. /**
  27892. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27893. * 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)
  27894. * @param channel Name of the sampler variable.
  27895. * @param postProcess Post process to get the output texture from.
  27896. */
  27897. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27898. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27899. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27900. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27901. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27902. /**
  27903. * Binds a buffer to a uniform.
  27904. * @param buffer Buffer to bind.
  27905. * @param name Name of the uniform variable to bind to.
  27906. */
  27907. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27908. /**
  27909. * Binds block to a uniform.
  27910. * @param blockName Name of the block to bind.
  27911. * @param index Index to bind.
  27912. */
  27913. bindUniformBlock(blockName: string, index: number): void;
  27914. /**
  27915. * Sets an interger value on a uniform variable.
  27916. * @param uniformName Name of the variable.
  27917. * @param value Value to be set.
  27918. * @returns this effect.
  27919. */
  27920. setInt(uniformName: string, value: number): Effect;
  27921. /**
  27922. * Sets an int array on a uniform variable.
  27923. * @param uniformName Name of the variable.
  27924. * @param array array to be set.
  27925. * @returns this effect.
  27926. */
  27927. setIntArray(uniformName: string, array: Int32Array): Effect;
  27928. /**
  27929. * 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)
  27930. * @param uniformName Name of the variable.
  27931. * @param array array to be set.
  27932. * @returns this effect.
  27933. */
  27934. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27935. /**
  27936. * 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)
  27937. * @param uniformName Name of the variable.
  27938. * @param array array to be set.
  27939. * @returns this effect.
  27940. */
  27941. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27942. /**
  27943. * 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)
  27944. * @param uniformName Name of the variable.
  27945. * @param array array to be set.
  27946. * @returns this effect.
  27947. */
  27948. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27949. /**
  27950. * Sets an float array on a uniform variable.
  27951. * @param uniformName Name of the variable.
  27952. * @param array array to be set.
  27953. * @returns this effect.
  27954. */
  27955. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27956. /**
  27957. * 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)
  27958. * @param uniformName Name of the variable.
  27959. * @param array array to be set.
  27960. * @returns this effect.
  27961. */
  27962. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  27963. /**
  27964. * 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)
  27965. * @param uniformName Name of the variable.
  27966. * @param array array to be set.
  27967. * @returns this effect.
  27968. */
  27969. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  27970. /**
  27971. * 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)
  27972. * @param uniformName Name of the variable.
  27973. * @param array array to be set.
  27974. * @returns this effect.
  27975. */
  27976. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  27977. /**
  27978. * Sets an array on a uniform variable.
  27979. * @param uniformName Name of the variable.
  27980. * @param array array to be set.
  27981. * @returns this effect.
  27982. */
  27983. setArray(uniformName: string, array: number[]): Effect;
  27984. /**
  27985. * 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)
  27986. * @param uniformName Name of the variable.
  27987. * @param array array to be set.
  27988. * @returns this effect.
  27989. */
  27990. setArray2(uniformName: string, array: number[]): Effect;
  27991. /**
  27992. * 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)
  27993. * @param uniformName Name of the variable.
  27994. * @param array array to be set.
  27995. * @returns this effect.
  27996. */
  27997. setArray3(uniformName: string, array: number[]): Effect;
  27998. /**
  27999. * 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)
  28000. * @param uniformName Name of the variable.
  28001. * @param array array to be set.
  28002. * @returns this effect.
  28003. */
  28004. setArray4(uniformName: string, array: number[]): Effect;
  28005. /**
  28006. * Sets matrices on a uniform variable.
  28007. * @param uniformName Name of the variable.
  28008. * @param matrices matrices to be set.
  28009. * @returns this effect.
  28010. */
  28011. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28012. /**
  28013. * Sets matrix on a uniform variable.
  28014. * @param uniformName Name of the variable.
  28015. * @param matrix matrix to be set.
  28016. * @returns this effect.
  28017. */
  28018. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28019. /**
  28020. * 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)
  28021. * @param uniformName Name of the variable.
  28022. * @param matrix matrix to be set.
  28023. * @returns this effect.
  28024. */
  28025. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28026. /**
  28027. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28028. * @param uniformName Name of the variable.
  28029. * @param matrix matrix to be set.
  28030. * @returns this effect.
  28031. */
  28032. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28033. /**
  28034. * Sets a float on a uniform variable.
  28035. * @param uniformName Name of the variable.
  28036. * @param value value to be set.
  28037. * @returns this effect.
  28038. */
  28039. setFloat(uniformName: string, value: number): Effect;
  28040. /**
  28041. * Sets a boolean on a uniform variable.
  28042. * @param uniformName Name of the variable.
  28043. * @param bool value to be set.
  28044. * @returns this effect.
  28045. */
  28046. setBool(uniformName: string, bool: boolean): Effect;
  28047. /**
  28048. * Sets a Vector2 on a uniform variable.
  28049. * @param uniformName Name of the variable.
  28050. * @param vector2 vector2 to be set.
  28051. * @returns this effect.
  28052. */
  28053. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28054. /**
  28055. * Sets a float2 on a uniform variable.
  28056. * @param uniformName Name of the variable.
  28057. * @param x First float in float2.
  28058. * @param y Second float in float2.
  28059. * @returns this effect.
  28060. */
  28061. setFloat2(uniformName: string, x: number, y: number): Effect;
  28062. /**
  28063. * Sets a Vector3 on a uniform variable.
  28064. * @param uniformName Name of the variable.
  28065. * @param vector3 Value to be set.
  28066. * @returns this effect.
  28067. */
  28068. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28069. /**
  28070. * Sets a float3 on a uniform variable.
  28071. * @param uniformName Name of the variable.
  28072. * @param x First float in float3.
  28073. * @param y Second float in float3.
  28074. * @param z Third float in float3.
  28075. * @returns this effect.
  28076. */
  28077. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28078. /**
  28079. * Sets a Vector4 on a uniform variable.
  28080. * @param uniformName Name of the variable.
  28081. * @param vector4 Value to be set.
  28082. * @returns this effect.
  28083. */
  28084. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28085. /**
  28086. * Sets a float4 on a uniform variable.
  28087. * @param uniformName Name of the variable.
  28088. * @param x First float in float4.
  28089. * @param y Second float in float4.
  28090. * @param z Third float in float4.
  28091. * @param w Fourth float in float4.
  28092. * @returns this effect.
  28093. */
  28094. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28095. /**
  28096. * Sets a Color3 on a uniform variable.
  28097. * @param uniformName Name of the variable.
  28098. * @param color3 Value to be set.
  28099. * @returns this effect.
  28100. */
  28101. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28102. /**
  28103. * Sets a Color4 on a uniform variable.
  28104. * @param uniformName Name of the variable.
  28105. * @param color3 Value to be set.
  28106. * @param alpha Alpha value to be set.
  28107. * @returns this effect.
  28108. */
  28109. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28110. /**
  28111. * Sets a Color4 on a uniform variable
  28112. * @param uniformName defines the name of the variable
  28113. * @param color4 defines the value to be set
  28114. * @returns this effect.
  28115. */
  28116. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28117. /** Release all associated resources */
  28118. dispose(): void;
  28119. /**
  28120. * This function will add a new shader to the shader store
  28121. * @param name the name of the shader
  28122. * @param pixelShader optional pixel shader content
  28123. * @param vertexShader optional vertex shader content
  28124. */
  28125. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28126. /**
  28127. * Store of each shader (The can be looked up using effect.key)
  28128. */
  28129. static ShadersStore: {
  28130. [key: string]: string;
  28131. };
  28132. /**
  28133. * Store of each included file for a shader (The can be looked up using effect.key)
  28134. */
  28135. static IncludesShadersStore: {
  28136. [key: string]: string;
  28137. };
  28138. /**
  28139. * Resets the cache of effects.
  28140. */
  28141. static ResetCache(): void;
  28142. }
  28143. }
  28144. declare module BABYLON {
  28145. /**
  28146. * Interface used to describe the capabilities of the engine relatively to the current browser
  28147. */
  28148. export interface EngineCapabilities {
  28149. /** Maximum textures units per fragment shader */
  28150. maxTexturesImageUnits: number;
  28151. /** Maximum texture units per vertex shader */
  28152. maxVertexTextureImageUnits: number;
  28153. /** Maximum textures units in the entire pipeline */
  28154. maxCombinedTexturesImageUnits: number;
  28155. /** Maximum texture size */
  28156. maxTextureSize: number;
  28157. /** Maximum cube texture size */
  28158. maxCubemapTextureSize: number;
  28159. /** Maximum render texture size */
  28160. maxRenderTextureSize: number;
  28161. /** Maximum number of vertex attributes */
  28162. maxVertexAttribs: number;
  28163. /** Maximum number of varyings */
  28164. maxVaryingVectors: number;
  28165. /** Maximum number of uniforms per vertex shader */
  28166. maxVertexUniformVectors: number;
  28167. /** Maximum number of uniforms per fragment shader */
  28168. maxFragmentUniformVectors: number;
  28169. /** Defines if standard derivates (dx/dy) are supported */
  28170. standardDerivatives: boolean;
  28171. /** Defines if s3tc texture compression is supported */
  28172. s3tc?: WEBGL_compressed_texture_s3tc;
  28173. /** Defines if pvrtc texture compression is supported */
  28174. pvrtc: any;
  28175. /** Defines if etc1 texture compression is supported */
  28176. etc1: any;
  28177. /** Defines if etc2 texture compression is supported */
  28178. etc2: any;
  28179. /** Defines if astc texture compression is supported */
  28180. astc: any;
  28181. /** Defines if float textures are supported */
  28182. textureFloat: boolean;
  28183. /** Defines if vertex array objects are supported */
  28184. vertexArrayObject: boolean;
  28185. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28186. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  28187. /** Gets the maximum level of anisotropy supported */
  28188. maxAnisotropy: number;
  28189. /** Defines if instancing is supported */
  28190. instancedArrays: boolean;
  28191. /** Defines if 32 bits indices are supported */
  28192. uintIndices: boolean;
  28193. /** Defines if high precision shaders are supported */
  28194. highPrecisionShaderSupported: boolean;
  28195. /** Defines if depth reading in the fragment shader is supported */
  28196. fragmentDepthSupported: boolean;
  28197. /** Defines if float texture linear filtering is supported*/
  28198. textureFloatLinearFiltering: boolean;
  28199. /** Defines if rendering to float textures is supported */
  28200. textureFloatRender: boolean;
  28201. /** Defines if half float textures are supported*/
  28202. textureHalfFloat: boolean;
  28203. /** Defines if half float texture linear filtering is supported*/
  28204. textureHalfFloatLinearFiltering: boolean;
  28205. /** Defines if rendering to half float textures is supported */
  28206. textureHalfFloatRender: boolean;
  28207. /** Defines if textureLOD shader command is supported */
  28208. textureLOD: boolean;
  28209. /** Defines if draw buffers extension is supported */
  28210. drawBuffersExtension: boolean;
  28211. /** Defines if depth textures are supported */
  28212. depthTextureExtension: boolean;
  28213. /** Defines if float color buffer are supported */
  28214. colorBufferFloat: boolean;
  28215. /** Gets disjoint timer query extension (null if not supported) */
  28216. timerQuery?: EXT_disjoint_timer_query;
  28217. /** Defines if timestamp can be used with timer query */
  28218. canUseTimestampForTimerQuery: boolean;
  28219. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28220. multiview?: any;
  28221. /** Function used to let the system compiles shaders in background */
  28222. parallelShaderCompile?: {
  28223. COMPLETION_STATUS_KHR: number;
  28224. };
  28225. /** Max number of texture samples for MSAA */
  28226. maxMSAASamples: number;
  28227. /** Defines if the blend min max extension is supported */
  28228. blendMinMax: boolean;
  28229. }
  28230. }
  28231. declare module BABYLON {
  28232. /**
  28233. * @hidden
  28234. **/
  28235. export class DepthCullingState {
  28236. private _isDepthTestDirty;
  28237. private _isDepthMaskDirty;
  28238. private _isDepthFuncDirty;
  28239. private _isCullFaceDirty;
  28240. private _isCullDirty;
  28241. private _isZOffsetDirty;
  28242. private _isFrontFaceDirty;
  28243. private _depthTest;
  28244. private _depthMask;
  28245. private _depthFunc;
  28246. private _cull;
  28247. private _cullFace;
  28248. private _zOffset;
  28249. private _frontFace;
  28250. /**
  28251. * Initializes the state.
  28252. */
  28253. constructor();
  28254. readonly isDirty: boolean;
  28255. zOffset: number;
  28256. cullFace: Nullable<number>;
  28257. cull: Nullable<boolean>;
  28258. depthFunc: Nullable<number>;
  28259. depthMask: boolean;
  28260. depthTest: boolean;
  28261. frontFace: Nullable<number>;
  28262. reset(): void;
  28263. apply(gl: WebGLRenderingContext): void;
  28264. }
  28265. }
  28266. declare module BABYLON {
  28267. /**
  28268. * @hidden
  28269. **/
  28270. export class StencilState {
  28271. /** 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 */
  28272. static readonly ALWAYS: number;
  28273. /** Passed to stencilOperation to specify that stencil value must be kept */
  28274. static readonly KEEP: number;
  28275. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28276. static readonly REPLACE: number;
  28277. private _isStencilTestDirty;
  28278. private _isStencilMaskDirty;
  28279. private _isStencilFuncDirty;
  28280. private _isStencilOpDirty;
  28281. private _stencilTest;
  28282. private _stencilMask;
  28283. private _stencilFunc;
  28284. private _stencilFuncRef;
  28285. private _stencilFuncMask;
  28286. private _stencilOpStencilFail;
  28287. private _stencilOpDepthFail;
  28288. private _stencilOpStencilDepthPass;
  28289. readonly isDirty: boolean;
  28290. stencilFunc: number;
  28291. stencilFuncRef: number;
  28292. stencilFuncMask: number;
  28293. stencilOpStencilFail: number;
  28294. stencilOpDepthFail: number;
  28295. stencilOpStencilDepthPass: number;
  28296. stencilMask: number;
  28297. stencilTest: boolean;
  28298. constructor();
  28299. reset(): void;
  28300. apply(gl: WebGLRenderingContext): void;
  28301. }
  28302. }
  28303. declare module BABYLON {
  28304. /**
  28305. * @hidden
  28306. **/
  28307. export class AlphaState {
  28308. private _isAlphaBlendDirty;
  28309. private _isBlendFunctionParametersDirty;
  28310. private _isBlendEquationParametersDirty;
  28311. private _isBlendConstantsDirty;
  28312. private _alphaBlend;
  28313. private _blendFunctionParameters;
  28314. private _blendEquationParameters;
  28315. private _blendConstants;
  28316. /**
  28317. * Initializes the state.
  28318. */
  28319. constructor();
  28320. readonly isDirty: boolean;
  28321. alphaBlend: boolean;
  28322. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28323. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28324. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28325. reset(): void;
  28326. apply(gl: WebGLRenderingContext): void;
  28327. }
  28328. }
  28329. declare module BABYLON {
  28330. /** @hidden */
  28331. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28332. attributeProcessor(attribute: string): string;
  28333. varyingProcessor(varying: string, isFragment: boolean): string;
  28334. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28335. }
  28336. }
  28337. declare module BABYLON {
  28338. /**
  28339. * Interface for attribute information associated with buffer instanciation
  28340. */
  28341. export interface InstancingAttributeInfo {
  28342. /**
  28343. * Index/offset of the attribute in the vertex shader
  28344. */
  28345. index: number;
  28346. /**
  28347. * size of the attribute, 1, 2, 3 or 4
  28348. */
  28349. attributeSize: number;
  28350. /**
  28351. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28352. * default is FLOAT
  28353. */
  28354. attributeType: number;
  28355. /**
  28356. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28357. */
  28358. normalized: boolean;
  28359. /**
  28360. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28361. */
  28362. offset: number;
  28363. /**
  28364. * Name of the GLSL attribute, for debugging purpose only
  28365. */
  28366. attributeName: string;
  28367. }
  28368. }
  28369. declare module BABYLON {
  28370. interface ThinEngine {
  28371. /**
  28372. * Update a video texture
  28373. * @param texture defines the texture to update
  28374. * @param video defines the video element to use
  28375. * @param invertY defines if data must be stored with Y axis inverted
  28376. */
  28377. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28378. }
  28379. }
  28380. declare module BABYLON {
  28381. /**
  28382. * Settings for finer control over video usage
  28383. */
  28384. export interface VideoTextureSettings {
  28385. /**
  28386. * Applies `autoplay` to video, if specified
  28387. */
  28388. autoPlay?: boolean;
  28389. /**
  28390. * Applies `loop` to video, if specified
  28391. */
  28392. loop?: boolean;
  28393. /**
  28394. * Automatically updates internal texture from video at every frame in the render loop
  28395. */
  28396. autoUpdateTexture: boolean;
  28397. /**
  28398. * Image src displayed during the video loading or until the user interacts with the video.
  28399. */
  28400. poster?: string;
  28401. }
  28402. /**
  28403. * If you want to display a video in your scene, this is the special texture for that.
  28404. * This special texture works similar to other textures, with the exception of a few parameters.
  28405. * @see https://doc.babylonjs.com/how_to/video_texture
  28406. */
  28407. export class VideoTexture extends Texture {
  28408. /**
  28409. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28410. */
  28411. readonly autoUpdateTexture: boolean;
  28412. /**
  28413. * The video instance used by the texture internally
  28414. */
  28415. readonly video: HTMLVideoElement;
  28416. private _onUserActionRequestedObservable;
  28417. /**
  28418. * Event triggerd when a dom action is required by the user to play the video.
  28419. * This happens due to recent changes in browser policies preventing video to auto start.
  28420. */
  28421. readonly onUserActionRequestedObservable: Observable<Texture>;
  28422. private _generateMipMaps;
  28423. private _engine;
  28424. private _stillImageCaptured;
  28425. private _displayingPosterTexture;
  28426. private _settings;
  28427. private _createInternalTextureOnEvent;
  28428. private _frameId;
  28429. /**
  28430. * Creates a video texture.
  28431. * If you want to display a video in your scene, this is the special texture for that.
  28432. * This special texture works similar to other textures, with the exception of a few parameters.
  28433. * @see https://doc.babylonjs.com/how_to/video_texture
  28434. * @param name optional name, will detect from video source, if not defined
  28435. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28436. * @param scene is obviously the current scene.
  28437. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28438. * @param invertY is false by default but can be used to invert video on Y axis
  28439. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28440. * @param settings allows finer control over video usage
  28441. */
  28442. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28443. private _getName;
  28444. private _getVideo;
  28445. private _createInternalTexture;
  28446. private reset;
  28447. /**
  28448. * @hidden Internal method to initiate `update`.
  28449. */ private _rebuild(): void;
  28450. /**
  28451. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28452. */
  28453. update(): void;
  28454. /**
  28455. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28456. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28457. */
  28458. updateTexture(isVisible: boolean): void;
  28459. protected _updateInternalTexture: () => void;
  28460. /**
  28461. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28462. * @param url New url.
  28463. */
  28464. updateURL(url: string): void;
  28465. /**
  28466. * Dispose the texture and release its associated resources.
  28467. */
  28468. dispose(): void;
  28469. /**
  28470. * Creates a video texture straight from a stream.
  28471. * @param scene Define the scene the texture should be created in
  28472. * @param stream Define the stream the texture should be created from
  28473. * @returns The created video texture as a promise
  28474. */
  28475. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28476. /**
  28477. * Creates a video texture straight from your WebCam video feed.
  28478. * @param scene Define the scene the texture should be created in
  28479. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28480. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28481. * @returns The created video texture as a promise
  28482. */
  28483. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28484. minWidth: number;
  28485. maxWidth: number;
  28486. minHeight: number;
  28487. maxHeight: number;
  28488. deviceId: string;
  28489. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28490. /**
  28491. * Creates a video texture straight from your WebCam video feed.
  28492. * @param scene Define the scene the texture should be created in
  28493. * @param onReady Define a callback to triggered once the texture will be ready
  28494. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28495. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28496. */
  28497. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28498. minWidth: number;
  28499. maxWidth: number;
  28500. minHeight: number;
  28501. maxHeight: number;
  28502. deviceId: string;
  28503. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28504. }
  28505. }
  28506. declare module BABYLON {
  28507. /**
  28508. * Defines the interface used by objects working like Scene
  28509. * @hidden
  28510. */
  28511. interface ISceneLike { private _addPendingData(data: any): void; private _removePendingData(data: any): void;
  28512. offlineProvider: IOfflineProvider;
  28513. }
  28514. /** Interface defining initialization parameters for Engine class */
  28515. export interface EngineOptions extends WebGLContextAttributes {
  28516. /**
  28517. * Defines if the engine should no exceed a specified device ratio
  28518. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28519. */
  28520. limitDeviceRatio?: number;
  28521. /**
  28522. * Defines if webvr should be enabled automatically
  28523. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28524. */
  28525. autoEnableWebVR?: boolean;
  28526. /**
  28527. * Defines if webgl2 should be turned off even if supported
  28528. * @see http://doc.babylonjs.com/features/webgl2
  28529. */
  28530. disableWebGL2Support?: boolean;
  28531. /**
  28532. * Defines if webaudio should be initialized as well
  28533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28534. */
  28535. audioEngine?: boolean;
  28536. /**
  28537. * Defines if animations should run using a deterministic lock step
  28538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28539. */
  28540. deterministicLockstep?: boolean;
  28541. /** Defines the maximum steps to use with deterministic lock step mode */
  28542. lockstepMaxSteps?: number;
  28543. /**
  28544. * Defines that engine should ignore context lost events
  28545. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28546. */
  28547. doNotHandleContextLost?: boolean;
  28548. /**
  28549. * Defines that engine should ignore modifying touch action attribute and style
  28550. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28551. */
  28552. doNotHandleTouchAction?: boolean;
  28553. /**
  28554. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28555. */
  28556. useHighPrecisionFloats?: boolean;
  28557. }
  28558. /**
  28559. * The base engine class (root of all engines)
  28560. */
  28561. export class ThinEngine {
  28562. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28563. static ExceptionList: ({
  28564. key: string;
  28565. capture: string;
  28566. captureConstraint: number;
  28567. targets: string[];
  28568. } | {
  28569. key: string;
  28570. capture: null;
  28571. captureConstraint: null;
  28572. targets: string[];
  28573. })[];
  28574. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  28575. /**
  28576. * Returns the current npm package of the sdk
  28577. */
  28578. static readonly NpmPackage: string;
  28579. /**
  28580. * Returns the current version of the framework
  28581. */
  28582. static readonly Version: string;
  28583. /**
  28584. * Returns a string describing the current engine
  28585. */
  28586. readonly description: string;
  28587. /**
  28588. * Gets or sets the epsilon value used by collision engine
  28589. */
  28590. static CollisionsEpsilon: number;
  28591. /**
  28592. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28593. */
  28594. static ShadersRepository: string;
  28595. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  28596. /**
  28597. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28598. */
  28599. forcePOTTextures: boolean;
  28600. /**
  28601. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28602. */
  28603. isFullscreen: boolean;
  28604. /**
  28605. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28606. */
  28607. cullBackFaces: boolean;
  28608. /**
  28609. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28610. */
  28611. renderEvenInBackground: boolean;
  28612. /**
  28613. * Gets or sets a boolean indicating that cache can be kept between frames
  28614. */
  28615. preventCacheWipeBetweenFrames: boolean;
  28616. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28617. validateShaderPrograms: boolean;
  28618. /**
  28619. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28620. */
  28621. disableUniformBuffers: boolean;
  28622. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  28623. /**
  28624. * Gets a boolean indicating that the engine supports uniform buffers
  28625. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28626. */
  28627. readonly supportsUniformBuffers: boolean;
  28628. /** @hidden */ private _gl: WebGLRenderingContext;
  28629. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28630. protected _windowIsBackground: boolean;
  28631. protected _webGLVersion: number;
  28632. protected _creationOptions: EngineOptions;
  28633. protected _highPrecisionShadersAllowed: boolean;
  28634. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  28635. /**
  28636. * Gets a boolean indicating that only power of 2 textures are supported
  28637. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28638. */
  28639. readonly needPOTTextures: boolean;
  28640. /** @hidden */ private _badOS: boolean;
  28641. /** @hidden */ private _badDesktopOS: boolean;
  28642. private _hardwareScalingLevel;
  28643. /** @hidden */ private _caps: EngineCapabilities;
  28644. private _isStencilEnable;
  28645. protected _colorWrite: boolean;
  28646. private _glVersion;
  28647. private _glRenderer;
  28648. private _glVendor;
  28649. /** @hidden */ private _videoTextureSupported: boolean;
  28650. protected _renderingQueueLaunched: boolean;
  28651. protected _activeRenderLoops: (() => void)[];
  28652. /**
  28653. * Observable signaled when a context lost event is raised
  28654. */
  28655. onContextLostObservable: Observable<ThinEngine>;
  28656. /**
  28657. * Observable signaled when a context restored event is raised
  28658. */
  28659. onContextRestoredObservable: Observable<ThinEngine>;
  28660. private _onContextLost;
  28661. private _onContextRestored;
  28662. protected _contextWasLost: boolean;
  28663. /** @hidden */ private _doNotHandleContextLost: boolean;
  28664. /**
  28665. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28667. */
  28668. doNotHandleContextLost: boolean;
  28669. /**
  28670. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28671. */
  28672. disableVertexArrayObjects: boolean;
  28673. /** @hidden */
  28674. protected _depthCullingState: DepthCullingState;
  28675. /** @hidden */
  28676. protected _stencilState: StencilState;
  28677. /** @hidden */
  28678. protected _alphaState: AlphaState;
  28679. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  28680. /** @hidden */
  28681. protected _activeChannel: number;
  28682. private _currentTextureChannel;
  28683. /** @hidden */
  28684. protected _boundTexturesCache: {
  28685. [key: string]: Nullable<InternalTexture>;
  28686. };
  28687. /** @hidden */
  28688. protected _currentEffect: Nullable<Effect>;
  28689. /** @hidden */
  28690. protected _currentProgram: Nullable<WebGLProgram>;
  28691. private _compiledEffects;
  28692. private _vertexAttribArraysEnabled;
  28693. /** @hidden */
  28694. protected _cachedViewport: Nullable<IViewportLike>;
  28695. private _cachedVertexArrayObject;
  28696. /** @hidden */
  28697. protected _cachedVertexBuffers: any;
  28698. /** @hidden */
  28699. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28700. /** @hidden */
  28701. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28702. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  28703. private _uintIndicesCurrentlySet;
  28704. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  28705. /** @hidden */
  28706. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28707. private _currentBufferPointers;
  28708. private _currentInstanceLocations;
  28709. private _currentInstanceBuffers;
  28710. private _textureUnits;
  28711. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  28712. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  28713. /** @hidden */ private _bindedRenderFunction: any;
  28714. private _vaoRecordInProgress;
  28715. private _mustWipeVertexAttributes;
  28716. private _emptyTexture;
  28717. private _emptyCubeTexture;
  28718. private _emptyTexture3D;
  28719. /** @hidden */ private _frameHandler: number;
  28720. private _nextFreeTextureSlots;
  28721. private _maxSimultaneousTextures;
  28722. private _activeRequests;
  28723. protected _texturesSupported: string[];
  28724. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  28725. protected readonly _supportsHardwareTextureRescaling: boolean;
  28726. /**
  28727. * Gets the list of texture formats supported
  28728. */
  28729. readonly texturesSupported: Array<string>;
  28730. /**
  28731. * Gets the list of texture formats in use
  28732. */
  28733. readonly textureFormatInUse: Nullable<string>;
  28734. /**
  28735. * Gets the current viewport
  28736. */
  28737. readonly currentViewport: Nullable<IViewportLike>;
  28738. /**
  28739. * Gets the default empty texture
  28740. */
  28741. readonly emptyTexture: InternalTexture;
  28742. /**
  28743. * Gets the default empty 3D texture
  28744. */
  28745. readonly emptyTexture3D: InternalTexture;
  28746. /**
  28747. * Gets the default empty cube texture
  28748. */
  28749. readonly emptyCubeTexture: InternalTexture;
  28750. /**
  28751. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28752. */
  28753. readonly premultipliedAlpha: boolean;
  28754. /**
  28755. * Observable event triggered before each texture is initialized
  28756. */
  28757. onBeforeTextureInitObservable: Observable<Texture>;
  28758. /**
  28759. * Creates a new engine
  28760. * @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
  28761. * @param antialias defines enable antialiasing (default: false)
  28762. * @param options defines further options to be sent to the getContext() function
  28763. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28764. */
  28765. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28766. private _rebuildInternalTextures;
  28767. private _rebuildEffects;
  28768. /**
  28769. * Gets a boolean indicating if all created effects are ready
  28770. * @returns true if all effects are ready
  28771. */
  28772. areAllEffectsReady(): boolean;
  28773. protected _rebuildBuffers(): void;
  28774. private _initGLContext;
  28775. /**
  28776. * Gets version of the current webGL context
  28777. */
  28778. readonly webGLVersion: number;
  28779. /**
  28780. * Gets a string idenfifying the name of the class
  28781. * @returns "Engine" string
  28782. */
  28783. getClassName(): string;
  28784. /**
  28785. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28786. */
  28787. readonly isStencilEnable: boolean;
  28788. /** @hidden */ private _prepareWorkingCanvas(): void;
  28789. /**
  28790. * Reset the texture cache to empty state
  28791. */
  28792. resetTextureCache(): void;
  28793. /**
  28794. * Gets an object containing information about the current webGL context
  28795. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28796. */
  28797. getGlInfo(): {
  28798. vendor: string;
  28799. renderer: string;
  28800. version: string;
  28801. };
  28802. /**
  28803. * Defines the hardware scaling level.
  28804. * By default the hardware scaling level is computed from the window device ratio.
  28805. * 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.
  28806. * @param level defines the level to use
  28807. */
  28808. setHardwareScalingLevel(level: number): void;
  28809. /**
  28810. * Gets the current hardware scaling level.
  28811. * By default the hardware scaling level is computed from the window device ratio.
  28812. * 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.
  28813. * @returns a number indicating the current hardware scaling level
  28814. */
  28815. getHardwareScalingLevel(): number;
  28816. /**
  28817. * Gets the list of loaded textures
  28818. * @returns an array containing all loaded textures
  28819. */
  28820. getLoadedTexturesCache(): InternalTexture[];
  28821. /**
  28822. * Gets the object containing all engine capabilities
  28823. * @returns the EngineCapabilities object
  28824. */
  28825. getCaps(): EngineCapabilities;
  28826. /**
  28827. * stop executing a render loop function and remove it from the execution array
  28828. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28829. */
  28830. stopRenderLoop(renderFunction?: () => void): void;
  28831. /** @hidden */ private _renderLoop(): void;
  28832. /**
  28833. * Gets the HTML canvas attached with the current webGL context
  28834. * @returns a HTML canvas
  28835. */
  28836. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28837. /**
  28838. * Gets host window
  28839. * @returns the host window object
  28840. */
  28841. getHostWindow(): Nullable<Window>;
  28842. /**
  28843. * Gets the current render width
  28844. * @param useScreen defines if screen size must be used (or the current render target if any)
  28845. * @returns a number defining the current render width
  28846. */
  28847. getRenderWidth(useScreen?: boolean): number;
  28848. /**
  28849. * Gets the current render height
  28850. * @param useScreen defines if screen size must be used (or the current render target if any)
  28851. * @returns a number defining the current render height
  28852. */
  28853. getRenderHeight(useScreen?: boolean): number;
  28854. /**
  28855. * Can be used to override the current requestAnimationFrame requester.
  28856. * @hidden
  28857. */
  28858. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  28859. /**
  28860. * Register and execute a render loop. The engine can have more than one render function
  28861. * @param renderFunction defines the function to continuously execute
  28862. */
  28863. runRenderLoop(renderFunction: () => void): void;
  28864. /**
  28865. * Clear the current render buffer or the current render target (if any is set up)
  28866. * @param color defines the color to use
  28867. * @param backBuffer defines if the back buffer must be cleared
  28868. * @param depth defines if the depth buffer must be cleared
  28869. * @param stencil defines if the stencil buffer must be cleared
  28870. */
  28871. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28872. private _viewportCached;
  28873. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  28874. /**
  28875. * Set the WebGL's viewport
  28876. * @param viewport defines the viewport element to be used
  28877. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28878. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28879. */
  28880. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  28881. /**
  28882. * Begin a new frame
  28883. */
  28884. beginFrame(): void;
  28885. /**
  28886. * Enf the current frame
  28887. */
  28888. endFrame(): void;
  28889. /**
  28890. * Resize the view according to the canvas' size
  28891. */
  28892. resize(): void;
  28893. /**
  28894. * Force a specific size of the canvas
  28895. * @param width defines the new canvas' width
  28896. * @param height defines the new canvas' height
  28897. */
  28898. setSize(width: number, height: number): void;
  28899. /**
  28900. * Binds the frame buffer to the specified texture.
  28901. * @param texture The texture to render to or null for the default canvas
  28902. * @param faceIndex The face of the texture to render to in case of cube texture
  28903. * @param requiredWidth The width of the target to render to
  28904. * @param requiredHeight The height of the target to render to
  28905. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28906. * @param depthStencilTexture The depth stencil texture to use to render
  28907. * @param lodLevel defines le lod level to bind to the frame buffer
  28908. */
  28909. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28910. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28911. /**
  28912. * Unbind the current render target texture from the webGL context
  28913. * @param texture defines the render target texture to unbind
  28914. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28915. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28916. */
  28917. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28918. /**
  28919. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28920. */
  28921. flushFramebuffer(): void;
  28922. /**
  28923. * Unbind the current render target and bind the default framebuffer
  28924. */
  28925. restoreDefaultFramebuffer(): void;
  28926. /** @hidden */
  28927. protected _resetVertexBufferBinding(): void;
  28928. /**
  28929. * Creates a vertex buffer
  28930. * @param data the data for the vertex buffer
  28931. * @returns the new WebGL static buffer
  28932. */
  28933. createVertexBuffer(data: DataArray): DataBuffer;
  28934. private _createVertexBuffer;
  28935. /**
  28936. * Creates a dynamic vertex buffer
  28937. * @param data the data for the dynamic vertex buffer
  28938. * @returns the new WebGL dynamic buffer
  28939. */
  28940. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28941. protected _resetIndexBufferBinding(): void;
  28942. /**
  28943. * Creates a new index buffer
  28944. * @param indices defines the content of the index buffer
  28945. * @param updatable defines if the index buffer must be updatable
  28946. * @returns a new webGL buffer
  28947. */
  28948. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28949. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  28950. /**
  28951. * Bind a webGL buffer to the webGL context
  28952. * @param buffer defines the buffer to bind
  28953. */
  28954. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28955. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  28956. private bindBuffer;
  28957. /**
  28958. * update the bound buffer with the given data
  28959. * @param data defines the data to update
  28960. */
  28961. updateArrayBuffer(data: Float32Array): void;
  28962. private _vertexAttribPointer;
  28963. private _bindIndexBufferWithCache;
  28964. private _bindVertexBuffersAttributes;
  28965. /**
  28966. * Records a vertex array object
  28967. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28968. * @param vertexBuffers defines the list of vertex buffers to store
  28969. * @param indexBuffer defines the index buffer to store
  28970. * @param effect defines the effect to store
  28971. * @returns the new vertex array object
  28972. */
  28973. recordVertexArrayObject(vertexBuffers: {
  28974. [key: string]: VertexBuffer;
  28975. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28976. /**
  28977. * Bind a specific vertex array object
  28978. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28979. * @param vertexArrayObject defines the vertex array object to bind
  28980. * @param indexBuffer defines the index buffer to bind
  28981. */
  28982. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28983. /**
  28984. * Bind webGl buffers directly to the webGL context
  28985. * @param vertexBuffer defines the vertex buffer to bind
  28986. * @param indexBuffer defines the index buffer to bind
  28987. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28988. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28989. * @param effect defines the effect associated with the vertex buffer
  28990. */
  28991. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28992. private _unbindVertexArrayObject;
  28993. /**
  28994. * Bind a list of vertex buffers to the webGL context
  28995. * @param vertexBuffers defines the list of vertex buffers to bind
  28996. * @param indexBuffer defines the index buffer to bind
  28997. * @param effect defines the effect associated with the vertex buffers
  28998. */
  28999. bindBuffers(vertexBuffers: {
  29000. [key: string]: Nullable<VertexBuffer>;
  29001. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29002. /**
  29003. * Unbind all instance attributes
  29004. */
  29005. unbindInstanceAttributes(): void;
  29006. /**
  29007. * Release and free the memory of a vertex array object
  29008. * @param vao defines the vertex array object to delete
  29009. */
  29010. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29011. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  29012. protected _deleteBuffer(buffer: DataBuffer): void;
  29013. /**
  29014. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29015. * @param instancesBuffer defines the webGL buffer to update and bind
  29016. * @param data defines the data to store in the buffer
  29017. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29018. */
  29019. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29020. /**
  29021. * Apply all cached states (depth, culling, stencil and alpha)
  29022. */
  29023. applyStates(): void;
  29024. /**
  29025. * Send a draw order
  29026. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29027. * @param indexStart defines the starting index
  29028. * @param indexCount defines the number of index to draw
  29029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29030. */
  29031. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29032. /**
  29033. * Draw a list of points
  29034. * @param verticesStart defines the index of first vertex to draw
  29035. * @param verticesCount defines the count of vertices to draw
  29036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29037. */
  29038. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29039. /**
  29040. * Draw a list of unindexed primitives
  29041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29042. * @param verticesStart defines the index of first vertex to draw
  29043. * @param verticesCount defines the count of vertices to draw
  29044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29045. */
  29046. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29047. /**
  29048. * Draw a list of indexed primitives
  29049. * @param fillMode defines the primitive to use
  29050. * @param indexStart defines the starting index
  29051. * @param indexCount defines the number of index to draw
  29052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29053. */
  29054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29055. /**
  29056. * Draw a list of unindexed primitives
  29057. * @param fillMode defines the primitive to use
  29058. * @param verticesStart defines the index of first vertex to draw
  29059. * @param verticesCount defines the count of vertices to draw
  29060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29061. */
  29062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29063. private _drawMode;
  29064. /** @hidden */
  29065. protected _reportDrawCall(): void;
  29066. /** @hidden */ private _releaseEffect(effect: Effect): void;
  29067. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29068. /**
  29069. * Create a new effect (used to store vertex/fragment shaders)
  29070. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29071. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29072. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29073. * @param samplers defines an array of string used to represent textures
  29074. * @param defines defines the string containing the defines to use to compile the shaders
  29075. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29076. * @param onCompiled defines a function to call when the effect creation is successful
  29077. * @param onError defines a function to call when the effect creation has failed
  29078. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29079. * @returns the new Effect
  29080. */
  29081. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29082. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29083. private _compileShader;
  29084. private _compileRawShader;
  29085. /**
  29086. * Directly creates a webGL program
  29087. * @param pipelineContext defines the pipeline context to attach to
  29088. * @param vertexCode defines the vertex shader code to use
  29089. * @param fragmentCode defines the fragment shader code to use
  29090. * @param context defines the webGL context to use (if not set, the current one will be used)
  29091. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29092. * @returns the new webGL program
  29093. */
  29094. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29095. /**
  29096. * Creates a webGL program
  29097. * @param pipelineContext defines the pipeline context to attach to
  29098. * @param vertexCode defines the vertex shader code to use
  29099. * @param fragmentCode defines the fragment shader code to use
  29100. * @param defines defines the string containing the defines to use to compile the shaders
  29101. * @param context defines the webGL context to use (if not set, the current one will be used)
  29102. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29103. * @returns the new webGL program
  29104. */
  29105. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29106. /**
  29107. * Creates a new pipeline context
  29108. * @returns the new pipeline
  29109. */
  29110. createPipelineContext(): IPipelineContext;
  29111. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29112. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29113. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29114. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29115. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29116. /**
  29117. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29118. * @param pipelineContext defines the pipeline context to use
  29119. * @param uniformsNames defines the list of uniform names
  29120. * @returns an array of webGL uniform locations
  29121. */
  29122. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29123. /**
  29124. * Gets the lsit of active attributes for a given webGL program
  29125. * @param pipelineContext defines the pipeline context to use
  29126. * @param attributesNames defines the list of attribute names to get
  29127. * @returns an array of indices indicating the offset of each attribute
  29128. */
  29129. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29130. /**
  29131. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29132. * @param effect defines the effect to activate
  29133. */
  29134. enableEffect(effect: Nullable<Effect>): void;
  29135. /**
  29136. * Set the value of an uniform to a number (int)
  29137. * @param uniform defines the webGL uniform location where to store the value
  29138. * @param value defines the int number to store
  29139. */
  29140. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29141. /**
  29142. * Set the value of an uniform to an array of int32
  29143. * @param uniform defines the webGL uniform location where to store the value
  29144. * @param array defines the array of int32 to store
  29145. */
  29146. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29147. /**
  29148. * Set the value of an uniform to an array of int32 (stored as vec2)
  29149. * @param uniform defines the webGL uniform location where to store the value
  29150. * @param array defines the array of int32 to store
  29151. */
  29152. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29153. /**
  29154. * Set the value of an uniform to an array of int32 (stored as vec3)
  29155. * @param uniform defines the webGL uniform location where to store the value
  29156. * @param array defines the array of int32 to store
  29157. */
  29158. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29159. /**
  29160. * Set the value of an uniform to an array of int32 (stored as vec4)
  29161. * @param uniform defines the webGL uniform location where to store the value
  29162. * @param array defines the array of int32 to store
  29163. */
  29164. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29165. /**
  29166. * Set the value of an uniform to an array of number
  29167. * @param uniform defines the webGL uniform location where to store the value
  29168. * @param array defines the array of number to store
  29169. */
  29170. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29171. /**
  29172. * Set the value of an uniform to an array of number (stored as vec2)
  29173. * @param uniform defines the webGL uniform location where to store the value
  29174. * @param array defines the array of number to store
  29175. */
  29176. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29177. /**
  29178. * Set the value of an uniform to an array of number (stored as vec3)
  29179. * @param uniform defines the webGL uniform location where to store the value
  29180. * @param array defines the array of number to store
  29181. */
  29182. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29183. /**
  29184. * Set the value of an uniform to an array of number (stored as vec4)
  29185. * @param uniform defines the webGL uniform location where to store the value
  29186. * @param array defines the array of number to store
  29187. */
  29188. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29189. /**
  29190. * Set the value of an uniform to an array of float32 (stored as matrices)
  29191. * @param uniform defines the webGL uniform location where to store the value
  29192. * @param matrices defines the array of float32 to store
  29193. */
  29194. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29195. /**
  29196. * Set the value of an uniform to a matrix (3x3)
  29197. * @param uniform defines the webGL uniform location where to store the value
  29198. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29199. */
  29200. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29201. /**
  29202. * Set the value of an uniform to a matrix (2x2)
  29203. * @param uniform defines the webGL uniform location where to store the value
  29204. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29205. */
  29206. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29207. /**
  29208. * Set the value of an uniform to a number (float)
  29209. * @param uniform defines the webGL uniform location where to store the value
  29210. * @param value defines the float number to store
  29211. */
  29212. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29213. /**
  29214. * Set the value of an uniform to a vec2
  29215. * @param uniform defines the webGL uniform location where to store the value
  29216. * @param x defines the 1st component of the value
  29217. * @param y defines the 2nd component of the value
  29218. */
  29219. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29220. /**
  29221. * Set the value of an uniform to a vec3
  29222. * @param uniform defines the webGL uniform location where to store the value
  29223. * @param x defines the 1st component of the value
  29224. * @param y defines the 2nd component of the value
  29225. * @param z defines the 3rd component of the value
  29226. */
  29227. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29228. /**
  29229. * Set the value of an uniform to a vec4
  29230. * @param uniform defines the webGL uniform location where to store the value
  29231. * @param x defines the 1st component of the value
  29232. * @param y defines the 2nd component of the value
  29233. * @param z defines the 3rd component of the value
  29234. * @param w defines the 4th component of the value
  29235. */
  29236. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29237. /**
  29238. * Gets the depth culling state manager
  29239. */
  29240. readonly depthCullingState: DepthCullingState;
  29241. /**
  29242. * Gets the alpha state manager
  29243. */
  29244. readonly alphaState: AlphaState;
  29245. /**
  29246. * Gets the stencil state manager
  29247. */
  29248. readonly stencilState: StencilState;
  29249. /**
  29250. * Clears the list of texture accessible through engine.
  29251. * This can help preventing texture load conflict due to name collision.
  29252. */
  29253. clearInternalTexturesCache(): void;
  29254. /**
  29255. * Force the entire cache to be cleared
  29256. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29257. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29258. */
  29259. wipeCaches(bruteForce?: boolean): void;
  29260. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29261. min: number;
  29262. mag: number;
  29263. };
  29264. /** @hidden */ private _createTexture(): WebGLTexture;
  29265. /**
  29266. * Usually called from Texture.ts.
  29267. * Passed information to create a WebGLTexture
  29268. * @param urlArg defines a value which contains one of the following:
  29269. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29270. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29271. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29273. * @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)
  29274. * @param scene needed for loading to the correct scene
  29275. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29276. * @param onLoad optional callback to be called upon successful completion
  29277. * @param onError optional callback to be called upon failure
  29278. * @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
  29279. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29280. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29281. * @param forcedExtension defines the extension to use to pick the right loader
  29282. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29283. * @param mimeType defines an optional mime type
  29284. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29285. */
  29286. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  29287. /**
  29288. * @hidden
  29289. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29290. /**
  29291. * Creates a raw texture
  29292. * @param data defines the data to store in the texture
  29293. * @param width defines the width of the texture
  29294. * @param height defines the height of the texture
  29295. * @param format defines the format of the data
  29296. * @param generateMipMaps defines if the engine should generate the mip levels
  29297. * @param invertY defines if data must be stored with Y axis inverted
  29298. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29299. * @param compression defines the compression used (null by default)
  29300. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29301. * @returns the raw texture inside an InternalTexture
  29302. */
  29303. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29304. /**
  29305. * Creates a new raw cube texture
  29306. * @param data defines the array of data to use to create each face
  29307. * @param size defines the size of the textures
  29308. * @param format defines the format of the data
  29309. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29310. * @param generateMipMaps defines if the engine should generate the mip levels
  29311. * @param invertY defines if data must be stored with Y axis inverted
  29312. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29313. * @param compression defines the compression used (null by default)
  29314. * @returns the cube texture as an InternalTexture
  29315. */
  29316. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29317. /**
  29318. * Creates a new raw 3D texture
  29319. * @param data defines the data used to create the texture
  29320. * @param width defines the width of the texture
  29321. * @param height defines the height of the texture
  29322. * @param depth defines the depth of the texture
  29323. * @param format defines the format of the texture
  29324. * @param generateMipMaps defines if the engine must generate mip levels
  29325. * @param invertY defines if data must be stored with Y axis inverted
  29326. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29327. * @param compression defines the compressed used (can be null)
  29328. * @param textureType defines the compressed used (can be null)
  29329. * @returns a new raw 3D texture (stored in an InternalTexture)
  29330. */
  29331. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29332. private _unpackFlipYCached;
  29333. /**
  29334. * In case you are sharing the context with other applications, it might
  29335. * be interested to not cache the unpack flip y state to ensure a consistent
  29336. * value would be set.
  29337. */
  29338. enableUnpackFlipYCached: boolean;
  29339. /** @hidden */ private _unpackFlipY(value: boolean): void;
  29340. /** @hidden */ private _getUnpackAlignement(): number;
  29341. /**
  29342. * Update the sampling mode of a given texture
  29343. * @param samplingMode defines the required sampling mode
  29344. * @param texture defines the texture to update
  29345. */
  29346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29347. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29348. width: number;
  29349. height: number;
  29350. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29351. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29352. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29353. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29354. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29355. private _prepareWebGLTexture;
  29356. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29357. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  29358. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  29359. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29360. protected _setProgram(program: WebGLProgram): void;
  29361. protected _boundUniforms: {
  29362. [key: number]: WebGLUniformLocation;
  29363. };
  29364. /**
  29365. * Binds an effect to the webGL context
  29366. * @param effect defines the effect to bind
  29367. */
  29368. bindSamplers(effect: Effect): void;
  29369. private _activateCurrentTexture;
  29370. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29371. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29372. /**
  29373. * Unbind all textures from the webGL context
  29374. */
  29375. unbindAllTextures(): void;
  29376. /**
  29377. * Sets a texture to the according uniform.
  29378. * @param channel The texture channel
  29379. * @param uniform The uniform to set
  29380. * @param texture The texture to apply
  29381. */
  29382. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29383. private _bindSamplerUniformToChannel;
  29384. private _getTextureWrapMode;
  29385. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29386. /**
  29387. * Sets an array of texture to the webGL context
  29388. * @param channel defines the channel where the texture array must be set
  29389. * @param uniform defines the associated uniform location
  29390. * @param textures defines the array of textures to bind
  29391. */
  29392. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29393. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29394. private _setTextureParameterFloat;
  29395. private _setTextureParameterInteger;
  29396. /**
  29397. * Unbind all vertex attributes from the webGL context
  29398. */
  29399. unbindAllAttributes(): void;
  29400. /**
  29401. * 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
  29402. */
  29403. releaseEffects(): void;
  29404. /**
  29405. * Dispose and release all associated resources
  29406. */
  29407. dispose(): void;
  29408. /**
  29409. * Attach a new callback raised when context lost event is fired
  29410. * @param callback defines the callback to call
  29411. */
  29412. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29413. /**
  29414. * Attach a new callback raised when context restored event is fired
  29415. * @param callback defines the callback to call
  29416. */
  29417. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29418. /**
  29419. * Get the current error code of the webGL context
  29420. * @returns the error code
  29421. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29422. */
  29423. getError(): number;
  29424. private _canRenderToFloatFramebuffer;
  29425. private _canRenderToHalfFloatFramebuffer;
  29426. private _canRenderToFramebuffer;
  29427. /** @hidden */ private _getWebGLTextureType(type: number): number;
  29428. /** @hidden */ private _getInternalFormat(format: number): number;
  29429. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29430. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  29431. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  29432. /**
  29433. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29434. * @returns true if the engine can be created
  29435. * @ignorenaming
  29436. */
  29437. static isSupported(): boolean;
  29438. /**
  29439. * Find the next highest power of two.
  29440. * @param x Number to start search from.
  29441. * @return Next highest power of two.
  29442. */
  29443. static CeilingPOT(x: number): number;
  29444. /**
  29445. * Find the next lowest power of two.
  29446. * @param x Number to start search from.
  29447. * @return Next lowest power of two.
  29448. */
  29449. static FloorPOT(x: number): number;
  29450. /**
  29451. * Find the nearest power of two.
  29452. * @param x Number to start search from.
  29453. * @return Next nearest power of two.
  29454. */
  29455. static NearestPOT(x: number): number;
  29456. /**
  29457. * Get the closest exponent of two
  29458. * @param value defines the value to approximate
  29459. * @param max defines the maximum value to return
  29460. * @param mode defines how to define the closest value
  29461. * @returns closest exponent of two of the given value
  29462. */
  29463. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29464. /**
  29465. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29466. * @param func - the function to be called
  29467. * @param requester - the object that will request the next frame. Falls back to window.
  29468. * @returns frame number
  29469. */
  29470. static QueueNewFrame(func: () => void, requester?: any): number;
  29471. }
  29472. }
  29473. declare module BABYLON {
  29474. /**
  29475. * Class representing spherical harmonics coefficients to the 3rd degree
  29476. */
  29477. export class SphericalHarmonics {
  29478. /**
  29479. * Defines whether or not the harmonics have been prescaled for rendering.
  29480. */
  29481. preScaled: boolean;
  29482. /**
  29483. * The l0,0 coefficients of the spherical harmonics
  29484. */
  29485. l00: Vector3;
  29486. /**
  29487. * The l1,-1 coefficients of the spherical harmonics
  29488. */
  29489. l1_1: Vector3;
  29490. /**
  29491. * The l1,0 coefficients of the spherical harmonics
  29492. */
  29493. l10: Vector3;
  29494. /**
  29495. * The l1,1 coefficients of the spherical harmonics
  29496. */
  29497. l11: Vector3;
  29498. /**
  29499. * The l2,-2 coefficients of the spherical harmonics
  29500. */
  29501. l2_2: Vector3;
  29502. /**
  29503. * The l2,-1 coefficients of the spherical harmonics
  29504. */
  29505. l2_1: Vector3;
  29506. /**
  29507. * The l2,0 coefficients of the spherical harmonics
  29508. */
  29509. l20: Vector3;
  29510. /**
  29511. * The l2,1 coefficients of the spherical harmonics
  29512. */
  29513. l21: Vector3;
  29514. /**
  29515. * The l2,2 coefficients of the spherical harmonics
  29516. */
  29517. l22: Vector3;
  29518. /**
  29519. * Adds a light to the spherical harmonics
  29520. * @param direction the direction of the light
  29521. * @param color the color of the light
  29522. * @param deltaSolidAngle the delta solid angle of the light
  29523. */
  29524. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  29525. /**
  29526. * Scales the spherical harmonics by the given amount
  29527. * @param scale the amount to scale
  29528. */
  29529. scaleInPlace(scale: number): void;
  29530. /**
  29531. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  29532. *
  29533. * ```
  29534. * E_lm = A_l * L_lm
  29535. * ```
  29536. *
  29537. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  29538. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  29539. * the scaling factors are given in equation 9.
  29540. */
  29541. convertIncidentRadianceToIrradiance(): void;
  29542. /**
  29543. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  29544. *
  29545. * ```
  29546. * L = (1/pi) * E * rho
  29547. * ```
  29548. *
  29549. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  29550. */
  29551. convertIrradianceToLambertianRadiance(): void;
  29552. /**
  29553. * Integrates the reconstruction coefficients directly in to the SH preventing further
  29554. * required operations at run time.
  29555. *
  29556. * This is simply done by scaling back the SH with Ylm constants parameter.
  29557. * The trigonometric part being applied by the shader at run time.
  29558. */
  29559. preScaleForRendering(): void;
  29560. /**
  29561. * Constructs a spherical harmonics from an array.
  29562. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  29563. * @returns the spherical harmonics
  29564. */
  29565. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  29566. /**
  29567. * Gets the spherical harmonics from polynomial
  29568. * @param polynomial the spherical polynomial
  29569. * @returns the spherical harmonics
  29570. */
  29571. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  29572. }
  29573. /**
  29574. * Class representing spherical polynomial coefficients to the 3rd degree
  29575. */
  29576. export class SphericalPolynomial {
  29577. private _harmonics;
  29578. /**
  29579. * The spherical harmonics used to create the polynomials.
  29580. */
  29581. readonly preScaledHarmonics: SphericalHarmonics;
  29582. /**
  29583. * The x coefficients of the spherical polynomial
  29584. */
  29585. x: Vector3;
  29586. /**
  29587. * The y coefficients of the spherical polynomial
  29588. */
  29589. y: Vector3;
  29590. /**
  29591. * The z coefficients of the spherical polynomial
  29592. */
  29593. z: Vector3;
  29594. /**
  29595. * The xx coefficients of the spherical polynomial
  29596. */
  29597. xx: Vector3;
  29598. /**
  29599. * The yy coefficients of the spherical polynomial
  29600. */
  29601. yy: Vector3;
  29602. /**
  29603. * The zz coefficients of the spherical polynomial
  29604. */
  29605. zz: Vector3;
  29606. /**
  29607. * The xy coefficients of the spherical polynomial
  29608. */
  29609. xy: Vector3;
  29610. /**
  29611. * The yz coefficients of the spherical polynomial
  29612. */
  29613. yz: Vector3;
  29614. /**
  29615. * The zx coefficients of the spherical polynomial
  29616. */
  29617. zx: Vector3;
  29618. /**
  29619. * Adds an ambient color to the spherical polynomial
  29620. * @param color the color to add
  29621. */
  29622. addAmbient(color: Color3): void;
  29623. /**
  29624. * Scales the spherical polynomial by the given amount
  29625. * @param scale the amount to scale
  29626. */
  29627. scaleInPlace(scale: number): void;
  29628. /**
  29629. * Gets the spherical polynomial from harmonics
  29630. * @param harmonics the spherical harmonics
  29631. * @returns the spherical polynomial
  29632. */
  29633. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  29634. /**
  29635. * Constructs a spherical polynomial from an array.
  29636. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  29637. * @returns the spherical polynomial
  29638. */
  29639. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  29640. }
  29641. }
  29642. declare module BABYLON {
  29643. /**
  29644. * Defines the source of the internal texture
  29645. */
  29646. export enum InternalTextureSource {
  29647. /**
  29648. * The source of the texture data is unknown
  29649. */
  29650. Unknown = 0,
  29651. /**
  29652. * Texture data comes from an URL
  29653. */
  29654. Url = 1,
  29655. /**
  29656. * Texture data is only used for temporary storage
  29657. */
  29658. Temp = 2,
  29659. /**
  29660. * Texture data comes from raw data (ArrayBuffer)
  29661. */
  29662. Raw = 3,
  29663. /**
  29664. * Texture content is dynamic (video or dynamic texture)
  29665. */
  29666. Dynamic = 4,
  29667. /**
  29668. * Texture content is generated by rendering to it
  29669. */
  29670. RenderTarget = 5,
  29671. /**
  29672. * Texture content is part of a multi render target process
  29673. */
  29674. MultiRenderTarget = 6,
  29675. /**
  29676. * Texture data comes from a cube data file
  29677. */
  29678. Cube = 7,
  29679. /**
  29680. * Texture data comes from a raw cube data
  29681. */
  29682. CubeRaw = 8,
  29683. /**
  29684. * Texture data come from a prefiltered cube data file
  29685. */
  29686. CubePrefiltered = 9,
  29687. /**
  29688. * Texture content is raw 3D data
  29689. */
  29690. Raw3D = 10,
  29691. /**
  29692. * Texture content is a depth texture
  29693. */
  29694. Depth = 11,
  29695. /**
  29696. * Texture data comes from a raw cube data encoded with RGBD
  29697. */
  29698. CubeRawRGBD = 12
  29699. }
  29700. /**
  29701. * Class used to store data associated with WebGL texture data for the engine
  29702. * This class should not be used directly
  29703. */
  29704. export class InternalTexture {
  29705. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  29706. /**
  29707. * Defines if the texture is ready
  29708. */
  29709. isReady: boolean;
  29710. /**
  29711. * Defines if the texture is a cube texture
  29712. */
  29713. isCube: boolean;
  29714. /**
  29715. * Defines if the texture contains 3D data
  29716. */
  29717. is3D: boolean;
  29718. /**
  29719. * Defines if the texture contains multiview data
  29720. */
  29721. isMultiview: boolean;
  29722. /**
  29723. * Gets the URL used to load this texture
  29724. */
  29725. url: string;
  29726. /**
  29727. * Gets the sampling mode of the texture
  29728. */
  29729. samplingMode: number;
  29730. /**
  29731. * Gets a boolean indicating if the texture needs mipmaps generation
  29732. */
  29733. generateMipMaps: boolean;
  29734. /**
  29735. * Gets the number of samples used by the texture (WebGL2+ only)
  29736. */
  29737. samples: number;
  29738. /**
  29739. * Gets the type of the texture (int, float...)
  29740. */
  29741. type: number;
  29742. /**
  29743. * Gets the format of the texture (RGB, RGBA...)
  29744. */
  29745. format: number;
  29746. /**
  29747. * Observable called when the texture is loaded
  29748. */
  29749. onLoadedObservable: Observable<InternalTexture>;
  29750. /**
  29751. * Gets the width of the texture
  29752. */
  29753. width: number;
  29754. /**
  29755. * Gets the height of the texture
  29756. */
  29757. height: number;
  29758. /**
  29759. * Gets the depth of the texture
  29760. */
  29761. depth: number;
  29762. /**
  29763. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  29764. */
  29765. baseWidth: number;
  29766. /**
  29767. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  29768. */
  29769. baseHeight: number;
  29770. /**
  29771. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  29772. */
  29773. baseDepth: number;
  29774. /**
  29775. * Gets a boolean indicating if the texture is inverted on Y axis
  29776. */
  29777. invertY: boolean;
  29778. /** @hidden */ private _invertVScale: boolean;
  29779. /** @hidden */ private _associatedChannel: number;
  29780. /** @hidden */ private _source: InternalTextureSource;
  29781. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29782. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  29783. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  29784. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29785. /** @hidden */ private _size: number;
  29786. /** @hidden */ private _extension: string;
  29787. /** @hidden */ private _files: Nullable<string[]>;
  29788. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29789. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29790. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  29791. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29792. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29793. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29794. /** @hidden */ private _attachments: Nullable<number[]>;
  29795. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  29796. /** @hidden */ private _cachedWrapU: Nullable<number>;
  29797. /** @hidden */ private _cachedWrapV: Nullable<number>;
  29798. /** @hidden */ private _cachedWrapR: Nullable<number>;
  29799. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  29800. /** @hidden */ private _isDisabled: boolean;
  29801. /** @hidden */ private _compression: Nullable<string>;
  29802. /** @hidden */ private _generateStencilBuffer: boolean;
  29803. /** @hidden */ private _generateDepthBuffer: boolean;
  29804. /** @hidden */ private _comparisonFunction: number;
  29805. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29806. /** @hidden */ private _lodGenerationScale: number;
  29807. /** @hidden */ private _lodGenerationOffset: number;
  29808. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  29809. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  29810. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  29811. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  29812. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  29813. /** @hidden */ private _isRGBD: boolean;
  29814. /** @hidden */ private _linearSpecularLOD: boolean;
  29815. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  29816. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  29817. /** @hidden */ private _references: number;
  29818. private _engine;
  29819. /**
  29820. * Gets the Engine the texture belongs to.
  29821. * @returns The babylon engine
  29822. */
  29823. getEngine(): ThinEngine;
  29824. /**
  29825. * Gets the data source type of the texture
  29826. */
  29827. readonly source: InternalTextureSource;
  29828. /**
  29829. * Creates a new InternalTexture
  29830. * @param engine defines the engine to use
  29831. * @param source defines the type of data that will be used
  29832. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29833. */
  29834. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  29835. /**
  29836. * Increments the number of references (ie. the number of Texture that point to it)
  29837. */
  29838. incrementReferences(): void;
  29839. /**
  29840. * Change the size of the texture (not the size of the content)
  29841. * @param width defines the new width
  29842. * @param height defines the new height
  29843. * @param depth defines the new depth (1 by default)
  29844. */
  29845. updateSize(width: int, height: int, depth?: int): void;
  29846. /** @hidden */ private _rebuild(): void;
  29847. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  29848. /**
  29849. * Dispose the current allocated resources
  29850. */
  29851. dispose(): void;
  29852. }
  29853. }
  29854. declare module BABYLON {
  29855. /**
  29856. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29858. */
  29859. export class Analyser {
  29860. /**
  29861. * Gets or sets the smoothing
  29862. * @ignorenaming
  29863. */
  29864. SMOOTHING: number;
  29865. /**
  29866. * Gets or sets the FFT table size
  29867. * @ignorenaming
  29868. */
  29869. FFT_SIZE: number;
  29870. /**
  29871. * Gets or sets the bar graph amplitude
  29872. * @ignorenaming
  29873. */
  29874. BARGRAPHAMPLITUDE: number;
  29875. /**
  29876. * Gets or sets the position of the debug canvas
  29877. * @ignorenaming
  29878. */
  29879. DEBUGCANVASPOS: {
  29880. x: number;
  29881. y: number;
  29882. };
  29883. /**
  29884. * Gets or sets the debug canvas size
  29885. * @ignorenaming
  29886. */
  29887. DEBUGCANVASSIZE: {
  29888. width: number;
  29889. height: number;
  29890. };
  29891. private _byteFreqs;
  29892. private _byteTime;
  29893. private _floatFreqs;
  29894. private _webAudioAnalyser;
  29895. private _debugCanvas;
  29896. private _debugCanvasContext;
  29897. private _scene;
  29898. private _registerFunc;
  29899. private _audioEngine;
  29900. /**
  29901. * Creates a new analyser
  29902. * @param scene defines hosting scene
  29903. */
  29904. constructor(scene: Scene);
  29905. /**
  29906. * Get the number of data values you will have to play with for the visualization
  29907. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29908. * @returns a number
  29909. */
  29910. getFrequencyBinCount(): number;
  29911. /**
  29912. * Gets the current frequency data as a byte array
  29913. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29914. * @returns a Uint8Array
  29915. */
  29916. getByteFrequencyData(): Uint8Array;
  29917. /**
  29918. * Gets the current waveform as a byte array
  29919. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29920. * @returns a Uint8Array
  29921. */
  29922. getByteTimeDomainData(): Uint8Array;
  29923. /**
  29924. * Gets the current frequency data as a float array
  29925. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29926. * @returns a Float32Array
  29927. */
  29928. getFloatFrequencyData(): Float32Array;
  29929. /**
  29930. * Renders the debug canvas
  29931. */
  29932. drawDebugCanvas(): void;
  29933. /**
  29934. * Stops rendering the debug canvas and removes it
  29935. */
  29936. stopDebugCanvas(): void;
  29937. /**
  29938. * Connects two audio nodes
  29939. * @param inputAudioNode defines first node to connect
  29940. * @param outputAudioNode defines second node to connect
  29941. */
  29942. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29943. /**
  29944. * Releases all associated resources
  29945. */
  29946. dispose(): void;
  29947. }
  29948. }
  29949. declare module BABYLON {
  29950. /**
  29951. * This represents an audio engine and it is responsible
  29952. * to play, synchronize and analyse sounds throughout the application.
  29953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29954. */
  29955. export interface IAudioEngine extends IDisposable {
  29956. /**
  29957. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29958. */
  29959. readonly canUseWebAudio: boolean;
  29960. /**
  29961. * Gets the current AudioContext if available.
  29962. */
  29963. readonly audioContext: Nullable<AudioContext>;
  29964. /**
  29965. * The master gain node defines the global audio volume of your audio engine.
  29966. */
  29967. readonly masterGain: GainNode;
  29968. /**
  29969. * Gets whether or not mp3 are supported by your browser.
  29970. */
  29971. readonly isMP3supported: boolean;
  29972. /**
  29973. * Gets whether or not ogg are supported by your browser.
  29974. */
  29975. readonly isOGGsupported: boolean;
  29976. /**
  29977. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29978. * @ignoreNaming
  29979. */
  29980. WarnedWebAudioUnsupported: boolean;
  29981. /**
  29982. * Defines if the audio engine relies on a custom unlocked button.
  29983. * In this case, the embedded button will not be displayed.
  29984. */
  29985. useCustomUnlockedButton: boolean;
  29986. /**
  29987. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29988. */
  29989. readonly unlocked: boolean;
  29990. /**
  29991. * Event raised when audio has been unlocked on the browser.
  29992. */
  29993. onAudioUnlockedObservable: Observable<AudioEngine>;
  29994. /**
  29995. * Event raised when audio has been locked on the browser.
  29996. */
  29997. onAudioLockedObservable: Observable<AudioEngine>;
  29998. /**
  29999. * Flags the audio engine in Locked state.
  30000. * This happens due to new browser policies preventing audio to autoplay.
  30001. */
  30002. lock(): void;
  30003. /**
  30004. * Unlocks the audio engine once a user action has been done on the dom.
  30005. * This is helpful to resume play once browser policies have been satisfied.
  30006. */
  30007. unlock(): void;
  30008. }
  30009. /**
  30010. * This represents the default audio engine used in babylon.
  30011. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30013. */
  30014. export class AudioEngine implements IAudioEngine {
  30015. private _audioContext;
  30016. private _audioContextInitialized;
  30017. private _muteButton;
  30018. private _hostElement;
  30019. /**
  30020. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30021. */
  30022. canUseWebAudio: boolean;
  30023. /**
  30024. * The master gain node defines the global audio volume of your audio engine.
  30025. */
  30026. masterGain: GainNode;
  30027. /**
  30028. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30029. * @ignoreNaming
  30030. */
  30031. WarnedWebAudioUnsupported: boolean;
  30032. /**
  30033. * Gets whether or not mp3 are supported by your browser.
  30034. */
  30035. isMP3supported: boolean;
  30036. /**
  30037. * Gets whether or not ogg are supported by your browser.
  30038. */
  30039. isOGGsupported: boolean;
  30040. /**
  30041. * Gets whether audio has been unlocked on the device.
  30042. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30043. * a user interaction has happened.
  30044. */
  30045. unlocked: boolean;
  30046. /**
  30047. * Defines if the audio engine relies on a custom unlocked button.
  30048. * In this case, the embedded button will not be displayed.
  30049. */
  30050. useCustomUnlockedButton: boolean;
  30051. /**
  30052. * Event raised when audio has been unlocked on the browser.
  30053. */
  30054. onAudioUnlockedObservable: Observable<AudioEngine>;
  30055. /**
  30056. * Event raised when audio has been locked on the browser.
  30057. */
  30058. onAudioLockedObservable: Observable<AudioEngine>;
  30059. /**
  30060. * Gets the current AudioContext if available.
  30061. */
  30062. readonly audioContext: Nullable<AudioContext>;
  30063. private _connectedAnalyser;
  30064. /**
  30065. * Instantiates a new audio engine.
  30066. *
  30067. * There should be only one per page as some browsers restrict the number
  30068. * of audio contexts you can create.
  30069. * @param hostElement defines the host element where to display the mute icon if necessary
  30070. */
  30071. constructor(hostElement?: Nullable<HTMLElement>);
  30072. /**
  30073. * Flags the audio engine in Locked state.
  30074. * This happens due to new browser policies preventing audio to autoplay.
  30075. */
  30076. lock(): void;
  30077. /**
  30078. * Unlocks the audio engine once a user action has been done on the dom.
  30079. * This is helpful to resume play once browser policies have been satisfied.
  30080. */
  30081. unlock(): void;
  30082. private _resumeAudioContext;
  30083. private _initializeAudioContext;
  30084. private _tryToRun;
  30085. private _triggerRunningState;
  30086. private _triggerSuspendedState;
  30087. private _displayMuteButton;
  30088. private _moveButtonToTopLeft;
  30089. private _onResize;
  30090. private _hideMuteButton;
  30091. /**
  30092. * Destroy and release the resources associated with the audio ccontext.
  30093. */
  30094. dispose(): void;
  30095. /**
  30096. * Gets the global volume sets on the master gain.
  30097. * @returns the global volume if set or -1 otherwise
  30098. */
  30099. getGlobalVolume(): number;
  30100. /**
  30101. * Sets the global volume of your experience (sets on the master gain).
  30102. * @param newVolume Defines the new global volume of the application
  30103. */
  30104. setGlobalVolume(newVolume: number): void;
  30105. /**
  30106. * Connect the audio engine to an audio analyser allowing some amazing
  30107. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30109. * @param analyser The analyser to connect to the engine
  30110. */
  30111. connectToAnalyser(analyser: Analyser): void;
  30112. }
  30113. }
  30114. declare module BABYLON {
  30115. /**
  30116. * Interface used to present a loading screen while loading a scene
  30117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30118. */
  30119. export interface ILoadingScreen {
  30120. /**
  30121. * Function called to display the loading screen
  30122. */
  30123. displayLoadingUI: () => void;
  30124. /**
  30125. * Function called to hide the loading screen
  30126. */
  30127. hideLoadingUI: () => void;
  30128. /**
  30129. * Gets or sets the color to use for the background
  30130. */
  30131. loadingUIBackgroundColor: string;
  30132. /**
  30133. * Gets or sets the text to display while loading
  30134. */
  30135. loadingUIText: string;
  30136. }
  30137. /**
  30138. * Class used for the default loading screen
  30139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30140. */
  30141. export class DefaultLoadingScreen implements ILoadingScreen {
  30142. private _renderingCanvas;
  30143. private _loadingText;
  30144. private _loadingDivBackgroundColor;
  30145. private _loadingDiv;
  30146. private _loadingTextDiv;
  30147. /** Gets or sets the logo url to use for the default loading screen */
  30148. static DefaultLogoUrl: string;
  30149. /** Gets or sets the spinner url to use for the default loading screen */
  30150. static DefaultSpinnerUrl: string;
  30151. /**
  30152. * Creates a new default loading screen
  30153. * @param _renderingCanvas defines the canvas used to render the scene
  30154. * @param _loadingText defines the default text to display
  30155. * @param _loadingDivBackgroundColor defines the default background color
  30156. */
  30157. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30158. /**
  30159. * Function called to display the loading screen
  30160. */
  30161. displayLoadingUI(): void;
  30162. /**
  30163. * Function called to hide the loading screen
  30164. */
  30165. hideLoadingUI(): void;
  30166. /**
  30167. * Gets or sets the text to display while loading
  30168. */
  30169. loadingUIText: string;
  30170. /**
  30171. * Gets or sets the color to use for the background
  30172. */
  30173. loadingUIBackgroundColor: string;
  30174. private _resizeLoadingUI;
  30175. }
  30176. }
  30177. declare module BABYLON {
  30178. /**
  30179. * Interface for any object that can request an animation frame
  30180. */
  30181. export interface ICustomAnimationFrameRequester {
  30182. /**
  30183. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30184. */
  30185. renderFunction?: Function;
  30186. /**
  30187. * Called to request the next frame to render to
  30188. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30189. */
  30190. requestAnimationFrame: Function;
  30191. /**
  30192. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30193. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30194. */
  30195. requestID?: number;
  30196. }
  30197. }
  30198. declare module BABYLON {
  30199. /**
  30200. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30201. */
  30202. export class PerformanceMonitor {
  30203. private _enabled;
  30204. private _rollingFrameTime;
  30205. private _lastFrameTimeMs;
  30206. /**
  30207. * constructor
  30208. * @param frameSampleSize The number of samples required to saturate the sliding window
  30209. */
  30210. constructor(frameSampleSize?: number);
  30211. /**
  30212. * Samples current frame
  30213. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30214. */
  30215. sampleFrame(timeMs?: number): void;
  30216. /**
  30217. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30218. */
  30219. readonly averageFrameTime: number;
  30220. /**
  30221. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30222. */
  30223. readonly averageFrameTimeVariance: number;
  30224. /**
  30225. * Returns the frame time of the most recent frame
  30226. */
  30227. readonly instantaneousFrameTime: number;
  30228. /**
  30229. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30230. */
  30231. readonly averageFPS: number;
  30232. /**
  30233. * Returns the average framerate in frames per second using the most recent frame time
  30234. */
  30235. readonly instantaneousFPS: number;
  30236. /**
  30237. * Returns true if enough samples have been taken to completely fill the sliding window
  30238. */
  30239. readonly isSaturated: boolean;
  30240. /**
  30241. * Enables contributions to the sliding window sample set
  30242. */
  30243. enable(): void;
  30244. /**
  30245. * Disables contributions to the sliding window sample set
  30246. * Samples will not be interpolated over the disabled period
  30247. */
  30248. disable(): void;
  30249. /**
  30250. * Returns true if sampling is enabled
  30251. */
  30252. readonly isEnabled: boolean;
  30253. /**
  30254. * Resets performance monitor
  30255. */
  30256. reset(): void;
  30257. }
  30258. /**
  30259. * RollingAverage
  30260. *
  30261. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30262. */
  30263. export class RollingAverage {
  30264. /**
  30265. * Current average
  30266. */
  30267. average: number;
  30268. /**
  30269. * Current variance
  30270. */
  30271. variance: number;
  30272. protected _samples: Array<number>;
  30273. protected _sampleCount: number;
  30274. protected _pos: number;
  30275. protected _m2: number;
  30276. /**
  30277. * constructor
  30278. * @param length The number of samples required to saturate the sliding window
  30279. */
  30280. constructor(length: number);
  30281. /**
  30282. * Adds a sample to the sample set
  30283. * @param v The sample value
  30284. */
  30285. add(v: number): void;
  30286. /**
  30287. * Returns previously added values or null if outside of history or outside the sliding window domain
  30288. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30289. * @return Value previously recorded with add() or null if outside of range
  30290. */
  30291. history(i: number): number;
  30292. /**
  30293. * Returns true if enough samples have been taken to completely fill the sliding window
  30294. * @return true if sample-set saturated
  30295. */
  30296. isSaturated(): boolean;
  30297. /**
  30298. * Resets the rolling average (equivalent to 0 samples taken so far)
  30299. */
  30300. reset(): void;
  30301. /**
  30302. * Wraps a value around the sample range boundaries
  30303. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30304. * @return Wrapped position in sample range
  30305. */
  30306. protected _wrapPosition(i: number): number;
  30307. }
  30308. }
  30309. declare module BABYLON {
  30310. /**
  30311. * This class is used to track a performance counter which is number based.
  30312. * The user has access to many properties which give statistics of different nature.
  30313. *
  30314. * The implementer can track two kinds of Performance Counter: time and count.
  30315. * 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.
  30316. * 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.
  30317. */
  30318. export class PerfCounter {
  30319. /**
  30320. * Gets or sets a global boolean to turn on and off all the counters
  30321. */
  30322. static Enabled: boolean;
  30323. /**
  30324. * Returns the smallest value ever
  30325. */
  30326. readonly min: number;
  30327. /**
  30328. * Returns the biggest value ever
  30329. */
  30330. readonly max: number;
  30331. /**
  30332. * Returns the average value since the performance counter is running
  30333. */
  30334. readonly average: number;
  30335. /**
  30336. * Returns the average value of the last second the counter was monitored
  30337. */
  30338. readonly lastSecAverage: number;
  30339. /**
  30340. * Returns the current value
  30341. */
  30342. readonly current: number;
  30343. /**
  30344. * Gets the accumulated total
  30345. */
  30346. readonly total: number;
  30347. /**
  30348. * Gets the total value count
  30349. */
  30350. readonly count: number;
  30351. /**
  30352. * Creates a new counter
  30353. */
  30354. constructor();
  30355. /**
  30356. * Call this method to start monitoring a new frame.
  30357. * 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.
  30358. */
  30359. fetchNewFrame(): void;
  30360. /**
  30361. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30362. * @param newCount the count value to add to the monitored count
  30363. * @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.
  30364. */
  30365. addCount(newCount: number, fetchResult: boolean): void;
  30366. /**
  30367. * Start monitoring this performance counter
  30368. */
  30369. beginMonitoring(): void;
  30370. /**
  30371. * Compute the time lapsed since the previous beginMonitoring() call.
  30372. * @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
  30373. */
  30374. endMonitoring(newFrame?: boolean): void;
  30375. private _fetchResult;
  30376. private _startMonitoringTime;
  30377. private _min;
  30378. private _max;
  30379. private _average;
  30380. private _current;
  30381. private _totalValueCount;
  30382. private _totalAccumulated;
  30383. private _lastSecAverage;
  30384. private _lastSecAccumulated;
  30385. private _lastSecTime;
  30386. private _lastSecValueCount;
  30387. }
  30388. }
  30389. declare module BABYLON {
  30390. /**
  30391. * Defines the interface used by display changed events
  30392. */
  30393. export interface IDisplayChangedEventArgs {
  30394. /** Gets the vrDisplay object (if any) */
  30395. vrDisplay: Nullable<any>;
  30396. /** Gets a boolean indicating if webVR is supported */
  30397. vrSupported: boolean;
  30398. }
  30399. /**
  30400. * Defines the interface used by objects containing a viewport (like a camera)
  30401. */
  30402. interface IViewportOwnerLike {
  30403. /**
  30404. * Gets or sets the viewport
  30405. */
  30406. viewport: IViewportLike;
  30407. }
  30408. /**
  30409. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30410. */
  30411. export class Engine extends ThinEngine {
  30412. /** Defines that alpha blending is disabled */
  30413. static readonly ALPHA_DISABLE: number;
  30414. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30415. static readonly ALPHA_ADD: number;
  30416. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30417. static readonly ALPHA_COMBINE: number;
  30418. /** Defines that alpha blending to DEST - SRC * DEST */
  30419. static readonly ALPHA_SUBTRACT: number;
  30420. /** Defines that alpha blending to SRC * DEST */
  30421. static readonly ALPHA_MULTIPLY: number;
  30422. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30423. static readonly ALPHA_MAXIMIZED: number;
  30424. /** Defines that alpha blending to SRC + DEST */
  30425. static readonly ALPHA_ONEONE: number;
  30426. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30427. static readonly ALPHA_PREMULTIPLIED: number;
  30428. /**
  30429. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30430. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30431. */
  30432. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30433. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30434. static readonly ALPHA_INTERPOLATE: number;
  30435. /**
  30436. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30437. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30438. */
  30439. static readonly ALPHA_SCREENMODE: number;
  30440. /** Defines that the ressource is not delayed*/
  30441. static readonly DELAYLOADSTATE_NONE: number;
  30442. /** Defines that the ressource was successfully delay loaded */
  30443. static readonly DELAYLOADSTATE_LOADED: number;
  30444. /** Defines that the ressource is currently delay loading */
  30445. static readonly DELAYLOADSTATE_LOADING: number;
  30446. /** Defines that the ressource is delayed and has not started loading */
  30447. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30448. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30449. static readonly NEVER: number;
  30450. /** 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 */
  30451. static readonly ALWAYS: number;
  30452. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30453. static readonly LESS: number;
  30454. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30455. static readonly EQUAL: number;
  30456. /** 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 */
  30457. static readonly LEQUAL: number;
  30458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30459. static readonly GREATER: number;
  30460. /** 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 */
  30461. static readonly GEQUAL: number;
  30462. /** 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 */
  30463. static readonly NOTEQUAL: number;
  30464. /** Passed to stencilOperation to specify that stencil value must be kept */
  30465. static readonly KEEP: number;
  30466. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30467. static readonly REPLACE: number;
  30468. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30469. static readonly INCR: number;
  30470. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30471. static readonly DECR: number;
  30472. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30473. static readonly INVERT: number;
  30474. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30475. static readonly INCR_WRAP: number;
  30476. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30477. static readonly DECR_WRAP: number;
  30478. /** Texture is not repeating outside of 0..1 UVs */
  30479. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30480. /** Texture is repeating outside of 0..1 UVs */
  30481. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30482. /** Texture is repeating and mirrored */
  30483. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30484. /** ALPHA */
  30485. static readonly TEXTUREFORMAT_ALPHA: number;
  30486. /** LUMINANCE */
  30487. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30488. /** LUMINANCE_ALPHA */
  30489. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30490. /** RGB */
  30491. static readonly TEXTUREFORMAT_RGB: number;
  30492. /** RGBA */
  30493. static readonly TEXTUREFORMAT_RGBA: number;
  30494. /** RED */
  30495. static readonly TEXTUREFORMAT_RED: number;
  30496. /** RED (2nd reference) */
  30497. static readonly TEXTUREFORMAT_R: number;
  30498. /** RG */
  30499. static readonly TEXTUREFORMAT_RG: number;
  30500. /** RED_INTEGER */
  30501. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30502. /** RED_INTEGER (2nd reference) */
  30503. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30504. /** RG_INTEGER */
  30505. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30506. /** RGB_INTEGER */
  30507. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30508. /** RGBA_INTEGER */
  30509. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30510. /** UNSIGNED_BYTE */
  30511. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30512. /** UNSIGNED_BYTE (2nd reference) */
  30513. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30514. /** FLOAT */
  30515. static readonly TEXTURETYPE_FLOAT: number;
  30516. /** HALF_FLOAT */
  30517. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30518. /** BYTE */
  30519. static readonly TEXTURETYPE_BYTE: number;
  30520. /** SHORT */
  30521. static readonly TEXTURETYPE_SHORT: number;
  30522. /** UNSIGNED_SHORT */
  30523. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30524. /** INT */
  30525. static readonly TEXTURETYPE_INT: number;
  30526. /** UNSIGNED_INT */
  30527. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30528. /** UNSIGNED_SHORT_4_4_4_4 */
  30529. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30530. /** UNSIGNED_SHORT_5_5_5_1 */
  30531. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30532. /** UNSIGNED_SHORT_5_6_5 */
  30533. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30534. /** UNSIGNED_INT_2_10_10_10_REV */
  30535. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30536. /** UNSIGNED_INT_24_8 */
  30537. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30538. /** UNSIGNED_INT_10F_11F_11F_REV */
  30539. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30540. /** UNSIGNED_INT_5_9_9_9_REV */
  30541. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30542. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30543. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30544. /** nearest is mag = nearest and min = nearest and mip = linear */
  30545. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30546. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30547. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30548. /** Trilinear is mag = linear and min = linear and mip = linear */
  30549. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30550. /** nearest is mag = nearest and min = nearest and mip = linear */
  30551. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30552. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30553. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30554. /** Trilinear is mag = linear and min = linear and mip = linear */
  30555. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30556. /** mag = nearest and min = nearest and mip = nearest */
  30557. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30558. /** mag = nearest and min = linear and mip = nearest */
  30559. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30560. /** mag = nearest and min = linear and mip = linear */
  30561. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30562. /** mag = nearest and min = linear and mip = none */
  30563. static readonly TEXTURE_NEAREST_LINEAR: number;
  30564. /** mag = nearest and min = nearest and mip = none */
  30565. static readonly TEXTURE_NEAREST_NEAREST: number;
  30566. /** mag = linear and min = nearest and mip = nearest */
  30567. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30568. /** mag = linear and min = nearest and mip = linear */
  30569. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30570. /** mag = linear and min = linear and mip = none */
  30571. static readonly TEXTURE_LINEAR_LINEAR: number;
  30572. /** mag = linear and min = nearest and mip = none */
  30573. static readonly TEXTURE_LINEAR_NEAREST: number;
  30574. /** Explicit coordinates mode */
  30575. static readonly TEXTURE_EXPLICIT_MODE: number;
  30576. /** Spherical coordinates mode */
  30577. static readonly TEXTURE_SPHERICAL_MODE: number;
  30578. /** Planar coordinates mode */
  30579. static readonly TEXTURE_PLANAR_MODE: number;
  30580. /** Cubic coordinates mode */
  30581. static readonly TEXTURE_CUBIC_MODE: number;
  30582. /** Projection coordinates mode */
  30583. static readonly TEXTURE_PROJECTION_MODE: number;
  30584. /** Skybox coordinates mode */
  30585. static readonly TEXTURE_SKYBOX_MODE: number;
  30586. /** Inverse Cubic coordinates mode */
  30587. static readonly TEXTURE_INVCUBIC_MODE: number;
  30588. /** Equirectangular coordinates mode */
  30589. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30590. /** Equirectangular Fixed coordinates mode */
  30591. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30592. /** Equirectangular Fixed Mirrored coordinates mode */
  30593. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30594. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30595. static readonly SCALEMODE_FLOOR: number;
  30596. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30597. static readonly SCALEMODE_NEAREST: number;
  30598. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30599. static readonly SCALEMODE_CEILING: number;
  30600. /**
  30601. * Returns the current npm package of the sdk
  30602. */
  30603. static readonly NpmPackage: string;
  30604. /**
  30605. * Returns the current version of the framework
  30606. */
  30607. static readonly Version: string;
  30608. /** Gets the list of created engines */
  30609. static readonly Instances: Engine[];
  30610. /**
  30611. * Gets the latest created engine
  30612. */
  30613. static readonly LastCreatedEngine: Nullable<Engine>;
  30614. /**
  30615. * Gets the latest created scene
  30616. */
  30617. static readonly LastCreatedScene: Nullable<Scene>;
  30618. /**
  30619. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30620. * @param flag defines which part of the materials must be marked as dirty
  30621. * @param predicate defines a predicate used to filter which materials should be affected
  30622. */
  30623. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30624. /**
  30625. * Method called to create the default loading screen.
  30626. * This can be overriden in your own app.
  30627. * @param canvas The rendering canvas element
  30628. * @returns The loading screen
  30629. */
  30630. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30631. /**
  30632. * Method called to create the default rescale post process on each engine.
  30633. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30634. /**
  30635. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30636. **/
  30637. enableOfflineSupport: boolean;
  30638. /**
  30639. * 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)
  30640. **/
  30641. disableManifestCheck: boolean;
  30642. /**
  30643. * Gets the list of created scenes
  30644. */
  30645. scenes: Scene[];
  30646. /**
  30647. * Event raised when a new scene is created
  30648. */
  30649. onNewSceneAddedObservable: Observable<Scene>;
  30650. /**
  30651. * Gets the list of created postprocesses
  30652. */
  30653. postProcesses: PostProcess[];
  30654. /**
  30655. * Gets a boolean indicating if the pointer is currently locked
  30656. */
  30657. isPointerLock: boolean;
  30658. /**
  30659. * Observable event triggered each time the rendering canvas is resized
  30660. */
  30661. onResizeObservable: Observable<Engine>;
  30662. /**
  30663. * Observable event triggered each time the canvas loses focus
  30664. */
  30665. onCanvasBlurObservable: Observable<Engine>;
  30666. /**
  30667. * Observable event triggered each time the canvas gains focus
  30668. */
  30669. onCanvasFocusObservable: Observable<Engine>;
  30670. /**
  30671. * Observable event triggered each time the canvas receives pointerout event
  30672. */
  30673. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30674. /**
  30675. * Observable raised when the engine begins a new frame
  30676. */
  30677. onBeginFrameObservable: Observable<Engine>;
  30678. /**
  30679. * If set, will be used to request the next animation frame for the render loop
  30680. */
  30681. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30682. /**
  30683. * Observable raised when the engine ends the current frame
  30684. */
  30685. onEndFrameObservable: Observable<Engine>;
  30686. /**
  30687. * Observable raised when the engine is about to compile a shader
  30688. */
  30689. onBeforeShaderCompilationObservable: Observable<Engine>;
  30690. /**
  30691. * Observable raised when the engine has jsut compiled a shader
  30692. */
  30693. onAfterShaderCompilationObservable: Observable<Engine>;
  30694. /**
  30695. * Gets the audio engine
  30696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30697. * @ignorenaming
  30698. */
  30699. static audioEngine: IAudioEngine;
  30700. /**
  30701. * Default AudioEngine factory responsible of creating the Audio Engine.
  30702. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30703. */
  30704. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30705. /**
  30706. * Default offline support factory responsible of creating a tool used to store data locally.
  30707. * By default, this will create a Database object if the workload has been embedded.
  30708. */
  30709. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30710. private _loadingScreen;
  30711. private _pointerLockRequested;
  30712. private _dummyFramebuffer;
  30713. private _rescalePostProcess;
  30714. /** @hidden */
  30715. protected _alphaMode: number;
  30716. /** @hidden */
  30717. protected _alphaEquation: number;
  30718. private _deterministicLockstep;
  30719. private _lockstepMaxSteps;
  30720. protected readonly _supportsHardwareTextureRescaling: boolean;
  30721. private _fps;
  30722. private _deltaTime;
  30723. /** @hidden */ private _drawCalls: PerfCounter;
  30724. /**
  30725. * Turn this value on if you want to pause FPS computation when in background
  30726. */
  30727. disablePerformanceMonitorInBackground: boolean;
  30728. private _performanceMonitor;
  30729. /**
  30730. * Gets the performance monitor attached to this engine
  30731. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30732. */
  30733. readonly performanceMonitor: PerformanceMonitor;
  30734. private _onFocus;
  30735. private _onBlur;
  30736. private _onCanvasPointerOut;
  30737. private _onCanvasBlur;
  30738. private _onCanvasFocus;
  30739. private _onFullscreenChange;
  30740. private _onPointerLockChange;
  30741. /**
  30742. * Creates a new engine
  30743. * @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
  30744. * @param antialias defines enable antialiasing (default: false)
  30745. * @param options defines further options to be sent to the getContext() function
  30746. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30747. */
  30748. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30749. /**
  30750. * Gets current aspect ratio
  30751. * @param viewportOwner defines the camera to use to get the aspect ratio
  30752. * @param useScreen defines if screen size must be used (or the current render target if any)
  30753. * @returns a number defining the aspect ratio
  30754. */
  30755. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30756. /**
  30757. * Gets current screen aspect ratio
  30758. * @returns a number defining the aspect ratio
  30759. */
  30760. getScreenAspectRatio(): number;
  30761. /**
  30762. * Gets host document
  30763. * @returns the host document object
  30764. */
  30765. getHostDocument(): Document;
  30766. /**
  30767. * Gets the client rect of the HTML canvas attached with the current webGL context
  30768. * @returns a client rectanglee
  30769. */
  30770. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30771. /**
  30772. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30774. * @returns true if engine is in deterministic lock step mode
  30775. */
  30776. isDeterministicLockStep(): boolean;
  30777. /**
  30778. * Gets the max steps when engine is running in deterministic lock step
  30779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30780. * @returns the max steps
  30781. */
  30782. getLockstepMaxSteps(): number;
  30783. /**
  30784. * Force the mipmap generation for the given render target texture
  30785. * @param texture defines the render target texture to use
  30786. */
  30787. generateMipMapsForCubemap(texture: InternalTexture): void;
  30788. /** States */
  30789. /**
  30790. * Set various states to the webGL context
  30791. * @param culling defines backface culling state
  30792. * @param zOffset defines the value to apply to zOffset (0 by default)
  30793. * @param force defines if states must be applied even if cache is up to date
  30794. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30795. */
  30796. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30797. /**
  30798. * Set the z offset to apply to current rendering
  30799. * @param value defines the offset to apply
  30800. */
  30801. setZOffset(value: number): void;
  30802. /**
  30803. * Gets the current value of the zOffset
  30804. * @returns the current zOffset state
  30805. */
  30806. getZOffset(): number;
  30807. /**
  30808. * Enable or disable depth buffering
  30809. * @param enable defines the state to set
  30810. */
  30811. setDepthBuffer(enable: boolean): void;
  30812. /**
  30813. * Gets a boolean indicating if depth writing is enabled
  30814. * @returns the current depth writing state
  30815. */
  30816. getDepthWrite(): boolean;
  30817. /**
  30818. * Enable or disable depth writing
  30819. * @param enable defines the state to set
  30820. */
  30821. setDepthWrite(enable: boolean): void;
  30822. /**
  30823. * Enable or disable color writing
  30824. * @param enable defines the state to set
  30825. */
  30826. setColorWrite(enable: boolean): void;
  30827. /**
  30828. * Gets a boolean indicating if color writing is enabled
  30829. * @returns the current color writing state
  30830. */
  30831. getColorWrite(): boolean;
  30832. /**
  30833. * Sets alpha constants used by some alpha blending modes
  30834. * @param r defines the red component
  30835. * @param g defines the green component
  30836. * @param b defines the blue component
  30837. * @param a defines the alpha component
  30838. */
  30839. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30840. /**
  30841. * Sets the current alpha mode
  30842. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30843. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30844. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30845. */
  30846. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30847. /**
  30848. * Gets the current alpha mode
  30849. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30850. * @returns the current alpha mode
  30851. */
  30852. getAlphaMode(): number;
  30853. /**
  30854. * Sets the current alpha equation
  30855. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  30856. */
  30857. setAlphaEquation(equation: number): void;
  30858. /**
  30859. * Gets the current alpha equation.
  30860. * @returns the current alpha equation
  30861. */
  30862. getAlphaEquation(): number;
  30863. /**
  30864. * Gets a boolean indicating if stencil buffer is enabled
  30865. * @returns the current stencil buffer state
  30866. */
  30867. getStencilBuffer(): boolean;
  30868. /**
  30869. * Enable or disable the stencil buffer
  30870. * @param enable defines if the stencil buffer must be enabled or disabled
  30871. */
  30872. setStencilBuffer(enable: boolean): void;
  30873. /**
  30874. * Gets the current stencil mask
  30875. * @returns a number defining the new stencil mask to use
  30876. */
  30877. getStencilMask(): number;
  30878. /**
  30879. * Sets the current stencil mask
  30880. * @param mask defines the new stencil mask to use
  30881. */
  30882. setStencilMask(mask: number): void;
  30883. /**
  30884. * Gets the current stencil function
  30885. * @returns a number defining the stencil function to use
  30886. */
  30887. getStencilFunction(): number;
  30888. /**
  30889. * Gets the current stencil reference value
  30890. * @returns a number defining the stencil reference value to use
  30891. */
  30892. getStencilFunctionReference(): number;
  30893. /**
  30894. * Gets the current stencil mask
  30895. * @returns a number defining the stencil mask to use
  30896. */
  30897. getStencilFunctionMask(): number;
  30898. /**
  30899. * Sets the current stencil function
  30900. * @param stencilFunc defines the new stencil function to use
  30901. */
  30902. setStencilFunction(stencilFunc: number): void;
  30903. /**
  30904. * Sets the current stencil reference
  30905. * @param reference defines the new stencil reference to use
  30906. */
  30907. setStencilFunctionReference(reference: number): void;
  30908. /**
  30909. * Sets the current stencil mask
  30910. * @param mask defines the new stencil mask to use
  30911. */
  30912. setStencilFunctionMask(mask: number): void;
  30913. /**
  30914. * Gets the current stencil operation when stencil fails
  30915. * @returns a number defining stencil operation to use when stencil fails
  30916. */
  30917. getStencilOperationFail(): number;
  30918. /**
  30919. * Gets the current stencil operation when depth fails
  30920. * @returns a number defining stencil operation to use when depth fails
  30921. */
  30922. getStencilOperationDepthFail(): number;
  30923. /**
  30924. * Gets the current stencil operation when stencil passes
  30925. * @returns a number defining stencil operation to use when stencil passes
  30926. */
  30927. getStencilOperationPass(): number;
  30928. /**
  30929. * Sets the stencil operation to use when stencil fails
  30930. * @param operation defines the stencil operation to use when stencil fails
  30931. */
  30932. setStencilOperationFail(operation: number): void;
  30933. /**
  30934. * Sets the stencil operation to use when depth fails
  30935. * @param operation defines the stencil operation to use when depth fails
  30936. */
  30937. setStencilOperationDepthFail(operation: number): void;
  30938. /**
  30939. * Sets the stencil operation to use when stencil passes
  30940. * @param operation defines the stencil operation to use when stencil passes
  30941. */
  30942. setStencilOperationPass(operation: number): void;
  30943. /**
  30944. * Sets a boolean indicating if the dithering state is enabled or disabled
  30945. * @param value defines the dithering state
  30946. */
  30947. setDitheringState(value: boolean): void;
  30948. /**
  30949. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30950. * @param value defines the rasterizer state
  30951. */
  30952. setRasterizerState(value: boolean): void;
  30953. /**
  30954. * Gets the current depth function
  30955. * @returns a number defining the depth function
  30956. */
  30957. getDepthFunction(): Nullable<number>;
  30958. /**
  30959. * Sets the current depth function
  30960. * @param depthFunc defines the function to use
  30961. */
  30962. setDepthFunction(depthFunc: number): void;
  30963. /**
  30964. * Sets the current depth function to GREATER
  30965. */
  30966. setDepthFunctionToGreater(): void;
  30967. /**
  30968. * Sets the current depth function to GEQUAL
  30969. */
  30970. setDepthFunctionToGreaterOrEqual(): void;
  30971. /**
  30972. * Sets the current depth function to LESS
  30973. */
  30974. setDepthFunctionToLess(): void;
  30975. /**
  30976. * Sets the current depth function to LEQUAL
  30977. */
  30978. setDepthFunctionToLessOrEqual(): void;
  30979. private _cachedStencilBuffer;
  30980. private _cachedStencilFunction;
  30981. private _cachedStencilMask;
  30982. private _cachedStencilOperationPass;
  30983. private _cachedStencilOperationFail;
  30984. private _cachedStencilOperationDepthFail;
  30985. private _cachedStencilReference;
  30986. /**
  30987. * Caches the the state of the stencil buffer
  30988. */
  30989. cacheStencilState(): void;
  30990. /**
  30991. * Restores the state of the stencil buffer
  30992. */
  30993. restoreStencilState(): void;
  30994. /**
  30995. * Directly set the WebGL Viewport
  30996. * @param x defines the x coordinate of the viewport (in screen space)
  30997. * @param y defines the y coordinate of the viewport (in screen space)
  30998. * @param width defines the width of the viewport (in screen space)
  30999. * @param height defines the height of the viewport (in screen space)
  31000. * @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
  31001. */
  31002. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31003. /**
  31004. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31005. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31006. * @param y defines the y-coordinate of the corner of the clear rectangle
  31007. * @param width defines the width of the clear rectangle
  31008. * @param height defines the height of the clear rectangle
  31009. * @param clearColor defines the clear color
  31010. */
  31011. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31012. /**
  31013. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31014. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31015. * @param y defines the y-coordinate of the corner of the clear rectangle
  31016. * @param width defines the width of the clear rectangle
  31017. * @param height defines the height of the clear rectangle
  31018. */
  31019. enableScissor(x: number, y: number, width: number, height: number): void;
  31020. /**
  31021. * Disable previously set scissor test rectangle
  31022. */
  31023. disableScissor(): void;
  31024. protected _reportDrawCall(): void;
  31025. /**
  31026. * Initializes a webVR display and starts listening to display change events
  31027. * The onVRDisplayChangedObservable will be notified upon these changes
  31028. * @returns The onVRDisplayChangedObservable
  31029. */
  31030. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31031. /** @hidden */ private _prepareVRComponent(): void;
  31032. /** @hidden */ private _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31033. /** @hidden */ private _submitVRFrame(): void;
  31034. /**
  31035. * Call this function to leave webVR mode
  31036. * Will do nothing if webVR is not supported or if there is no webVR device
  31037. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31038. */
  31039. disableVR(): void;
  31040. /**
  31041. * Gets a boolean indicating that the system is in VR mode and is presenting
  31042. * @returns true if VR mode is engaged
  31043. */
  31044. isVRPresenting(): boolean;
  31045. /** @hidden */ private _requestVRFrame(): void;
  31046. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31047. /**
  31048. * Gets the source code of the vertex shader associated with a specific webGL program
  31049. * @param program defines the program to use
  31050. * @returns a string containing the source code of the vertex shader associated with the program
  31051. */
  31052. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31053. /**
  31054. * Gets the source code of the fragment shader associated with a specific webGL program
  31055. * @param program defines the program to use
  31056. * @returns a string containing the source code of the fragment shader associated with the program
  31057. */
  31058. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31059. /**
  31060. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31061. * @param x defines the x coordinate of the rectangle where pixels must be read
  31062. * @param y defines the y coordinate of the rectangle where pixels must be read
  31063. * @param width defines the width of the rectangle where pixels must be read
  31064. * @param height defines the height of the rectangle where pixels must be read
  31065. * @returns a Uint8Array containing RGBA colors
  31066. */
  31067. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31068. /**
  31069. * Sets a depth stencil texture from a render target to the according uniform.
  31070. * @param channel The texture channel
  31071. * @param uniform The uniform to set
  31072. * @param texture The render target texture containing the depth stencil texture to apply
  31073. */
  31074. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31075. /**
  31076. * Sets a texture to the webGL context from a postprocess
  31077. * @param channel defines the channel to use
  31078. * @param postProcess defines the source postprocess
  31079. */
  31080. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31081. /**
  31082. * Binds the output of the passed in post process to the texture channel specified
  31083. * @param channel The channel the texture should be bound to
  31084. * @param postProcess The post process which's output should be bound
  31085. */
  31086. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31087. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31088. protected _rebuildBuffers(): void; private _renderLoop(): void;
  31089. /**
  31090. * Toggle full screen mode
  31091. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31092. */
  31093. switchFullscreen(requestPointerLock: boolean): void;
  31094. /**
  31095. * Enters full screen mode
  31096. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31097. */
  31098. enterFullscreen(requestPointerLock: boolean): void;
  31099. /**
  31100. * Exits full screen mode
  31101. */
  31102. exitFullscreen(): void;
  31103. /**
  31104. * Enters Pointerlock mode
  31105. */
  31106. enterPointerlock(): void;
  31107. /**
  31108. * Exits Pointerlock mode
  31109. */
  31110. exitPointerlock(): void;
  31111. /**
  31112. * Begin a new frame
  31113. */
  31114. beginFrame(): void;
  31115. /**
  31116. * Enf the current frame
  31117. */
  31118. endFrame(): void;
  31119. resize(): void;
  31120. /**
  31121. * Set the compressed texture format to use, based on the formats you have, and the formats
  31122. * supported by the hardware / browser.
  31123. *
  31124. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31125. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31126. * to API arguments needed to compressed textures. This puts the burden on the container
  31127. * generator to house the arcane code for determining these for current & future formats.
  31128. *
  31129. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31130. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31131. *
  31132. * Note: The result of this call is not taken into account when a texture is base64.
  31133. *
  31134. * @param formatsAvailable defines the list of those format families you have created
  31135. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31136. *
  31137. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31138. * @returns The extension selected.
  31139. */
  31140. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31141. /**
  31142. * Force a specific size of the canvas
  31143. * @param width defines the new canvas' width
  31144. * @param height defines the new canvas' height
  31145. */
  31146. setSize(width: number, height: number): void;
  31147. /**
  31148. * Updates a dynamic vertex buffer.
  31149. * @param vertexBuffer the vertex buffer to update
  31150. * @param data the data used to update the vertex buffer
  31151. * @param byteOffset the byte offset of the data
  31152. * @param byteLength the byte length of the data
  31153. */
  31154. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31155. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31156. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram; private _releaseTexture(texture: InternalTexture): void;
  31157. /**
  31158. * @hidden
  31159. * Rescales a texture
  31160. * @param source input texutre
  31161. * @param destination destination texture
  31162. * @param scene scene to use to render the resize
  31163. * @param internalFormat format to use when resizing
  31164. * @param onComplete callback to be called when resize has completed
  31165. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31166. /**
  31167. * Gets the current framerate
  31168. * @returns a number representing the framerate
  31169. */
  31170. getFps(): number;
  31171. /**
  31172. * Gets the time spent between current and previous frame
  31173. * @returns a number representing the delta time in ms
  31174. */
  31175. getDeltaTime(): number;
  31176. private _measureFps;
  31177. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  31178. /**
  31179. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31180. * @param renderTarget The render target to set the frame buffer for
  31181. */
  31182. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31183. /**
  31184. * Update a dynamic index buffer
  31185. * @param indexBuffer defines the target index buffer
  31186. * @param indices defines the data to update
  31187. * @param offset defines the offset in the target index buffer where update should start
  31188. */
  31189. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31190. /**
  31191. * Updates the sample count of a render target texture
  31192. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31193. * @param texture defines the texture to update
  31194. * @param samples defines the sample count to set
  31195. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31196. */
  31197. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31198. /**
  31199. * Updates a depth texture Comparison Mode and Function.
  31200. * If the comparison Function is equal to 0, the mode will be set to none.
  31201. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31202. * @param texture The texture to set the comparison function for
  31203. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31204. */
  31205. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31206. /**
  31207. * Creates a webGL buffer to use with instanciation
  31208. * @param capacity defines the size of the buffer
  31209. * @returns the webGL buffer
  31210. */
  31211. createInstancesBuffer(capacity: number): DataBuffer;
  31212. /**
  31213. * Delete a webGL buffer used with instanciation
  31214. * @param buffer defines the webGL buffer to delete
  31215. */
  31216. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31217. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31218. dispose(): void;
  31219. private _disableTouchAction;
  31220. /**
  31221. * Display the loading screen
  31222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31223. */
  31224. displayLoadingUI(): void;
  31225. /**
  31226. * Hide the loading screen
  31227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31228. */
  31229. hideLoadingUI(): void;
  31230. /**
  31231. * Gets the current loading screen object
  31232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31233. */
  31234. /**
  31235. * Sets the current loading screen object
  31236. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31237. */
  31238. loadingScreen: ILoadingScreen;
  31239. /**
  31240. * Sets the current loading screen text
  31241. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31242. */
  31243. loadingUIText: string;
  31244. /**
  31245. * Sets the current loading screen background color
  31246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31247. */
  31248. loadingUIBackgroundColor: string;
  31249. /** Pointerlock and fullscreen */
  31250. /**
  31251. * Ask the browser to promote the current element to pointerlock mode
  31252. * @param element defines the DOM element to promote
  31253. */ private static _RequestPointerlock(element: HTMLElement): void;
  31254. /**
  31255. * Asks the browser to exit pointerlock mode
  31256. */ private static _ExitPointerlock(): void;
  31257. /**
  31258. * Ask the browser to promote the current element to fullscreen rendering mode
  31259. * @param element defines the DOM element to promote
  31260. */ private static _RequestFullscreen(element: HTMLElement): void;
  31261. /**
  31262. * Asks the browser to exit fullscreen mode
  31263. */ private static _ExitFullscreen(): void;
  31264. }
  31265. }
  31266. declare module BABYLON {
  31267. /**
  31268. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31269. * during the life time of the application.
  31270. */
  31271. export class EngineStore {
  31272. /** Gets the list of created engines */
  31273. static Instances: Engine[];
  31274. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31275. /**
  31276. * Gets the latest created engine
  31277. */
  31278. static readonly LastCreatedEngine: Nullable<Engine>;
  31279. /**
  31280. * Gets the latest created scene
  31281. */
  31282. static readonly LastCreatedScene: Nullable<Scene>;
  31283. /**
  31284. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31285. * @ignorenaming
  31286. */
  31287. static UseFallbackTexture: boolean;
  31288. /**
  31289. * Texture content used if a texture cannot loaded
  31290. * @ignorenaming
  31291. */
  31292. static FallbackTexture: string;
  31293. }
  31294. }
  31295. declare module BABYLON {
  31296. /**
  31297. * Helper class that provides a small promise polyfill
  31298. */
  31299. export class PromisePolyfill {
  31300. /**
  31301. * Static function used to check if the polyfill is required
  31302. * If this is the case then the function will inject the polyfill to window.Promise
  31303. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31304. */
  31305. static Apply(force?: boolean): void;
  31306. }
  31307. }
  31308. declare module BABYLON {
  31309. /**
  31310. * Interface for screenshot methods with describe argument called `size` as object with options
  31311. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31312. */
  31313. export interface IScreenshotSize {
  31314. /**
  31315. * number in pixels for canvas height
  31316. */
  31317. height?: number;
  31318. /**
  31319. * multiplier allowing render at a higher or lower resolution
  31320. * If value is defined then height and width will be ignored and taken from camera
  31321. */
  31322. precision?: number;
  31323. /**
  31324. * number in pixels for canvas width
  31325. */
  31326. width?: number;
  31327. }
  31328. }
  31329. declare module BABYLON {
  31330. interface IColor4Like {
  31331. r: float;
  31332. g: float;
  31333. b: float;
  31334. a: float;
  31335. }
  31336. /**
  31337. * Class containing a set of static utilities functions
  31338. */
  31339. export class Tools {
  31340. /**
  31341. * Gets or sets the base URL to use to load assets
  31342. */
  31343. static BaseUrl: string;
  31344. /**
  31345. * Enable/Disable Custom HTTP Request Headers globally.
  31346. * default = false
  31347. * @see CustomRequestHeaders
  31348. */
  31349. static UseCustomRequestHeaders: boolean;
  31350. /**
  31351. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31352. * i.e. when loading files, where the server/service expects an Authorization header
  31353. */
  31354. static CustomRequestHeaders: {
  31355. [key: string]: string;
  31356. };
  31357. /**
  31358. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31359. */
  31360. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31361. /**
  31362. * Default behaviour for cors in the application.
  31363. * It can be a string if the expected behavior is identical in the entire app.
  31364. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31365. */
  31366. static CorsBehavior: string | ((url: string | string[]) => string);
  31367. /**
  31368. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31369. * @ignorenaming
  31370. */
  31371. static UseFallbackTexture: boolean;
  31372. /**
  31373. * Use this object to register external classes like custom textures or material
  31374. * to allow the laoders to instantiate them
  31375. */
  31376. static RegisteredExternalClasses: {
  31377. [key: string]: Object;
  31378. };
  31379. /**
  31380. * Texture content used if a texture cannot loaded
  31381. * @ignorenaming
  31382. */
  31383. static fallbackTexture: string;
  31384. /**
  31385. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31386. * @param u defines the coordinate on X axis
  31387. * @param v defines the coordinate on Y axis
  31388. * @param width defines the width of the source data
  31389. * @param height defines the height of the source data
  31390. * @param pixels defines the source byte array
  31391. * @param color defines the output color
  31392. */
  31393. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31394. /**
  31395. * Interpolates between a and b via alpha
  31396. * @param a The lower value (returned when alpha = 0)
  31397. * @param b The upper value (returned when alpha = 1)
  31398. * @param alpha The interpolation-factor
  31399. * @return The mixed value
  31400. */
  31401. static Mix(a: number, b: number, alpha: number): number;
  31402. /**
  31403. * Tries to instantiate a new object from a given class name
  31404. * @param className defines the class name to instantiate
  31405. * @returns the new object or null if the system was not able to do the instantiation
  31406. */
  31407. static Instantiate(className: string): any;
  31408. /**
  31409. * Provides a slice function that will work even on IE
  31410. * @param data defines the array to slice
  31411. * @param start defines the start of the data (optional)
  31412. * @param end defines the end of the data (optional)
  31413. * @returns the new sliced array
  31414. */
  31415. static Slice<T>(data: T, start?: number, end?: number): T;
  31416. /**
  31417. * Polyfill for setImmediate
  31418. * @param action defines the action to execute after the current execution block
  31419. */
  31420. static SetImmediate(action: () => void): void;
  31421. /**
  31422. * Function indicating if a number is an exponent of 2
  31423. * @param value defines the value to test
  31424. * @returns true if the value is an exponent of 2
  31425. */
  31426. static IsExponentOfTwo(value: number): boolean;
  31427. private static _tmpFloatArray;
  31428. /**
  31429. * Returns the nearest 32-bit single precision float representation of a Number
  31430. * @param value A Number. If the parameter is of a different type, it will get converted
  31431. * to a number or to NaN if it cannot be converted
  31432. * @returns number
  31433. */
  31434. static FloatRound(value: number): number;
  31435. /**
  31436. * Extracts the filename from a path
  31437. * @param path defines the path to use
  31438. * @returns the filename
  31439. */
  31440. static GetFilename(path: string): string;
  31441. /**
  31442. * Extracts the "folder" part of a path (everything before the filename).
  31443. * @param uri The URI to extract the info from
  31444. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31445. * @returns The "folder" part of the path
  31446. */
  31447. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31448. /**
  31449. * Extracts text content from a DOM element hierarchy
  31450. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31451. */
  31452. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31453. /**
  31454. * Convert an angle in radians to degrees
  31455. * @param angle defines the angle to convert
  31456. * @returns the angle in degrees
  31457. */
  31458. static ToDegrees(angle: number): number;
  31459. /**
  31460. * Convert an angle in degrees to radians
  31461. * @param angle defines the angle to convert
  31462. * @returns the angle in radians
  31463. */
  31464. static ToRadians(angle: number): number;
  31465. /**
  31466. * Returns an array if obj is not an array
  31467. * @param obj defines the object to evaluate as an array
  31468. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31469. * @returns either obj directly if obj is an array or a new array containing obj
  31470. */
  31471. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31472. /**
  31473. * Gets the pointer prefix to use
  31474. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31475. */
  31476. static GetPointerPrefix(): string;
  31477. /**
  31478. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31479. * @param url define the url we are trying
  31480. * @param element define the dom element where to configure the cors policy
  31481. */
  31482. static SetCorsBehavior(url: string | string[], element: {
  31483. crossOrigin: string | null;
  31484. }): void;
  31485. /**
  31486. * Removes unwanted characters from an url
  31487. * @param url defines the url to clean
  31488. * @returns the cleaned url
  31489. */
  31490. static CleanUrl(url: string): string;
  31491. /**
  31492. * Gets or sets a function used to pre-process url before using them to load assets
  31493. */
  31494. static PreprocessUrl: (url: string) => string;
  31495. /**
  31496. * Loads an image as an HTMLImageElement.
  31497. * @param input url string, ArrayBuffer, or Blob to load
  31498. * @param onLoad callback called when the image successfully loads
  31499. * @param onError callback called when the image fails to load
  31500. * @param offlineProvider offline provider for caching
  31501. * @param mimeType optional mime type
  31502. * @returns the HTMLImageElement of the loaded image
  31503. */
  31504. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31505. /**
  31506. * Loads a file from a url
  31507. * @param url url string, ArrayBuffer, or Blob to load
  31508. * @param onSuccess callback called when the file successfully loads
  31509. * @param onProgress callback called while file is loading (if the server supports this mode)
  31510. * @param offlineProvider defines the offline provider for caching
  31511. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31512. * @param onError callback called when the file fails to load
  31513. * @returns a file request object
  31514. */
  31515. 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;
  31516. /**
  31517. * Loads a file from a url
  31518. * @param url the file url to load
  31519. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31520. */
  31521. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31522. /**
  31523. * Load a script (identified by an url). When the url returns, the
  31524. * content of this file is added into a new script element, attached to the DOM (body element)
  31525. * @param scriptUrl defines the url of the script to laod
  31526. * @param onSuccess defines the callback called when the script is loaded
  31527. * @param onError defines the callback to call if an error occurs
  31528. * @param scriptId defines the id of the script element
  31529. */
  31530. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31531. /**
  31532. * Load an asynchronous script (identified by an url). When the url returns, the
  31533. * content of this file is added into a new script element, attached to the DOM (body element)
  31534. * @param scriptUrl defines the url of the script to laod
  31535. * @param scriptId defines the id of the script element
  31536. * @returns a promise request object
  31537. */
  31538. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31539. /**
  31540. * Loads a file from a blob
  31541. * @param fileToLoad defines the blob to use
  31542. * @param callback defines the callback to call when data is loaded
  31543. * @param progressCallback defines the callback to call during loading process
  31544. * @returns a file request object
  31545. */
  31546. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31547. /**
  31548. * Reads a file from a File object
  31549. * @param file defines the file to load
  31550. * @param onSuccess defines the callback to call when data is loaded
  31551. * @param onProgress defines the callback to call during loading process
  31552. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31553. * @param onError defines the callback to call when an error occurs
  31554. * @returns a file request object
  31555. */
  31556. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  31557. /**
  31558. * Creates a data url from a given string content
  31559. * @param content defines the content to convert
  31560. * @returns the new data url link
  31561. */
  31562. static FileAsURL(content: string): string;
  31563. /**
  31564. * Format the given number to a specific decimal format
  31565. * @param value defines the number to format
  31566. * @param decimals defines the number of decimals to use
  31567. * @returns the formatted string
  31568. */
  31569. static Format(value: number, decimals?: number): string;
  31570. /**
  31571. * Tries to copy an object by duplicating every property
  31572. * @param source defines the source object
  31573. * @param destination defines the target object
  31574. * @param doNotCopyList defines a list of properties to avoid
  31575. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31576. */
  31577. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31578. /**
  31579. * Gets a boolean indicating if the given object has no own property
  31580. * @param obj defines the object to test
  31581. * @returns true if object has no own property
  31582. */
  31583. static IsEmpty(obj: any): boolean;
  31584. /**
  31585. * Function used to register events at window level
  31586. * @param windowElement defines the Window object to use
  31587. * @param events defines the events to register
  31588. */
  31589. static RegisterTopRootEvents(windowElement: Window, events: {
  31590. name: string;
  31591. handler: Nullable<(e: FocusEvent) => any>;
  31592. }[]): void;
  31593. /**
  31594. * Function used to unregister events from window level
  31595. * @param windowElement defines the Window object to use
  31596. * @param events defines the events to unregister
  31597. */
  31598. static UnregisterTopRootEvents(windowElement: Window, events: {
  31599. name: string;
  31600. handler: Nullable<(e: FocusEvent) => any>;
  31601. }[]): void;
  31602. /**
  31603. * @ignore
  31604. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31605. /**
  31606. * Dumps the current bound framebuffer
  31607. * @param width defines the rendering width
  31608. * @param height defines the rendering height
  31609. * @param engine defines the hosting engine
  31610. * @param successCallback defines the callback triggered once the data are available
  31611. * @param mimeType defines the mime type of the result
  31612. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31613. */
  31614. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31615. /**
  31616. * Converts the canvas data to blob.
  31617. * This acts as a polyfill for browsers not supporting the to blob function.
  31618. * @param canvas Defines the canvas to extract the data from
  31619. * @param successCallback Defines the callback triggered once the data are available
  31620. * @param mimeType Defines the mime type of the result
  31621. */
  31622. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31623. /**
  31624. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31625. * @param successCallback defines the callback triggered once the data are available
  31626. * @param mimeType defines the mime type of the result
  31627. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31628. */
  31629. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31630. /**
  31631. * Downloads a blob in the browser
  31632. * @param blob defines the blob to download
  31633. * @param fileName defines the name of the downloaded file
  31634. */
  31635. static Download(blob: Blob, fileName: string): void;
  31636. /**
  31637. * Captures a screenshot of the current rendering
  31638. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31639. * @param engine defines the rendering engine
  31640. * @param camera defines the source camera
  31641. * @param size This parameter can be set to a single number or to an object with the
  31642. * following (optional) properties: precision, width, height. If a single number is passed,
  31643. * it will be used for both width and height. If an object is passed, the screenshot size
  31644. * will be derived from the parameters. The precision property is a multiplier allowing
  31645. * rendering at a higher or lower resolution
  31646. * @param successCallback defines the callback receives a single parameter which contains the
  31647. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31648. * src parameter of an <img> to display it
  31649. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31650. * Check your browser for supported MIME types
  31651. */
  31652. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31653. /**
  31654. * Captures a screenshot of the current rendering
  31655. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31656. * @param engine defines the rendering engine
  31657. * @param camera defines the source camera
  31658. * @param size This parameter can be set to a single number or to an object with the
  31659. * following (optional) properties: precision, width, height. If a single number is passed,
  31660. * it will be used for both width and height. If an object is passed, the screenshot size
  31661. * will be derived from the parameters. The precision property is a multiplier allowing
  31662. * rendering at a higher or lower resolution
  31663. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31664. * Check your browser for supported MIME types
  31665. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31666. * to the src parameter of an <img> to display it
  31667. */
  31668. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31669. /**
  31670. * Generates an image screenshot from the specified camera.
  31671. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31672. * @param engine The engine to use for rendering
  31673. * @param camera The camera to use for rendering
  31674. * @param size This parameter can be set to a single number or to an object with the
  31675. * following (optional) properties: precision, width, height. If a single number is passed,
  31676. * it will be used for both width and height. If an object is passed, the screenshot size
  31677. * will be derived from the parameters. The precision property is a multiplier allowing
  31678. * rendering at a higher or lower resolution
  31679. * @param successCallback The callback receives a single parameter which contains the
  31680. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31681. * src parameter of an <img> to display it
  31682. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31683. * Check your browser for supported MIME types
  31684. * @param samples Texture samples (default: 1)
  31685. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31686. * @param fileName A name for for the downloaded file.
  31687. */
  31688. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31689. /**
  31690. * Generates an image screenshot from the specified camera.
  31691. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31692. * @param engine The engine to use for rendering
  31693. * @param camera The camera to use for rendering
  31694. * @param size This parameter can be set to a single number or to an object with the
  31695. * following (optional) properties: precision, width, height. If a single number is passed,
  31696. * it will be used for both width and height. If an object is passed, the screenshot size
  31697. * will be derived from the parameters. The precision property is a multiplier allowing
  31698. * rendering at a higher or lower resolution
  31699. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31700. * Check your browser for supported MIME types
  31701. * @param samples Texture samples (default: 1)
  31702. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31703. * @param fileName A name for for the downloaded file.
  31704. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31705. * to the src parameter of an <img> to display it
  31706. */
  31707. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31708. /**
  31709. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31710. * Be aware Math.random() could cause collisions, but:
  31711. * "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"
  31712. * @returns a pseudo random id
  31713. */
  31714. static RandomId(): string;
  31715. /**
  31716. * Test if the given uri is a base64 string
  31717. * @param uri The uri to test
  31718. * @return True if the uri is a base64 string or false otherwise
  31719. */
  31720. static IsBase64(uri: string): boolean;
  31721. /**
  31722. * Decode the given base64 uri.
  31723. * @param uri The uri to decode
  31724. * @return The decoded base64 data.
  31725. */
  31726. static DecodeBase64(uri: string): ArrayBuffer;
  31727. /**
  31728. * Gets the absolute url.
  31729. * @param url the input url
  31730. * @return the absolute url
  31731. */
  31732. static GetAbsoluteUrl(url: string): string;
  31733. /**
  31734. * No log
  31735. */
  31736. static readonly NoneLogLevel: number;
  31737. /**
  31738. * Only message logs
  31739. */
  31740. static readonly MessageLogLevel: number;
  31741. /**
  31742. * Only warning logs
  31743. */
  31744. static readonly WarningLogLevel: number;
  31745. /**
  31746. * Only error logs
  31747. */
  31748. static readonly ErrorLogLevel: number;
  31749. /**
  31750. * All logs
  31751. */
  31752. static readonly AllLogLevel: number;
  31753. /**
  31754. * Gets a value indicating the number of loading errors
  31755. * @ignorenaming
  31756. */
  31757. static readonly errorsCount: number;
  31758. /**
  31759. * Callback called when a new log is added
  31760. */
  31761. static OnNewCacheEntry: (entry: string) => void;
  31762. /**
  31763. * Log a message to the console
  31764. * @param message defines the message to log
  31765. */
  31766. static Log(message: string): void;
  31767. /**
  31768. * Write a warning message to the console
  31769. * @param message defines the message to log
  31770. */
  31771. static Warn(message: string): void;
  31772. /**
  31773. * Write an error message to the console
  31774. * @param message defines the message to log
  31775. */
  31776. static Error(message: string): void;
  31777. /**
  31778. * Gets current log cache (list of logs)
  31779. */
  31780. static readonly LogCache: string;
  31781. /**
  31782. * Clears the log cache
  31783. */
  31784. static ClearLogCache(): void;
  31785. /**
  31786. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31787. */
  31788. static LogLevels: number;
  31789. /**
  31790. * Checks if the window object exists
  31791. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31792. */
  31793. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31794. /**
  31795. * No performance log
  31796. */
  31797. static readonly PerformanceNoneLogLevel: number;
  31798. /**
  31799. * Use user marks to log performance
  31800. */
  31801. static readonly PerformanceUserMarkLogLevel: number;
  31802. /**
  31803. * Log performance to the console
  31804. */
  31805. static readonly PerformanceConsoleLogLevel: number;
  31806. private static _performance;
  31807. /**
  31808. * Sets the current performance log level
  31809. */
  31810. static PerformanceLogLevel: number;
  31811. private static _StartPerformanceCounterDisabled;
  31812. private static _EndPerformanceCounterDisabled;
  31813. private static _StartUserMark;
  31814. private static _EndUserMark;
  31815. private static _StartPerformanceConsole;
  31816. private static _EndPerformanceConsole;
  31817. /**
  31818. * Starts a performance counter
  31819. */
  31820. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31821. /**
  31822. * Ends a specific performance coutner
  31823. */
  31824. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31825. /**
  31826. * Gets either window.performance.now() if supported or Date.now() else
  31827. */
  31828. static readonly Now: number;
  31829. /**
  31830. * This method will return the name of the class used to create the instance of the given object.
  31831. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31832. * @param object the object to get the class name from
  31833. * @param isType defines if the object is actually a type
  31834. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31835. */
  31836. static GetClassName(object: any, isType?: boolean): string;
  31837. /**
  31838. * Gets the first element of an array satisfying a given predicate
  31839. * @param array defines the array to browse
  31840. * @param predicate defines the predicate to use
  31841. * @returns null if not found or the element
  31842. */
  31843. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31844. /**
  31845. * This method will return the name of the full name of the class, including its owning module (if any).
  31846. * 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).
  31847. * @param object the object to get the class name from
  31848. * @param isType defines if the object is actually a type
  31849. * @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.
  31850. * @ignorenaming
  31851. */
  31852. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31853. /**
  31854. * Returns a promise that resolves after the given amount of time.
  31855. * @param delay Number of milliseconds to delay
  31856. * @returns Promise that resolves after the given amount of time
  31857. */
  31858. static DelayAsync(delay: number): Promise<void>;
  31859. }
  31860. /**
  31861. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31862. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31863. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31864. * @param name The name of the class, case should be preserved
  31865. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31866. */
  31867. export function className(name: string, module?: string): (target: Object) => void;
  31868. /**
  31869. * An implementation of a loop for asynchronous functions.
  31870. */
  31871. export class AsyncLoop {
  31872. /**
  31873. * Defines the number of iterations for the loop
  31874. */
  31875. iterations: number;
  31876. /**
  31877. * Defines the current index of the loop.
  31878. */
  31879. index: number;
  31880. private _done;
  31881. private _fn;
  31882. private _successCallback;
  31883. /**
  31884. * Constructor.
  31885. * @param iterations the number of iterations.
  31886. * @param func the function to run each iteration
  31887. * @param successCallback the callback that will be called upon succesful execution
  31888. * @param offset starting offset.
  31889. */
  31890. constructor(
  31891. /**
  31892. * Defines the number of iterations for the loop
  31893. */
  31894. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31895. /**
  31896. * Execute the next iteration. Must be called after the last iteration was finished.
  31897. */
  31898. executeNext(): void;
  31899. /**
  31900. * Break the loop and run the success callback.
  31901. */
  31902. breakLoop(): void;
  31903. /**
  31904. * Create and run an async loop.
  31905. * @param iterations the number of iterations.
  31906. * @param fn the function to run each iteration
  31907. * @param successCallback the callback that will be called upon succesful execution
  31908. * @param offset starting offset.
  31909. * @returns the created async loop object
  31910. */
  31911. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31912. /**
  31913. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31914. * @param iterations total number of iterations
  31915. * @param syncedIterations number of synchronous iterations in each async iteration.
  31916. * @param fn the function to call each iteration.
  31917. * @param callback a success call back that will be called when iterating stops.
  31918. * @param breakFunction a break condition (optional)
  31919. * @param timeout timeout settings for the setTimeout function. default - 0.
  31920. * @returns the created async loop object
  31921. */
  31922. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31923. }
  31924. }
  31925. declare module BABYLON {
  31926. /**
  31927. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31928. * The underlying implementation relies on an associative array to ensure the best performances.
  31929. * The value can be anything including 'null' but except 'undefined'
  31930. */
  31931. export class StringDictionary<T> {
  31932. /**
  31933. * This will clear this dictionary and copy the content from the 'source' one.
  31934. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31935. * @param source the dictionary to take the content from and copy to this dictionary
  31936. */
  31937. copyFrom(source: StringDictionary<T>): void;
  31938. /**
  31939. * Get a value based from its key
  31940. * @param key the given key to get the matching value from
  31941. * @return the value if found, otherwise undefined is returned
  31942. */
  31943. get(key: string): T | undefined;
  31944. /**
  31945. * Get a value from its key or add it if it doesn't exist.
  31946. * This method will ensure you that a given key/data will be present in the dictionary.
  31947. * @param key the given key to get the matching value from
  31948. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31949. * The factory will only be invoked if there's no data for the given key.
  31950. * @return the value corresponding to the key.
  31951. */
  31952. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31953. /**
  31954. * Get a value from its key if present in the dictionary otherwise add it
  31955. * @param key the key to get the value from
  31956. * @param val if there's no such key/value pair in the dictionary add it with this value
  31957. * @return the value corresponding to the key
  31958. */
  31959. getOrAdd(key: string, val: T): T;
  31960. /**
  31961. * Check if there's a given key in the dictionary
  31962. * @param key the key to check for
  31963. * @return true if the key is present, false otherwise
  31964. */
  31965. contains(key: string): boolean;
  31966. /**
  31967. * Add a new key and its corresponding value
  31968. * @param key the key to add
  31969. * @param value the value corresponding to the key
  31970. * @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
  31971. */
  31972. add(key: string, value: T): boolean;
  31973. /**
  31974. * Update a specific value associated to a key
  31975. * @param key defines the key to use
  31976. * @param value defines the value to store
  31977. * @returns true if the value was updated (or false if the key was not found)
  31978. */
  31979. set(key: string, value: T): boolean;
  31980. /**
  31981. * Get the element of the given key and remove it from the dictionary
  31982. * @param key defines the key to search
  31983. * @returns the value associated with the key or null if not found
  31984. */
  31985. getAndRemove(key: string): Nullable<T>;
  31986. /**
  31987. * Remove a key/value from the dictionary.
  31988. * @param key the key to remove
  31989. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31990. */
  31991. remove(key: string): boolean;
  31992. /**
  31993. * Clear the whole content of the dictionary
  31994. */
  31995. clear(): void;
  31996. /**
  31997. * Gets the current count
  31998. */
  31999. readonly count: number;
  32000. /**
  32001. * Execute a callback on each key/val of the dictionary.
  32002. * Note that you can remove any element in this dictionary in the callback implementation
  32003. * @param callback the callback to execute on a given key/value pair
  32004. */
  32005. forEach(callback: (key: string, val: T) => void): void;
  32006. /**
  32007. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32008. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32009. * Note that you can remove any element in this dictionary in the callback implementation
  32010. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32011. * @returns the first item
  32012. */
  32013. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32014. private _count;
  32015. private _data;
  32016. }
  32017. }
  32018. declare module BABYLON {
  32019. /** @hidden */
  32020. export interface ICollisionCoordinator {
  32021. createCollider(): Collider;
  32022. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32023. init(scene: Scene): void;
  32024. }
  32025. /** @hidden */
  32026. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32027. private _scene;
  32028. private _scaledPosition;
  32029. private _scaledVelocity;
  32030. private _finalPosition;
  32031. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32032. createCollider(): Collider;
  32033. init(scene: Scene): void;
  32034. private _collideWithWorld;
  32035. }
  32036. }
  32037. declare module BABYLON {
  32038. /**
  32039. * Class used to manage all inputs for the scene.
  32040. */
  32041. export class InputManager {
  32042. /** The distance in pixel that you have to move to prevent some events */
  32043. static DragMovementThreshold: number;
  32044. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32045. static LongPressDelay: number;
  32046. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32047. static DoubleClickDelay: number;
  32048. /** If you need to check double click without raising a single click at first click, enable this flag */
  32049. static ExclusiveDoubleClickMode: boolean;
  32050. private _wheelEventName;
  32051. private _onPointerMove;
  32052. private _onPointerDown;
  32053. private _onPointerUp;
  32054. private _initClickEvent;
  32055. private _initActionManager;
  32056. private _delayedSimpleClick;
  32057. private _delayedSimpleClickTimeout;
  32058. private _previousDelayedSimpleClickTimeout;
  32059. private _meshPickProceed;
  32060. private _previousButtonPressed;
  32061. private _currentPickResult;
  32062. private _previousPickResult;
  32063. private _totalPointersPressed;
  32064. private _doubleClickOccured;
  32065. private _pointerOverMesh;
  32066. private _pickedDownMesh;
  32067. private _pickedUpMesh;
  32068. private _pointerX;
  32069. private _pointerY;
  32070. private _unTranslatedPointerX;
  32071. private _unTranslatedPointerY;
  32072. private _startingPointerPosition;
  32073. private _previousStartingPointerPosition;
  32074. private _startingPointerTime;
  32075. private _previousStartingPointerTime;
  32076. private _pointerCaptures;
  32077. private _onKeyDown;
  32078. private _onKeyUp;
  32079. private _onCanvasFocusObserver;
  32080. private _onCanvasBlurObserver;
  32081. private _scene;
  32082. /**
  32083. * Creates a new InputManager
  32084. * @param scene defines the hosting scene
  32085. */
  32086. constructor(scene: Scene);
  32087. /**
  32088. * Gets the mesh that is currently under the pointer
  32089. */
  32090. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32091. /**
  32092. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32093. */
  32094. readonly unTranslatedPointer: Vector2;
  32095. /**
  32096. * Gets or sets the current on-screen X position of the pointer
  32097. */
  32098. pointerX: number;
  32099. /**
  32100. * Gets or sets the current on-screen Y position of the pointer
  32101. */
  32102. pointerY: number;
  32103. private _updatePointerPosition;
  32104. private _processPointerMove;
  32105. private _setRayOnPointerInfo;
  32106. private _checkPrePointerObservable;
  32107. /**
  32108. * Use this method to simulate a pointer move on a mesh
  32109. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32110. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32111. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32112. */
  32113. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32114. /**
  32115. * Use this method to simulate a pointer down on a mesh
  32116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32119. */
  32120. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32121. private _processPointerDown;
  32122. /** @hidden */ private _isPointerSwiping(): boolean;
  32123. /**
  32124. * Use this method to simulate a pointer up on a mesh
  32125. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32126. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32127. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32128. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32129. */
  32130. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32131. private _processPointerUp;
  32132. /**
  32133. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32134. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32135. * @returns true if the pointer was captured
  32136. */
  32137. isPointerCaptured(pointerId?: number): boolean;
  32138. /**
  32139. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32140. * @param attachUp defines if you want to attach events to pointerup
  32141. * @param attachDown defines if you want to attach events to pointerdown
  32142. * @param attachMove defines if you want to attach events to pointermove
  32143. */
  32144. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32145. /**
  32146. * Detaches all event handlers
  32147. */
  32148. detachControl(): void;
  32149. /**
  32150. * Force the value of meshUnderPointer
  32151. * @param mesh defines the mesh to use
  32152. */
  32153. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32154. /**
  32155. * Gets the mesh under the pointer
  32156. * @returns a Mesh or null if no mesh is under the pointer
  32157. */
  32158. getPointerOverMesh(): Nullable<AbstractMesh>;
  32159. }
  32160. }
  32161. declare module BABYLON {
  32162. /**
  32163. * Helper class used to generate session unique ID
  32164. */
  32165. export class UniqueIdGenerator {
  32166. private static _UniqueIdCounter;
  32167. /**
  32168. * Gets an unique (relatively to the current scene) Id
  32169. */
  32170. static readonly UniqueId: number;
  32171. }
  32172. }
  32173. declare module BABYLON {
  32174. /**
  32175. * This class defines the direct association between an animation and a target
  32176. */
  32177. export class TargetedAnimation {
  32178. /**
  32179. * Animation to perform
  32180. */
  32181. animation: Animation;
  32182. /**
  32183. * Target to animate
  32184. */
  32185. target: any;
  32186. /**
  32187. * Serialize the object
  32188. * @returns the JSON object representing the current entity
  32189. */
  32190. serialize(): any;
  32191. }
  32192. /**
  32193. * Use this class to create coordinated animations on multiple targets
  32194. */
  32195. export class AnimationGroup implements IDisposable {
  32196. /** The name of the animation group */
  32197. name: string;
  32198. private _scene;
  32199. private _targetedAnimations;
  32200. private _animatables;
  32201. private _from;
  32202. private _to;
  32203. private _isStarted;
  32204. private _isPaused;
  32205. private _speedRatio;
  32206. private _loopAnimation;
  32207. /**
  32208. * Gets or sets the unique id of the node
  32209. */
  32210. uniqueId: number;
  32211. /**
  32212. * This observable will notify when one animation have ended
  32213. */
  32214. onAnimationEndObservable: Observable<TargetedAnimation>;
  32215. /**
  32216. * Observer raised when one animation loops
  32217. */
  32218. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32219. /**
  32220. * Observer raised when all animations have looped
  32221. */
  32222. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  32223. /**
  32224. * This observable will notify when all animations have ended.
  32225. */
  32226. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32227. /**
  32228. * This observable will notify when all animations have paused.
  32229. */
  32230. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32231. /**
  32232. * This observable will notify when all animations are playing.
  32233. */
  32234. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32235. /**
  32236. * Gets the first frame
  32237. */
  32238. readonly from: number;
  32239. /**
  32240. * Gets the last frame
  32241. */
  32242. readonly to: number;
  32243. /**
  32244. * Define if the animations are started
  32245. */
  32246. readonly isStarted: boolean;
  32247. /**
  32248. * Gets a value indicating that the current group is playing
  32249. */
  32250. readonly isPlaying: boolean;
  32251. /**
  32252. * Gets or sets the speed ratio to use for all animations
  32253. */
  32254. /**
  32255. * Gets or sets the speed ratio to use for all animations
  32256. */
  32257. speedRatio: number;
  32258. /**
  32259. * Gets or sets if all animations should loop or not
  32260. */
  32261. loopAnimation: boolean;
  32262. /**
  32263. * Gets the targeted animations for this animation group
  32264. */
  32265. readonly targetedAnimations: Array<TargetedAnimation>;
  32266. /**
  32267. * returning the list of animatables controlled by this animation group.
  32268. */
  32269. readonly animatables: Array<Animatable>;
  32270. /**
  32271. * Instantiates a new Animation Group.
  32272. * This helps managing several animations at once.
  32273. * @see http://doc.babylonjs.com/how_to/group
  32274. * @param name Defines the name of the group
  32275. * @param scene Defines the scene the group belongs to
  32276. */
  32277. constructor(
  32278. /** The name of the animation group */
  32279. name: string, scene?: Nullable<Scene>);
  32280. /**
  32281. * Add an animation (with its target) in the group
  32282. * @param animation defines the animation we want to add
  32283. * @param target defines the target of the animation
  32284. * @returns the TargetedAnimation object
  32285. */
  32286. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32287. /**
  32288. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32289. * It can add constant keys at begin or end
  32290. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32291. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32292. * @returns the animation group
  32293. */
  32294. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32295. private _animationLoopCount;
  32296. private _animationLoopFlags;
  32297. private _processLoop;
  32298. /**
  32299. * Start all animations on given targets
  32300. * @param loop defines if animations must loop
  32301. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32302. * @param from defines the from key (optional)
  32303. * @param to defines the to key (optional)
  32304. * @returns the current animation group
  32305. */
  32306. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32307. /**
  32308. * Pause all animations
  32309. * @returns the animation group
  32310. */
  32311. pause(): AnimationGroup;
  32312. /**
  32313. * Play all animations to initial state
  32314. * This function will start() the animations if they were not started or will restart() them if they were paused
  32315. * @param loop defines if animations must loop
  32316. * @returns the animation group
  32317. */
  32318. play(loop?: boolean): AnimationGroup;
  32319. /**
  32320. * Reset all animations to initial state
  32321. * @returns the animation group
  32322. */
  32323. reset(): AnimationGroup;
  32324. /**
  32325. * Restart animations from key 0
  32326. * @returns the animation group
  32327. */
  32328. restart(): AnimationGroup;
  32329. /**
  32330. * Stop all animations
  32331. * @returns the animation group
  32332. */
  32333. stop(): AnimationGroup;
  32334. /**
  32335. * Set animation weight for all animatables
  32336. * @param weight defines the weight to use
  32337. * @return the animationGroup
  32338. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32339. */
  32340. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32341. /**
  32342. * Synchronize and normalize all animatables with a source animatable
  32343. * @param root defines the root animatable to synchronize with
  32344. * @return the animationGroup
  32345. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32346. */
  32347. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32348. /**
  32349. * Goes to a specific frame in this animation group
  32350. * @param frame the frame number to go to
  32351. * @return the animationGroup
  32352. */
  32353. goToFrame(frame: number): AnimationGroup;
  32354. /**
  32355. * Dispose all associated resources
  32356. */
  32357. dispose(): void;
  32358. private _checkAnimationGroupEnded;
  32359. /**
  32360. * Clone the current animation group and returns a copy
  32361. * @param newName defines the name of the new group
  32362. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32363. * @returns the new aniamtion group
  32364. */
  32365. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32366. /**
  32367. * Serializes the animationGroup to an object
  32368. * @returns Serialized object
  32369. */
  32370. serialize(): any;
  32371. /**
  32372. * Returns a new AnimationGroup object parsed from the source provided.
  32373. * @param parsedAnimationGroup defines the source
  32374. * @param scene defines the scene that will receive the animationGroup
  32375. * @returns a new AnimationGroup
  32376. */
  32377. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32378. /**
  32379. * Returns the string "AnimationGroup"
  32380. * @returns "AnimationGroup"
  32381. */
  32382. getClassName(): string;
  32383. /**
  32384. * Creates a detailled string about the object
  32385. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32386. * @returns a string representing the object
  32387. */
  32388. toString(fullDetails?: boolean): string;
  32389. }
  32390. }
  32391. declare module BABYLON {
  32392. /**
  32393. * Define an interface for all classes that will hold resources
  32394. */
  32395. export interface IDisposable {
  32396. /**
  32397. * Releases all held resources
  32398. */
  32399. dispose(): void;
  32400. }
  32401. /** Interface defining initialization parameters for Scene class */
  32402. export interface SceneOptions {
  32403. /**
  32404. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32405. * It will improve performance when the number of geometries becomes important.
  32406. */
  32407. useGeometryUniqueIdsMap?: boolean;
  32408. /**
  32409. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32410. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32411. */
  32412. useMaterialMeshMap?: boolean;
  32413. /**
  32414. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32415. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32416. */
  32417. useClonedMeshhMap?: boolean;
  32418. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32419. virtual?: boolean;
  32420. }
  32421. /**
  32422. * Represents a scene to be rendered by the engine.
  32423. * @see http://doc.babylonjs.com/features/scene
  32424. */
  32425. export class Scene extends AbstractScene implements IAnimatable {
  32426. /** The fog is deactivated */
  32427. static readonly FOGMODE_NONE: number;
  32428. /** The fog density is following an exponential function */
  32429. static readonly FOGMODE_EXP: number;
  32430. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32431. static readonly FOGMODE_EXP2: number;
  32432. /** The fog density is following a linear function. */
  32433. static readonly FOGMODE_LINEAR: number;
  32434. /**
  32435. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32436. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32437. */
  32438. static MinDeltaTime: number;
  32439. /**
  32440. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32442. */
  32443. static MaxDeltaTime: number;
  32444. /**
  32445. * Factory used to create the default material.
  32446. * @param name The name of the material to create
  32447. * @param scene The scene to create the material for
  32448. * @returns The default material
  32449. */
  32450. static DefaultMaterialFactory(scene: Scene): Material;
  32451. /**
  32452. * Factory used to create the a collision coordinator.
  32453. * @returns The collision coordinator
  32454. */
  32455. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32456. /** @hidden */ private _inputManager: InputManager;
  32457. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32458. cameraToUseForPointers: Nullable<Camera>;
  32459. /** @hidden */ protected readonly _isScene: boolean;
  32460. /**
  32461. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32462. */
  32463. autoClear: boolean;
  32464. /**
  32465. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32466. */
  32467. autoClearDepthAndStencil: boolean;
  32468. /**
  32469. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32470. */
  32471. clearColor: Color4;
  32472. /**
  32473. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32474. */
  32475. ambientColor: Color3;
  32476. /**
  32477. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32478. * It should only be one of the following (if not the default embedded one):
  32479. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32480. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32481. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32482. * The material properties need to be setup according to the type of texture in use.
  32483. */
  32484. environmentBRDFTexture: BaseTexture;
  32485. /** @hidden */
  32486. protected _environmentTexture: Nullable<BaseTexture>;
  32487. /**
  32488. * Texture used in all pbr material as the reflection texture.
  32489. * As in the majority of the scene they are the same (exception for multi room and so on),
  32490. * this is easier to reference from here than from all the materials.
  32491. */
  32492. /**
  32493. * Texture used in all pbr material as the reflection texture.
  32494. * As in the majority of the scene they are the same (exception for multi room and so on),
  32495. * this is easier to set here than in all the materials.
  32496. */
  32497. environmentTexture: Nullable<BaseTexture>;
  32498. /** @hidden */
  32499. protected _environmentIntensity: number;
  32500. /**
  32501. * Intensity of the environment in all pbr material.
  32502. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32503. * As in the majority of the scene they are the same (exception for multi room and so on),
  32504. * this is easier to reference from here than from all the materials.
  32505. */
  32506. /**
  32507. * Intensity of the environment in all pbr material.
  32508. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32509. * As in the majority of the scene they are the same (exception for multi room and so on),
  32510. * this is easier to set here than in all the materials.
  32511. */
  32512. environmentIntensity: number;
  32513. /** @hidden */
  32514. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32515. /**
  32516. * Default image processing configuration used either in the rendering
  32517. * Forward main pass or through the imageProcessingPostProcess if present.
  32518. * As in the majority of the scene they are the same (exception for multi camera),
  32519. * this is easier to reference from here than from all the materials and post process.
  32520. *
  32521. * No setter as we it is a shared configuration, you can set the values instead.
  32522. */
  32523. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32524. private _forceWireframe;
  32525. /**
  32526. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32527. */
  32528. forceWireframe: boolean;
  32529. private _forcePointsCloud;
  32530. /**
  32531. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32532. */
  32533. forcePointsCloud: boolean;
  32534. /**
  32535. * Gets or sets the active clipplane 1
  32536. */
  32537. clipPlane: Nullable<Plane>;
  32538. /**
  32539. * Gets or sets the active clipplane 2
  32540. */
  32541. clipPlane2: Nullable<Plane>;
  32542. /**
  32543. * Gets or sets the active clipplane 3
  32544. */
  32545. clipPlane3: Nullable<Plane>;
  32546. /**
  32547. * Gets or sets the active clipplane 4
  32548. */
  32549. clipPlane4: Nullable<Plane>;
  32550. /**
  32551. * Gets or sets a boolean indicating if animations are enabled
  32552. */
  32553. animationsEnabled: boolean;
  32554. private _animationPropertiesOverride;
  32555. /**
  32556. * Gets or sets the animation properties override
  32557. */
  32558. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32559. /**
  32560. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32561. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32562. */
  32563. useConstantAnimationDeltaTime: boolean;
  32564. /**
  32565. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32566. * Please note that it requires to run a ray cast through the scene on every frame
  32567. */
  32568. constantlyUpdateMeshUnderPointer: boolean;
  32569. /**
  32570. * Defines the HTML cursor to use when hovering over interactive elements
  32571. */
  32572. hoverCursor: string;
  32573. /**
  32574. * Defines the HTML default cursor to use (empty by default)
  32575. */
  32576. defaultCursor: string;
  32577. /**
  32578. * Defines wether cursors are handled by the scene.
  32579. */
  32580. doNotHandleCursors: boolean;
  32581. /**
  32582. * This is used to call preventDefault() on pointer down
  32583. * in order to block unwanted artifacts like system double clicks
  32584. */
  32585. preventDefaultOnPointerDown: boolean;
  32586. /**
  32587. * This is used to call preventDefault() on pointer up
  32588. * in order to block unwanted artifacts like system double clicks
  32589. */
  32590. preventDefaultOnPointerUp: boolean;
  32591. /**
  32592. * Gets or sets user defined metadata
  32593. */
  32594. metadata: any;
  32595. /**
  32596. * For internal use only. Please do not use.
  32597. */
  32598. reservedDataStore: any;
  32599. /**
  32600. * Gets the name of the plugin used to load this scene (null by default)
  32601. */
  32602. loadingPluginName: string;
  32603. /**
  32604. * Use this array to add regular expressions used to disable offline support for specific urls
  32605. */
  32606. disableOfflineSupportExceptionRules: RegExp[];
  32607. /**
  32608. * An event triggered when the scene is disposed.
  32609. */
  32610. onDisposeObservable: Observable<Scene>;
  32611. private _onDisposeObserver;
  32612. /** Sets a function to be executed when this scene is disposed. */
  32613. onDispose: () => void;
  32614. /**
  32615. * An event triggered before rendering the scene (right after animations and physics)
  32616. */
  32617. onBeforeRenderObservable: Observable<Scene>;
  32618. private _onBeforeRenderObserver;
  32619. /** Sets a function to be executed before rendering this scene */
  32620. beforeRender: Nullable<() => void>;
  32621. /**
  32622. * An event triggered after rendering the scene
  32623. */
  32624. onAfterRenderObservable: Observable<Scene>;
  32625. /**
  32626. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32627. */
  32628. onAfterRenderCameraObservable: Observable<Camera>;
  32629. private _onAfterRenderObserver;
  32630. /** Sets a function to be executed after rendering this scene */
  32631. afterRender: Nullable<() => void>;
  32632. /**
  32633. * An event triggered before animating the scene
  32634. */
  32635. onBeforeAnimationsObservable: Observable<Scene>;
  32636. /**
  32637. * An event triggered after animations processing
  32638. */
  32639. onAfterAnimationsObservable: Observable<Scene>;
  32640. /**
  32641. * An event triggered before draw calls are ready to be sent
  32642. */
  32643. onBeforeDrawPhaseObservable: Observable<Scene>;
  32644. /**
  32645. * An event triggered after draw calls have been sent
  32646. */
  32647. onAfterDrawPhaseObservable: Observable<Scene>;
  32648. /**
  32649. * An event triggered when the scene is ready
  32650. */
  32651. onReadyObservable: Observable<Scene>;
  32652. /**
  32653. * An event triggered before rendering a camera
  32654. */
  32655. onBeforeCameraRenderObservable: Observable<Camera>;
  32656. private _onBeforeCameraRenderObserver;
  32657. /** Sets a function to be executed before rendering a camera*/
  32658. beforeCameraRender: () => void;
  32659. /**
  32660. * An event triggered after rendering a camera
  32661. */
  32662. onAfterCameraRenderObservable: Observable<Camera>;
  32663. private _onAfterCameraRenderObserver;
  32664. /** Sets a function to be executed after rendering a camera*/
  32665. afterCameraRender: () => void;
  32666. /**
  32667. * An event triggered when active meshes evaluation is about to start
  32668. */
  32669. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32670. /**
  32671. * An event triggered when active meshes evaluation is done
  32672. */
  32673. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32674. /**
  32675. * An event triggered when particles rendering is about to start
  32676. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32677. */
  32678. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32679. /**
  32680. * An event triggered when particles rendering is done
  32681. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32682. */
  32683. onAfterParticlesRenderingObservable: Observable<Scene>;
  32684. /**
  32685. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32686. */
  32687. onDataLoadedObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered when a camera is created
  32690. */
  32691. onNewCameraAddedObservable: Observable<Camera>;
  32692. /**
  32693. * An event triggered when a camera is removed
  32694. */
  32695. onCameraRemovedObservable: Observable<Camera>;
  32696. /**
  32697. * An event triggered when a light is created
  32698. */
  32699. onNewLightAddedObservable: Observable<Light>;
  32700. /**
  32701. * An event triggered when a light is removed
  32702. */
  32703. onLightRemovedObservable: Observable<Light>;
  32704. /**
  32705. * An event triggered when a geometry is created
  32706. */
  32707. onNewGeometryAddedObservable: Observable<Geometry>;
  32708. /**
  32709. * An event triggered when a geometry is removed
  32710. */
  32711. onGeometryRemovedObservable: Observable<Geometry>;
  32712. /**
  32713. * An event triggered when a transform node is created
  32714. */
  32715. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32716. /**
  32717. * An event triggered when a transform node is removed
  32718. */
  32719. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32720. /**
  32721. * An event triggered when a mesh is created
  32722. */
  32723. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32724. /**
  32725. * An event triggered when a mesh is removed
  32726. */
  32727. onMeshRemovedObservable: Observable<AbstractMesh>;
  32728. /**
  32729. * An event triggered when a skeleton is created
  32730. */
  32731. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32732. /**
  32733. * An event triggered when a skeleton is removed
  32734. */
  32735. onSkeletonRemovedObservable: Observable<Skeleton>;
  32736. /**
  32737. * An event triggered when a material is created
  32738. */
  32739. onNewMaterialAddedObservable: Observable<Material>;
  32740. /**
  32741. * An event triggered when a material is removed
  32742. */
  32743. onMaterialRemovedObservable: Observable<Material>;
  32744. /**
  32745. * An event triggered when a texture is created
  32746. */
  32747. onNewTextureAddedObservable: Observable<BaseTexture>;
  32748. /**
  32749. * An event triggered when a texture is removed
  32750. */
  32751. onTextureRemovedObservable: Observable<BaseTexture>;
  32752. /**
  32753. * An event triggered when render targets are about to be rendered
  32754. * Can happen multiple times per frame.
  32755. */
  32756. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32757. /**
  32758. * An event triggered when render targets were rendered.
  32759. * Can happen multiple times per frame.
  32760. */
  32761. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32762. /**
  32763. * An event triggered before calculating deterministic simulation step
  32764. */
  32765. onBeforeStepObservable: Observable<Scene>;
  32766. /**
  32767. * An event triggered after calculating deterministic simulation step
  32768. */
  32769. onAfterStepObservable: Observable<Scene>;
  32770. /**
  32771. * An event triggered when the activeCamera property is updated
  32772. */
  32773. onActiveCameraChanged: Observable<Scene>;
  32774. /**
  32775. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32776. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32777. * 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)
  32778. */
  32779. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32780. /**
  32781. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32782. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32783. * 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)
  32784. */
  32785. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32786. /**
  32787. * This Observable will when a mesh has been imported into the scene.
  32788. */
  32789. onMeshImportedObservable: Observable<AbstractMesh>;
  32790. /**
  32791. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32792. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32793. */
  32794. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32795. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32796. /**
  32797. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32798. */
  32799. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32800. /**
  32801. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32802. */
  32803. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32804. /**
  32805. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32806. */
  32807. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32808. /** Callback called when a pointer move is detected */
  32809. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32810. /** Callback called when a pointer down is detected */
  32811. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32812. /** Callback called when a pointer up is detected */
  32813. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32814. /** Callback called when a pointer pick is detected */
  32815. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32816. /**
  32817. * 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).
  32818. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32819. */
  32820. onPrePointerObservable: Observable<PointerInfoPre>;
  32821. /**
  32822. * Observable event triggered each time an input event is received from the rendering canvas
  32823. */
  32824. onPointerObservable: Observable<PointerInfo>;
  32825. /**
  32826. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32827. */
  32828. readonly unTranslatedPointer: Vector2;
  32829. /**
  32830. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32831. */
  32832. static DragMovementThreshold: number;
  32833. /**
  32834. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32835. */
  32836. static LongPressDelay: number;
  32837. /**
  32838. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32839. */
  32840. static DoubleClickDelay: number;
  32841. /** If you need to check double click without raising a single click at first click, enable this flag */
  32842. static ExclusiveDoubleClickMode: boolean;
  32843. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32844. /**
  32845. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32846. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32847. */
  32848. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32849. /**
  32850. * Observable event triggered each time an keyboard event is received from the hosting window
  32851. */
  32852. onKeyboardObservable: Observable<KeyboardInfo>;
  32853. private _useRightHandedSystem;
  32854. /**
  32855. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32856. */
  32857. useRightHandedSystem: boolean;
  32858. private _timeAccumulator;
  32859. private _currentStepId;
  32860. private _currentInternalStep;
  32861. /**
  32862. * Sets the step Id used by deterministic lock step
  32863. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32864. * @param newStepId defines the step Id
  32865. */
  32866. setStepId(newStepId: number): void;
  32867. /**
  32868. * Gets the step Id used by deterministic lock step
  32869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32870. * @returns the step Id
  32871. */
  32872. getStepId(): number;
  32873. /**
  32874. * Gets the internal step used by deterministic lock step
  32875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32876. * @returns the internal step
  32877. */
  32878. getInternalStep(): number;
  32879. private _fogEnabled;
  32880. /**
  32881. * Gets or sets a boolean indicating if fog is enabled on this scene
  32882. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32883. * (Default is true)
  32884. */
  32885. fogEnabled: boolean;
  32886. private _fogMode;
  32887. /**
  32888. * Gets or sets the fog mode to use
  32889. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32890. * | mode | value |
  32891. * | --- | --- |
  32892. * | FOGMODE_NONE | 0 |
  32893. * | FOGMODE_EXP | 1 |
  32894. * | FOGMODE_EXP2 | 2 |
  32895. * | FOGMODE_LINEAR | 3 |
  32896. */
  32897. fogMode: number;
  32898. /**
  32899. * Gets or sets the fog color to use
  32900. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32901. * (Default is Color3(0.2, 0.2, 0.3))
  32902. */
  32903. fogColor: Color3;
  32904. /**
  32905. * Gets or sets the fog density to use
  32906. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32907. * (Default is 0.1)
  32908. */
  32909. fogDensity: number;
  32910. /**
  32911. * Gets or sets the fog start distance to use
  32912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32913. * (Default is 0)
  32914. */
  32915. fogStart: number;
  32916. /**
  32917. * Gets or sets the fog end distance to use
  32918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32919. * (Default is 1000)
  32920. */
  32921. fogEnd: number;
  32922. private _shadowsEnabled;
  32923. /**
  32924. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32925. */
  32926. shadowsEnabled: boolean;
  32927. private _lightsEnabled;
  32928. /**
  32929. * Gets or sets a boolean indicating if lights are enabled on this scene
  32930. */
  32931. lightsEnabled: boolean;
  32932. /** All of the active cameras added to this scene. */
  32933. activeCameras: Camera[];
  32934. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32935. /** Gets or sets the current active camera */
  32936. activeCamera: Nullable<Camera>;
  32937. private _defaultMaterial;
  32938. /** The default material used on meshes when no material is affected */
  32939. /** The default material used on meshes when no material is affected */
  32940. defaultMaterial: Material;
  32941. private _texturesEnabled;
  32942. /**
  32943. * Gets or sets a boolean indicating if textures are enabled on this scene
  32944. */
  32945. texturesEnabled: boolean;
  32946. /**
  32947. * Gets or sets a boolean indicating if particles are enabled on this scene
  32948. */
  32949. particlesEnabled: boolean;
  32950. /**
  32951. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32952. */
  32953. spritesEnabled: boolean;
  32954. private _skeletonsEnabled;
  32955. /**
  32956. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32957. */
  32958. skeletonsEnabled: boolean;
  32959. /**
  32960. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32961. */
  32962. lensFlaresEnabled: boolean;
  32963. /**
  32964. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32966. */
  32967. collisionsEnabled: boolean;
  32968. private _collisionCoordinator;
  32969. /** @hidden */
  32970. readonly collisionCoordinator: ICollisionCoordinator;
  32971. /**
  32972. * Defines the gravity applied to this scene (used only for collisions)
  32973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32974. */
  32975. gravity: Vector3;
  32976. /**
  32977. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32978. */
  32979. postProcessesEnabled: boolean;
  32980. /**
  32981. * The list of postprocesses added to the scene
  32982. */
  32983. postProcesses: PostProcess[];
  32984. /**
  32985. * Gets the current postprocess manager
  32986. */
  32987. postProcessManager: PostProcessManager;
  32988. /**
  32989. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32990. */
  32991. renderTargetsEnabled: boolean;
  32992. /**
  32993. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32994. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32995. */
  32996. dumpNextRenderTargets: boolean;
  32997. /**
  32998. * The list of user defined render targets added to the scene
  32999. */
  33000. customRenderTargets: RenderTargetTexture[];
  33001. /**
  33002. * Defines if texture loading must be delayed
  33003. * If true, textures will only be loaded when they need to be rendered
  33004. */
  33005. useDelayedTextureLoading: boolean;
  33006. /**
  33007. * Gets the list of meshes imported to the scene through SceneLoader
  33008. */
  33009. importedMeshesFiles: String[];
  33010. /**
  33011. * Gets or sets a boolean indicating if probes are enabled on this scene
  33012. */
  33013. probesEnabled: boolean;
  33014. /**
  33015. * Gets or sets the current offline provider to use to store scene data
  33016. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33017. */
  33018. offlineProvider: IOfflineProvider;
  33019. /**
  33020. * Gets or sets the action manager associated with the scene
  33021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33022. */
  33023. actionManager: AbstractActionManager;
  33024. private _meshesForIntersections;
  33025. /**
  33026. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33027. */
  33028. proceduralTexturesEnabled: boolean;
  33029. private _engine;
  33030. private _totalVertices;
  33031. /** @hidden */ private _activeIndices: PerfCounter;
  33032. /** @hidden */ private _activeParticles: PerfCounter;
  33033. /** @hidden */ private _activeBones: PerfCounter;
  33034. private _animationRatio;
  33035. /** @hidden */ private _animationTimeLast: number;
  33036. /** @hidden */ private _animationTime: number;
  33037. /**
  33038. * Gets or sets a general scale for animation speed
  33039. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33040. */
  33041. animationTimeScale: number;
  33042. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  33043. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  33044. /** @hidden */ private _cachedVisibility: Nullable<number>;
  33045. private _renderId;
  33046. private _frameId;
  33047. private _executeWhenReadyTimeoutId;
  33048. private _intermediateRendering;
  33049. private _viewUpdateFlag;
  33050. private _projectionUpdateFlag;
  33051. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  33052. private _activeRequests;
  33053. /** @hidden */ private _pendingData: any[];
  33054. private _isDisposed;
  33055. /**
  33056. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33057. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33058. */
  33059. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33060. private _activeMeshes;
  33061. private _processedMaterials;
  33062. private _renderTargets;
  33063. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  33064. private _activeSkeletons;
  33065. private _softwareSkinnedMeshes;
  33066. private _renderingManager;
  33067. /** @hidden */ private _activeAnimatables: Animatable[];
  33068. private _transformMatrix;
  33069. private _sceneUbo;
  33070. /** @hidden */ private _viewMatrix: Matrix;
  33071. private _projectionMatrix;
  33072. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  33073. /** @hidden */ private _frustumPlanes: Plane[];
  33074. /**
  33075. * Gets the list of frustum planes (built from the active camera)
  33076. */
  33077. readonly frustumPlanes: Plane[];
  33078. /**
  33079. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33080. * This is useful if there are more lights that the maximum simulteanous authorized
  33081. */
  33082. requireLightSorting: boolean;
  33083. /** @hidden */
  33084. readonly useMaterialMeshMap: boolean;
  33085. /** @hidden */
  33086. readonly useClonedMeshhMap: boolean;
  33087. private _externalData;
  33088. private _uid;
  33089. /**
  33090. * @hidden
  33091. * Backing store of defined scene components.
  33092. */ private _components: ISceneComponent[];
  33093. /**
  33094. * @hidden
  33095. * Backing store of defined scene components.
  33096. */ private _serializableComponents: ISceneSerializableComponent[];
  33097. /**
  33098. * List of components to register on the next registration step.
  33099. */
  33100. private _transientComponents;
  33101. /**
  33102. * Registers the transient components if needed.
  33103. */
  33104. private _registerTransientComponents;
  33105. /**
  33106. * @hidden
  33107. * Add a component to the scene.
  33108. * Note that the ccomponent could be registered on th next frame if this is called after
  33109. * the register component stage.
  33110. * @param component Defines the component to add to the scene
  33111. */ private _addComponent(component: ISceneComponent): void;
  33112. /**
  33113. * @hidden
  33114. * Gets a component from the scene.
  33115. * @param name defines the name of the component to retrieve
  33116. * @returns the component or null if not present
  33117. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  33118. /**
  33119. * @hidden
  33120. * Defines the actions happening before camera updates.
  33121. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33122. /**
  33123. * @hidden
  33124. * Defines the actions happening before clear the canvas.
  33125. */ private _beforeClearStage: Stage<SimpleStageAction>;
  33126. /**
  33127. * @hidden
  33128. * Defines the actions when collecting render targets for the frame.
  33129. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33130. /**
  33131. * @hidden
  33132. * Defines the actions happening for one camera in the frame.
  33133. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33134. /**
  33135. * @hidden
  33136. * Defines the actions happening during the per mesh ready checks.
  33137. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  33138. /**
  33139. * @hidden
  33140. * Defines the actions happening before evaluate active mesh checks.
  33141. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33142. /**
  33143. * @hidden
  33144. * Defines the actions happening during the evaluate sub mesh checks.
  33145. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33146. /**
  33147. * @hidden
  33148. * Defines the actions happening during the active mesh stage.
  33149. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  33150. /**
  33151. * @hidden
  33152. * Defines the actions happening during the per camera render target step.
  33153. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33154. /**
  33155. * @hidden
  33156. * Defines the actions happening just before the active camera is drawing.
  33157. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  33158. /**
  33159. * @hidden
  33160. * Defines the actions happening just before a render target is drawing.
  33161. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33162. /**
  33163. * @hidden
  33164. * Defines the actions happening just before a rendering group is drawing.
  33165. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33166. /**
  33167. * @hidden
  33168. * Defines the actions happening just before a mesh is drawing.
  33169. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33170. /**
  33171. * @hidden
  33172. * Defines the actions happening just after a mesh has been drawn.
  33173. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33174. /**
  33175. * @hidden
  33176. * Defines the actions happening just after a rendering group has been drawn.
  33177. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33178. /**
  33179. * @hidden
  33180. * Defines the actions happening just after the active camera has been drawn.
  33181. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  33182. /**
  33183. * @hidden
  33184. * Defines the actions happening just after a render target has been drawn.
  33185. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33186. /**
  33187. * @hidden
  33188. * Defines the actions happening just after rendering all cameras and computing intersections.
  33189. */ private _afterRenderStage: Stage<SimpleStageAction>;
  33190. /**
  33191. * @hidden
  33192. * Defines the actions happening when a pointer move event happens.
  33193. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  33194. /**
  33195. * @hidden
  33196. * Defines the actions happening when a pointer down event happens.
  33197. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  33198. /**
  33199. * @hidden
  33200. * Defines the actions happening when a pointer up event happens.
  33201. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  33202. /**
  33203. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33204. */
  33205. private geometriesByUniqueId;
  33206. /**
  33207. * Creates a new Scene
  33208. * @param engine defines the engine to use to render this scene
  33209. * @param options defines the scene options
  33210. */
  33211. constructor(engine: Engine, options?: SceneOptions);
  33212. /**
  33213. * Gets a string idenfifying the name of the class
  33214. * @returns "Scene" string
  33215. */
  33216. getClassName(): string;
  33217. private _defaultMeshCandidates;
  33218. /**
  33219. * @hidden
  33220. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33221. private _defaultSubMeshCandidates;
  33222. /**
  33223. * @hidden
  33224. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33225. /**
  33226. * Sets the default candidate providers for the scene.
  33227. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33228. * and getCollidingSubMeshCandidates to their default function
  33229. */
  33230. setDefaultCandidateProviders(): void;
  33231. /**
  33232. * Gets the mesh that is currently under the pointer
  33233. */
  33234. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33235. /**
  33236. * Gets or sets the current on-screen X position of the pointer
  33237. */
  33238. pointerX: number;
  33239. /**
  33240. * Gets or sets the current on-screen Y position of the pointer
  33241. */
  33242. pointerY: number;
  33243. /**
  33244. * Gets the cached material (ie. the latest rendered one)
  33245. * @returns the cached material
  33246. */
  33247. getCachedMaterial(): Nullable<Material>;
  33248. /**
  33249. * Gets the cached effect (ie. the latest rendered one)
  33250. * @returns the cached effect
  33251. */
  33252. getCachedEffect(): Nullable<Effect>;
  33253. /**
  33254. * Gets the cached visibility state (ie. the latest rendered one)
  33255. * @returns the cached visibility state
  33256. */
  33257. getCachedVisibility(): Nullable<number>;
  33258. /**
  33259. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33260. * @param material defines the current material
  33261. * @param effect defines the current effect
  33262. * @param visibility defines the current visibility state
  33263. * @returns true if one parameter is not cached
  33264. */
  33265. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33266. /**
  33267. * Gets the engine associated with the scene
  33268. * @returns an Engine
  33269. */
  33270. getEngine(): Engine;
  33271. /**
  33272. * Gets the total number of vertices rendered per frame
  33273. * @returns the total number of vertices rendered per frame
  33274. */
  33275. getTotalVertices(): number;
  33276. /**
  33277. * Gets the performance counter for total vertices
  33278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33279. */
  33280. readonly totalVerticesPerfCounter: PerfCounter;
  33281. /**
  33282. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33283. * @returns the total number of active indices rendered per frame
  33284. */
  33285. getActiveIndices(): number;
  33286. /**
  33287. * Gets the performance counter for active indices
  33288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33289. */
  33290. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33291. /**
  33292. * Gets the total number of active particles rendered per frame
  33293. * @returns the total number of active particles rendered per frame
  33294. */
  33295. getActiveParticles(): number;
  33296. /**
  33297. * Gets the performance counter for active particles
  33298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33299. */
  33300. readonly activeParticlesPerfCounter: PerfCounter;
  33301. /**
  33302. * Gets the total number of active bones rendered per frame
  33303. * @returns the total number of active bones rendered per frame
  33304. */
  33305. getActiveBones(): number;
  33306. /**
  33307. * Gets the performance counter for active bones
  33308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33309. */
  33310. readonly activeBonesPerfCounter: PerfCounter;
  33311. /**
  33312. * Gets the array of active meshes
  33313. * @returns an array of AbstractMesh
  33314. */
  33315. getActiveMeshes(): SmartArray<AbstractMesh>;
  33316. /**
  33317. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33318. * @returns a number
  33319. */
  33320. getAnimationRatio(): number;
  33321. /**
  33322. * Gets an unique Id for the current render phase
  33323. * @returns a number
  33324. */
  33325. getRenderId(): number;
  33326. /**
  33327. * Gets an unique Id for the current frame
  33328. * @returns a number
  33329. */
  33330. getFrameId(): number;
  33331. /** Call this function if you want to manually increment the render Id*/
  33332. incrementRenderId(): void;
  33333. private _createUbo;
  33334. /**
  33335. * Use this method to simulate a pointer move on a mesh
  33336. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33337. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33338. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33339. * @returns the current scene
  33340. */
  33341. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33342. /**
  33343. * Use this method to simulate a pointer down on a mesh
  33344. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33345. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33346. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33347. * @returns the current scene
  33348. */
  33349. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33350. /**
  33351. * Use this method to simulate a pointer up on a mesh
  33352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33355. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33356. * @returns the current scene
  33357. */
  33358. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33359. /**
  33360. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33361. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33362. * @returns true if the pointer was captured
  33363. */
  33364. isPointerCaptured(pointerId?: number): boolean;
  33365. /**
  33366. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33367. * @param attachUp defines if you want to attach events to pointerup
  33368. * @param attachDown defines if you want to attach events to pointerdown
  33369. * @param attachMove defines if you want to attach events to pointermove
  33370. */
  33371. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33372. /** Detaches all event handlers*/
  33373. detachControl(): void;
  33374. /**
  33375. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33376. * Delay loaded resources are not taking in account
  33377. * @return true if all required resources are ready
  33378. */
  33379. isReady(): boolean;
  33380. /** Resets all cached information relative to material (including effect and visibility) */
  33381. resetCachedMaterial(): void;
  33382. /**
  33383. * Registers a function to be called before every frame render
  33384. * @param func defines the function to register
  33385. */
  33386. registerBeforeRender(func: () => void): void;
  33387. /**
  33388. * Unregisters a function called before every frame render
  33389. * @param func defines the function to unregister
  33390. */
  33391. unregisterBeforeRender(func: () => void): void;
  33392. /**
  33393. * Registers a function to be called after every frame render
  33394. * @param func defines the function to register
  33395. */
  33396. registerAfterRender(func: () => void): void;
  33397. /**
  33398. * Unregisters a function called after every frame render
  33399. * @param func defines the function to unregister
  33400. */
  33401. unregisterAfterRender(func: () => void): void;
  33402. private _executeOnceBeforeRender;
  33403. /**
  33404. * The provided function will run before render once and will be disposed afterwards.
  33405. * A timeout delay can be provided so that the function will be executed in N ms.
  33406. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33407. * @param func The function to be executed.
  33408. * @param timeout optional delay in ms
  33409. */
  33410. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33411. /** @hidden */ private _addPendingData(data: any): void;
  33412. /** @hidden */ private _removePendingData(data: any): void;
  33413. /**
  33414. * Returns the number of items waiting to be loaded
  33415. * @returns the number of items waiting to be loaded
  33416. */
  33417. getWaitingItemsCount(): number;
  33418. /**
  33419. * Returns a boolean indicating if the scene is still loading data
  33420. */
  33421. readonly isLoading: boolean;
  33422. /**
  33423. * Registers a function to be executed when the scene is ready
  33424. * @param {Function} func - the function to be executed
  33425. */
  33426. executeWhenReady(func: () => void): void;
  33427. /**
  33428. * Returns a promise that resolves when the scene is ready
  33429. * @returns A promise that resolves when the scene is ready
  33430. */
  33431. whenReadyAsync(): Promise<void>;
  33432. /** @hidden */ private _checkIsReady(): void;
  33433. /**
  33434. * Gets all animatable attached to the scene
  33435. */
  33436. readonly animatables: Animatable[];
  33437. /**
  33438. * Resets the last animation time frame.
  33439. * Useful to override when animations start running when loading a scene for the first time.
  33440. */
  33441. resetLastAnimationTimeFrame(): void;
  33442. /**
  33443. * Gets the current view matrix
  33444. * @returns a Matrix
  33445. */
  33446. getViewMatrix(): Matrix;
  33447. /**
  33448. * Gets the current projection matrix
  33449. * @returns a Matrix
  33450. */
  33451. getProjectionMatrix(): Matrix;
  33452. /**
  33453. * Gets the current transform matrix
  33454. * @returns a Matrix made of View * Projection
  33455. */
  33456. getTransformMatrix(): Matrix;
  33457. /**
  33458. * Sets the current transform matrix
  33459. * @param viewL defines the View matrix to use
  33460. * @param projectionL defines the Projection matrix to use
  33461. * @param viewR defines the right View matrix to use (if provided)
  33462. * @param projectionR defines the right Projection matrix to use (if provided)
  33463. */
  33464. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33465. /**
  33466. * Gets the uniform buffer used to store scene data
  33467. * @returns a UniformBuffer
  33468. */
  33469. getSceneUniformBuffer(): UniformBuffer;
  33470. /**
  33471. * Gets an unique (relatively to the current scene) Id
  33472. * @returns an unique number for the scene
  33473. */
  33474. getUniqueId(): number;
  33475. /**
  33476. * Add a mesh to the list of scene's meshes
  33477. * @param newMesh defines the mesh to add
  33478. * @param recursive if all child meshes should also be added to the scene
  33479. */
  33480. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33481. /**
  33482. * Remove a mesh for the list of scene's meshes
  33483. * @param toRemove defines the mesh to remove
  33484. * @param recursive if all child meshes should also be removed from the scene
  33485. * @returns the index where the mesh was in the mesh list
  33486. */
  33487. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33488. /**
  33489. * Add a transform node to the list of scene's transform nodes
  33490. * @param newTransformNode defines the transform node to add
  33491. */
  33492. addTransformNode(newTransformNode: TransformNode): void;
  33493. /**
  33494. * Remove a transform node for the list of scene's transform nodes
  33495. * @param toRemove defines the transform node to remove
  33496. * @returns the index where the transform node was in the transform node list
  33497. */
  33498. removeTransformNode(toRemove: TransformNode): number;
  33499. /**
  33500. * Remove a skeleton for the list of scene's skeletons
  33501. * @param toRemove defines the skeleton to remove
  33502. * @returns the index where the skeleton was in the skeleton list
  33503. */
  33504. removeSkeleton(toRemove: Skeleton): number;
  33505. /**
  33506. * Remove a morph target for the list of scene's morph targets
  33507. * @param toRemove defines the morph target to remove
  33508. * @returns the index where the morph target was in the morph target list
  33509. */
  33510. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33511. /**
  33512. * Remove a light for the list of scene's lights
  33513. * @param toRemove defines the light to remove
  33514. * @returns the index where the light was in the light list
  33515. */
  33516. removeLight(toRemove: Light): number;
  33517. /**
  33518. * Remove a camera for the list of scene's cameras
  33519. * @param toRemove defines the camera to remove
  33520. * @returns the index where the camera was in the camera list
  33521. */
  33522. removeCamera(toRemove: Camera): number;
  33523. /**
  33524. * Remove a particle system for the list of scene's particle systems
  33525. * @param toRemove defines the particle system to remove
  33526. * @returns the index where the particle system was in the particle system list
  33527. */
  33528. removeParticleSystem(toRemove: IParticleSystem): number;
  33529. /**
  33530. * Remove a animation for the list of scene's animations
  33531. * @param toRemove defines the animation to remove
  33532. * @returns the index where the animation was in the animation list
  33533. */
  33534. removeAnimation(toRemove: Animation): number;
  33535. /**
  33536. * Will stop the animation of the given target
  33537. * @param target - the target
  33538. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33539. * @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)
  33540. */
  33541. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33542. /**
  33543. * Removes the given animation group from this scene.
  33544. * @param toRemove The animation group to remove
  33545. * @returns The index of the removed animation group
  33546. */
  33547. removeAnimationGroup(toRemove: AnimationGroup): number;
  33548. /**
  33549. * Removes the given multi-material from this scene.
  33550. * @param toRemove The multi-material to remove
  33551. * @returns The index of the removed multi-material
  33552. */
  33553. removeMultiMaterial(toRemove: MultiMaterial): number;
  33554. /**
  33555. * Removes the given material from this scene.
  33556. * @param toRemove The material to remove
  33557. * @returns The index of the removed material
  33558. */
  33559. removeMaterial(toRemove: Material): number;
  33560. /**
  33561. * Removes the given action manager from this scene.
  33562. * @param toRemove The action manager to remove
  33563. * @returns The index of the removed action manager
  33564. */
  33565. removeActionManager(toRemove: AbstractActionManager): number;
  33566. /**
  33567. * Removes the given texture from this scene.
  33568. * @param toRemove The texture to remove
  33569. * @returns The index of the removed texture
  33570. */
  33571. removeTexture(toRemove: BaseTexture): number;
  33572. /**
  33573. * Adds the given light to this scene
  33574. * @param newLight The light to add
  33575. */
  33576. addLight(newLight: Light): void;
  33577. /**
  33578. * Sorts the list list based on light priorities
  33579. */
  33580. sortLightsByPriority(): void;
  33581. /**
  33582. * Adds the given camera to this scene
  33583. * @param newCamera The camera to add
  33584. */
  33585. addCamera(newCamera: Camera): void;
  33586. /**
  33587. * Adds the given skeleton to this scene
  33588. * @param newSkeleton The skeleton to add
  33589. */
  33590. addSkeleton(newSkeleton: Skeleton): void;
  33591. /**
  33592. * Adds the given particle system to this scene
  33593. * @param newParticleSystem The particle system to add
  33594. */
  33595. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33596. /**
  33597. * Adds the given animation to this scene
  33598. * @param newAnimation The animation to add
  33599. */
  33600. addAnimation(newAnimation: Animation): void;
  33601. /**
  33602. * Adds the given animation group to this scene.
  33603. * @param newAnimationGroup The animation group to add
  33604. */
  33605. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33606. /**
  33607. * Adds the given multi-material to this scene
  33608. * @param newMultiMaterial The multi-material to add
  33609. */
  33610. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33611. /**
  33612. * Adds the given material to this scene
  33613. * @param newMaterial The material to add
  33614. */
  33615. addMaterial(newMaterial: Material): void;
  33616. /**
  33617. * Adds the given morph target to this scene
  33618. * @param newMorphTargetManager The morph target to add
  33619. */
  33620. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33621. /**
  33622. * Adds the given geometry to this scene
  33623. * @param newGeometry The geometry to add
  33624. */
  33625. addGeometry(newGeometry: Geometry): void;
  33626. /**
  33627. * Adds the given action manager to this scene
  33628. * @param newActionManager The action manager to add
  33629. */
  33630. addActionManager(newActionManager: AbstractActionManager): void;
  33631. /**
  33632. * Adds the given texture to this scene.
  33633. * @param newTexture The texture to add
  33634. */
  33635. addTexture(newTexture: BaseTexture): void;
  33636. /**
  33637. * Switch active camera
  33638. * @param newCamera defines the new active camera
  33639. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33640. */
  33641. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33642. /**
  33643. * sets the active camera of the scene using its ID
  33644. * @param id defines the camera's ID
  33645. * @return the new active camera or null if none found.
  33646. */
  33647. setActiveCameraByID(id: string): Nullable<Camera>;
  33648. /**
  33649. * sets the active camera of the scene using its name
  33650. * @param name defines the camera's name
  33651. * @returns the new active camera or null if none found.
  33652. */
  33653. setActiveCameraByName(name: string): Nullable<Camera>;
  33654. /**
  33655. * get an animation group using its name
  33656. * @param name defines the material's name
  33657. * @return the animation group or null if none found.
  33658. */
  33659. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33660. /**
  33661. * Get a material using its unique id
  33662. * @param uniqueId defines the material's unique id
  33663. * @return the material or null if none found.
  33664. */
  33665. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33666. /**
  33667. * get a material using its id
  33668. * @param id defines the material's ID
  33669. * @return the material or null if none found.
  33670. */
  33671. getMaterialByID(id: string): Nullable<Material>;
  33672. /**
  33673. * Gets a the last added material using a given id
  33674. * @param id defines the material's ID
  33675. * @return the last material with the given id or null if none found.
  33676. */
  33677. getLastMaterialByID(id: string): Nullable<Material>;
  33678. /**
  33679. * Gets a material using its name
  33680. * @param name defines the material's name
  33681. * @return the material or null if none found.
  33682. */
  33683. getMaterialByName(name: string): Nullable<Material>;
  33684. /**
  33685. * Get a texture using its unique id
  33686. * @param uniqueId defines the texture's unique id
  33687. * @return the texture or null if none found.
  33688. */
  33689. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33690. /**
  33691. * Gets a camera using its id
  33692. * @param id defines the id to look for
  33693. * @returns the camera or null if not found
  33694. */
  33695. getCameraByID(id: string): Nullable<Camera>;
  33696. /**
  33697. * Gets a camera using its unique id
  33698. * @param uniqueId defines the unique id to look for
  33699. * @returns the camera or null if not found
  33700. */
  33701. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33702. /**
  33703. * Gets a camera using its name
  33704. * @param name defines the camera's name
  33705. * @return the camera or null if none found.
  33706. */
  33707. getCameraByName(name: string): Nullable<Camera>;
  33708. /**
  33709. * Gets a bone using its id
  33710. * @param id defines the bone's id
  33711. * @return the bone or null if not found
  33712. */
  33713. getBoneByID(id: string): Nullable<Bone>;
  33714. /**
  33715. * Gets a bone using its id
  33716. * @param name defines the bone's name
  33717. * @return the bone or null if not found
  33718. */
  33719. getBoneByName(name: string): Nullable<Bone>;
  33720. /**
  33721. * Gets a light node using its name
  33722. * @param name defines the the light's name
  33723. * @return the light or null if none found.
  33724. */
  33725. getLightByName(name: string): Nullable<Light>;
  33726. /**
  33727. * Gets a light node using its id
  33728. * @param id defines the light's id
  33729. * @return the light or null if none found.
  33730. */
  33731. getLightByID(id: string): Nullable<Light>;
  33732. /**
  33733. * Gets a light node using its scene-generated unique ID
  33734. * @param uniqueId defines the light's unique id
  33735. * @return the light or null if none found.
  33736. */
  33737. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33738. /**
  33739. * Gets a particle system by id
  33740. * @param id defines the particle system id
  33741. * @return the corresponding system or null if none found
  33742. */
  33743. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33744. /**
  33745. * Gets a geometry using its ID
  33746. * @param id defines the geometry's id
  33747. * @return the geometry or null if none found.
  33748. */
  33749. getGeometryByID(id: string): Nullable<Geometry>;
  33750. private _getGeometryByUniqueID;
  33751. /**
  33752. * Add a new geometry to this scene
  33753. * @param geometry defines the geometry to be added to the scene.
  33754. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33755. * @return a boolean defining if the geometry was added or not
  33756. */
  33757. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33758. /**
  33759. * Removes an existing geometry
  33760. * @param geometry defines the geometry to be removed from the scene
  33761. * @return a boolean defining if the geometry was removed or not
  33762. */
  33763. removeGeometry(geometry: Geometry): boolean;
  33764. /**
  33765. * Gets the list of geometries attached to the scene
  33766. * @returns an array of Geometry
  33767. */
  33768. getGeometries(): Geometry[];
  33769. /**
  33770. * Gets the first added mesh found of a given ID
  33771. * @param id defines the id to search for
  33772. * @return the mesh found or null if not found at all
  33773. */
  33774. getMeshByID(id: string): Nullable<AbstractMesh>;
  33775. /**
  33776. * Gets a list of meshes using their id
  33777. * @param id defines the id to search for
  33778. * @returns a list of meshes
  33779. */
  33780. getMeshesByID(id: string): Array<AbstractMesh>;
  33781. /**
  33782. * Gets the first added transform node found of a given ID
  33783. * @param id defines the id to search for
  33784. * @return the found transform node or null if not found at all.
  33785. */
  33786. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33787. /**
  33788. * Gets a transform node with its auto-generated unique id
  33789. * @param uniqueId efines the unique id to search for
  33790. * @return the found transform node or null if not found at all.
  33791. */
  33792. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33793. /**
  33794. * Gets a list of transform nodes using their id
  33795. * @param id defines the id to search for
  33796. * @returns a list of transform nodes
  33797. */
  33798. getTransformNodesByID(id: string): Array<TransformNode>;
  33799. /**
  33800. * Gets a mesh with its auto-generated unique id
  33801. * @param uniqueId defines the unique id to search for
  33802. * @return the found mesh or null if not found at all.
  33803. */
  33804. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33805. /**
  33806. * Gets a the last added mesh using a given id
  33807. * @param id defines the id to search for
  33808. * @return the found mesh or null if not found at all.
  33809. */
  33810. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33811. /**
  33812. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33813. * @param id defines the id to search for
  33814. * @return the found node or null if not found at all
  33815. */
  33816. getLastEntryByID(id: string): Nullable<Node>;
  33817. /**
  33818. * Gets a node (Mesh, Camera, Light) using a given id
  33819. * @param id defines the id to search for
  33820. * @return the found node or null if not found at all
  33821. */
  33822. getNodeByID(id: string): Nullable<Node>;
  33823. /**
  33824. * Gets a node (Mesh, Camera, Light) using a given name
  33825. * @param name defines the name to search for
  33826. * @return the found node or null if not found at all.
  33827. */
  33828. getNodeByName(name: string): Nullable<Node>;
  33829. /**
  33830. * Gets a mesh using a given name
  33831. * @param name defines the name to search for
  33832. * @return the found mesh or null if not found at all.
  33833. */
  33834. getMeshByName(name: string): Nullable<AbstractMesh>;
  33835. /**
  33836. * Gets a transform node using a given name
  33837. * @param name defines the name to search for
  33838. * @return the found transform node or null if not found at all.
  33839. */
  33840. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33841. /**
  33842. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33843. * @param id defines the id to search for
  33844. * @return the found skeleton or null if not found at all.
  33845. */
  33846. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33847. /**
  33848. * Gets a skeleton using a given auto generated unique id
  33849. * @param uniqueId defines the unique id to search for
  33850. * @return the found skeleton or null if not found at all.
  33851. */
  33852. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33853. /**
  33854. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33855. * @param id defines the id to search for
  33856. * @return the found skeleton or null if not found at all.
  33857. */
  33858. getSkeletonById(id: string): Nullable<Skeleton>;
  33859. /**
  33860. * Gets a skeleton using a given name
  33861. * @param name defines the name to search for
  33862. * @return the found skeleton or null if not found at all.
  33863. */
  33864. getSkeletonByName(name: string): Nullable<Skeleton>;
  33865. /**
  33866. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33867. * @param id defines the id to search for
  33868. * @return the found morph target manager or null if not found at all.
  33869. */
  33870. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33871. /**
  33872. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33873. * @param id defines the id to search for
  33874. * @return the found morph target or null if not found at all.
  33875. */
  33876. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33877. /**
  33878. * Gets a boolean indicating if the given mesh is active
  33879. * @param mesh defines the mesh to look for
  33880. * @returns true if the mesh is in the active list
  33881. */
  33882. isActiveMesh(mesh: AbstractMesh): boolean;
  33883. /**
  33884. * Return a unique id as a string which can serve as an identifier for the scene
  33885. */
  33886. readonly uid: string;
  33887. /**
  33888. * Add an externaly attached data from its key.
  33889. * This method call will fail and return false, if such key already exists.
  33890. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33891. * @param key the unique key that identifies the data
  33892. * @param data the data object to associate to the key for this Engine instance
  33893. * @return true if no such key were already present and the data was added successfully, false otherwise
  33894. */
  33895. addExternalData<T>(key: string, data: T): boolean;
  33896. /**
  33897. * Get an externaly attached data from its key
  33898. * @param key the unique key that identifies the data
  33899. * @return the associated data, if present (can be null), or undefined if not present
  33900. */
  33901. getExternalData<T>(key: string): Nullable<T>;
  33902. /**
  33903. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33904. * @param key the unique key that identifies the data
  33905. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33906. * @return the associated data, can be null if the factory returned null.
  33907. */
  33908. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33909. /**
  33910. * Remove an externaly attached data from the Engine instance
  33911. * @param key the unique key that identifies the data
  33912. * @return true if the data was successfully removed, false if it doesn't exist
  33913. */
  33914. removeExternalData(key: string): boolean;
  33915. private _evaluateSubMesh;
  33916. /**
  33917. * Clear the processed materials smart array preventing retention point in material dispose.
  33918. */
  33919. freeProcessedMaterials(): void;
  33920. private _preventFreeActiveMeshesAndRenderingGroups;
  33921. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33922. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33923. * when disposing several meshes in a row or a hierarchy of meshes.
  33924. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33925. */
  33926. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33927. /**
  33928. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33929. */
  33930. freeActiveMeshes(): void;
  33931. /**
  33932. * Clear the info related to rendering groups preventing retention points during dispose.
  33933. */
  33934. freeRenderingGroups(): void;
  33935. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33936. /**
  33937. * Lambda returning the list of potentially active meshes.
  33938. */
  33939. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33940. /**
  33941. * Lambda returning the list of potentially active sub meshes.
  33942. */
  33943. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33944. /**
  33945. * Lambda returning the list of potentially intersecting sub meshes.
  33946. */
  33947. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33948. /**
  33949. * Lambda returning the list of potentially colliding sub meshes.
  33950. */
  33951. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33952. private _activeMeshesFrozen;
  33953. /**
  33954. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33955. * @returns the current scene
  33956. */
  33957. freezeActiveMeshes(): Scene;
  33958. /**
  33959. * Use this function to restart evaluating active meshes on every frame
  33960. * @returns the current scene
  33961. */
  33962. unfreezeActiveMeshes(): Scene;
  33963. private _evaluateActiveMeshes;
  33964. private _activeMesh;
  33965. /**
  33966. * Update the transform matrix to update from the current active camera
  33967. * @param force defines a boolean used to force the update even if cache is up to date
  33968. */
  33969. updateTransformMatrix(force?: boolean): void;
  33970. private _bindFrameBuffer;
  33971. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33972. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33973. private _processSubCameras;
  33974. private _checkIntersections;
  33975. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33976. /**
  33977. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33978. */
  33979. getDeterministicFrameTime: () => number;
  33980. /** @hidden */ private _animate(): void;
  33981. /** Execute all animations (for a frame) */
  33982. animate(): void;
  33983. /**
  33984. * Render the scene
  33985. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33986. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33987. */
  33988. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33989. /**
  33990. * Freeze all materials
  33991. * A frozen material will not be updatable but should be faster to render
  33992. */
  33993. freezeMaterials(): void;
  33994. /**
  33995. * Unfreeze all materials
  33996. * A frozen material will not be updatable but should be faster to render
  33997. */
  33998. unfreezeMaterials(): void;
  33999. /**
  34000. * Releases all held ressources
  34001. */
  34002. dispose(): void;
  34003. /**
  34004. * Gets if the scene is already disposed
  34005. */
  34006. readonly isDisposed: boolean;
  34007. /**
  34008. * Call this function to reduce memory footprint of the scene.
  34009. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34010. */
  34011. clearCachedVertexData(): void;
  34012. /**
  34013. * This function will remove the local cached buffer data from texture.
  34014. * It will save memory but will prevent the texture from being rebuilt
  34015. */
  34016. cleanCachedTextureBuffer(): void;
  34017. /**
  34018. * Get the world extend vectors with an optional filter
  34019. *
  34020. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34021. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34022. */
  34023. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34024. min: Vector3;
  34025. max: Vector3;
  34026. };
  34027. /**
  34028. * Creates a ray that can be used to pick in the scene
  34029. * @param x defines the x coordinate of the origin (on-screen)
  34030. * @param y defines the y coordinate of the origin (on-screen)
  34031. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34032. * @param camera defines the camera to use for the picking
  34033. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34034. * @returns a Ray
  34035. */
  34036. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34037. /**
  34038. * Creates a ray that can be used to pick in the scene
  34039. * @param x defines the x coordinate of the origin (on-screen)
  34040. * @param y defines the y coordinate of the origin (on-screen)
  34041. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34042. * @param result defines the ray where to store the picking ray
  34043. * @param camera defines the camera to use for the picking
  34044. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34045. * @returns the current scene
  34046. */
  34047. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34048. /**
  34049. * Creates a ray that can be used to pick in the scene
  34050. * @param x defines the x coordinate of the origin (on-screen)
  34051. * @param y defines the y coordinate of the origin (on-screen)
  34052. * @param camera defines the camera to use for the picking
  34053. * @returns a Ray
  34054. */
  34055. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34056. /**
  34057. * Creates a ray that can be used to pick in the scene
  34058. * @param x defines the x coordinate of the origin (on-screen)
  34059. * @param y defines the y coordinate of the origin (on-screen)
  34060. * @param result defines the ray where to store the picking ray
  34061. * @param camera defines the camera to use for the picking
  34062. * @returns the current scene
  34063. */
  34064. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34065. /** Launch a ray to try to pick a mesh in the scene
  34066. * @param x position on screen
  34067. * @param y position on screen
  34068. * @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
  34069. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34070. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34071. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34072. * @returns a PickingInfo
  34073. */
  34074. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34075. /** Use the given ray to pick a mesh in the scene
  34076. * @param ray The ray to use to pick meshes
  34077. * @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
  34078. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34080. * @returns a PickingInfo
  34081. */
  34082. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34083. /**
  34084. * Launch a ray to try to pick a mesh in the scene
  34085. * @param x X position on screen
  34086. * @param y Y position on screen
  34087. * @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
  34088. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34089. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34090. * @returns an array of PickingInfo
  34091. */
  34092. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34093. /**
  34094. * Launch a ray to try to pick a mesh in the scene
  34095. * @param ray Ray to use
  34096. * @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
  34097. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34098. * @returns an array of PickingInfo
  34099. */
  34100. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34101. /**
  34102. * Force the value of meshUnderPointer
  34103. * @param mesh defines the mesh to use
  34104. */
  34105. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34106. /**
  34107. * Gets the mesh under the pointer
  34108. * @returns a Mesh or null if no mesh is under the pointer
  34109. */
  34110. getPointerOverMesh(): Nullable<AbstractMesh>;
  34111. /** @hidden */ private _rebuildGeometries(): void;
  34112. /** @hidden */ private _rebuildTextures(): void;
  34113. private _getByTags;
  34114. /**
  34115. * Get a list of meshes by tags
  34116. * @param tagsQuery defines the tags query to use
  34117. * @param forEach defines a predicate used to filter results
  34118. * @returns an array of Mesh
  34119. */
  34120. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34121. /**
  34122. * Get a list of cameras by tags
  34123. * @param tagsQuery defines the tags query to use
  34124. * @param forEach defines a predicate used to filter results
  34125. * @returns an array of Camera
  34126. */
  34127. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34128. /**
  34129. * Get a list of lights by tags
  34130. * @param tagsQuery defines the tags query to use
  34131. * @param forEach defines a predicate used to filter results
  34132. * @returns an array of Light
  34133. */
  34134. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34135. /**
  34136. * Get a list of materials by tags
  34137. * @param tagsQuery defines the tags query to use
  34138. * @param forEach defines a predicate used to filter results
  34139. * @returns an array of Material
  34140. */
  34141. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34142. /**
  34143. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34144. * This allowed control for front to back rendering or reversly depending of the special needs.
  34145. *
  34146. * @param renderingGroupId The rendering group id corresponding to its index
  34147. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34148. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34149. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34150. */
  34151. 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;
  34152. /**
  34153. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34154. *
  34155. * @param renderingGroupId The rendering group id corresponding to its index
  34156. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34157. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34158. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34159. */
  34160. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34161. /**
  34162. * Gets the current auto clear configuration for one rendering group of the rendering
  34163. * manager.
  34164. * @param index the rendering group index to get the information for
  34165. * @returns The auto clear setup for the requested rendering group
  34166. */
  34167. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34168. private _blockMaterialDirtyMechanism;
  34169. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34170. blockMaterialDirtyMechanism: boolean;
  34171. /**
  34172. * Will flag all materials as dirty to trigger new shader compilation
  34173. * @param flag defines the flag used to specify which material part must be marked as dirty
  34174. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34175. */
  34176. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34177. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  34178. /** @hidden */ private _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34179. /** @hidden */ private _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  34180. /** @hidden */ private _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  34181. /** @hidden */ private _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34182. /** @hidden */ private _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34183. }
  34184. }
  34185. declare module BABYLON {
  34186. /**
  34187. * Set of assets to keep when moving a scene into an asset container.
  34188. */
  34189. export class KeepAssets extends AbstractScene {
  34190. }
  34191. /**
  34192. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  34193. */
  34194. export class InstantiatedEntries {
  34195. /**
  34196. * List of new root nodes (eg. nodes with no parent)
  34197. */
  34198. rootNodes: TransformNode[];
  34199. /**
  34200. * List of new skeletons
  34201. */
  34202. skeletons: Skeleton[];
  34203. /**
  34204. * List of new animation groups
  34205. */
  34206. animationGroups: AnimationGroup[];
  34207. }
  34208. /**
  34209. * Container with a set of assets that can be added or removed from a scene.
  34210. */
  34211. export class AssetContainer extends AbstractScene {
  34212. /**
  34213. * The scene the AssetContainer belongs to.
  34214. */
  34215. scene: Scene;
  34216. /**
  34217. * Instantiates an AssetContainer.
  34218. * @param scene The scene the AssetContainer belongs to.
  34219. */
  34220. constructor(scene: Scene);
  34221. /**
  34222. * Instantiate or clone all meshes and add the new ones to the scene.
  34223. * Skeletons and animation groups will all be cloned
  34224. * @param nameFunction defines an optional function used to get new names for clones
  34225. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  34226. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  34227. */
  34228. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  34229. /**
  34230. * Adds all the assets from the container to the scene.
  34231. */
  34232. addAllToScene(): void;
  34233. /**
  34234. * Removes all the assets in the container from the scene
  34235. */
  34236. removeAllFromScene(): void;
  34237. /**
  34238. * Disposes all the assets in the container
  34239. */
  34240. dispose(): void;
  34241. private _moveAssets;
  34242. /**
  34243. * Removes all the assets contained in the scene and adds them to the container.
  34244. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34245. */
  34246. moveAllFromScene(keepAssets?: KeepAssets): void;
  34247. /**
  34248. * 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.
  34249. * @returns the root mesh
  34250. */
  34251. createRootMesh(): Mesh;
  34252. }
  34253. }
  34254. declare module BABYLON {
  34255. /**
  34256. * Defines how the parser contract is defined.
  34257. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34258. */
  34259. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34260. /**
  34261. * Defines how the individual parser contract is defined.
  34262. * These parser can parse an individual asset
  34263. */
  34264. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34265. /**
  34266. * Base class of the scene acting as a container for the different elements composing a scene.
  34267. * This class is dynamically extended by the different components of the scene increasing
  34268. * flexibility and reducing coupling
  34269. */
  34270. export abstract class AbstractScene {
  34271. /**
  34272. * Stores the list of available parsers in the application.
  34273. */
  34274. private static _BabylonFileParsers;
  34275. /**
  34276. * Stores the list of available individual parsers in the application.
  34277. */
  34278. private static _IndividualBabylonFileParsers;
  34279. /**
  34280. * Adds a parser in the list of available ones
  34281. * @param name Defines the name of the parser
  34282. * @param parser Defines the parser to add
  34283. */
  34284. static AddParser(name: string, parser: BabylonFileParser): void;
  34285. /**
  34286. * Gets a general parser from the list of avaialble ones
  34287. * @param name Defines the name of the parser
  34288. * @returns the requested parser or null
  34289. */
  34290. static GetParser(name: string): Nullable<BabylonFileParser>;
  34291. /**
  34292. * Adds n individual parser in the list of available ones
  34293. * @param name Defines the name of the parser
  34294. * @param parser Defines the parser to add
  34295. */
  34296. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34297. /**
  34298. * Gets an individual parser from the list of avaialble ones
  34299. * @param name Defines the name of the parser
  34300. * @returns the requested parser or null
  34301. */
  34302. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34303. /**
  34304. * Parser json data and populate both a scene and its associated container object
  34305. * @param jsonData Defines the data to parse
  34306. * @param scene Defines the scene to parse the data for
  34307. * @param container Defines the container attached to the parsing sequence
  34308. * @param rootUrl Defines the root url of the data
  34309. */
  34310. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34311. /**
  34312. * Gets the list of root nodes (ie. nodes with no parent)
  34313. */
  34314. rootNodes: Node[];
  34315. /** All of the cameras added to this scene
  34316. * @see http://doc.babylonjs.com/babylon101/cameras
  34317. */
  34318. cameras: Camera[];
  34319. /**
  34320. * All of the lights added to this scene
  34321. * @see http://doc.babylonjs.com/babylon101/lights
  34322. */
  34323. lights: Light[];
  34324. /**
  34325. * All of the (abstract) meshes added to this scene
  34326. */
  34327. meshes: AbstractMesh[];
  34328. /**
  34329. * The list of skeletons added to the scene
  34330. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34331. */
  34332. skeletons: Skeleton[];
  34333. /**
  34334. * All of the particle systems added to this scene
  34335. * @see http://doc.babylonjs.com/babylon101/particles
  34336. */
  34337. particleSystems: IParticleSystem[];
  34338. /**
  34339. * Gets a list of Animations associated with the scene
  34340. */
  34341. animations: Animation[];
  34342. /**
  34343. * All of the animation groups added to this scene
  34344. * @see http://doc.babylonjs.com/how_to/group
  34345. */
  34346. animationGroups: AnimationGroup[];
  34347. /**
  34348. * All of the multi-materials added to this scene
  34349. * @see http://doc.babylonjs.com/how_to/multi_materials
  34350. */
  34351. multiMaterials: MultiMaterial[];
  34352. /**
  34353. * All of the materials added to this scene
  34354. * In the context of a Scene, it is not supposed to be modified manually.
  34355. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  34356. * Note also that the order of the Material within the array is not significant and might change.
  34357. * @see http://doc.babylonjs.com/babylon101/materials
  34358. */
  34359. materials: Material[];
  34360. /**
  34361. * The list of morph target managers added to the scene
  34362. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34363. */
  34364. morphTargetManagers: MorphTargetManager[];
  34365. /**
  34366. * The list of geometries used in the scene.
  34367. */
  34368. geometries: Geometry[];
  34369. /**
  34370. * All of the tranform nodes added to this scene
  34371. * In the context of a Scene, it is not supposed to be modified manually.
  34372. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34373. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34374. * @see http://doc.babylonjs.com/how_to/transformnode
  34375. */
  34376. transformNodes: TransformNode[];
  34377. /**
  34378. * ActionManagers available on the scene.
  34379. */
  34380. actionManagers: AbstractActionManager[];
  34381. /**
  34382. * Textures to keep.
  34383. */
  34384. textures: BaseTexture[];
  34385. /**
  34386. * Environment texture for the scene
  34387. */
  34388. environmentTexture: Nullable<BaseTexture>;
  34389. }
  34390. }
  34391. declare module BABYLON {
  34392. /**
  34393. * Interface used to define options for Sound class
  34394. */
  34395. export interface ISoundOptions {
  34396. /**
  34397. * Does the sound autoplay once loaded.
  34398. */
  34399. autoplay?: boolean;
  34400. /**
  34401. * Does the sound loop after it finishes playing once.
  34402. */
  34403. loop?: boolean;
  34404. /**
  34405. * Sound's volume
  34406. */
  34407. volume?: number;
  34408. /**
  34409. * Is it a spatial sound?
  34410. */
  34411. spatialSound?: boolean;
  34412. /**
  34413. * Maximum distance to hear that sound
  34414. */
  34415. maxDistance?: number;
  34416. /**
  34417. * Uses user defined attenuation function
  34418. */
  34419. useCustomAttenuation?: boolean;
  34420. /**
  34421. * Define the roll off factor of spatial sounds.
  34422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34423. */
  34424. rolloffFactor?: number;
  34425. /**
  34426. * Define the reference distance the sound should be heard perfectly.
  34427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34428. */
  34429. refDistance?: number;
  34430. /**
  34431. * Define the distance attenuation model the sound will follow.
  34432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34433. */
  34434. distanceModel?: string;
  34435. /**
  34436. * Defines the playback speed (1 by default)
  34437. */
  34438. playbackRate?: number;
  34439. /**
  34440. * Defines if the sound is from a streaming source
  34441. */
  34442. streaming?: boolean;
  34443. /**
  34444. * Defines an optional length (in seconds) inside the sound file
  34445. */
  34446. length?: number;
  34447. /**
  34448. * Defines an optional offset (in seconds) inside the sound file
  34449. */
  34450. offset?: number;
  34451. /**
  34452. * If true, URLs will not be required to state the audio file codec to use.
  34453. */
  34454. skipCodecCheck?: boolean;
  34455. }
  34456. /**
  34457. * Defines a sound that can be played in the application.
  34458. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34460. */
  34461. export class Sound {
  34462. /**
  34463. * The name of the sound in the scene.
  34464. */
  34465. name: string;
  34466. /**
  34467. * Does the sound autoplay once loaded.
  34468. */
  34469. autoplay: boolean;
  34470. /**
  34471. * Does the sound loop after it finishes playing once.
  34472. */
  34473. loop: boolean;
  34474. /**
  34475. * Does the sound use a custom attenuation curve to simulate the falloff
  34476. * happening when the source gets further away from the camera.
  34477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34478. */
  34479. useCustomAttenuation: boolean;
  34480. /**
  34481. * The sound track id this sound belongs to.
  34482. */
  34483. soundTrackId: number;
  34484. /**
  34485. * Is this sound currently played.
  34486. */
  34487. isPlaying: boolean;
  34488. /**
  34489. * Is this sound currently paused.
  34490. */
  34491. isPaused: boolean;
  34492. /**
  34493. * Does this sound enables spatial sound.
  34494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34495. */
  34496. spatialSound: boolean;
  34497. /**
  34498. * Define the reference distance the sound should be heard perfectly.
  34499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34500. */
  34501. refDistance: number;
  34502. /**
  34503. * Define the roll off factor of spatial sounds.
  34504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34505. */
  34506. rolloffFactor: number;
  34507. /**
  34508. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34510. */
  34511. maxDistance: number;
  34512. /**
  34513. * Define the distance attenuation model the sound will follow.
  34514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34515. */
  34516. distanceModel: string;
  34517. /**
  34518. * @hidden
  34519. * Back Compat
  34520. **/
  34521. onended: () => any;
  34522. /**
  34523. * Observable event when the current playing sound finishes.
  34524. */
  34525. onEndedObservable: Observable<Sound>;
  34526. private _panningModel;
  34527. private _playbackRate;
  34528. private _streaming;
  34529. private _startTime;
  34530. private _startOffset;
  34531. private _position;
  34532. /** @hidden */ private _positionInEmitterSpace: boolean;
  34533. private _localDirection;
  34534. private _volume;
  34535. private _isReadyToPlay;
  34536. private _isDirectional;
  34537. private _readyToPlayCallback;
  34538. private _audioBuffer;
  34539. private _soundSource;
  34540. private _streamingSource;
  34541. private _soundPanner;
  34542. private _soundGain;
  34543. private _inputAudioNode;
  34544. private _outputAudioNode;
  34545. private _coneInnerAngle;
  34546. private _coneOuterAngle;
  34547. private _coneOuterGain;
  34548. private _scene;
  34549. private _connectedTransformNode;
  34550. private _customAttenuationFunction;
  34551. private _registerFunc;
  34552. private _isOutputConnected;
  34553. private _htmlAudioElement;
  34554. private _urlType;
  34555. private _length?;
  34556. private _offset?;
  34557. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34558. /**
  34559. * Create a sound and attach it to a scene
  34560. * @param name Name of your sound
  34561. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34562. * @param scene defines the scene the sound belongs to
  34563. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34564. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34565. */
  34566. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34567. /**
  34568. * Release the sound and its associated resources
  34569. */
  34570. dispose(): void;
  34571. /**
  34572. * Gets if the sounds is ready to be played or not.
  34573. * @returns true if ready, otherwise false
  34574. */
  34575. isReady(): boolean;
  34576. private _soundLoaded;
  34577. /**
  34578. * Sets the data of the sound from an audiobuffer
  34579. * @param audioBuffer The audioBuffer containing the data
  34580. */
  34581. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34582. /**
  34583. * Updates the current sounds options such as maxdistance, loop...
  34584. * @param options A JSON object containing values named as the object properties
  34585. */
  34586. updateOptions(options: ISoundOptions): void;
  34587. private _createSpatialParameters;
  34588. private _updateSpatialParameters;
  34589. /**
  34590. * Switch the panning model to HRTF:
  34591. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34593. */
  34594. switchPanningModelToHRTF(): void;
  34595. /**
  34596. * Switch the panning model to Equal Power:
  34597. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34599. */
  34600. switchPanningModelToEqualPower(): void;
  34601. private _switchPanningModel;
  34602. /**
  34603. * Connect this sound to a sound track audio node like gain...
  34604. * @param soundTrackAudioNode the sound track audio node to connect to
  34605. */
  34606. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34607. /**
  34608. * Transform this sound into a directional source
  34609. * @param coneInnerAngle Size of the inner cone in degree
  34610. * @param coneOuterAngle Size of the outer cone in degree
  34611. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34612. */
  34613. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34614. /**
  34615. * Gets or sets the inner angle for the directional cone.
  34616. */
  34617. /**
  34618. * Gets or sets the inner angle for the directional cone.
  34619. */
  34620. directionalConeInnerAngle: number;
  34621. /**
  34622. * Gets or sets the outer angle for the directional cone.
  34623. */
  34624. /**
  34625. * Gets or sets the outer angle for the directional cone.
  34626. */
  34627. directionalConeOuterAngle: number;
  34628. /**
  34629. * Sets the position of the emitter if spatial sound is enabled
  34630. * @param newPosition Defines the new posisiton
  34631. */
  34632. setPosition(newPosition: Vector3): void;
  34633. /**
  34634. * Sets the local direction of the emitter if spatial sound is enabled
  34635. * @param newLocalDirection Defines the new local direction
  34636. */
  34637. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34638. private _updateDirection;
  34639. /** @hidden */
  34640. updateDistanceFromListener(): void;
  34641. /**
  34642. * Sets a new custom attenuation function for the sound.
  34643. * @param callback Defines the function used for the attenuation
  34644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34645. */
  34646. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34647. /**
  34648. * Play the sound
  34649. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34650. * @param offset (optional) Start the sound at a specific time in seconds
  34651. * @param length (optional) Sound duration (in seconds)
  34652. */
  34653. play(time?: number, offset?: number, length?: number): void;
  34654. private _onended;
  34655. /**
  34656. * Stop the sound
  34657. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34658. */
  34659. stop(time?: number): void;
  34660. /**
  34661. * Put the sound in pause
  34662. */
  34663. pause(): void;
  34664. /**
  34665. * Sets a dedicated volume for this sounds
  34666. * @param newVolume Define the new volume of the sound
  34667. * @param time Define time for gradual change to new volume
  34668. */
  34669. setVolume(newVolume: number, time?: number): void;
  34670. /**
  34671. * Set the sound play back rate
  34672. * @param newPlaybackRate Define the playback rate the sound should be played at
  34673. */
  34674. setPlaybackRate(newPlaybackRate: number): void;
  34675. /**
  34676. * Gets the volume of the sound.
  34677. * @returns the volume of the sound
  34678. */
  34679. getVolume(): number;
  34680. /**
  34681. * Attach the sound to a dedicated mesh
  34682. * @param transformNode The transform node to connect the sound with
  34683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34684. */
  34685. attachToMesh(transformNode: TransformNode): void;
  34686. /**
  34687. * Detach the sound from the previously attached mesh
  34688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34689. */
  34690. detachFromMesh(): void;
  34691. private _onRegisterAfterWorldMatrixUpdate;
  34692. /**
  34693. * Clone the current sound in the scene.
  34694. * @returns the new sound clone
  34695. */
  34696. clone(): Nullable<Sound>;
  34697. /**
  34698. * Gets the current underlying audio buffer containing the data
  34699. * @returns the audio buffer
  34700. */
  34701. getAudioBuffer(): Nullable<AudioBuffer>;
  34702. /**
  34703. * Serializes the Sound in a JSON representation
  34704. * @returns the JSON representation of the sound
  34705. */
  34706. serialize(): any;
  34707. /**
  34708. * Parse a JSON representation of a sound to innstantiate in a given scene
  34709. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34710. * @param scene Define the scene the new parsed sound should be created in
  34711. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34712. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34713. * @returns the newly parsed sound
  34714. */
  34715. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34716. }
  34717. }
  34718. declare module BABYLON {
  34719. /**
  34720. * This defines an action helpful to play a defined sound on a triggered action.
  34721. */
  34722. export class PlaySoundAction extends Action {
  34723. private _sound;
  34724. /**
  34725. * Instantiate the action
  34726. * @param triggerOptions defines the trigger options
  34727. * @param sound defines the sound to play
  34728. * @param condition defines the trigger related conditions
  34729. */
  34730. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34731. /** @hidden */ private _prepare(): void;
  34732. /**
  34733. * Execute the action and play the sound.
  34734. */
  34735. execute(): void;
  34736. /**
  34737. * Serializes the actions and its related information.
  34738. * @param parent defines the object to serialize in
  34739. * @returns the serialized object
  34740. */
  34741. serialize(parent: any): any;
  34742. }
  34743. /**
  34744. * This defines an action helpful to stop a defined sound on a triggered action.
  34745. */
  34746. export class StopSoundAction extends Action {
  34747. private _sound;
  34748. /**
  34749. * Instantiate the action
  34750. * @param triggerOptions defines the trigger options
  34751. * @param sound defines the sound to stop
  34752. * @param condition defines the trigger related conditions
  34753. */
  34754. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34755. /** @hidden */ private _prepare(): void;
  34756. /**
  34757. * Execute the action and stop the sound.
  34758. */
  34759. execute(): void;
  34760. /**
  34761. * Serializes the actions and its related information.
  34762. * @param parent defines the object to serialize in
  34763. * @returns the serialized object
  34764. */
  34765. serialize(parent: any): any;
  34766. }
  34767. }
  34768. declare module BABYLON {
  34769. /**
  34770. * This defines an action responsible to change the value of a property
  34771. * by interpolating between its current value and the newly set one once triggered.
  34772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34773. */
  34774. export class InterpolateValueAction extends Action {
  34775. /**
  34776. * Defines the path of the property where the value should be interpolated
  34777. */
  34778. propertyPath: string;
  34779. /**
  34780. * Defines the target value at the end of the interpolation.
  34781. */
  34782. value: any;
  34783. /**
  34784. * Defines the time it will take for the property to interpolate to the value.
  34785. */
  34786. duration: number;
  34787. /**
  34788. * Defines if the other scene animations should be stopped when the action has been triggered
  34789. */
  34790. stopOtherAnimations?: boolean;
  34791. /**
  34792. * Defines a callback raised once the interpolation animation has been done.
  34793. */
  34794. onInterpolationDone?: () => void;
  34795. /**
  34796. * Observable triggered once the interpolation animation has been done.
  34797. */
  34798. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34799. private _target;
  34800. private _effectiveTarget;
  34801. private _property;
  34802. /**
  34803. * Instantiate the action
  34804. * @param triggerOptions defines the trigger options
  34805. * @param target defines the object containing the value to interpolate
  34806. * @param propertyPath defines the path to the property in the target object
  34807. * @param value defines the target value at the end of the interpolation
  34808. * @param duration deines the time it will take for the property to interpolate to the value.
  34809. * @param condition defines the trigger related conditions
  34810. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34811. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34812. */
  34813. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34814. /** @hidden */ private _prepare(): void;
  34815. /**
  34816. * Execute the action starts the value interpolation.
  34817. */
  34818. execute(): void;
  34819. /**
  34820. * Serializes the actions and its related information.
  34821. * @param parent defines the object to serialize in
  34822. * @returns the serialized object
  34823. */
  34824. serialize(parent: any): any;
  34825. }
  34826. }
  34827. declare module BABYLON {
  34828. /**
  34829. * Options allowed during the creation of a sound track.
  34830. */
  34831. export interface ISoundTrackOptions {
  34832. /**
  34833. * The volume the sound track should take during creation
  34834. */
  34835. volume?: number;
  34836. /**
  34837. * Define if the sound track is the main sound track of the scene
  34838. */
  34839. mainTrack?: boolean;
  34840. }
  34841. /**
  34842. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34843. * It will be also used in a future release to apply effects on a specific track.
  34844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34845. */
  34846. export class SoundTrack {
  34847. /**
  34848. * The unique identifier of the sound track in the scene.
  34849. */
  34850. id: number;
  34851. /**
  34852. * The list of sounds included in the sound track.
  34853. */
  34854. soundCollection: Array<Sound>;
  34855. private _outputAudioNode;
  34856. private _scene;
  34857. private _isMainTrack;
  34858. private _connectedAnalyser;
  34859. private _options;
  34860. private _isInitialized;
  34861. /**
  34862. * Creates a new sound track.
  34863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34864. * @param scene Define the scene the sound track belongs to
  34865. * @param options
  34866. */
  34867. constructor(scene: Scene, options?: ISoundTrackOptions);
  34868. private _initializeSoundTrackAudioGraph;
  34869. /**
  34870. * Release the sound track and its associated resources
  34871. */
  34872. dispose(): void;
  34873. /**
  34874. * Adds a sound to this sound track
  34875. * @param sound define the cound to add
  34876. * @ignoreNaming
  34877. */
  34878. AddSound(sound: Sound): void;
  34879. /**
  34880. * Removes a sound to this sound track
  34881. * @param sound define the cound to remove
  34882. * @ignoreNaming
  34883. */
  34884. RemoveSound(sound: Sound): void;
  34885. /**
  34886. * Set a global volume for the full sound track.
  34887. * @param newVolume Define the new volume of the sound track
  34888. */
  34889. setVolume(newVolume: number): void;
  34890. /**
  34891. * Switch the panning model to HRTF:
  34892. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34894. */
  34895. switchPanningModelToHRTF(): void;
  34896. /**
  34897. * Switch the panning model to Equal Power:
  34898. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34900. */
  34901. switchPanningModelToEqualPower(): void;
  34902. /**
  34903. * Connect the sound track to an audio analyser allowing some amazing
  34904. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34906. * @param analyser The analyser to connect to the engine
  34907. */
  34908. connectToAnalyser(analyser: Analyser): void;
  34909. }
  34910. }
  34911. declare module BABYLON {
  34912. interface AbstractScene {
  34913. /**
  34914. * The list of sounds used in the scene.
  34915. */
  34916. sounds: Nullable<Array<Sound>>;
  34917. }
  34918. interface Scene {
  34919. /**
  34920. * @hidden
  34921. * Backing field
  34922. */ private _mainSoundTrack: SoundTrack;
  34923. /**
  34924. * The main sound track played by the scene.
  34925. * It cotains your primary collection of sounds.
  34926. */
  34927. mainSoundTrack: SoundTrack;
  34928. /**
  34929. * The list of sound tracks added to the scene
  34930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34931. */
  34932. soundTracks: Nullable<Array<SoundTrack>>;
  34933. /**
  34934. * Gets a sound using a given name
  34935. * @param name defines the name to search for
  34936. * @return the found sound or null if not found at all.
  34937. */
  34938. getSoundByName(name: string): Nullable<Sound>;
  34939. /**
  34940. * Gets or sets if audio support is enabled
  34941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34942. */
  34943. audioEnabled: boolean;
  34944. /**
  34945. * Gets or sets if audio will be output to headphones
  34946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34947. */
  34948. headphone: boolean;
  34949. /**
  34950. * Gets or sets custom audio listener position provider
  34951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34952. */
  34953. audioListenerPositionProvider: Nullable<() => Vector3>;
  34954. /**
  34955. * Gets or sets a refresh rate when using 3D audio positioning
  34956. */
  34957. audioPositioningRefreshRate: number;
  34958. }
  34959. /**
  34960. * Defines the sound scene component responsible to manage any sounds
  34961. * in a given scene.
  34962. */
  34963. export class AudioSceneComponent implements ISceneSerializableComponent {
  34964. /**
  34965. * The component name helpfull to identify the component in the list of scene components.
  34966. */
  34967. readonly name: string;
  34968. /**
  34969. * The scene the component belongs to.
  34970. */
  34971. scene: Scene;
  34972. private _audioEnabled;
  34973. /**
  34974. * Gets whether audio is enabled or not.
  34975. * Please use related enable/disable method to switch state.
  34976. */
  34977. readonly audioEnabled: boolean;
  34978. private _headphone;
  34979. /**
  34980. * Gets whether audio is outputing to headphone or not.
  34981. * Please use the according Switch methods to change output.
  34982. */
  34983. readonly headphone: boolean;
  34984. /**
  34985. * Gets or sets a refresh rate when using 3D audio positioning
  34986. */
  34987. audioPositioningRefreshRate: number;
  34988. private _audioListenerPositionProvider;
  34989. /**
  34990. * Gets the current audio listener position provider
  34991. */
  34992. /**
  34993. * Sets a custom listener position for all sounds in the scene
  34994. * By default, this is the position of the first active camera
  34995. */
  34996. audioListenerPositionProvider: Nullable<() => Vector3>;
  34997. /**
  34998. * Creates a new instance of the component for the given scene
  34999. * @param scene Defines the scene to register the component in
  35000. */
  35001. constructor(scene: Scene);
  35002. /**
  35003. * Registers the component in a given scene
  35004. */
  35005. register(): void;
  35006. /**
  35007. * Rebuilds the elements related to this component in case of
  35008. * context lost for instance.
  35009. */
  35010. rebuild(): void;
  35011. /**
  35012. * Serializes the component data to the specified json object
  35013. * @param serializationObject The object to serialize to
  35014. */
  35015. serialize(serializationObject: any): void;
  35016. /**
  35017. * Adds all the elements from the container to the scene
  35018. * @param container the container holding the elements
  35019. */
  35020. addFromContainer(container: AbstractScene): void;
  35021. /**
  35022. * Removes all the elements in the container from the scene
  35023. * @param container contains the elements to remove
  35024. * @param dispose if the removed element should be disposed (default: false)
  35025. */
  35026. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35027. /**
  35028. * Disposes the component and the associated ressources.
  35029. */
  35030. dispose(): void;
  35031. /**
  35032. * Disables audio in the associated scene.
  35033. */
  35034. disableAudio(): void;
  35035. /**
  35036. * Enables audio in the associated scene.
  35037. */
  35038. enableAudio(): void;
  35039. /**
  35040. * Switch audio to headphone output.
  35041. */
  35042. switchAudioModeForHeadphones(): void;
  35043. /**
  35044. * Switch audio to normal speakers.
  35045. */
  35046. switchAudioModeForNormalSpeakers(): void;
  35047. private _cachedCameraDirection;
  35048. private _cachedCameraPosition;
  35049. private _lastCheck;
  35050. private _afterRender;
  35051. }
  35052. }
  35053. declare module BABYLON {
  35054. /**
  35055. * Wraps one or more Sound objects and selects one with random weight for playback.
  35056. */
  35057. export class WeightedSound {
  35058. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35059. loop: boolean;
  35060. private _coneInnerAngle;
  35061. private _coneOuterAngle;
  35062. private _volume;
  35063. /** A Sound is currently playing. */
  35064. isPlaying: boolean;
  35065. /** A Sound is currently paused. */
  35066. isPaused: boolean;
  35067. private _sounds;
  35068. private _weights;
  35069. private _currentIndex?;
  35070. /**
  35071. * Creates a new WeightedSound from the list of sounds given.
  35072. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35073. * @param sounds Array of Sounds that will be selected from.
  35074. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35075. */
  35076. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35077. /**
  35078. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35079. */
  35080. /**
  35081. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35082. */
  35083. directionalConeInnerAngle: number;
  35084. /**
  35085. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35086. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35087. */
  35088. /**
  35089. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35090. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35091. */
  35092. directionalConeOuterAngle: number;
  35093. /**
  35094. * Playback volume.
  35095. */
  35096. /**
  35097. * Playback volume.
  35098. */
  35099. volume: number;
  35100. private _onended;
  35101. /**
  35102. * Suspend playback
  35103. */
  35104. pause(): void;
  35105. /**
  35106. * Stop playback
  35107. */
  35108. stop(): void;
  35109. /**
  35110. * Start playback.
  35111. * @param startOffset Position the clip head at a specific time in seconds.
  35112. */
  35113. play(startOffset?: number): void;
  35114. }
  35115. }
  35116. declare module BABYLON {
  35117. /**
  35118. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35120. */
  35121. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35122. /**
  35123. * Gets the name of the behavior.
  35124. */
  35125. readonly name: string;
  35126. /**
  35127. * The easing function used by animations
  35128. */
  35129. static EasingFunction: BackEase;
  35130. /**
  35131. * The easing mode used by animations
  35132. */
  35133. static EasingMode: number;
  35134. /**
  35135. * The duration of the animation, in milliseconds
  35136. */
  35137. transitionDuration: number;
  35138. /**
  35139. * Length of the distance animated by the transition when lower radius is reached
  35140. */
  35141. lowerRadiusTransitionRange: number;
  35142. /**
  35143. * Length of the distance animated by the transition when upper radius is reached
  35144. */
  35145. upperRadiusTransitionRange: number;
  35146. private _autoTransitionRange;
  35147. /**
  35148. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35149. */
  35150. /**
  35151. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35152. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35153. */
  35154. autoTransitionRange: boolean;
  35155. private _attachedCamera;
  35156. private _onAfterCheckInputsObserver;
  35157. private _onMeshTargetChangedObserver;
  35158. /**
  35159. * Initializes the behavior.
  35160. */
  35161. init(): void;
  35162. /**
  35163. * Attaches the behavior to its arc rotate camera.
  35164. * @param camera Defines the camera to attach the behavior to
  35165. */
  35166. attach(camera: ArcRotateCamera): void;
  35167. /**
  35168. * Detaches the behavior from its current arc rotate camera.
  35169. */
  35170. detach(): void;
  35171. private _radiusIsAnimating;
  35172. private _radiusBounceTransition;
  35173. private _animatables;
  35174. private _cachedWheelPrecision;
  35175. /**
  35176. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35177. * @param radiusLimit The limit to check against.
  35178. * @return Bool to indicate if at limit.
  35179. */
  35180. private _isRadiusAtLimit;
  35181. /**
  35182. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35183. * @param radiusDelta The delta by which to animate to. Can be negative.
  35184. */
  35185. private _applyBoundRadiusAnimation;
  35186. /**
  35187. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35188. */
  35189. protected _clearAnimationLocks(): void;
  35190. /**
  35191. * Stops and removes all animations that have been applied to the camera
  35192. */
  35193. stopAllAnimations(): void;
  35194. }
  35195. }
  35196. declare module BABYLON {
  35197. /**
  35198. * 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.
  35199. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35200. */
  35201. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35202. /**
  35203. * Gets the name of the behavior.
  35204. */
  35205. readonly name: string;
  35206. private _mode;
  35207. private _radiusScale;
  35208. private _positionScale;
  35209. private _defaultElevation;
  35210. private _elevationReturnTime;
  35211. private _elevationReturnWaitTime;
  35212. private _zoomStopsAnimation;
  35213. private _framingTime;
  35214. /**
  35215. * The easing function used by animations
  35216. */
  35217. static EasingFunction: ExponentialEase;
  35218. /**
  35219. * The easing mode used by animations
  35220. */
  35221. static EasingMode: number;
  35222. /**
  35223. * Sets the current mode used by the behavior
  35224. */
  35225. /**
  35226. * Gets current mode used by the behavior.
  35227. */
  35228. mode: number;
  35229. /**
  35230. * Sets the scale applied to the radius (1 by default)
  35231. */
  35232. /**
  35233. * Gets the scale applied to the radius
  35234. */
  35235. radiusScale: number;
  35236. /**
  35237. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35238. */
  35239. /**
  35240. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35241. */
  35242. positionScale: number;
  35243. /**
  35244. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35245. * behaviour is triggered, in radians.
  35246. */
  35247. /**
  35248. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35249. * behaviour is triggered, in radians.
  35250. */
  35251. defaultElevation: number;
  35252. /**
  35253. * Sets the time (in milliseconds) taken to return to the default beta position.
  35254. * Negative value indicates camera should not return to default.
  35255. */
  35256. /**
  35257. * Gets the time (in milliseconds) taken to return to the default beta position.
  35258. * Negative value indicates camera should not return to default.
  35259. */
  35260. elevationReturnTime: number;
  35261. /**
  35262. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35263. */
  35264. /**
  35265. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35266. */
  35267. elevationReturnWaitTime: number;
  35268. /**
  35269. * Sets the flag that indicates if user zooming should stop animation.
  35270. */
  35271. /**
  35272. * Gets the flag that indicates if user zooming should stop animation.
  35273. */
  35274. zoomStopsAnimation: boolean;
  35275. /**
  35276. * Sets the transition time when framing the mesh, in milliseconds
  35277. */
  35278. /**
  35279. * Gets the transition time when framing the mesh, in milliseconds
  35280. */
  35281. framingTime: number;
  35282. /**
  35283. * Define if the behavior should automatically change the configured
  35284. * camera limits and sensibilities.
  35285. */
  35286. autoCorrectCameraLimitsAndSensibility: boolean;
  35287. private _onPrePointerObservableObserver;
  35288. private _onAfterCheckInputsObserver;
  35289. private _onMeshTargetChangedObserver;
  35290. private _attachedCamera;
  35291. private _isPointerDown;
  35292. private _lastInteractionTime;
  35293. /**
  35294. * Initializes the behavior.
  35295. */
  35296. init(): void;
  35297. /**
  35298. * Attaches the behavior to its arc rotate camera.
  35299. * @param camera Defines the camera to attach the behavior to
  35300. */
  35301. attach(camera: ArcRotateCamera): void;
  35302. /**
  35303. * Detaches the behavior from its current arc rotate camera.
  35304. */
  35305. detach(): void;
  35306. private _animatables;
  35307. private _betaIsAnimating;
  35308. private _betaTransition;
  35309. private _radiusTransition;
  35310. private _vectorTransition;
  35311. /**
  35312. * Targets the given mesh and updates zoom level accordingly.
  35313. * @param mesh The mesh to target.
  35314. * @param radius Optional. If a cached radius position already exists, overrides default.
  35315. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35316. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35317. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35318. */
  35319. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35320. /**
  35321. * Targets the given mesh with its children and updates zoom level accordingly.
  35322. * @param mesh The mesh to target.
  35323. * @param radius Optional. If a cached radius position already exists, overrides default.
  35324. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35325. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35326. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35327. */
  35328. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35329. /**
  35330. * Targets the given meshes with their children and updates zoom level accordingly.
  35331. * @param meshes The mesh to target.
  35332. * @param radius Optional. If a cached radius position already exists, overrides default.
  35333. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35334. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35335. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35336. */
  35337. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35338. /**
  35339. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35340. * @param minimumWorld Determines the smaller position of the bounding box extend
  35341. * @param maximumWorld Determines the bigger position of the bounding box extend
  35342. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35343. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35344. */
  35345. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35346. /**
  35347. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35348. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35349. * frustum width.
  35350. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35351. * to fully enclose the mesh in the viewing frustum.
  35352. */
  35353. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35354. /**
  35355. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35356. * is automatically returned to its default position (expected to be above ground plane).
  35357. */
  35358. private _maintainCameraAboveGround;
  35359. /**
  35360. * Returns the frustum slope based on the canvas ratio and camera FOV
  35361. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35362. */
  35363. private _getFrustumSlope;
  35364. /**
  35365. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35366. */
  35367. private _clearAnimationLocks;
  35368. /**
  35369. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35370. */
  35371. private _applyUserInteraction;
  35372. /**
  35373. * Stops and removes all animations that have been applied to the camera
  35374. */
  35375. stopAllAnimations(): void;
  35376. /**
  35377. * Gets a value indicating if the user is moving the camera
  35378. */
  35379. readonly isUserIsMoving: boolean;
  35380. /**
  35381. * The camera can move all the way towards the mesh.
  35382. */
  35383. static IgnoreBoundsSizeMode: number;
  35384. /**
  35385. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35386. */
  35387. static FitFrustumSidesMode: number;
  35388. }
  35389. }
  35390. declare module BABYLON {
  35391. /**
  35392. * Base class for Camera Pointer Inputs.
  35393. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35394. * for example usage.
  35395. */
  35396. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35397. /**
  35398. * Defines the camera the input is attached to.
  35399. */
  35400. abstract camera: Camera;
  35401. /**
  35402. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35403. */
  35404. protected _altKey: boolean;
  35405. protected _ctrlKey: boolean;
  35406. protected _metaKey: boolean;
  35407. protected _shiftKey: boolean;
  35408. /**
  35409. * Which mouse buttons were pressed at time of last mouse event.
  35410. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35411. */
  35412. protected _buttonsPressed: number;
  35413. /**
  35414. * Defines the buttons associated with the input to handle camera move.
  35415. */
  35416. buttons: number[];
  35417. /**
  35418. * Attach the input controls to a specific dom element to get the input from.
  35419. * @param element Defines the element the controls should be listened from
  35420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35421. */
  35422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35423. /**
  35424. * Detach the current controls from the specified dom element.
  35425. * @param element Defines the element to stop listening the inputs from
  35426. */
  35427. detachControl(element: Nullable<HTMLElement>): void;
  35428. /**
  35429. * Gets the class name of the current input.
  35430. * @returns the class name
  35431. */
  35432. getClassName(): string;
  35433. /**
  35434. * Get the friendly name associated with the input class.
  35435. * @returns the input friendly name
  35436. */
  35437. getSimpleName(): string;
  35438. /**
  35439. * Called on pointer POINTERDOUBLETAP event.
  35440. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35441. */
  35442. protected onDoubleTap(type: string): void;
  35443. /**
  35444. * Called on pointer POINTERMOVE event if only a single touch is active.
  35445. * Override this method to provide functionality.
  35446. */
  35447. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35448. /**
  35449. * Called on pointer POINTERMOVE event if multiple touches are active.
  35450. * Override this method to provide functionality.
  35451. */
  35452. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35453. /**
  35454. * Called on JS contextmenu event.
  35455. * Override this method to provide functionality.
  35456. */
  35457. protected onContextMenu(evt: PointerEvent): void;
  35458. /**
  35459. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35460. * press.
  35461. * Override this method to provide functionality.
  35462. */
  35463. protected onButtonDown(evt: PointerEvent): void;
  35464. /**
  35465. * Called each time a new POINTERUP event occurs. Ie, for each button
  35466. * release.
  35467. * Override this method to provide functionality.
  35468. */
  35469. protected onButtonUp(evt: PointerEvent): void;
  35470. /**
  35471. * Called when window becomes inactive.
  35472. * Override this method to provide functionality.
  35473. */
  35474. protected onLostFocus(): void;
  35475. private _pointerInput;
  35476. private _observer;
  35477. private _onLostFocus;
  35478. private pointA;
  35479. private pointB;
  35480. }
  35481. }
  35482. declare module BABYLON {
  35483. /**
  35484. * Manage the pointers inputs to control an arc rotate camera.
  35485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35486. */
  35487. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35488. /**
  35489. * Defines the camera the input is attached to.
  35490. */
  35491. camera: ArcRotateCamera;
  35492. /**
  35493. * Gets the class name of the current input.
  35494. * @returns the class name
  35495. */
  35496. getClassName(): string;
  35497. /**
  35498. * Defines the buttons associated with the input to handle camera move.
  35499. */
  35500. buttons: number[];
  35501. /**
  35502. * Defines the pointer angular sensibility along the X axis or how fast is
  35503. * the camera rotating.
  35504. */
  35505. angularSensibilityX: number;
  35506. /**
  35507. * Defines the pointer angular sensibility along the Y axis or how fast is
  35508. * the camera rotating.
  35509. */
  35510. angularSensibilityY: number;
  35511. /**
  35512. * Defines the pointer pinch precision or how fast is the camera zooming.
  35513. */
  35514. pinchPrecision: number;
  35515. /**
  35516. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35517. * from 0.
  35518. * It defines the percentage of current camera.radius to use as delta when
  35519. * pinch zoom is used.
  35520. */
  35521. pinchDeltaPercentage: number;
  35522. /**
  35523. * Defines the pointer panning sensibility or how fast is the camera moving.
  35524. */
  35525. panningSensibility: number;
  35526. /**
  35527. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35528. */
  35529. multiTouchPanning: boolean;
  35530. /**
  35531. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35532. * zoom (pinch) through multitouch.
  35533. */
  35534. multiTouchPanAndZoom: boolean;
  35535. /**
  35536. * Revers pinch action direction.
  35537. */
  35538. pinchInwards: boolean;
  35539. private _isPanClick;
  35540. private _twoFingerActivityCount;
  35541. private _isPinching;
  35542. /**
  35543. * Called on pointer POINTERMOVE event if only a single touch is active.
  35544. */
  35545. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35546. /**
  35547. * Called on pointer POINTERDOUBLETAP event.
  35548. */
  35549. protected onDoubleTap(type: string): void;
  35550. /**
  35551. * Called on pointer POINTERMOVE event if multiple touches are active.
  35552. */
  35553. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35554. /**
  35555. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35556. * press.
  35557. */
  35558. protected onButtonDown(evt: PointerEvent): void;
  35559. /**
  35560. * Called each time a new POINTERUP event occurs. Ie, for each button
  35561. * release.
  35562. */
  35563. protected onButtonUp(evt: PointerEvent): void;
  35564. /**
  35565. * Called when window becomes inactive.
  35566. */
  35567. protected onLostFocus(): void;
  35568. }
  35569. }
  35570. declare module BABYLON {
  35571. /**
  35572. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35574. */
  35575. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35576. /**
  35577. * Defines the camera the input is attached to.
  35578. */
  35579. camera: ArcRotateCamera;
  35580. /**
  35581. * Defines the list of key codes associated with the up action (increase alpha)
  35582. */
  35583. keysUp: number[];
  35584. /**
  35585. * Defines the list of key codes associated with the down action (decrease alpha)
  35586. */
  35587. keysDown: number[];
  35588. /**
  35589. * Defines the list of key codes associated with the left action (increase beta)
  35590. */
  35591. keysLeft: number[];
  35592. /**
  35593. * Defines the list of key codes associated with the right action (decrease beta)
  35594. */
  35595. keysRight: number[];
  35596. /**
  35597. * Defines the list of key codes associated with the reset action.
  35598. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35599. */
  35600. keysReset: number[];
  35601. /**
  35602. * Defines the panning sensibility of the inputs.
  35603. * (How fast is the camera paning)
  35604. */
  35605. panningSensibility: number;
  35606. /**
  35607. * Defines the zooming sensibility of the inputs.
  35608. * (How fast is the camera zooming)
  35609. */
  35610. zoomingSensibility: number;
  35611. /**
  35612. * Defines wether maintaining the alt key down switch the movement mode from
  35613. * orientation to zoom.
  35614. */
  35615. useAltToZoom: boolean;
  35616. /**
  35617. * Rotation speed of the camera
  35618. */
  35619. angularSpeed: number;
  35620. private _keys;
  35621. private _ctrlPressed;
  35622. private _altPressed;
  35623. private _onCanvasBlurObserver;
  35624. private _onKeyboardObserver;
  35625. private _engine;
  35626. private _scene;
  35627. /**
  35628. * Attach the input controls to a specific dom element to get the input from.
  35629. * @param element Defines the element the controls should be listened from
  35630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35631. */
  35632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35633. /**
  35634. * Detach the current controls from the specified dom element.
  35635. * @param element Defines the element to stop listening the inputs from
  35636. */
  35637. detachControl(element: Nullable<HTMLElement>): void;
  35638. /**
  35639. * Update the current camera state depending on the inputs that have been used this frame.
  35640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35641. */
  35642. checkInputs(): void;
  35643. /**
  35644. * Gets the class name of the current intput.
  35645. * @returns the class name
  35646. */
  35647. getClassName(): string;
  35648. /**
  35649. * Get the friendly name associated with the input class.
  35650. * @returns the input friendly name
  35651. */
  35652. getSimpleName(): string;
  35653. }
  35654. }
  35655. declare module BABYLON {
  35656. /**
  35657. * Manage the mouse wheel inputs to control an arc rotate camera.
  35658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35659. */
  35660. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35661. /**
  35662. * Defines the camera the input is attached to.
  35663. */
  35664. camera: ArcRotateCamera;
  35665. /**
  35666. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35667. */
  35668. wheelPrecision: number;
  35669. /**
  35670. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35671. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35672. */
  35673. wheelDeltaPercentage: number;
  35674. private _wheel;
  35675. private _observer;
  35676. private computeDeltaFromMouseWheelLegacyEvent;
  35677. /**
  35678. * Attach the input controls to a specific dom element to get the input from.
  35679. * @param element Defines the element the controls should be listened from
  35680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35681. */
  35682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35683. /**
  35684. * Detach the current controls from the specified dom element.
  35685. * @param element Defines the element to stop listening the inputs from
  35686. */
  35687. detachControl(element: Nullable<HTMLElement>): void;
  35688. /**
  35689. * Gets the class name of the current intput.
  35690. * @returns the class name
  35691. */
  35692. getClassName(): string;
  35693. /**
  35694. * Get the friendly name associated with the input class.
  35695. * @returns the input friendly name
  35696. */
  35697. getSimpleName(): string;
  35698. }
  35699. }
  35700. declare module BABYLON {
  35701. /**
  35702. * Default Inputs manager for the ArcRotateCamera.
  35703. * It groups all the default supported inputs for ease of use.
  35704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35705. */
  35706. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35707. /**
  35708. * Instantiates a new ArcRotateCameraInputsManager.
  35709. * @param camera Defines the camera the inputs belong to
  35710. */
  35711. constructor(camera: ArcRotateCamera);
  35712. /**
  35713. * Add mouse wheel input support to the input manager.
  35714. * @returns the current input manager
  35715. */
  35716. addMouseWheel(): ArcRotateCameraInputsManager;
  35717. /**
  35718. * Add pointers input support to the input manager.
  35719. * @returns the current input manager
  35720. */
  35721. addPointers(): ArcRotateCameraInputsManager;
  35722. /**
  35723. * Add keyboard input support to the input manager.
  35724. * @returns the current input manager
  35725. */
  35726. addKeyboard(): ArcRotateCameraInputsManager;
  35727. }
  35728. }
  35729. declare module BABYLON {
  35730. /**
  35731. * This represents an orbital type of camera.
  35732. *
  35733. * 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.
  35734. * 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.
  35735. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35736. */
  35737. export class ArcRotateCamera extends TargetCamera {
  35738. /**
  35739. * Defines the rotation angle of the camera along the longitudinal axis.
  35740. */
  35741. alpha: number;
  35742. /**
  35743. * Defines the rotation angle of the camera along the latitudinal axis.
  35744. */
  35745. beta: number;
  35746. /**
  35747. * Defines the radius of the camera from it s target point.
  35748. */
  35749. radius: number;
  35750. protected _target: Vector3;
  35751. protected _targetHost: Nullable<AbstractMesh>;
  35752. /**
  35753. * Defines the target point of the camera.
  35754. * The camera looks towards it form the radius distance.
  35755. */
  35756. target: Vector3;
  35757. /**
  35758. * Define the current local position of the camera in the scene
  35759. */
  35760. position: Vector3;
  35761. protected _upVector: Vector3;
  35762. protected _upToYMatrix: Matrix;
  35763. protected _YToUpMatrix: Matrix;
  35764. /**
  35765. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35766. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35767. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35768. */
  35769. upVector: Vector3;
  35770. /**
  35771. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35772. */
  35773. setMatUp(): void;
  35774. /**
  35775. * Current inertia value on the longitudinal axis.
  35776. * The bigger this number the longer it will take for the camera to stop.
  35777. */
  35778. inertialAlphaOffset: number;
  35779. /**
  35780. * Current inertia value on the latitudinal axis.
  35781. * The bigger this number the longer it will take for the camera to stop.
  35782. */
  35783. inertialBetaOffset: number;
  35784. /**
  35785. * Current inertia value on the radius axis.
  35786. * The bigger this number the longer it will take for the camera to stop.
  35787. */
  35788. inertialRadiusOffset: number;
  35789. /**
  35790. * Minimum allowed angle on the longitudinal axis.
  35791. * This can help limiting how the Camera is able to move in the scene.
  35792. */
  35793. lowerAlphaLimit: Nullable<number>;
  35794. /**
  35795. * Maximum allowed angle on the longitudinal axis.
  35796. * This can help limiting how the Camera is able to move in the scene.
  35797. */
  35798. upperAlphaLimit: Nullable<number>;
  35799. /**
  35800. * Minimum allowed angle on the latitudinal axis.
  35801. * This can help limiting how the Camera is able to move in the scene.
  35802. */
  35803. lowerBetaLimit: number;
  35804. /**
  35805. * Maximum allowed angle on the latitudinal axis.
  35806. * This can help limiting how the Camera is able to move in the scene.
  35807. */
  35808. upperBetaLimit: number;
  35809. /**
  35810. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35811. * This can help limiting how the Camera is able to move in the scene.
  35812. */
  35813. lowerRadiusLimit: Nullable<number>;
  35814. /**
  35815. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35816. * This can help limiting how the Camera is able to move in the scene.
  35817. */
  35818. upperRadiusLimit: Nullable<number>;
  35819. /**
  35820. * Defines the current inertia value used during panning of the camera along the X axis.
  35821. */
  35822. inertialPanningX: number;
  35823. /**
  35824. * Defines the current inertia value used during panning of the camera along the Y axis.
  35825. */
  35826. inertialPanningY: number;
  35827. /**
  35828. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35829. * Basically if your fingers moves away from more than this distance you will be considered
  35830. * in pinch mode.
  35831. */
  35832. pinchToPanMaxDistance: number;
  35833. /**
  35834. * Defines the maximum distance the camera can pan.
  35835. * This could help keeping the cammera always in your scene.
  35836. */
  35837. panningDistanceLimit: Nullable<number>;
  35838. /**
  35839. * Defines the target of the camera before paning.
  35840. */
  35841. panningOriginTarget: Vector3;
  35842. /**
  35843. * Defines the value of the inertia used during panning.
  35844. * 0 would mean stop inertia and one would mean no decelleration at all.
  35845. */
  35846. panningInertia: number;
  35847. /**
  35848. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35849. */
  35850. angularSensibilityX: number;
  35851. /**
  35852. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35853. */
  35854. angularSensibilityY: number;
  35855. /**
  35856. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35857. */
  35858. pinchPrecision: number;
  35859. /**
  35860. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35861. * It will be used instead of pinchDeltaPrecision if different from 0.
  35862. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35863. */
  35864. pinchDeltaPercentage: number;
  35865. /**
  35866. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35867. */
  35868. panningSensibility: number;
  35869. /**
  35870. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35871. */
  35872. keysUp: number[];
  35873. /**
  35874. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35875. */
  35876. keysDown: number[];
  35877. /**
  35878. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35879. */
  35880. keysLeft: number[];
  35881. /**
  35882. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35883. */
  35884. keysRight: number[];
  35885. /**
  35886. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35887. */
  35888. wheelPrecision: number;
  35889. /**
  35890. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35891. * It will be used instead of pinchDeltaPrecision if different from 0.
  35892. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35893. */
  35894. wheelDeltaPercentage: number;
  35895. /**
  35896. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35897. */
  35898. zoomOnFactor: number;
  35899. /**
  35900. * Defines a screen offset for the camera position.
  35901. */
  35902. targetScreenOffset: Vector2;
  35903. /**
  35904. * Allows the camera to be completely reversed.
  35905. * If false the camera can not arrive upside down.
  35906. */
  35907. allowUpsideDown: boolean;
  35908. /**
  35909. * Define if double tap/click is used to restore the previously saved state of the camera.
  35910. */
  35911. useInputToRestoreState: boolean;
  35912. /** @hidden */ private _viewMatrix: Matrix;
  35913. /** @hidden */ private _useCtrlForPanning: boolean;
  35914. /** @hidden */ private _panningMouseButton: number;
  35915. /**
  35916. * Defines the input associated to the camera.
  35917. */
  35918. inputs: ArcRotateCameraInputsManager;
  35919. /** @hidden */ private _reset: () => void;
  35920. /**
  35921. * Defines the allowed panning axis.
  35922. */
  35923. panningAxis: Vector3;
  35924. protected _localDirection: Vector3;
  35925. protected _transformedDirection: Vector3;
  35926. private _bouncingBehavior;
  35927. /**
  35928. * Gets the bouncing behavior of the camera if it has been enabled.
  35929. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35930. */
  35931. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35932. /**
  35933. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35935. */
  35936. useBouncingBehavior: boolean;
  35937. private _framingBehavior;
  35938. /**
  35939. * Gets the framing behavior of the camera if it has been enabled.
  35940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35941. */
  35942. readonly framingBehavior: Nullable<FramingBehavior>;
  35943. /**
  35944. * Defines if the framing behavior of the camera is enabled on the camera.
  35945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35946. */
  35947. useFramingBehavior: boolean;
  35948. private _autoRotationBehavior;
  35949. /**
  35950. * Gets the auto rotation behavior of the camera if it has been enabled.
  35951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35952. */
  35953. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35954. /**
  35955. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35956. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35957. */
  35958. useAutoRotationBehavior: boolean;
  35959. /**
  35960. * Observable triggered when the mesh target has been changed on the camera.
  35961. */
  35962. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35963. /**
  35964. * Event raised when the camera is colliding with a mesh.
  35965. */
  35966. onCollide: (collidedMesh: AbstractMesh) => void;
  35967. /**
  35968. * Defines whether the camera should check collision with the objects oh the scene.
  35969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35970. */
  35971. checkCollisions: boolean;
  35972. /**
  35973. * Defines the collision radius of the camera.
  35974. * This simulates a sphere around the camera.
  35975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35976. */
  35977. collisionRadius: Vector3;
  35978. protected _collider: Collider;
  35979. protected _previousPosition: Vector3;
  35980. protected _collisionVelocity: Vector3;
  35981. protected _newPosition: Vector3;
  35982. protected _previousAlpha: number;
  35983. protected _previousBeta: number;
  35984. protected _previousRadius: number;
  35985. protected _collisionTriggered: boolean;
  35986. protected _targetBoundingCenter: Nullable<Vector3>;
  35987. private _computationVector;
  35988. /**
  35989. * Instantiates a new ArcRotateCamera in a given scene
  35990. * @param name Defines the name of the camera
  35991. * @param alpha Defines the camera rotation along the logitudinal axis
  35992. * @param beta Defines the camera rotation along the latitudinal axis
  35993. * @param radius Defines the camera distance from its target
  35994. * @param target Defines the camera target
  35995. * @param scene Defines the scene the camera belongs to
  35996. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35997. */
  35998. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35999. /** @hidden */ private _initCache(): void;
  36000. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  36001. protected _getTargetPosition(): Vector3;
  36002. private _storedAlpha;
  36003. private _storedBeta;
  36004. private _storedRadius;
  36005. private _storedTarget;
  36006. private _storedTargetScreenOffset;
  36007. /**
  36008. * Stores the current state of the camera (alpha, beta, radius and target)
  36009. * @returns the camera itself
  36010. */
  36011. storeState(): Camera;
  36012. /**
  36013. * @hidden
  36014. * Restored camera state. You must call storeState() first
  36015. */ private _restoreStateValues(): boolean;
  36016. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  36017. /**
  36018. * Attached controls to the current camera.
  36019. * @param element Defines the element the controls should be listened from
  36020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36021. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36022. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36023. */
  36024. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36025. /**
  36026. * Detach the current controls from the camera.
  36027. * The camera will stop reacting to inputs.
  36028. * @param element Defines the element to stop listening the inputs from
  36029. */
  36030. detachControl(element: HTMLElement): void;
  36031. /** @hidden */ private _checkInputs(): void;
  36032. protected _checkLimits(): void;
  36033. /**
  36034. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36035. */
  36036. rebuildAnglesAndRadius(): void;
  36037. /**
  36038. * Use a position to define the current camera related information like alpha, beta and radius
  36039. * @param position Defines the position to set the camera at
  36040. */
  36041. setPosition(position: Vector3): void;
  36042. /**
  36043. * Defines the target the camera should look at.
  36044. * This will automatically adapt alpha beta and radius to fit within the new target.
  36045. * @param target Defines the new target as a Vector or a mesh
  36046. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36047. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36048. */
  36049. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36050. /** @hidden */ private _getViewMatrix(): Matrix;
  36051. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36052. /**
  36053. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36054. * @param meshes Defines the mesh to zoom on
  36055. * @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)
  36056. */
  36057. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36058. /**
  36059. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36060. * The target will be changed but the radius
  36061. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36062. * @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)
  36063. */
  36064. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36065. min: Vector3;
  36066. max: Vector3;
  36067. distance: number;
  36068. }, doNotUpdateMaxZ?: boolean): void;
  36069. /**
  36070. * @override
  36071. * Override Camera.createRigCamera
  36072. */
  36073. createRigCamera(name: string, cameraIndex: number): Camera;
  36074. /**
  36075. * @hidden
  36076. * @override
  36077. * Override Camera._updateRigCameras
  36078. */ private _updateRigCameras(): void;
  36079. /**
  36080. * Destroy the camera and release the current resources hold by it.
  36081. */
  36082. dispose(): void;
  36083. /**
  36084. * Gets the current object class name.
  36085. * @return the class name
  36086. */
  36087. getClassName(): string;
  36088. }
  36089. }
  36090. declare module BABYLON {
  36091. /**
  36092. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36093. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36094. */
  36095. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36096. /**
  36097. * Gets the name of the behavior.
  36098. */
  36099. readonly name: string;
  36100. private _zoomStopsAnimation;
  36101. private _idleRotationSpeed;
  36102. private _idleRotationWaitTime;
  36103. private _idleRotationSpinupTime;
  36104. /**
  36105. * Sets the flag that indicates if user zooming should stop animation.
  36106. */
  36107. /**
  36108. * Gets the flag that indicates if user zooming should stop animation.
  36109. */
  36110. zoomStopsAnimation: boolean;
  36111. /**
  36112. * Sets the default speed at which the camera rotates around the model.
  36113. */
  36114. /**
  36115. * Gets the default speed at which the camera rotates around the model.
  36116. */
  36117. idleRotationSpeed: number;
  36118. /**
  36119. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36120. */
  36121. /**
  36122. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36123. */
  36124. idleRotationWaitTime: number;
  36125. /**
  36126. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36127. */
  36128. /**
  36129. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36130. */
  36131. idleRotationSpinupTime: number;
  36132. /**
  36133. * Gets a value indicating if the camera is currently rotating because of this behavior
  36134. */
  36135. readonly rotationInProgress: boolean;
  36136. private _onPrePointerObservableObserver;
  36137. private _onAfterCheckInputsObserver;
  36138. private _attachedCamera;
  36139. private _isPointerDown;
  36140. private _lastFrameTime;
  36141. private _lastInteractionTime;
  36142. private _cameraRotationSpeed;
  36143. /**
  36144. * Initializes the behavior.
  36145. */
  36146. init(): void;
  36147. /**
  36148. * Attaches the behavior to its arc rotate camera.
  36149. * @param camera Defines the camera to attach the behavior to
  36150. */
  36151. attach(camera: ArcRotateCamera): void;
  36152. /**
  36153. * Detaches the behavior from its current arc rotate camera.
  36154. */
  36155. detach(): void;
  36156. /**
  36157. * Returns true if user is scrolling.
  36158. * @return true if user is scrolling.
  36159. */
  36160. private _userIsZooming;
  36161. private _lastFrameRadius;
  36162. private _shouldAnimationStopForInteraction;
  36163. /**
  36164. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36165. */
  36166. private _applyUserInteraction;
  36167. private _userIsMoving;
  36168. }
  36169. }
  36170. declare module BABYLON {
  36171. /**
  36172. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36173. */
  36174. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36175. private ui;
  36176. /**
  36177. * The name of the behavior
  36178. */
  36179. name: string;
  36180. /**
  36181. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36182. */
  36183. distanceAwayFromFace: number;
  36184. /**
  36185. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36186. */
  36187. distanceAwayFromBottomOfFace: number;
  36188. private _faceVectors;
  36189. private _target;
  36190. private _scene;
  36191. private _onRenderObserver;
  36192. private _tmpMatrix;
  36193. private _tmpVector;
  36194. /**
  36195. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36196. * @param ui The transform node that should be attched to the mesh
  36197. */
  36198. constructor(ui: TransformNode);
  36199. /**
  36200. * Initializes the behavior
  36201. */
  36202. init(): void;
  36203. private _closestFace;
  36204. private _zeroVector;
  36205. private _lookAtTmpMatrix;
  36206. private _lookAtToRef;
  36207. /**
  36208. * Attaches the AttachToBoxBehavior to the passed in mesh
  36209. * @param target The mesh that the specified node will be attached to
  36210. */
  36211. attach(target: Mesh): void;
  36212. /**
  36213. * Detaches the behavior from the mesh
  36214. */
  36215. detach(): void;
  36216. }
  36217. }
  36218. declare module BABYLON {
  36219. /**
  36220. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36221. */
  36222. export class FadeInOutBehavior implements Behavior<Mesh> {
  36223. /**
  36224. * Time in milliseconds to delay before fading in (Default: 0)
  36225. */
  36226. delay: number;
  36227. /**
  36228. * Time in milliseconds for the mesh to fade in (Default: 300)
  36229. */
  36230. fadeInTime: number;
  36231. private _millisecondsPerFrame;
  36232. private _hovered;
  36233. private _hoverValue;
  36234. private _ownerNode;
  36235. /**
  36236. * Instatiates the FadeInOutBehavior
  36237. */
  36238. constructor();
  36239. /**
  36240. * The name of the behavior
  36241. */
  36242. readonly name: string;
  36243. /**
  36244. * Initializes the behavior
  36245. */
  36246. init(): void;
  36247. /**
  36248. * Attaches the fade behavior on the passed in mesh
  36249. * @param ownerNode The mesh that will be faded in/out once attached
  36250. */
  36251. attach(ownerNode: Mesh): void;
  36252. /**
  36253. * Detaches the behavior from the mesh
  36254. */
  36255. detach(): void;
  36256. /**
  36257. * Triggers the mesh to begin fading in or out
  36258. * @param value if the object should fade in or out (true to fade in)
  36259. */
  36260. fadeIn(value: boolean): void;
  36261. private _update;
  36262. private _setAllVisibility;
  36263. }
  36264. }
  36265. declare module BABYLON {
  36266. /**
  36267. * Class containing a set of static utilities functions for managing Pivots
  36268. * @hidden
  36269. */
  36270. export class PivotTools {
  36271. private static _PivotCached;
  36272. private static _OldPivotPoint;
  36273. private static _PivotTranslation;
  36274. private static _PivotTmpVector;
  36275. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36276. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  36277. }
  36278. }
  36279. declare module BABYLON {
  36280. /**
  36281. * Class containing static functions to help procedurally build meshes
  36282. */
  36283. export class PlaneBuilder {
  36284. /**
  36285. * Creates a plane mesh
  36286. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36287. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36288. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36290. * * 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
  36291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36292. * @param name defines the name of the mesh
  36293. * @param options defines the options used to create the mesh
  36294. * @param scene defines the hosting scene
  36295. * @returns the plane mesh
  36296. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36297. */
  36298. static CreatePlane(name: string, options: {
  36299. size?: number;
  36300. width?: number;
  36301. height?: number;
  36302. sideOrientation?: number;
  36303. frontUVs?: Vector4;
  36304. backUVs?: Vector4;
  36305. updatable?: boolean;
  36306. sourcePlane?: Plane;
  36307. }, scene?: Nullable<Scene>): Mesh;
  36308. }
  36309. }
  36310. declare module BABYLON {
  36311. /**
  36312. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36313. */
  36314. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36315. private static _AnyMouseID;
  36316. /**
  36317. * Abstract mesh the behavior is set on
  36318. */
  36319. attachedNode: AbstractMesh;
  36320. private _dragPlane;
  36321. private _scene;
  36322. private _pointerObserver;
  36323. private _beforeRenderObserver;
  36324. private static _planeScene;
  36325. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36326. /**
  36327. * 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)
  36328. */
  36329. maxDragAngle: number;
  36330. /**
  36331. * @hidden
  36332. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36333. /**
  36334. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36335. */
  36336. currentDraggingPointerID: number;
  36337. /**
  36338. * The last position where the pointer hit the drag plane in world space
  36339. */
  36340. lastDragPosition: Vector3;
  36341. /**
  36342. * If the behavior is currently in a dragging state
  36343. */
  36344. dragging: boolean;
  36345. /**
  36346. * 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)
  36347. */
  36348. dragDeltaRatio: number;
  36349. /**
  36350. * If the drag plane orientation should be updated during the dragging (Default: true)
  36351. */
  36352. updateDragPlane: boolean;
  36353. private _debugMode;
  36354. private _moving;
  36355. /**
  36356. * Fires each time the attached mesh is dragged with the pointer
  36357. * * delta between last drag position and current drag position in world space
  36358. * * dragDistance along the drag axis
  36359. * * dragPlaneNormal normal of the current drag plane used during the drag
  36360. * * dragPlanePoint in world space where the drag intersects the drag plane
  36361. */
  36362. onDragObservable: Observable<{
  36363. delta: Vector3;
  36364. dragPlanePoint: Vector3;
  36365. dragPlaneNormal: Vector3;
  36366. dragDistance: number;
  36367. pointerId: number;
  36368. }>;
  36369. /**
  36370. * Fires each time a drag begins (eg. mouse down on mesh)
  36371. */
  36372. onDragStartObservable: Observable<{
  36373. dragPlanePoint: Vector3;
  36374. pointerId: number;
  36375. }>;
  36376. /**
  36377. * Fires each time a drag ends (eg. mouse release after drag)
  36378. */
  36379. onDragEndObservable: Observable<{
  36380. dragPlanePoint: Vector3;
  36381. pointerId: number;
  36382. }>;
  36383. /**
  36384. * If the attached mesh should be moved when dragged
  36385. */
  36386. moveAttached: boolean;
  36387. /**
  36388. * If the drag behavior will react to drag events (Default: true)
  36389. */
  36390. enabled: boolean;
  36391. /**
  36392. * If pointer events should start and release the drag (Default: true)
  36393. */
  36394. startAndReleaseDragOnPointerEvents: boolean;
  36395. /**
  36396. * If camera controls should be detached during the drag
  36397. */
  36398. detachCameraControls: boolean;
  36399. /**
  36400. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36401. */
  36402. useObjectOrienationForDragging: boolean;
  36403. private _options;
  36404. /**
  36405. * Creates a pointer drag behavior that can be attached to a mesh
  36406. * @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)
  36407. */
  36408. constructor(options?: {
  36409. dragAxis?: Vector3;
  36410. dragPlaneNormal?: Vector3;
  36411. });
  36412. /**
  36413. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36414. */
  36415. validateDrag: (targetPosition: Vector3) => boolean;
  36416. /**
  36417. * The name of the behavior
  36418. */
  36419. readonly name: string;
  36420. /**
  36421. * Initializes the behavior
  36422. */
  36423. init(): void;
  36424. private _tmpVector;
  36425. private _alternatePickedPoint;
  36426. private _worldDragAxis;
  36427. private _targetPosition;
  36428. private _attachedElement;
  36429. /**
  36430. * Attaches the drag behavior the passed in mesh
  36431. * @param ownerNode The mesh that will be dragged around once attached
  36432. * @param predicate Predicate to use for pick filtering
  36433. */
  36434. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36435. /**
  36436. * Force relase the drag action by code.
  36437. */
  36438. releaseDrag(): void;
  36439. private _startDragRay;
  36440. private _lastPointerRay;
  36441. /**
  36442. * Simulates the start of a pointer drag event on the behavior
  36443. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36444. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36445. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36446. */
  36447. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36448. private _startDrag;
  36449. private _dragDelta;
  36450. private _moveDrag;
  36451. private _pickWithRayOnDragPlane;
  36452. private _pointA;
  36453. private _pointB;
  36454. private _pointC;
  36455. private _lineA;
  36456. private _lineB;
  36457. private _localAxis;
  36458. private _lookAt;
  36459. private _updateDragPlanePosition;
  36460. /**
  36461. * Detaches the behavior from the mesh
  36462. */
  36463. detach(): void;
  36464. }
  36465. }
  36466. declare module BABYLON {
  36467. /**
  36468. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36469. */
  36470. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36471. private _dragBehaviorA;
  36472. private _dragBehaviorB;
  36473. private _startDistance;
  36474. private _initialScale;
  36475. private _targetScale;
  36476. private _ownerNode;
  36477. private _sceneRenderObserver;
  36478. /**
  36479. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36480. */
  36481. constructor();
  36482. /**
  36483. * The name of the behavior
  36484. */
  36485. readonly name: string;
  36486. /**
  36487. * Initializes the behavior
  36488. */
  36489. init(): void;
  36490. private _getCurrentDistance;
  36491. /**
  36492. * Attaches the scale behavior the passed in mesh
  36493. * @param ownerNode The mesh that will be scaled around once attached
  36494. */
  36495. attach(ownerNode: Mesh): void;
  36496. /**
  36497. * Detaches the behavior from the mesh
  36498. */
  36499. detach(): void;
  36500. }
  36501. }
  36502. declare module BABYLON {
  36503. /**
  36504. * 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
  36505. */
  36506. export class SixDofDragBehavior implements Behavior<Mesh> {
  36507. private static _virtualScene;
  36508. private _ownerNode;
  36509. private _sceneRenderObserver;
  36510. private _scene;
  36511. private _targetPosition;
  36512. private _virtualOriginMesh;
  36513. private _virtualDragMesh;
  36514. private _pointerObserver;
  36515. private _moving;
  36516. private _startingOrientation;
  36517. /**
  36518. * 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)
  36519. */
  36520. private zDragFactor;
  36521. /**
  36522. * If the object should rotate to face the drag origin
  36523. */
  36524. rotateDraggedObject: boolean;
  36525. /**
  36526. * If the behavior is currently in a dragging state
  36527. */
  36528. dragging: boolean;
  36529. /**
  36530. * 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)
  36531. */
  36532. dragDeltaRatio: number;
  36533. /**
  36534. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36535. */
  36536. currentDraggingPointerID: number;
  36537. /**
  36538. * If camera controls should be detached during the drag
  36539. */
  36540. detachCameraControls: boolean;
  36541. /**
  36542. * Fires each time a drag starts
  36543. */
  36544. onDragStartObservable: Observable<{}>;
  36545. /**
  36546. * Fires each time a drag ends (eg. mouse release after drag)
  36547. */
  36548. onDragEndObservable: Observable<{}>;
  36549. /**
  36550. * 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
  36551. */
  36552. constructor();
  36553. /**
  36554. * The name of the behavior
  36555. */
  36556. readonly name: string;
  36557. /**
  36558. * Initializes the behavior
  36559. */
  36560. init(): void;
  36561. /**
  36562. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36563. */
  36564. private readonly _pointerCamera;
  36565. /**
  36566. * Attaches the scale behavior the passed in mesh
  36567. * @param ownerNode The mesh that will be scaled around once attached
  36568. */
  36569. attach(ownerNode: Mesh): void;
  36570. /**
  36571. * Detaches the behavior from the mesh
  36572. */
  36573. detach(): void;
  36574. }
  36575. }
  36576. declare module BABYLON {
  36577. /**
  36578. * Class used to apply inverse kinematics to bones
  36579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36580. */
  36581. export class BoneIKController {
  36582. private static _tmpVecs;
  36583. private static _tmpQuat;
  36584. private static _tmpMats;
  36585. /**
  36586. * Gets or sets the target mesh
  36587. */
  36588. targetMesh: AbstractMesh;
  36589. /** Gets or sets the mesh used as pole */
  36590. poleTargetMesh: AbstractMesh;
  36591. /**
  36592. * Gets or sets the bone used as pole
  36593. */
  36594. poleTargetBone: Nullable<Bone>;
  36595. /**
  36596. * Gets or sets the target position
  36597. */
  36598. targetPosition: Vector3;
  36599. /**
  36600. * Gets or sets the pole target position
  36601. */
  36602. poleTargetPosition: Vector3;
  36603. /**
  36604. * Gets or sets the pole target local offset
  36605. */
  36606. poleTargetLocalOffset: Vector3;
  36607. /**
  36608. * Gets or sets the pole angle
  36609. */
  36610. poleAngle: number;
  36611. /**
  36612. * Gets or sets the mesh associated with the controller
  36613. */
  36614. mesh: AbstractMesh;
  36615. /**
  36616. * 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)
  36617. */
  36618. slerpAmount: number;
  36619. private _bone1Quat;
  36620. private _bone1Mat;
  36621. private _bone2Ang;
  36622. private _bone1;
  36623. private _bone2;
  36624. private _bone1Length;
  36625. private _bone2Length;
  36626. private _maxAngle;
  36627. private _maxReach;
  36628. private _rightHandedSystem;
  36629. private _bendAxis;
  36630. private _slerping;
  36631. private _adjustRoll;
  36632. /**
  36633. * Gets or sets maximum allowed angle
  36634. */
  36635. maxAngle: number;
  36636. /**
  36637. * Creates a new BoneIKController
  36638. * @param mesh defines the mesh to control
  36639. * @param bone defines the bone to control
  36640. * @param options defines options to set up the controller
  36641. */
  36642. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36643. targetMesh?: AbstractMesh;
  36644. poleTargetMesh?: AbstractMesh;
  36645. poleTargetBone?: Bone;
  36646. poleTargetLocalOffset?: Vector3;
  36647. poleAngle?: number;
  36648. bendAxis?: Vector3;
  36649. maxAngle?: number;
  36650. slerpAmount?: number;
  36651. });
  36652. private _setMaxAngle;
  36653. /**
  36654. * Force the controller to update the bones
  36655. */
  36656. update(): void;
  36657. }
  36658. }
  36659. declare module BABYLON {
  36660. /**
  36661. * Class used to make a bone look toward a point in space
  36662. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36663. */
  36664. export class BoneLookController {
  36665. private static _tmpVecs;
  36666. private static _tmpQuat;
  36667. private static _tmpMats;
  36668. /**
  36669. * The target Vector3 that the bone will look at
  36670. */
  36671. target: Vector3;
  36672. /**
  36673. * The mesh that the bone is attached to
  36674. */
  36675. mesh: AbstractMesh;
  36676. /**
  36677. * The bone that will be looking to the target
  36678. */
  36679. bone: Bone;
  36680. /**
  36681. * The up axis of the coordinate system that is used when the bone is rotated
  36682. */
  36683. upAxis: Vector3;
  36684. /**
  36685. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36686. */
  36687. upAxisSpace: Space;
  36688. /**
  36689. * Used to make an adjustment to the yaw of the bone
  36690. */
  36691. adjustYaw: number;
  36692. /**
  36693. * Used to make an adjustment to the pitch of the bone
  36694. */
  36695. adjustPitch: number;
  36696. /**
  36697. * Used to make an adjustment to the roll of the bone
  36698. */
  36699. adjustRoll: number;
  36700. /**
  36701. * 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)
  36702. */
  36703. slerpAmount: number;
  36704. private _minYaw;
  36705. private _maxYaw;
  36706. private _minPitch;
  36707. private _maxPitch;
  36708. private _minYawSin;
  36709. private _minYawCos;
  36710. private _maxYawSin;
  36711. private _maxYawCos;
  36712. private _midYawConstraint;
  36713. private _minPitchTan;
  36714. private _maxPitchTan;
  36715. private _boneQuat;
  36716. private _slerping;
  36717. private _transformYawPitch;
  36718. private _transformYawPitchInv;
  36719. private _firstFrameSkipped;
  36720. private _yawRange;
  36721. private _fowardAxis;
  36722. /**
  36723. * Gets or sets the minimum yaw angle that the bone can look to
  36724. */
  36725. minYaw: number;
  36726. /**
  36727. * Gets or sets the maximum yaw angle that the bone can look to
  36728. */
  36729. maxYaw: number;
  36730. /**
  36731. * Gets or sets the minimum pitch angle that the bone can look to
  36732. */
  36733. minPitch: number;
  36734. /**
  36735. * Gets or sets the maximum pitch angle that the bone can look to
  36736. */
  36737. maxPitch: number;
  36738. /**
  36739. * Create a BoneLookController
  36740. * @param mesh the mesh that the bone belongs to
  36741. * @param bone the bone that will be looking to the target
  36742. * @param target the target Vector3 to look at
  36743. * @param options optional settings:
  36744. * * maxYaw: the maximum angle the bone will yaw to
  36745. * * minYaw: the minimum angle the bone will yaw to
  36746. * * maxPitch: the maximum angle the bone will pitch to
  36747. * * minPitch: the minimum angle the bone will yaw to
  36748. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36749. * * upAxis: the up axis of the coordinate system
  36750. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36751. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36752. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36753. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36754. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36755. * * adjustRoll: used to make an adjustment to the roll of the bone
  36756. **/
  36757. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36758. maxYaw?: number;
  36759. minYaw?: number;
  36760. maxPitch?: number;
  36761. minPitch?: number;
  36762. slerpAmount?: number;
  36763. upAxis?: Vector3;
  36764. upAxisSpace?: Space;
  36765. yawAxis?: Vector3;
  36766. pitchAxis?: Vector3;
  36767. adjustYaw?: number;
  36768. adjustPitch?: number;
  36769. adjustRoll?: number;
  36770. });
  36771. /**
  36772. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36773. */
  36774. update(): void;
  36775. private _getAngleDiff;
  36776. private _getAngleBetween;
  36777. private _isAngleBetween;
  36778. }
  36779. }
  36780. declare module BABYLON {
  36781. /**
  36782. * Manage the gamepad inputs to control an arc rotate camera.
  36783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36784. */
  36785. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36786. /**
  36787. * Defines the camera the input is attached to.
  36788. */
  36789. camera: ArcRotateCamera;
  36790. /**
  36791. * Defines the gamepad the input is gathering event from.
  36792. */
  36793. gamepad: Nullable<Gamepad>;
  36794. /**
  36795. * Defines the gamepad rotation sensiblity.
  36796. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36797. */
  36798. gamepadRotationSensibility: number;
  36799. /**
  36800. * Defines the gamepad move sensiblity.
  36801. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36802. */
  36803. gamepadMoveSensibility: number;
  36804. private _yAxisScale;
  36805. /**
  36806. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  36807. */
  36808. invertYAxis: boolean;
  36809. private _onGamepadConnectedObserver;
  36810. private _onGamepadDisconnectedObserver;
  36811. /**
  36812. * Attach the input controls to a specific dom element to get the input from.
  36813. * @param element Defines the element the controls should be listened from
  36814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36815. */
  36816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36817. /**
  36818. * Detach the current controls from the specified dom element.
  36819. * @param element Defines the element to stop listening the inputs from
  36820. */
  36821. detachControl(element: Nullable<HTMLElement>): void;
  36822. /**
  36823. * Update the current camera state depending on the inputs that have been used this frame.
  36824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36825. */
  36826. checkInputs(): void;
  36827. /**
  36828. * Gets the class name of the current intput.
  36829. * @returns the class name
  36830. */
  36831. getClassName(): string;
  36832. /**
  36833. * Get the friendly name associated with the input class.
  36834. * @returns the input friendly name
  36835. */
  36836. getSimpleName(): string;
  36837. }
  36838. }
  36839. declare module BABYLON {
  36840. interface ArcRotateCameraInputsManager {
  36841. /**
  36842. * Add orientation input support to the input manager.
  36843. * @returns the current input manager
  36844. */
  36845. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36846. }
  36847. /**
  36848. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36850. */
  36851. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36852. /**
  36853. * Defines the camera the input is attached to.
  36854. */
  36855. camera: ArcRotateCamera;
  36856. /**
  36857. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36858. */
  36859. alphaCorrection: number;
  36860. /**
  36861. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36862. */
  36863. gammaCorrection: number;
  36864. private _alpha;
  36865. private _gamma;
  36866. private _dirty;
  36867. private _deviceOrientationHandler;
  36868. /**
  36869. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36870. */
  36871. constructor();
  36872. /**
  36873. * Attach the input controls to a specific dom element to get the input from.
  36874. * @param element Defines the element the controls should be listened from
  36875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36876. */
  36877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36878. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36879. /**
  36880. * Update the current camera state depending on the inputs that have been used this frame.
  36881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36882. */
  36883. checkInputs(): void;
  36884. /**
  36885. * Detach the current controls from the specified dom element.
  36886. * @param element Defines the element to stop listening the inputs from
  36887. */
  36888. detachControl(element: Nullable<HTMLElement>): void;
  36889. /**
  36890. * Gets the class name of the current intput.
  36891. * @returns the class name
  36892. */
  36893. getClassName(): string;
  36894. /**
  36895. * Get the friendly name associated with the input class.
  36896. * @returns the input friendly name
  36897. */
  36898. getSimpleName(): string;
  36899. }
  36900. }
  36901. declare module BABYLON {
  36902. /**
  36903. * Listen to mouse events to control the camera.
  36904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36905. */
  36906. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36907. /**
  36908. * Defines the camera the input is attached to.
  36909. */
  36910. camera: FlyCamera;
  36911. /**
  36912. * Defines if touch is enabled. (Default is true.)
  36913. */
  36914. touchEnabled: boolean;
  36915. /**
  36916. * Defines the buttons associated with the input to handle camera rotation.
  36917. */
  36918. buttons: number[];
  36919. /**
  36920. * Assign buttons for Yaw control.
  36921. */
  36922. buttonsYaw: number[];
  36923. /**
  36924. * Assign buttons for Pitch control.
  36925. */
  36926. buttonsPitch: number[];
  36927. /**
  36928. * Assign buttons for Roll control.
  36929. */
  36930. buttonsRoll: number[];
  36931. /**
  36932. * Detect if any button is being pressed while mouse is moved.
  36933. * -1 = Mouse locked.
  36934. * 0 = Left button.
  36935. * 1 = Middle Button.
  36936. * 2 = Right Button.
  36937. */
  36938. activeButton: number;
  36939. /**
  36940. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36941. * Higher values reduce its sensitivity.
  36942. */
  36943. angularSensibility: number;
  36944. private _mousemoveCallback;
  36945. private _observer;
  36946. private _rollObserver;
  36947. private previousPosition;
  36948. private noPreventDefault;
  36949. private element;
  36950. /**
  36951. * Listen to mouse events to control the camera.
  36952. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36954. */
  36955. constructor(touchEnabled?: boolean);
  36956. /**
  36957. * Attach the mouse control to the HTML DOM element.
  36958. * @param element Defines the element that listens to the input events.
  36959. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36960. */
  36961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36962. /**
  36963. * Detach the current controls from the specified dom element.
  36964. * @param element Defines the element to stop listening the inputs from
  36965. */
  36966. detachControl(element: Nullable<HTMLElement>): void;
  36967. /**
  36968. * Gets the class name of the current input.
  36969. * @returns the class name.
  36970. */
  36971. getClassName(): string;
  36972. /**
  36973. * Get the friendly name associated with the input class.
  36974. * @returns the input's friendly name.
  36975. */
  36976. getSimpleName(): string;
  36977. private _pointerInput;
  36978. private _onMouseMove;
  36979. /**
  36980. * Rotate camera by mouse offset.
  36981. */
  36982. private rotateCamera;
  36983. }
  36984. }
  36985. declare module BABYLON {
  36986. /**
  36987. * Default Inputs manager for the FlyCamera.
  36988. * It groups all the default supported inputs for ease of use.
  36989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36990. */
  36991. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36992. /**
  36993. * Instantiates a new FlyCameraInputsManager.
  36994. * @param camera Defines the camera the inputs belong to.
  36995. */
  36996. constructor(camera: FlyCamera);
  36997. /**
  36998. * Add keyboard input support to the input manager.
  36999. * @returns the new FlyCameraKeyboardMoveInput().
  37000. */
  37001. addKeyboard(): FlyCameraInputsManager;
  37002. /**
  37003. * Add mouse input support to the input manager.
  37004. * @param touchEnabled Enable touch screen support.
  37005. * @returns the new FlyCameraMouseInput().
  37006. */
  37007. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37008. }
  37009. }
  37010. declare module BABYLON {
  37011. /**
  37012. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37013. * such as in a 3D Space Shooter or a Flight Simulator.
  37014. */
  37015. export class FlyCamera extends TargetCamera {
  37016. /**
  37017. * Define the collision ellipsoid of the camera.
  37018. * This is helpful for simulating a camera body, like a player's body.
  37019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37020. */
  37021. ellipsoid: Vector3;
  37022. /**
  37023. * Define an offset for the position of the ellipsoid around the camera.
  37024. * This can be helpful if the camera is attached away from the player's body center,
  37025. * such as at its head.
  37026. */
  37027. ellipsoidOffset: Vector3;
  37028. /**
  37029. * Enable or disable collisions of the camera with the rest of the scene objects.
  37030. */
  37031. checkCollisions: boolean;
  37032. /**
  37033. * Enable or disable gravity on the camera.
  37034. */
  37035. applyGravity: boolean;
  37036. /**
  37037. * Define the current direction the camera is moving to.
  37038. */
  37039. cameraDirection: Vector3;
  37040. /**
  37041. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37042. * This overrides and empties cameraRotation.
  37043. */
  37044. rotationQuaternion: Quaternion;
  37045. /**
  37046. * Track Roll to maintain the wanted Rolling when looking around.
  37047. */ private _trackRoll: number;
  37048. /**
  37049. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37050. */
  37051. rollCorrect: number;
  37052. /**
  37053. * Mimic a banked turn, Rolling the camera when Yawing.
  37054. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37055. */
  37056. bankedTurn: boolean;
  37057. /**
  37058. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37059. */
  37060. bankedTurnLimit: number;
  37061. /**
  37062. * Value of 0 disables the banked Roll.
  37063. * Value of 1 is equal to the Yaw angle in radians.
  37064. */
  37065. bankedTurnMultiplier: number;
  37066. /**
  37067. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37068. */
  37069. inputs: FlyCameraInputsManager;
  37070. /**
  37071. * Gets the input sensibility for mouse input.
  37072. * Higher values reduce sensitivity.
  37073. */
  37074. /**
  37075. * Sets the input sensibility for a mouse input.
  37076. * Higher values reduce sensitivity.
  37077. */
  37078. angularSensibility: number;
  37079. /**
  37080. * Get the keys for camera movement forward.
  37081. */
  37082. /**
  37083. * Set the keys for camera movement forward.
  37084. */
  37085. keysForward: number[];
  37086. /**
  37087. * Get the keys for camera movement backward.
  37088. */
  37089. keysBackward: number[];
  37090. /**
  37091. * Get the keys for camera movement up.
  37092. */
  37093. /**
  37094. * Set the keys for camera movement up.
  37095. */
  37096. keysUp: number[];
  37097. /**
  37098. * Get the keys for camera movement down.
  37099. */
  37100. /**
  37101. * Set the keys for camera movement down.
  37102. */
  37103. keysDown: number[];
  37104. /**
  37105. * Get the keys for camera movement left.
  37106. */
  37107. /**
  37108. * Set the keys for camera movement left.
  37109. */
  37110. keysLeft: number[];
  37111. /**
  37112. * Set the keys for camera movement right.
  37113. */
  37114. /**
  37115. * Set the keys for camera movement right.
  37116. */
  37117. keysRight: number[];
  37118. /**
  37119. * Event raised when the camera collides with a mesh in the scene.
  37120. */
  37121. onCollide: (collidedMesh: AbstractMesh) => void;
  37122. private _collider;
  37123. private _needMoveForGravity;
  37124. private _oldPosition;
  37125. private _diffPosition;
  37126. private _newPosition;
  37127. /** @hidden */ private _localDirection: Vector3;
  37128. /** @hidden */ private _transformedDirection: Vector3;
  37129. /**
  37130. * Instantiates a FlyCamera.
  37131. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37132. * such as in a 3D Space Shooter or a Flight Simulator.
  37133. * @param name Define the name of the camera in the scene.
  37134. * @param position Define the starting position of the camera in the scene.
  37135. * @param scene Define the scene the camera belongs to.
  37136. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37137. */
  37138. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37139. /**
  37140. * Attach a control to the HTML DOM element.
  37141. * @param element Defines the element that listens to the input events.
  37142. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37143. */
  37144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37145. /**
  37146. * Detach a control from the HTML DOM element.
  37147. * The camera will stop reacting to that input.
  37148. * @param element Defines the element that listens to the input events.
  37149. */
  37150. detachControl(element: HTMLElement): void;
  37151. private _collisionMask;
  37152. /**
  37153. * Get the mask that the camera ignores in collision events.
  37154. */
  37155. /**
  37156. * Set the mask that the camera ignores in collision events.
  37157. */
  37158. collisionMask: number;
  37159. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  37160. /** @hidden */
  37161. private _onCollisionPositionChange;
  37162. /** @hidden */ private _checkInputs(): void;
  37163. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  37164. /** @hidden */ private _updatePosition(): void;
  37165. /**
  37166. * Restore the Roll to its target value at the rate specified.
  37167. * @param rate - Higher means slower restoring.
  37168. * @hidden
  37169. */
  37170. restoreRoll(rate: number): void;
  37171. /**
  37172. * Destroy the camera and release the current resources held by it.
  37173. */
  37174. dispose(): void;
  37175. /**
  37176. * Get the current object class name.
  37177. * @returns the class name.
  37178. */
  37179. getClassName(): string;
  37180. }
  37181. }
  37182. declare module BABYLON {
  37183. /**
  37184. * Listen to keyboard events to control the camera.
  37185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37186. */
  37187. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37188. /**
  37189. * Defines the camera the input is attached to.
  37190. */
  37191. camera: FlyCamera;
  37192. /**
  37193. * The list of keyboard keys used to control the forward move of the camera.
  37194. */
  37195. keysForward: number[];
  37196. /**
  37197. * The list of keyboard keys used to control the backward move of the camera.
  37198. */
  37199. keysBackward: number[];
  37200. /**
  37201. * The list of keyboard keys used to control the forward move of the camera.
  37202. */
  37203. keysUp: number[];
  37204. /**
  37205. * The list of keyboard keys used to control the backward move of the camera.
  37206. */
  37207. keysDown: number[];
  37208. /**
  37209. * The list of keyboard keys used to control the right strafe move of the camera.
  37210. */
  37211. keysRight: number[];
  37212. /**
  37213. * The list of keyboard keys used to control the left strafe move of the camera.
  37214. */
  37215. keysLeft: number[];
  37216. private _keys;
  37217. private _onCanvasBlurObserver;
  37218. private _onKeyboardObserver;
  37219. private _engine;
  37220. private _scene;
  37221. /**
  37222. * Attach the input controls to a specific dom element to get the input from.
  37223. * @param element Defines the element the controls should be listened from
  37224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37225. */
  37226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37227. /**
  37228. * Detach the current controls from the specified dom element.
  37229. * @param element Defines the element to stop listening the inputs from
  37230. */
  37231. detachControl(element: Nullable<HTMLElement>): void;
  37232. /**
  37233. * Gets the class name of the current intput.
  37234. * @returns the class name
  37235. */
  37236. getClassName(): string;
  37237. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  37238. /**
  37239. * Get the friendly name associated with the input class.
  37240. * @returns the input friendly name
  37241. */
  37242. getSimpleName(): string;
  37243. /**
  37244. * Update the current camera state depending on the inputs that have been used this frame.
  37245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37246. */
  37247. checkInputs(): void;
  37248. }
  37249. }
  37250. declare module BABYLON {
  37251. /**
  37252. * Manage the mouse wheel inputs to control a follow camera.
  37253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37254. */
  37255. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37256. /**
  37257. * Defines the camera the input is attached to.
  37258. */
  37259. camera: FollowCamera;
  37260. /**
  37261. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37262. */
  37263. axisControlRadius: boolean;
  37264. /**
  37265. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37266. */
  37267. axisControlHeight: boolean;
  37268. /**
  37269. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37270. */
  37271. axisControlRotation: boolean;
  37272. /**
  37273. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37274. * relation to mouseWheel events.
  37275. */
  37276. wheelPrecision: number;
  37277. /**
  37278. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37279. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37280. */
  37281. wheelDeltaPercentage: number;
  37282. private _wheel;
  37283. private _observer;
  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. * Gets the class name of the current intput.
  37297. * @returns the class name
  37298. */
  37299. getClassName(): string;
  37300. /**
  37301. * Get the friendly name associated with the input class.
  37302. * @returns the input friendly name
  37303. */
  37304. getSimpleName(): string;
  37305. }
  37306. }
  37307. declare module BABYLON {
  37308. /**
  37309. * Manage the pointers inputs to control an follow camera.
  37310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37311. */
  37312. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37313. /**
  37314. * Defines the camera the input is attached to.
  37315. */
  37316. camera: FollowCamera;
  37317. /**
  37318. * Gets the class name of the current input.
  37319. * @returns the class name
  37320. */
  37321. getClassName(): string;
  37322. /**
  37323. * Defines the pointer angular sensibility along the X axis or how fast is
  37324. * the camera rotating.
  37325. * A negative number will reverse the axis direction.
  37326. */
  37327. angularSensibilityX: number;
  37328. /**
  37329. * Defines the pointer angular sensibility along the Y axis or how fast is
  37330. * the camera rotating.
  37331. * A negative number will reverse the axis direction.
  37332. */
  37333. angularSensibilityY: number;
  37334. /**
  37335. * Defines the pointer pinch precision or how fast is the camera zooming.
  37336. * A negative number will reverse the axis direction.
  37337. */
  37338. pinchPrecision: number;
  37339. /**
  37340. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37341. * from 0.
  37342. * It defines the percentage of current camera.radius to use as delta when
  37343. * pinch zoom is used.
  37344. */
  37345. pinchDeltaPercentage: number;
  37346. /**
  37347. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37348. */
  37349. axisXControlRadius: boolean;
  37350. /**
  37351. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37352. */
  37353. axisXControlHeight: boolean;
  37354. /**
  37355. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37356. */
  37357. axisXControlRotation: boolean;
  37358. /**
  37359. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37360. */
  37361. axisYControlRadius: boolean;
  37362. /**
  37363. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37364. */
  37365. axisYControlHeight: boolean;
  37366. /**
  37367. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37368. */
  37369. axisYControlRotation: boolean;
  37370. /**
  37371. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37372. */
  37373. axisPinchControlRadius: boolean;
  37374. /**
  37375. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37376. */
  37377. axisPinchControlHeight: boolean;
  37378. /**
  37379. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37380. */
  37381. axisPinchControlRotation: boolean;
  37382. /**
  37383. * Log error messages if basic misconfiguration has occurred.
  37384. */
  37385. warningEnable: boolean;
  37386. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37387. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37388. private _warningCounter;
  37389. private _warning;
  37390. }
  37391. }
  37392. declare module BABYLON {
  37393. /**
  37394. * Default Inputs manager for the FollowCamera.
  37395. * It groups all the default supported inputs for ease of use.
  37396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37397. */
  37398. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37399. /**
  37400. * Instantiates a new FollowCameraInputsManager.
  37401. * @param camera Defines the camera the inputs belong to
  37402. */
  37403. constructor(camera: FollowCamera);
  37404. /**
  37405. * Add keyboard input support to the input manager.
  37406. * @returns the current input manager
  37407. */
  37408. addKeyboard(): FollowCameraInputsManager;
  37409. /**
  37410. * Add mouse wheel input support to the input manager.
  37411. * @returns the current input manager
  37412. */
  37413. addMouseWheel(): FollowCameraInputsManager;
  37414. /**
  37415. * Add pointers input support to the input manager.
  37416. * @returns the current input manager
  37417. */
  37418. addPointers(): FollowCameraInputsManager;
  37419. /**
  37420. * Add orientation input support to the input manager.
  37421. * @returns the current input manager
  37422. */
  37423. addVRDeviceOrientation(): FollowCameraInputsManager;
  37424. }
  37425. }
  37426. declare module BABYLON {
  37427. /**
  37428. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37429. * an arc rotate version arcFollowCamera are available.
  37430. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37431. */
  37432. export class FollowCamera extends TargetCamera {
  37433. /**
  37434. * Distance the follow camera should follow an object at
  37435. */
  37436. radius: number;
  37437. /**
  37438. * Minimum allowed distance of the camera to the axis of rotation
  37439. * (The camera can not get closer).
  37440. * This can help limiting how the Camera is able to move in the scene.
  37441. */
  37442. lowerRadiusLimit: Nullable<number>;
  37443. /**
  37444. * Maximum allowed distance of the camera to the axis of rotation
  37445. * (The camera can not get further).
  37446. * This can help limiting how the Camera is able to move in the scene.
  37447. */
  37448. upperRadiusLimit: Nullable<number>;
  37449. /**
  37450. * Define a rotation offset between the camera and the object it follows
  37451. */
  37452. rotationOffset: number;
  37453. /**
  37454. * Minimum allowed angle to camera position relative to target object.
  37455. * This can help limiting how the Camera is able to move in the scene.
  37456. */
  37457. lowerRotationOffsetLimit: Nullable<number>;
  37458. /**
  37459. * Maximum allowed angle to camera position relative to target object.
  37460. * This can help limiting how the Camera is able to move in the scene.
  37461. */
  37462. upperRotationOffsetLimit: Nullable<number>;
  37463. /**
  37464. * Define a height offset between the camera and the object it follows.
  37465. * It can help following an object from the top (like a car chaing a plane)
  37466. */
  37467. heightOffset: number;
  37468. /**
  37469. * Minimum allowed height of camera position relative to target object.
  37470. * This can help limiting how the Camera is able to move in the scene.
  37471. */
  37472. lowerHeightOffsetLimit: Nullable<number>;
  37473. /**
  37474. * Maximum allowed height of camera position relative to target object.
  37475. * This can help limiting how the Camera is able to move in the scene.
  37476. */
  37477. upperHeightOffsetLimit: Nullable<number>;
  37478. /**
  37479. * Define how fast the camera can accelerate to follow it s target.
  37480. */
  37481. cameraAcceleration: number;
  37482. /**
  37483. * Define the speed limit of the camera following an object.
  37484. */
  37485. maxCameraSpeed: number;
  37486. /**
  37487. * Define the target of the camera.
  37488. */
  37489. lockedTarget: Nullable<AbstractMesh>;
  37490. /**
  37491. * Defines the input associated with the camera.
  37492. */
  37493. inputs: FollowCameraInputsManager;
  37494. /**
  37495. * Instantiates the follow camera.
  37496. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37497. * @param name Define the name of the camera in the scene
  37498. * @param position Define the position of the camera
  37499. * @param scene Define the scene the camera belong to
  37500. * @param lockedTarget Define the target of the camera
  37501. */
  37502. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37503. private _follow;
  37504. /**
  37505. * Attached controls to the current camera.
  37506. * @param element Defines the element the controls should be listened from
  37507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37508. */
  37509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37510. /**
  37511. * Detach the current controls from the camera.
  37512. * The camera will stop reacting to inputs.
  37513. * @param element Defines the element to stop listening the inputs from
  37514. */
  37515. detachControl(element: HTMLElement): void;
  37516. /** @hidden */ private _checkInputs(): void;
  37517. private _checkLimits;
  37518. /**
  37519. * Gets the camera class name.
  37520. * @returns the class name
  37521. */
  37522. getClassName(): string;
  37523. }
  37524. /**
  37525. * Arc Rotate version of the follow camera.
  37526. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37527. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37528. */
  37529. export class ArcFollowCamera extends TargetCamera {
  37530. /** The longitudinal angle of the camera */
  37531. alpha: number;
  37532. /** The latitudinal angle of the camera */
  37533. beta: number;
  37534. /** The radius of the camera from its target */
  37535. radius: number;
  37536. /** Define the camera target (the messh it should follow) */
  37537. target: Nullable<AbstractMesh>;
  37538. private _cartesianCoordinates;
  37539. /**
  37540. * Instantiates a new ArcFollowCamera
  37541. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37542. * @param name Define the name of the camera
  37543. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37544. * @param beta Define the rotation angle of the camera around the elevation axis
  37545. * @param radius Define the radius of the camera from its target point
  37546. * @param target Define the target of the camera
  37547. * @param scene Define the scene the camera belongs to
  37548. */
  37549. constructor(name: string,
  37550. /** The longitudinal angle of the camera */
  37551. alpha: number,
  37552. /** The latitudinal angle of the camera */
  37553. beta: number,
  37554. /** The radius of the camera from its target */
  37555. radius: number,
  37556. /** Define the camera target (the messh it should follow) */
  37557. target: Nullable<AbstractMesh>, scene: Scene);
  37558. private _follow;
  37559. /** @hidden */ private _checkInputs(): void;
  37560. /**
  37561. * Returns the class name of the object.
  37562. * It is mostly used internally for serialization purposes.
  37563. */
  37564. getClassName(): string;
  37565. }
  37566. }
  37567. declare module BABYLON {
  37568. /**
  37569. * Manage the keyboard inputs to control the movement of a follow camera.
  37570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37571. */
  37572. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37573. /**
  37574. * Defines the camera the input is attached to.
  37575. */
  37576. camera: FollowCamera;
  37577. /**
  37578. * Defines the list of key codes associated with the up action (increase heightOffset)
  37579. */
  37580. keysHeightOffsetIncr: number[];
  37581. /**
  37582. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37583. */
  37584. keysHeightOffsetDecr: number[];
  37585. /**
  37586. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37587. */
  37588. keysHeightOffsetModifierAlt: boolean;
  37589. /**
  37590. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37591. */
  37592. keysHeightOffsetModifierCtrl: boolean;
  37593. /**
  37594. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37595. */
  37596. keysHeightOffsetModifierShift: boolean;
  37597. /**
  37598. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37599. */
  37600. keysRotationOffsetIncr: number[];
  37601. /**
  37602. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37603. */
  37604. keysRotationOffsetDecr: number[];
  37605. /**
  37606. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37607. */
  37608. keysRotationOffsetModifierAlt: boolean;
  37609. /**
  37610. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37611. */
  37612. keysRotationOffsetModifierCtrl: boolean;
  37613. /**
  37614. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37615. */
  37616. keysRotationOffsetModifierShift: boolean;
  37617. /**
  37618. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37619. */
  37620. keysRadiusIncr: number[];
  37621. /**
  37622. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37623. */
  37624. keysRadiusDecr: number[];
  37625. /**
  37626. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37627. */
  37628. keysRadiusModifierAlt: boolean;
  37629. /**
  37630. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37631. */
  37632. keysRadiusModifierCtrl: boolean;
  37633. /**
  37634. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37635. */
  37636. keysRadiusModifierShift: boolean;
  37637. /**
  37638. * Defines the rate of change of heightOffset.
  37639. */
  37640. heightSensibility: number;
  37641. /**
  37642. * Defines the rate of change of rotationOffset.
  37643. */
  37644. rotationSensibility: number;
  37645. /**
  37646. * Defines the rate of change of radius.
  37647. */
  37648. radiusSensibility: number;
  37649. private _keys;
  37650. private _ctrlPressed;
  37651. private _altPressed;
  37652. private _shiftPressed;
  37653. private _onCanvasBlurObserver;
  37654. private _onKeyboardObserver;
  37655. private _engine;
  37656. private _scene;
  37657. /**
  37658. * Attach the input controls to a specific dom element to get the input from.
  37659. * @param element Defines the element the controls should be listened from
  37660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37661. */
  37662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37663. /**
  37664. * Detach the current controls from the specified dom element.
  37665. * @param element Defines the element to stop listening the inputs from
  37666. */
  37667. detachControl(element: Nullable<HTMLElement>): void;
  37668. /**
  37669. * Update the current camera state depending on the inputs that have been used this frame.
  37670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37671. */
  37672. checkInputs(): void;
  37673. /**
  37674. * Gets the class name of the current input.
  37675. * @returns the class name
  37676. */
  37677. getClassName(): string;
  37678. /**
  37679. * Get the friendly name associated with the input class.
  37680. * @returns the input friendly name
  37681. */
  37682. getSimpleName(): string;
  37683. /**
  37684. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37685. * allow modification of the heightOffset value.
  37686. */
  37687. private _modifierHeightOffset;
  37688. /**
  37689. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37690. * allow modification of the rotationOffset value.
  37691. */
  37692. private _modifierRotationOffset;
  37693. /**
  37694. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37695. * allow modification of the radius value.
  37696. */
  37697. private _modifierRadius;
  37698. }
  37699. }
  37700. declare module BABYLON {
  37701. interface FreeCameraInputsManager {
  37702. /**
  37703. * @hidden
  37704. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37705. /**
  37706. * Add orientation input support to the input manager.
  37707. * @returns the current input manager
  37708. */
  37709. addDeviceOrientation(): FreeCameraInputsManager;
  37710. }
  37711. /**
  37712. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37713. * Screen rotation is taken into account.
  37714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37715. */
  37716. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37717. private _camera;
  37718. private _screenOrientationAngle;
  37719. private _constantTranform;
  37720. private _screenQuaternion;
  37721. private _alpha;
  37722. private _beta;
  37723. private _gamma;
  37724. /**
  37725. * Can be used to detect if a device orientation sensor is availible on a device
  37726. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37727. * @returns a promise that will resolve on orientation change
  37728. */
  37729. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37730. /**
  37731. * @hidden
  37732. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37733. /**
  37734. * Instantiates a new input
  37735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37736. */
  37737. constructor();
  37738. /**
  37739. * Define the camera controlled by the input.
  37740. */
  37741. camera: FreeCamera;
  37742. /**
  37743. * Attach the input controls to a specific dom element to get the input from.
  37744. * @param element Defines the element the controls should be listened from
  37745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37746. */
  37747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37748. private _orientationChanged;
  37749. private _deviceOrientation;
  37750. /**
  37751. * Detach the current controls from the specified dom element.
  37752. * @param element Defines the element to stop listening the inputs from
  37753. */
  37754. detachControl(element: Nullable<HTMLElement>): void;
  37755. /**
  37756. * Update the current camera state depending on the inputs that have been used this frame.
  37757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37758. */
  37759. checkInputs(): void;
  37760. /**
  37761. * Gets the class name of the current intput.
  37762. * @returns the class name
  37763. */
  37764. getClassName(): string;
  37765. /**
  37766. * Get the friendly name associated with the input class.
  37767. * @returns the input friendly name
  37768. */
  37769. getSimpleName(): string;
  37770. }
  37771. }
  37772. declare module BABYLON {
  37773. /**
  37774. * Manage the gamepad inputs to control a free camera.
  37775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37776. */
  37777. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37778. /**
  37779. * Define the camera the input is attached to.
  37780. */
  37781. camera: FreeCamera;
  37782. /**
  37783. * Define the Gamepad controlling the input
  37784. */
  37785. gamepad: Nullable<Gamepad>;
  37786. /**
  37787. * Defines the gamepad rotation sensiblity.
  37788. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37789. */
  37790. gamepadAngularSensibility: number;
  37791. /**
  37792. * Defines the gamepad move sensiblity.
  37793. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37794. */
  37795. gamepadMoveSensibility: number;
  37796. private _yAxisScale;
  37797. /**
  37798. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37799. */
  37800. invertYAxis: boolean;
  37801. private _onGamepadConnectedObserver;
  37802. private _onGamepadDisconnectedObserver;
  37803. private _cameraTransform;
  37804. private _deltaTransform;
  37805. private _vector3;
  37806. private _vector2;
  37807. /**
  37808. * Attach the input controls to a specific dom element to get the input from.
  37809. * @param element Defines the element the controls should be listened from
  37810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37811. */
  37812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37813. /**
  37814. * Detach the current controls from the specified dom element.
  37815. * @param element Defines the element to stop listening the inputs from
  37816. */
  37817. detachControl(element: Nullable<HTMLElement>): void;
  37818. /**
  37819. * Update the current camera state depending on the inputs that have been used this frame.
  37820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37821. */
  37822. checkInputs(): void;
  37823. /**
  37824. * Gets the class name of the current intput.
  37825. * @returns the class name
  37826. */
  37827. getClassName(): string;
  37828. /**
  37829. * Get the friendly name associated with the input class.
  37830. * @returns the input friendly name
  37831. */
  37832. getSimpleName(): string;
  37833. }
  37834. }
  37835. declare module BABYLON {
  37836. /**
  37837. * Defines the potential axis of a Joystick
  37838. */
  37839. export enum JoystickAxis {
  37840. /** X axis */
  37841. X = 0,
  37842. /** Y axis */
  37843. Y = 1,
  37844. /** Z axis */
  37845. Z = 2
  37846. }
  37847. /**
  37848. * Class used to define virtual joystick (used in touch mode)
  37849. */
  37850. export class VirtualJoystick {
  37851. /**
  37852. * Gets or sets a boolean indicating that left and right values must be inverted
  37853. */
  37854. reverseLeftRight: boolean;
  37855. /**
  37856. * Gets or sets a boolean indicating that up and down values must be inverted
  37857. */
  37858. reverseUpDown: boolean;
  37859. /**
  37860. * Gets the offset value for the position (ie. the change of the position value)
  37861. */
  37862. deltaPosition: Vector3;
  37863. /**
  37864. * Gets a boolean indicating if the virtual joystick was pressed
  37865. */
  37866. pressed: boolean;
  37867. /**
  37868. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37869. */
  37870. static Canvas: Nullable<HTMLCanvasElement>;
  37871. private static _globalJoystickIndex;
  37872. private static vjCanvasContext;
  37873. private static vjCanvasWidth;
  37874. private static vjCanvasHeight;
  37875. private static halfWidth;
  37876. private _action;
  37877. private _axisTargetedByLeftAndRight;
  37878. private _axisTargetedByUpAndDown;
  37879. private _joystickSensibility;
  37880. private _inversedSensibility;
  37881. private _joystickPointerID;
  37882. private _joystickColor;
  37883. private _joystickPointerPos;
  37884. private _joystickPreviousPointerPos;
  37885. private _joystickPointerStartPos;
  37886. private _deltaJoystickVector;
  37887. private _leftJoystick;
  37888. private _touches;
  37889. private _onPointerDownHandlerRef;
  37890. private _onPointerMoveHandlerRef;
  37891. private _onPointerUpHandlerRef;
  37892. private _onResize;
  37893. /**
  37894. * Creates a new virtual joystick
  37895. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37896. */
  37897. constructor(leftJoystick?: boolean);
  37898. /**
  37899. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37900. * @param newJoystickSensibility defines the new sensibility
  37901. */
  37902. setJoystickSensibility(newJoystickSensibility: number): void;
  37903. private _onPointerDown;
  37904. private _onPointerMove;
  37905. private _onPointerUp;
  37906. /**
  37907. * Change the color of the virtual joystick
  37908. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37909. */
  37910. setJoystickColor(newColor: string): void;
  37911. /**
  37912. * Defines a callback to call when the joystick is touched
  37913. * @param action defines the callback
  37914. */
  37915. setActionOnTouch(action: () => any): void;
  37916. /**
  37917. * Defines which axis you'd like to control for left & right
  37918. * @param axis defines the axis to use
  37919. */
  37920. setAxisForLeftRight(axis: JoystickAxis): void;
  37921. /**
  37922. * Defines which axis you'd like to control for up & down
  37923. * @param axis defines the axis to use
  37924. */
  37925. setAxisForUpDown(axis: JoystickAxis): void;
  37926. private _drawVirtualJoystick;
  37927. /**
  37928. * Release internal HTML canvas
  37929. */
  37930. releaseCanvas(): void;
  37931. }
  37932. }
  37933. declare module BABYLON {
  37934. interface FreeCameraInputsManager {
  37935. /**
  37936. * Add virtual joystick input support to the input manager.
  37937. * @returns the current input manager
  37938. */
  37939. addVirtualJoystick(): FreeCameraInputsManager;
  37940. }
  37941. /**
  37942. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37944. */
  37945. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37946. /**
  37947. * Defines the camera the input is attached to.
  37948. */
  37949. camera: FreeCamera;
  37950. private _leftjoystick;
  37951. private _rightjoystick;
  37952. /**
  37953. * Gets the left stick of the virtual joystick.
  37954. * @returns The virtual Joystick
  37955. */
  37956. getLeftJoystick(): VirtualJoystick;
  37957. /**
  37958. * Gets the right stick of the virtual joystick.
  37959. * @returns The virtual Joystick
  37960. */
  37961. getRightJoystick(): VirtualJoystick;
  37962. /**
  37963. * Update the current camera state depending on the inputs that have been used this frame.
  37964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37965. */
  37966. checkInputs(): void;
  37967. /**
  37968. * Attach the input controls to a specific dom element to get the input from.
  37969. * @param element Defines the element the controls should be listened from
  37970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37971. */
  37972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37973. /**
  37974. * Detach the current controls from the specified dom element.
  37975. * @param element Defines the element to stop listening the inputs from
  37976. */
  37977. detachControl(element: Nullable<HTMLElement>): void;
  37978. /**
  37979. * Gets the class name of the current intput.
  37980. * @returns the class name
  37981. */
  37982. getClassName(): string;
  37983. /**
  37984. * Get the friendly name associated with the input class.
  37985. * @returns the input friendly name
  37986. */
  37987. getSimpleName(): string;
  37988. }
  37989. }
  37990. declare module BABYLON {
  37991. /**
  37992. * This represents a FPS type of camera controlled by touch.
  37993. * This is like a universal camera minus the Gamepad controls.
  37994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37995. */
  37996. export class TouchCamera extends FreeCamera {
  37997. /**
  37998. * Defines the touch sensibility for rotation.
  37999. * The higher the faster.
  38000. */
  38001. touchAngularSensibility: number;
  38002. /**
  38003. * Defines the touch sensibility for move.
  38004. * The higher the faster.
  38005. */
  38006. touchMoveSensibility: number;
  38007. /**
  38008. * Instantiates a new touch camera.
  38009. * This represents a FPS type of camera controlled by touch.
  38010. * This is like a universal camera minus the Gamepad controls.
  38011. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38012. * @param name Define the name of the camera in the scene
  38013. * @param position Define the start position of the camera in the scene
  38014. * @param scene Define the scene the camera belongs to
  38015. */
  38016. constructor(name: string, position: Vector3, scene: Scene);
  38017. /**
  38018. * Gets the current object class name.
  38019. * @return the class name
  38020. */
  38021. getClassName(): string;
  38022. /** @hidden */ private _setupInputs(): void;
  38023. }
  38024. }
  38025. declare module BABYLON {
  38026. /**
  38027. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38028. * being tilted forward or back and left or right.
  38029. */
  38030. export class DeviceOrientationCamera extends FreeCamera {
  38031. private _initialQuaternion;
  38032. private _quaternionCache;
  38033. private _tmpDragQuaternion;
  38034. private _disablePointerInputWhenUsingDeviceOrientation;
  38035. /**
  38036. * Creates a new device orientation camera
  38037. * @param name The name of the camera
  38038. * @param position The start position camera
  38039. * @param scene The scene the camera belongs to
  38040. */
  38041. constructor(name: string, position: Vector3, scene: Scene);
  38042. /**
  38043. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38044. */
  38045. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38046. private _dragFactor;
  38047. /**
  38048. * Enabled turning on the y axis when the orientation sensor is active
  38049. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38050. */
  38051. enableHorizontalDragging(dragFactor?: number): void;
  38052. /**
  38053. * Gets the current instance class name ("DeviceOrientationCamera").
  38054. * This helps avoiding instanceof at run time.
  38055. * @returns the class name
  38056. */
  38057. getClassName(): string;
  38058. /**
  38059. * @hidden
  38060. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38061. */ private _checkInputs(): void;
  38062. /**
  38063. * Reset the camera to its default orientation on the specified axis only.
  38064. * @param axis The axis to reset
  38065. */
  38066. resetToCurrentRotation(axis?: Axis): void;
  38067. }
  38068. }
  38069. declare module BABYLON {
  38070. /**
  38071. * Defines supported buttons for XBox360 compatible gamepads
  38072. */
  38073. export enum Xbox360Button {
  38074. /** A */
  38075. A = 0,
  38076. /** B */
  38077. B = 1,
  38078. /** X */
  38079. X = 2,
  38080. /** Y */
  38081. Y = 3,
  38082. /** Start */
  38083. Start = 4,
  38084. /** Back */
  38085. Back = 5,
  38086. /** Left button */
  38087. LB = 6,
  38088. /** Right button */
  38089. RB = 7,
  38090. /** Left stick */
  38091. LeftStick = 8,
  38092. /** Right stick */
  38093. RightStick = 9
  38094. }
  38095. /** Defines values for XBox360 DPad */
  38096. export enum Xbox360Dpad {
  38097. /** Up */
  38098. Up = 0,
  38099. /** Down */
  38100. Down = 1,
  38101. /** Left */
  38102. Left = 2,
  38103. /** Right */
  38104. Right = 3
  38105. }
  38106. /**
  38107. * Defines a XBox360 gamepad
  38108. */
  38109. export class Xbox360Pad extends Gamepad {
  38110. private _leftTrigger;
  38111. private _rightTrigger;
  38112. private _onlefttriggerchanged;
  38113. private _onrighttriggerchanged;
  38114. private _onbuttondown;
  38115. private _onbuttonup;
  38116. private _ondpaddown;
  38117. private _ondpadup;
  38118. /** Observable raised when a button is pressed */
  38119. onButtonDownObservable: Observable<Xbox360Button>;
  38120. /** Observable raised when a button is released */
  38121. onButtonUpObservable: Observable<Xbox360Button>;
  38122. /** Observable raised when a pad is pressed */
  38123. onPadDownObservable: Observable<Xbox360Dpad>;
  38124. /** Observable raised when a pad is released */
  38125. onPadUpObservable: Observable<Xbox360Dpad>;
  38126. private _buttonA;
  38127. private _buttonB;
  38128. private _buttonX;
  38129. private _buttonY;
  38130. private _buttonBack;
  38131. private _buttonStart;
  38132. private _buttonLB;
  38133. private _buttonRB;
  38134. private _buttonLeftStick;
  38135. private _buttonRightStick;
  38136. private _dPadUp;
  38137. private _dPadDown;
  38138. private _dPadLeft;
  38139. private _dPadRight;
  38140. private _isXboxOnePad;
  38141. /**
  38142. * Creates a new XBox360 gamepad object
  38143. * @param id defines the id of this gamepad
  38144. * @param index defines its index
  38145. * @param gamepad defines the internal HTML gamepad object
  38146. * @param xboxOne defines if it is a XBox One gamepad
  38147. */
  38148. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38149. /**
  38150. * Defines the callback to call when left trigger is pressed
  38151. * @param callback defines the callback to use
  38152. */
  38153. onlefttriggerchanged(callback: (value: number) => void): void;
  38154. /**
  38155. * Defines the callback to call when right trigger is pressed
  38156. * @param callback defines the callback to use
  38157. */
  38158. onrighttriggerchanged(callback: (value: number) => void): void;
  38159. /**
  38160. * Gets the left trigger value
  38161. */
  38162. /**
  38163. * Sets the left trigger value
  38164. */
  38165. leftTrigger: number;
  38166. /**
  38167. * Gets the right trigger value
  38168. */
  38169. /**
  38170. * Sets the right trigger value
  38171. */
  38172. rightTrigger: number;
  38173. /**
  38174. * Defines the callback to call when a button is pressed
  38175. * @param callback defines the callback to use
  38176. */
  38177. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38178. /**
  38179. * Defines the callback to call when a button is released
  38180. * @param callback defines the callback to use
  38181. */
  38182. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38183. /**
  38184. * Defines the callback to call when a pad is pressed
  38185. * @param callback defines the callback to use
  38186. */
  38187. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38188. /**
  38189. * Defines the callback to call when a pad is released
  38190. * @param callback defines the callback to use
  38191. */
  38192. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38193. private _setButtonValue;
  38194. private _setDPadValue;
  38195. /**
  38196. * Gets the value of the `A` button
  38197. */
  38198. /**
  38199. * Sets the value of the `A` button
  38200. */
  38201. buttonA: number;
  38202. /**
  38203. * Gets the value of the `B` button
  38204. */
  38205. /**
  38206. * Sets the value of the `B` button
  38207. */
  38208. buttonB: number;
  38209. /**
  38210. * Gets the value of the `X` button
  38211. */
  38212. /**
  38213. * Sets the value of the `X` button
  38214. */
  38215. buttonX: number;
  38216. /**
  38217. * Gets the value of the `Y` button
  38218. */
  38219. /**
  38220. * Sets the value of the `Y` button
  38221. */
  38222. buttonY: number;
  38223. /**
  38224. * Gets the value of the `Start` button
  38225. */
  38226. /**
  38227. * Sets the value of the `Start` button
  38228. */
  38229. buttonStart: number;
  38230. /**
  38231. * Gets the value of the `Back` button
  38232. */
  38233. /**
  38234. * Sets the value of the `Back` button
  38235. */
  38236. buttonBack: number;
  38237. /**
  38238. * Gets the value of the `Left` button
  38239. */
  38240. /**
  38241. * Sets the value of the `Left` button
  38242. */
  38243. buttonLB: number;
  38244. /**
  38245. * Gets the value of the `Right` button
  38246. */
  38247. /**
  38248. * Sets the value of the `Right` button
  38249. */
  38250. buttonRB: number;
  38251. /**
  38252. * Gets the value of the Left joystick
  38253. */
  38254. /**
  38255. * Sets the value of the Left joystick
  38256. */
  38257. buttonLeftStick: number;
  38258. /**
  38259. * Gets the value of the Right joystick
  38260. */
  38261. /**
  38262. * Sets the value of the Right joystick
  38263. */
  38264. buttonRightStick: number;
  38265. /**
  38266. * Gets the value of D-pad up
  38267. */
  38268. /**
  38269. * Sets the value of D-pad up
  38270. */
  38271. dPadUp: number;
  38272. /**
  38273. * Gets the value of D-pad down
  38274. */
  38275. /**
  38276. * Sets the value of D-pad down
  38277. */
  38278. dPadDown: number;
  38279. /**
  38280. * Gets the value of D-pad left
  38281. */
  38282. /**
  38283. * Sets the value of D-pad left
  38284. */
  38285. dPadLeft: number;
  38286. /**
  38287. * Gets the value of D-pad right
  38288. */
  38289. /**
  38290. * Sets the value of D-pad right
  38291. */
  38292. dPadRight: number;
  38293. /**
  38294. * Force the gamepad to synchronize with device values
  38295. */
  38296. update(): void;
  38297. /**
  38298. * Disposes the gamepad
  38299. */
  38300. dispose(): void;
  38301. }
  38302. }
  38303. declare module BABYLON {
  38304. /**
  38305. * Defines supported buttons for DualShock compatible gamepads
  38306. */
  38307. export enum DualShockButton {
  38308. /** Cross */
  38309. Cross = 0,
  38310. /** Circle */
  38311. Circle = 1,
  38312. /** Square */
  38313. Square = 2,
  38314. /** Triangle */
  38315. Triangle = 3,
  38316. /** Options */
  38317. Options = 4,
  38318. /** Share */
  38319. Share = 5,
  38320. /** L1 */
  38321. L1 = 6,
  38322. /** R1 */
  38323. R1 = 7,
  38324. /** Left stick */
  38325. LeftStick = 8,
  38326. /** Right stick */
  38327. RightStick = 9
  38328. }
  38329. /** Defines values for DualShock DPad */
  38330. export enum DualShockDpad {
  38331. /** Up */
  38332. Up = 0,
  38333. /** Down */
  38334. Down = 1,
  38335. /** Left */
  38336. Left = 2,
  38337. /** Right */
  38338. Right = 3
  38339. }
  38340. /**
  38341. * Defines a DualShock gamepad
  38342. */
  38343. export class DualShockPad extends Gamepad {
  38344. private _leftTrigger;
  38345. private _rightTrigger;
  38346. private _onlefttriggerchanged;
  38347. private _onrighttriggerchanged;
  38348. private _onbuttondown;
  38349. private _onbuttonup;
  38350. private _ondpaddown;
  38351. private _ondpadup;
  38352. /** Observable raised when a button is pressed */
  38353. onButtonDownObservable: Observable<DualShockButton>;
  38354. /** Observable raised when a button is released */
  38355. onButtonUpObservable: Observable<DualShockButton>;
  38356. /** Observable raised when a pad is pressed */
  38357. onPadDownObservable: Observable<DualShockDpad>;
  38358. /** Observable raised when a pad is released */
  38359. onPadUpObservable: Observable<DualShockDpad>;
  38360. private _buttonCross;
  38361. private _buttonCircle;
  38362. private _buttonSquare;
  38363. private _buttonTriangle;
  38364. private _buttonShare;
  38365. private _buttonOptions;
  38366. private _buttonL1;
  38367. private _buttonR1;
  38368. private _buttonLeftStick;
  38369. private _buttonRightStick;
  38370. private _dPadUp;
  38371. private _dPadDown;
  38372. private _dPadLeft;
  38373. private _dPadRight;
  38374. /**
  38375. * Creates a new DualShock gamepad object
  38376. * @param id defines the id of this gamepad
  38377. * @param index defines its index
  38378. * @param gamepad defines the internal HTML gamepad object
  38379. */
  38380. constructor(id: string, index: number, gamepad: any);
  38381. /**
  38382. * Defines the callback to call when left trigger is pressed
  38383. * @param callback defines the callback to use
  38384. */
  38385. onlefttriggerchanged(callback: (value: number) => void): void;
  38386. /**
  38387. * Defines the callback to call when right trigger is pressed
  38388. * @param callback defines the callback to use
  38389. */
  38390. onrighttriggerchanged(callback: (value: number) => void): void;
  38391. /**
  38392. * Gets the left trigger value
  38393. */
  38394. /**
  38395. * Sets the left trigger value
  38396. */
  38397. leftTrigger: number;
  38398. /**
  38399. * Gets the right trigger value
  38400. */
  38401. /**
  38402. * Sets the right trigger value
  38403. */
  38404. rightTrigger: number;
  38405. /**
  38406. * Defines the callback to call when a button is pressed
  38407. * @param callback defines the callback to use
  38408. */
  38409. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38410. /**
  38411. * Defines the callback to call when a button is released
  38412. * @param callback defines the callback to use
  38413. */
  38414. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38415. /**
  38416. * Defines the callback to call when a pad is pressed
  38417. * @param callback defines the callback to use
  38418. */
  38419. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38420. /**
  38421. * Defines the callback to call when a pad is released
  38422. * @param callback defines the callback to use
  38423. */
  38424. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38425. private _setButtonValue;
  38426. private _setDPadValue;
  38427. /**
  38428. * Gets the value of the `Cross` button
  38429. */
  38430. /**
  38431. * Sets the value of the `Cross` button
  38432. */
  38433. buttonCross: number;
  38434. /**
  38435. * Gets the value of the `Circle` button
  38436. */
  38437. /**
  38438. * Sets the value of the `Circle` button
  38439. */
  38440. buttonCircle: number;
  38441. /**
  38442. * Gets the value of the `Square` button
  38443. */
  38444. /**
  38445. * Sets the value of the `Square` button
  38446. */
  38447. buttonSquare: number;
  38448. /**
  38449. * Gets the value of the `Triangle` button
  38450. */
  38451. /**
  38452. * Sets the value of the `Triangle` button
  38453. */
  38454. buttonTriangle: number;
  38455. /**
  38456. * Gets the value of the `Options` button
  38457. */
  38458. /**
  38459. * Sets the value of the `Options` button
  38460. */
  38461. buttonOptions: number;
  38462. /**
  38463. * Gets the value of the `Share` button
  38464. */
  38465. /**
  38466. * Sets the value of the `Share` button
  38467. */
  38468. buttonShare: number;
  38469. /**
  38470. * Gets the value of the `L1` button
  38471. */
  38472. /**
  38473. * Sets the value of the `L1` button
  38474. */
  38475. buttonL1: number;
  38476. /**
  38477. * Gets the value of the `R1` button
  38478. */
  38479. /**
  38480. * Sets the value of the `R1` button
  38481. */
  38482. buttonR1: number;
  38483. /**
  38484. * Gets the value of the Left joystick
  38485. */
  38486. /**
  38487. * Sets the value of the Left joystick
  38488. */
  38489. buttonLeftStick: number;
  38490. /**
  38491. * Gets the value of the Right joystick
  38492. */
  38493. /**
  38494. * Sets the value of the Right joystick
  38495. */
  38496. buttonRightStick: number;
  38497. /**
  38498. * Gets the value of D-pad up
  38499. */
  38500. /**
  38501. * Sets the value of D-pad up
  38502. */
  38503. dPadUp: number;
  38504. /**
  38505. * Gets the value of D-pad down
  38506. */
  38507. /**
  38508. * Sets the value of D-pad down
  38509. */
  38510. dPadDown: number;
  38511. /**
  38512. * Gets the value of D-pad left
  38513. */
  38514. /**
  38515. * Sets the value of D-pad left
  38516. */
  38517. dPadLeft: number;
  38518. /**
  38519. * Gets the value of D-pad right
  38520. */
  38521. /**
  38522. * Sets the value of D-pad right
  38523. */
  38524. dPadRight: number;
  38525. /**
  38526. * Force the gamepad to synchronize with device values
  38527. */
  38528. update(): void;
  38529. /**
  38530. * Disposes the gamepad
  38531. */
  38532. dispose(): void;
  38533. }
  38534. }
  38535. declare module BABYLON {
  38536. /**
  38537. * Manager for handling gamepads
  38538. */
  38539. export class GamepadManager {
  38540. private _scene?;
  38541. private _babylonGamepads;
  38542. private _oneGamepadConnected;
  38543. /** @hidden */ private _isMonitoring: boolean;
  38544. private _gamepadEventSupported;
  38545. private _gamepadSupport;
  38546. /**
  38547. * observable to be triggered when the gamepad controller has been connected
  38548. */
  38549. onGamepadConnectedObservable: Observable<Gamepad>;
  38550. /**
  38551. * observable to be triggered when the gamepad controller has been disconnected
  38552. */
  38553. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38554. private _onGamepadConnectedEvent;
  38555. private _onGamepadDisconnectedEvent;
  38556. /**
  38557. * Initializes the gamepad manager
  38558. * @param _scene BabylonJS scene
  38559. */
  38560. constructor(_scene?: Scene | undefined);
  38561. /**
  38562. * The gamepads in the game pad manager
  38563. */
  38564. readonly gamepads: Gamepad[];
  38565. /**
  38566. * Get the gamepad controllers based on type
  38567. * @param type The type of gamepad controller
  38568. * @returns Nullable gamepad
  38569. */
  38570. getGamepadByType(type?: number): Nullable<Gamepad>;
  38571. /**
  38572. * Disposes the gamepad manager
  38573. */
  38574. dispose(): void;
  38575. private _addNewGamepad;
  38576. private _startMonitoringGamepads;
  38577. private _stopMonitoringGamepads;
  38578. /** @hidden */ private _checkGamepadsStatus(): void;
  38579. private _updateGamepadObjects;
  38580. }
  38581. }
  38582. declare module BABYLON {
  38583. interface Scene {
  38584. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38585. /**
  38586. * Gets the gamepad manager associated with the scene
  38587. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38588. */
  38589. gamepadManager: GamepadManager;
  38590. }
  38591. /**
  38592. * Interface representing a free camera inputs manager
  38593. */
  38594. interface FreeCameraInputsManager {
  38595. /**
  38596. * Adds gamepad input support to the FreeCameraInputsManager.
  38597. * @returns the FreeCameraInputsManager
  38598. */
  38599. addGamepad(): FreeCameraInputsManager;
  38600. }
  38601. /**
  38602. * Interface representing an arc rotate camera inputs manager
  38603. */
  38604. interface ArcRotateCameraInputsManager {
  38605. /**
  38606. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38607. * @returns the camera inputs manager
  38608. */
  38609. addGamepad(): ArcRotateCameraInputsManager;
  38610. }
  38611. /**
  38612. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38613. */
  38614. export class GamepadSystemSceneComponent implements ISceneComponent {
  38615. /**
  38616. * The component name helpfull to identify the component in the list of scene components.
  38617. */
  38618. readonly name: string;
  38619. /**
  38620. * The scene the component belongs to.
  38621. */
  38622. scene: Scene;
  38623. /**
  38624. * Creates a new instance of the component for the given scene
  38625. * @param scene Defines the scene to register the component in
  38626. */
  38627. constructor(scene: Scene);
  38628. /**
  38629. * Registers the component in a given scene
  38630. */
  38631. register(): void;
  38632. /**
  38633. * Rebuilds the elements related to this component in case of
  38634. * context lost for instance.
  38635. */
  38636. rebuild(): void;
  38637. /**
  38638. * Disposes the component and the associated ressources
  38639. */
  38640. dispose(): void;
  38641. private _beforeCameraUpdate;
  38642. }
  38643. }
  38644. declare module BABYLON {
  38645. /**
  38646. * 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,
  38647. * which still works and will still be found in many Playgrounds.
  38648. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38649. */
  38650. export class UniversalCamera extends TouchCamera {
  38651. /**
  38652. * Defines the gamepad rotation sensiblity.
  38653. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38654. */
  38655. gamepadAngularSensibility: number;
  38656. /**
  38657. * Defines the gamepad move sensiblity.
  38658. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38659. */
  38660. gamepadMoveSensibility: number;
  38661. /**
  38662. * 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,
  38663. * which still works and will still be found in many Playgrounds.
  38664. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38665. * @param name Define the name of the camera in the scene
  38666. * @param position Define the start position of the camera in the scene
  38667. * @param scene Define the scene the camera belongs to
  38668. */
  38669. constructor(name: string, position: Vector3, scene: Scene);
  38670. /**
  38671. * Gets the current object class name.
  38672. * @return the class name
  38673. */
  38674. getClassName(): string;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * This represents a FPS type of camera. This is only here for back compat purpose.
  38680. * Please use the UniversalCamera instead as both are identical.
  38681. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38682. */
  38683. export class GamepadCamera extends UniversalCamera {
  38684. /**
  38685. * Instantiates a new Gamepad Camera
  38686. * This represents a FPS type of camera. This is only here for back compat purpose.
  38687. * Please use the UniversalCamera instead as both are identical.
  38688. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38689. * @param name Define the name of the camera in the scene
  38690. * @param position Define the start position of the camera in the scene
  38691. * @param scene Define the scene the camera belongs to
  38692. */
  38693. constructor(name: string, position: Vector3, scene: Scene);
  38694. /**
  38695. * Gets the current object class name.
  38696. * @return the class name
  38697. */
  38698. getClassName(): string;
  38699. }
  38700. }
  38701. declare module BABYLON {
  38702. /** @hidden */
  38703. export var passPixelShader: {
  38704. name: string;
  38705. shader: string;
  38706. };
  38707. }
  38708. declare module BABYLON {
  38709. /** @hidden */
  38710. export var passCubePixelShader: {
  38711. name: string;
  38712. shader: string;
  38713. };
  38714. }
  38715. declare module BABYLON {
  38716. /**
  38717. * PassPostProcess which produces an output the same as it's input
  38718. */
  38719. export class PassPostProcess extends PostProcess {
  38720. /**
  38721. * Creates the PassPostProcess
  38722. * @param name The name of the effect.
  38723. * @param options The required width/height ratio to downsize to before computing the render pass.
  38724. * @param camera The camera to apply the render pass to.
  38725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38726. * @param engine The engine which the post process will be applied. (default: current engine)
  38727. * @param reusable If the post process can be reused on the same frame. (default: false)
  38728. * @param textureType The type of texture to be used when performing the post processing.
  38729. * @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)
  38730. */
  38731. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38732. }
  38733. /**
  38734. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38735. */
  38736. export class PassCubePostProcess extends PostProcess {
  38737. private _face;
  38738. /**
  38739. * Gets or sets the cube face to display.
  38740. * * 0 is +X
  38741. * * 1 is -X
  38742. * * 2 is +Y
  38743. * * 3 is -Y
  38744. * * 4 is +Z
  38745. * * 5 is -Z
  38746. */
  38747. face: number;
  38748. /**
  38749. * Creates the PassCubePostProcess
  38750. * @param name The name of the effect.
  38751. * @param options The required width/height ratio to downsize to before computing the render pass.
  38752. * @param camera The camera to apply the render pass to.
  38753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38754. * @param engine The engine which the post process will be applied. (default: current engine)
  38755. * @param reusable If the post process can be reused on the same frame. (default: false)
  38756. * @param textureType The type of texture to be used when performing the post processing.
  38757. * @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)
  38758. */
  38759. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38760. }
  38761. }
  38762. declare module BABYLON {
  38763. /** @hidden */
  38764. export var anaglyphPixelShader: {
  38765. name: string;
  38766. shader: string;
  38767. };
  38768. }
  38769. declare module BABYLON {
  38770. /**
  38771. * Postprocess used to generate anaglyphic rendering
  38772. */
  38773. export class AnaglyphPostProcess extends PostProcess {
  38774. private _passedProcess;
  38775. /**
  38776. * Creates a new AnaglyphPostProcess
  38777. * @param name defines postprocess name
  38778. * @param options defines creation options or target ratio scale
  38779. * @param rigCameras defines cameras using this postprocess
  38780. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38781. * @param engine defines hosting engine
  38782. * @param reusable defines if the postprocess will be reused multiple times per frame
  38783. */
  38784. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38785. }
  38786. }
  38787. declare module BABYLON {
  38788. /**
  38789. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38790. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38791. */
  38792. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38793. /**
  38794. * Creates a new AnaglyphArcRotateCamera
  38795. * @param name defines camera name
  38796. * @param alpha defines alpha angle (in radians)
  38797. * @param beta defines beta angle (in radians)
  38798. * @param radius defines radius
  38799. * @param target defines camera target
  38800. * @param interaxialDistance defines distance between each color axis
  38801. * @param scene defines the hosting scene
  38802. */
  38803. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38804. /**
  38805. * Gets camera class name
  38806. * @returns AnaglyphArcRotateCamera
  38807. */
  38808. getClassName(): string;
  38809. }
  38810. }
  38811. declare module BABYLON {
  38812. /**
  38813. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38814. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38815. */
  38816. export class AnaglyphFreeCamera extends FreeCamera {
  38817. /**
  38818. * Creates a new AnaglyphFreeCamera
  38819. * @param name defines camera name
  38820. * @param position defines initial position
  38821. * @param interaxialDistance defines distance between each color axis
  38822. * @param scene defines the hosting scene
  38823. */
  38824. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38825. /**
  38826. * Gets camera class name
  38827. * @returns AnaglyphFreeCamera
  38828. */
  38829. getClassName(): string;
  38830. }
  38831. }
  38832. declare module BABYLON {
  38833. /**
  38834. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38835. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38836. */
  38837. export class AnaglyphGamepadCamera extends GamepadCamera {
  38838. /**
  38839. * Creates a new AnaglyphGamepadCamera
  38840. * @param name defines camera name
  38841. * @param position defines initial position
  38842. * @param interaxialDistance defines distance between each color axis
  38843. * @param scene defines the hosting scene
  38844. */
  38845. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38846. /**
  38847. * Gets camera class name
  38848. * @returns AnaglyphGamepadCamera
  38849. */
  38850. getClassName(): string;
  38851. }
  38852. }
  38853. declare module BABYLON {
  38854. /**
  38855. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38856. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38857. */
  38858. export class AnaglyphUniversalCamera extends UniversalCamera {
  38859. /**
  38860. * Creates a new AnaglyphUniversalCamera
  38861. * @param name defines camera name
  38862. * @param position defines initial position
  38863. * @param interaxialDistance defines distance between each color axis
  38864. * @param scene defines the hosting scene
  38865. */
  38866. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38867. /**
  38868. * Gets camera class name
  38869. * @returns AnaglyphUniversalCamera
  38870. */
  38871. getClassName(): string;
  38872. }
  38873. }
  38874. declare module BABYLON {
  38875. /** @hidden */
  38876. export var stereoscopicInterlacePixelShader: {
  38877. name: string;
  38878. shader: string;
  38879. };
  38880. }
  38881. declare module BABYLON {
  38882. /**
  38883. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38884. */
  38885. export class StereoscopicInterlacePostProcess extends PostProcess {
  38886. private _stepSize;
  38887. private _passedProcess;
  38888. /**
  38889. * Initializes a StereoscopicInterlacePostProcess
  38890. * @param name The name of the effect.
  38891. * @param rigCameras The rig cameras to be appled to the post process
  38892. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38894. * @param engine The engine which the post process will be applied. (default: current engine)
  38895. * @param reusable If the post process can be reused on the same frame. (default: false)
  38896. */
  38897. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38898. }
  38899. }
  38900. declare module BABYLON {
  38901. /**
  38902. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38903. * @see http://doc.babylonjs.com/features/cameras
  38904. */
  38905. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38906. /**
  38907. * Creates a new StereoscopicArcRotateCamera
  38908. * @param name defines camera name
  38909. * @param alpha defines alpha angle (in radians)
  38910. * @param beta defines beta angle (in radians)
  38911. * @param radius defines radius
  38912. * @param target defines camera target
  38913. * @param interaxialDistance defines distance between each color axis
  38914. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38915. * @param scene defines the hosting scene
  38916. */
  38917. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38918. /**
  38919. * Gets camera class name
  38920. * @returns StereoscopicArcRotateCamera
  38921. */
  38922. getClassName(): string;
  38923. }
  38924. }
  38925. declare module BABYLON {
  38926. /**
  38927. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38928. * @see http://doc.babylonjs.com/features/cameras
  38929. */
  38930. export class StereoscopicFreeCamera extends FreeCamera {
  38931. /**
  38932. * Creates a new StereoscopicFreeCamera
  38933. * @param name defines camera name
  38934. * @param position defines initial position
  38935. * @param interaxialDistance defines distance between each color axis
  38936. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38937. * @param scene defines the hosting scene
  38938. */
  38939. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38940. /**
  38941. * Gets camera class name
  38942. * @returns StereoscopicFreeCamera
  38943. */
  38944. getClassName(): string;
  38945. }
  38946. }
  38947. declare module BABYLON {
  38948. /**
  38949. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38950. * @see http://doc.babylonjs.com/features/cameras
  38951. */
  38952. export class StereoscopicGamepadCamera extends GamepadCamera {
  38953. /**
  38954. * Creates a new StereoscopicGamepadCamera
  38955. * @param name defines camera name
  38956. * @param position defines initial position
  38957. * @param interaxialDistance defines distance between each color axis
  38958. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38959. * @param scene defines the hosting scene
  38960. */
  38961. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38962. /**
  38963. * Gets camera class name
  38964. * @returns StereoscopicGamepadCamera
  38965. */
  38966. getClassName(): string;
  38967. }
  38968. }
  38969. declare module BABYLON {
  38970. /**
  38971. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38972. * @see http://doc.babylonjs.com/features/cameras
  38973. */
  38974. export class StereoscopicUniversalCamera extends UniversalCamera {
  38975. /**
  38976. * Creates a new StereoscopicUniversalCamera
  38977. * @param name defines camera name
  38978. * @param position defines initial position
  38979. * @param interaxialDistance defines distance between each color axis
  38980. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38981. * @param scene defines the hosting scene
  38982. */
  38983. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38984. /**
  38985. * Gets camera class name
  38986. * @returns StereoscopicUniversalCamera
  38987. */
  38988. getClassName(): string;
  38989. }
  38990. }
  38991. declare module BABYLON {
  38992. /**
  38993. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38994. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38995. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38996. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38997. */
  38998. export class VirtualJoysticksCamera extends FreeCamera {
  38999. /**
  39000. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39001. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39002. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39003. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39004. * @param name Define the name of the camera in the scene
  39005. * @param position Define the start position of the camera in the scene
  39006. * @param scene Define the scene the camera belongs to
  39007. */
  39008. constructor(name: string, position: Vector3, scene: Scene);
  39009. /**
  39010. * Gets the current object class name.
  39011. * @return the class name
  39012. */
  39013. getClassName(): string;
  39014. }
  39015. }
  39016. declare module BABYLON {
  39017. /**
  39018. * This represents all the required metrics to create a VR camera.
  39019. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39020. */
  39021. export class VRCameraMetrics {
  39022. /**
  39023. * Define the horizontal resolution off the screen.
  39024. */
  39025. hResolution: number;
  39026. /**
  39027. * Define the vertical resolution off the screen.
  39028. */
  39029. vResolution: number;
  39030. /**
  39031. * Define the horizontal screen size.
  39032. */
  39033. hScreenSize: number;
  39034. /**
  39035. * Define the vertical screen size.
  39036. */
  39037. vScreenSize: number;
  39038. /**
  39039. * Define the vertical screen center position.
  39040. */
  39041. vScreenCenter: number;
  39042. /**
  39043. * Define the distance of the eyes to the screen.
  39044. */
  39045. eyeToScreenDistance: number;
  39046. /**
  39047. * Define the distance between both lenses
  39048. */
  39049. lensSeparationDistance: number;
  39050. /**
  39051. * Define the distance between both viewer's eyes.
  39052. */
  39053. interpupillaryDistance: number;
  39054. /**
  39055. * Define the distortion factor of the VR postprocess.
  39056. * Please, touch with care.
  39057. */
  39058. distortionK: number[];
  39059. /**
  39060. * Define the chromatic aberration correction factors for the VR post process.
  39061. */
  39062. chromaAbCorrection: number[];
  39063. /**
  39064. * Define the scale factor of the post process.
  39065. * The smaller the better but the slower.
  39066. */
  39067. postProcessScaleFactor: number;
  39068. /**
  39069. * Define an offset for the lens center.
  39070. */
  39071. lensCenterOffset: number;
  39072. /**
  39073. * Define if the current vr camera should compensate the distortion of the lense or not.
  39074. */
  39075. compensateDistortion: boolean;
  39076. /**
  39077. * Defines if multiview should be enabled when rendering (Default: false)
  39078. */
  39079. multiviewEnabled: boolean;
  39080. /**
  39081. * Gets the rendering aspect ratio based on the provided resolutions.
  39082. */
  39083. readonly aspectRatio: number;
  39084. /**
  39085. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39086. */
  39087. readonly aspectRatioFov: number;
  39088. /**
  39089. * @hidden
  39090. */
  39091. readonly leftHMatrix: Matrix;
  39092. /**
  39093. * @hidden
  39094. */
  39095. readonly rightHMatrix: Matrix;
  39096. /**
  39097. * @hidden
  39098. */
  39099. readonly leftPreViewMatrix: Matrix;
  39100. /**
  39101. * @hidden
  39102. */
  39103. readonly rightPreViewMatrix: Matrix;
  39104. /**
  39105. * Get the default VRMetrics based on the most generic setup.
  39106. * @returns the default vr metrics
  39107. */
  39108. static GetDefault(): VRCameraMetrics;
  39109. }
  39110. }
  39111. declare module BABYLON {
  39112. /** @hidden */
  39113. export var vrDistortionCorrectionPixelShader: {
  39114. name: string;
  39115. shader: string;
  39116. };
  39117. }
  39118. declare module BABYLON {
  39119. /**
  39120. * VRDistortionCorrectionPostProcess used for mobile VR
  39121. */
  39122. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39123. private _isRightEye;
  39124. private _distortionFactors;
  39125. private _postProcessScaleFactor;
  39126. private _lensCenterOffset;
  39127. private _scaleIn;
  39128. private _scaleFactor;
  39129. private _lensCenter;
  39130. /**
  39131. * Initializes the VRDistortionCorrectionPostProcess
  39132. * @param name The name of the effect.
  39133. * @param camera The camera to apply the render pass to.
  39134. * @param isRightEye If this is for the right eye distortion
  39135. * @param vrMetrics All the required metrics for the VR camera
  39136. */
  39137. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39138. }
  39139. }
  39140. declare module BABYLON {
  39141. /**
  39142. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39143. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39144. */
  39145. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39146. /**
  39147. * Creates a new VRDeviceOrientationArcRotateCamera
  39148. * @param name defines camera name
  39149. * @param alpha defines the camera rotation along the logitudinal axis
  39150. * @param beta defines the camera rotation along the latitudinal axis
  39151. * @param radius defines the camera distance from its target
  39152. * @param target defines the camera target
  39153. * @param scene defines the scene the camera belongs to
  39154. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39155. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39156. */
  39157. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39158. /**
  39159. * Gets camera class name
  39160. * @returns VRDeviceOrientationArcRotateCamera
  39161. */
  39162. getClassName(): string;
  39163. }
  39164. }
  39165. declare module BABYLON {
  39166. /**
  39167. * Camera used to simulate VR rendering (based on FreeCamera)
  39168. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39169. */
  39170. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39171. /**
  39172. * Creates a new VRDeviceOrientationFreeCamera
  39173. * @param name defines camera name
  39174. * @param position defines the start position of the camera
  39175. * @param scene defines the scene the camera belongs to
  39176. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39177. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39178. */
  39179. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39180. /**
  39181. * Gets camera class name
  39182. * @returns VRDeviceOrientationFreeCamera
  39183. */
  39184. getClassName(): string;
  39185. }
  39186. }
  39187. declare module BABYLON {
  39188. /**
  39189. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39190. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39191. */
  39192. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39193. /**
  39194. * Creates a new VRDeviceOrientationGamepadCamera
  39195. * @param name defines camera name
  39196. * @param position defines the start position of the camera
  39197. * @param scene defines the scene the camera belongs to
  39198. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39199. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39200. */
  39201. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39202. /**
  39203. * Gets camera class name
  39204. * @returns VRDeviceOrientationGamepadCamera
  39205. */
  39206. getClassName(): string;
  39207. }
  39208. }
  39209. declare module BABYLON {
  39210. /**
  39211. * Base class of materials working in push mode in babylon JS
  39212. * @hidden
  39213. */
  39214. export class PushMaterial extends Material {
  39215. protected _activeEffect: Effect;
  39216. protected _normalMatrix: Matrix;
  39217. /**
  39218. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39219. * This means that the material can keep using a previous shader while a new one is being compiled.
  39220. * This is mostly used when shader parallel compilation is supported (true by default)
  39221. */
  39222. allowShaderHotSwapping: boolean;
  39223. constructor(name: string, scene: Scene);
  39224. getEffect(): Effect;
  39225. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39226. /**
  39227. * Binds the given world matrix to the active effect
  39228. *
  39229. * @param world the matrix to bind
  39230. */
  39231. bindOnlyWorldMatrix(world: Matrix): void;
  39232. /**
  39233. * Binds the given normal matrix to the active effect
  39234. *
  39235. * @param normalMatrix the matrix to bind
  39236. */
  39237. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39238. bind(world: Matrix, mesh?: Mesh): void;
  39239. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39240. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39241. }
  39242. }
  39243. declare module BABYLON {
  39244. /**
  39245. * This groups all the flags used to control the materials channel.
  39246. */
  39247. export class MaterialFlags {
  39248. private static _DiffuseTextureEnabled;
  39249. /**
  39250. * Are diffuse textures enabled in the application.
  39251. */
  39252. static DiffuseTextureEnabled: boolean;
  39253. private static _AmbientTextureEnabled;
  39254. /**
  39255. * Are ambient textures enabled in the application.
  39256. */
  39257. static AmbientTextureEnabled: boolean;
  39258. private static _OpacityTextureEnabled;
  39259. /**
  39260. * Are opacity textures enabled in the application.
  39261. */
  39262. static OpacityTextureEnabled: boolean;
  39263. private static _ReflectionTextureEnabled;
  39264. /**
  39265. * Are reflection textures enabled in the application.
  39266. */
  39267. static ReflectionTextureEnabled: boolean;
  39268. private static _EmissiveTextureEnabled;
  39269. /**
  39270. * Are emissive textures enabled in the application.
  39271. */
  39272. static EmissiveTextureEnabled: boolean;
  39273. private static _SpecularTextureEnabled;
  39274. /**
  39275. * Are specular textures enabled in the application.
  39276. */
  39277. static SpecularTextureEnabled: boolean;
  39278. private static _BumpTextureEnabled;
  39279. /**
  39280. * Are bump textures enabled in the application.
  39281. */
  39282. static BumpTextureEnabled: boolean;
  39283. private static _LightmapTextureEnabled;
  39284. /**
  39285. * Are lightmap textures enabled in the application.
  39286. */
  39287. static LightmapTextureEnabled: boolean;
  39288. private static _RefractionTextureEnabled;
  39289. /**
  39290. * Are refraction textures enabled in the application.
  39291. */
  39292. static RefractionTextureEnabled: boolean;
  39293. private static _ColorGradingTextureEnabled;
  39294. /**
  39295. * Are color grading textures enabled in the application.
  39296. */
  39297. static ColorGradingTextureEnabled: boolean;
  39298. private static _FresnelEnabled;
  39299. /**
  39300. * Are fresnels enabled in the application.
  39301. */
  39302. static FresnelEnabled: boolean;
  39303. private static _ClearCoatTextureEnabled;
  39304. /**
  39305. * Are clear coat textures enabled in the application.
  39306. */
  39307. static ClearCoatTextureEnabled: boolean;
  39308. private static _ClearCoatBumpTextureEnabled;
  39309. /**
  39310. * Are clear coat bump textures enabled in the application.
  39311. */
  39312. static ClearCoatBumpTextureEnabled: boolean;
  39313. private static _ClearCoatTintTextureEnabled;
  39314. /**
  39315. * Are clear coat tint textures enabled in the application.
  39316. */
  39317. static ClearCoatTintTextureEnabled: boolean;
  39318. private static _SheenTextureEnabled;
  39319. /**
  39320. * Are sheen textures enabled in the application.
  39321. */
  39322. static SheenTextureEnabled: boolean;
  39323. private static _AnisotropicTextureEnabled;
  39324. /**
  39325. * Are anisotropic textures enabled in the application.
  39326. */
  39327. static AnisotropicTextureEnabled: boolean;
  39328. private static _ThicknessTextureEnabled;
  39329. /**
  39330. * Are thickness textures enabled in the application.
  39331. */
  39332. static ThicknessTextureEnabled: boolean;
  39333. }
  39334. }
  39335. declare module BABYLON {
  39336. /** @hidden */
  39337. export var defaultFragmentDeclaration: {
  39338. name: string;
  39339. shader: string;
  39340. };
  39341. }
  39342. declare module BABYLON {
  39343. /** @hidden */
  39344. export var defaultUboDeclaration: {
  39345. name: string;
  39346. shader: string;
  39347. };
  39348. }
  39349. declare module BABYLON {
  39350. /** @hidden */
  39351. export var lightFragmentDeclaration: {
  39352. name: string;
  39353. shader: string;
  39354. };
  39355. }
  39356. declare module BABYLON {
  39357. /** @hidden */
  39358. export var lightUboDeclaration: {
  39359. name: string;
  39360. shader: string;
  39361. };
  39362. }
  39363. declare module BABYLON {
  39364. /** @hidden */
  39365. export var lightsFragmentFunctions: {
  39366. name: string;
  39367. shader: string;
  39368. };
  39369. }
  39370. declare module BABYLON {
  39371. /** @hidden */
  39372. export var shadowsFragmentFunctions: {
  39373. name: string;
  39374. shader: string;
  39375. };
  39376. }
  39377. declare module BABYLON {
  39378. /** @hidden */
  39379. export var fresnelFunction: {
  39380. name: string;
  39381. shader: string;
  39382. };
  39383. }
  39384. declare module BABYLON {
  39385. /** @hidden */
  39386. export var reflectionFunction: {
  39387. name: string;
  39388. shader: string;
  39389. };
  39390. }
  39391. declare module BABYLON {
  39392. /** @hidden */
  39393. export var bumpFragmentFunctions: {
  39394. name: string;
  39395. shader: string;
  39396. };
  39397. }
  39398. declare module BABYLON {
  39399. /** @hidden */
  39400. export var logDepthDeclaration: {
  39401. name: string;
  39402. shader: string;
  39403. };
  39404. }
  39405. declare module BABYLON {
  39406. /** @hidden */
  39407. export var bumpFragment: {
  39408. name: string;
  39409. shader: string;
  39410. };
  39411. }
  39412. declare module BABYLON {
  39413. /** @hidden */
  39414. export var depthPrePass: {
  39415. name: string;
  39416. shader: string;
  39417. };
  39418. }
  39419. declare module BABYLON {
  39420. /** @hidden */
  39421. export var lightFragment: {
  39422. name: string;
  39423. shader: string;
  39424. };
  39425. }
  39426. declare module BABYLON {
  39427. /** @hidden */
  39428. export var logDepthFragment: {
  39429. name: string;
  39430. shader: string;
  39431. };
  39432. }
  39433. declare module BABYLON {
  39434. /** @hidden */
  39435. export var defaultPixelShader: {
  39436. name: string;
  39437. shader: string;
  39438. };
  39439. }
  39440. declare module BABYLON {
  39441. /** @hidden */
  39442. export var defaultVertexDeclaration: {
  39443. name: string;
  39444. shader: string;
  39445. };
  39446. }
  39447. declare module BABYLON {
  39448. /** @hidden */
  39449. export var bumpVertexDeclaration: {
  39450. name: string;
  39451. shader: string;
  39452. };
  39453. }
  39454. declare module BABYLON {
  39455. /** @hidden */
  39456. export var bumpVertex: {
  39457. name: string;
  39458. shader: string;
  39459. };
  39460. }
  39461. declare module BABYLON {
  39462. /** @hidden */
  39463. export var fogVertex: {
  39464. name: string;
  39465. shader: string;
  39466. };
  39467. }
  39468. declare module BABYLON {
  39469. /** @hidden */
  39470. export var shadowsVertex: {
  39471. name: string;
  39472. shader: string;
  39473. };
  39474. }
  39475. declare module BABYLON {
  39476. /** @hidden */
  39477. export var pointCloudVertex: {
  39478. name: string;
  39479. shader: string;
  39480. };
  39481. }
  39482. declare module BABYLON {
  39483. /** @hidden */
  39484. export var logDepthVertex: {
  39485. name: string;
  39486. shader: string;
  39487. };
  39488. }
  39489. declare module BABYLON {
  39490. /** @hidden */
  39491. export var defaultVertexShader: {
  39492. name: string;
  39493. shader: string;
  39494. };
  39495. }
  39496. declare module BABYLON {
  39497. /** @hidden */
  39498. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39499. MAINUV1: boolean;
  39500. MAINUV2: boolean;
  39501. DIFFUSE: boolean;
  39502. DIFFUSEDIRECTUV: number;
  39503. AMBIENT: boolean;
  39504. AMBIENTDIRECTUV: number;
  39505. OPACITY: boolean;
  39506. OPACITYDIRECTUV: number;
  39507. OPACITYRGB: boolean;
  39508. REFLECTION: boolean;
  39509. EMISSIVE: boolean;
  39510. EMISSIVEDIRECTUV: number;
  39511. SPECULAR: boolean;
  39512. SPECULARDIRECTUV: number;
  39513. BUMP: boolean;
  39514. BUMPDIRECTUV: number;
  39515. PARALLAX: boolean;
  39516. PARALLAXOCCLUSION: boolean;
  39517. SPECULAROVERALPHA: boolean;
  39518. CLIPPLANE: boolean;
  39519. CLIPPLANE2: boolean;
  39520. CLIPPLANE3: boolean;
  39521. CLIPPLANE4: boolean;
  39522. ALPHATEST: boolean;
  39523. DEPTHPREPASS: boolean;
  39524. ALPHAFROMDIFFUSE: boolean;
  39525. POINTSIZE: boolean;
  39526. FOG: boolean;
  39527. SPECULARTERM: boolean;
  39528. DIFFUSEFRESNEL: boolean;
  39529. OPACITYFRESNEL: boolean;
  39530. REFLECTIONFRESNEL: boolean;
  39531. REFRACTIONFRESNEL: boolean;
  39532. EMISSIVEFRESNEL: boolean;
  39533. FRESNEL: boolean;
  39534. NORMAL: boolean;
  39535. UV1: boolean;
  39536. UV2: boolean;
  39537. VERTEXCOLOR: boolean;
  39538. VERTEXALPHA: boolean;
  39539. NUM_BONE_INFLUENCERS: number;
  39540. BonesPerMesh: number;
  39541. BONETEXTURE: boolean;
  39542. INSTANCES: boolean;
  39543. GLOSSINESS: boolean;
  39544. ROUGHNESS: boolean;
  39545. EMISSIVEASILLUMINATION: boolean;
  39546. LINKEMISSIVEWITHDIFFUSE: boolean;
  39547. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39548. LIGHTMAP: boolean;
  39549. LIGHTMAPDIRECTUV: number;
  39550. OBJECTSPACE_NORMALMAP: boolean;
  39551. USELIGHTMAPASSHADOWMAP: boolean;
  39552. REFLECTIONMAP_3D: boolean;
  39553. REFLECTIONMAP_SPHERICAL: boolean;
  39554. REFLECTIONMAP_PLANAR: boolean;
  39555. REFLECTIONMAP_CUBIC: boolean;
  39556. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39557. REFLECTIONMAP_PROJECTION: boolean;
  39558. REFLECTIONMAP_SKYBOX: boolean;
  39559. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39560. REFLECTIONMAP_EXPLICIT: boolean;
  39561. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39562. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39563. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39564. INVERTCUBICMAP: boolean;
  39565. LOGARITHMICDEPTH: boolean;
  39566. REFRACTION: boolean;
  39567. REFRACTIONMAP_3D: boolean;
  39568. REFLECTIONOVERALPHA: boolean;
  39569. TWOSIDEDLIGHTING: boolean;
  39570. SHADOWFLOAT: boolean;
  39571. MORPHTARGETS: boolean;
  39572. MORPHTARGETS_NORMAL: boolean;
  39573. MORPHTARGETS_TANGENT: boolean;
  39574. MORPHTARGETS_UV: boolean;
  39575. NUM_MORPH_INFLUENCERS: number;
  39576. NONUNIFORMSCALING: boolean;
  39577. PREMULTIPLYALPHA: boolean;
  39578. IMAGEPROCESSING: boolean;
  39579. VIGNETTE: boolean;
  39580. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39581. VIGNETTEBLENDMODEOPAQUE: boolean;
  39582. TONEMAPPING: boolean;
  39583. TONEMAPPING_ACES: boolean;
  39584. CONTRAST: boolean;
  39585. COLORCURVES: boolean;
  39586. COLORGRADING: boolean;
  39587. COLORGRADING3D: boolean;
  39588. SAMPLER3DGREENDEPTH: boolean;
  39589. SAMPLER3DBGRMAP: boolean;
  39590. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39591. MULTIVIEW: boolean;
  39592. /**
  39593. * If the reflection texture on this material is in linear color space
  39594. * @hidden
  39595. */
  39596. IS_REFLECTION_LINEAR: boolean;
  39597. /**
  39598. * If the refraction texture on this material is in linear color space
  39599. * @hidden
  39600. */
  39601. IS_REFRACTION_LINEAR: boolean;
  39602. EXPOSURE: boolean;
  39603. constructor();
  39604. setReflectionMode(modeToEnable: string): void;
  39605. }
  39606. /**
  39607. * This is the default material used in Babylon. It is the best trade off between quality
  39608. * and performances.
  39609. * @see http://doc.babylonjs.com/babylon101/materials
  39610. */
  39611. export class StandardMaterial extends PushMaterial {
  39612. private _diffuseTexture;
  39613. /**
  39614. * The basic texture of the material as viewed under a light.
  39615. */
  39616. diffuseTexture: Nullable<BaseTexture>;
  39617. private _ambientTexture;
  39618. /**
  39619. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39620. */
  39621. ambientTexture: Nullable<BaseTexture>;
  39622. private _opacityTexture;
  39623. /**
  39624. * Define the transparency of the material from a texture.
  39625. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39626. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39627. */
  39628. opacityTexture: Nullable<BaseTexture>;
  39629. private _reflectionTexture;
  39630. /**
  39631. * Define the texture used to display the reflection.
  39632. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39633. */
  39634. reflectionTexture: Nullable<BaseTexture>;
  39635. private _emissiveTexture;
  39636. /**
  39637. * Define texture of the material as if self lit.
  39638. * This will be mixed in the final result even in the absence of light.
  39639. */
  39640. emissiveTexture: Nullable<BaseTexture>;
  39641. private _specularTexture;
  39642. /**
  39643. * Define how the color and intensity of the highlight given by the light in the material.
  39644. */
  39645. specularTexture: Nullable<BaseTexture>;
  39646. private _bumpTexture;
  39647. /**
  39648. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39649. * 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.
  39650. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39651. */
  39652. bumpTexture: Nullable<BaseTexture>;
  39653. private _lightmapTexture;
  39654. /**
  39655. * Complex lighting can be computationally expensive to compute at runtime.
  39656. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39657. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39658. */
  39659. lightmapTexture: Nullable<BaseTexture>;
  39660. private _refractionTexture;
  39661. /**
  39662. * Define the texture used to display the refraction.
  39663. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39664. */
  39665. refractionTexture: Nullable<BaseTexture>;
  39666. /**
  39667. * The color of the material lit by the environmental background lighting.
  39668. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39669. */
  39670. ambientColor: Color3;
  39671. /**
  39672. * The basic color of the material as viewed under a light.
  39673. */
  39674. diffuseColor: Color3;
  39675. /**
  39676. * Define how the color and intensity of the highlight given by the light in the material.
  39677. */
  39678. specularColor: Color3;
  39679. /**
  39680. * Define the color of the material as if self lit.
  39681. * This will be mixed in the final result even in the absence of light.
  39682. */
  39683. emissiveColor: Color3;
  39684. /**
  39685. * Defines how sharp are the highlights in the material.
  39686. * The bigger the value the sharper giving a more glossy feeling to the result.
  39687. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39688. */
  39689. specularPower: number;
  39690. private _useAlphaFromDiffuseTexture;
  39691. /**
  39692. * Does the transparency come from the diffuse texture alpha channel.
  39693. */
  39694. useAlphaFromDiffuseTexture: boolean;
  39695. private _useEmissiveAsIllumination;
  39696. /**
  39697. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39698. */
  39699. useEmissiveAsIllumination: boolean;
  39700. private _linkEmissiveWithDiffuse;
  39701. /**
  39702. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39703. * the emissive level when the final color is close to one.
  39704. */
  39705. linkEmissiveWithDiffuse: boolean;
  39706. private _useSpecularOverAlpha;
  39707. /**
  39708. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39709. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39710. */
  39711. useSpecularOverAlpha: boolean;
  39712. private _useReflectionOverAlpha;
  39713. /**
  39714. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39715. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39716. */
  39717. useReflectionOverAlpha: boolean;
  39718. private _disableLighting;
  39719. /**
  39720. * Does lights from the scene impacts this material.
  39721. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39722. */
  39723. disableLighting: boolean;
  39724. private _useObjectSpaceNormalMap;
  39725. /**
  39726. * Allows using an object space normal map (instead of tangent space).
  39727. */
  39728. useObjectSpaceNormalMap: boolean;
  39729. private _useParallax;
  39730. /**
  39731. * Is parallax enabled or not.
  39732. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39733. */
  39734. useParallax: boolean;
  39735. private _useParallaxOcclusion;
  39736. /**
  39737. * Is parallax occlusion enabled or not.
  39738. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39739. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39740. */
  39741. useParallaxOcclusion: boolean;
  39742. /**
  39743. * 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.
  39744. */
  39745. parallaxScaleBias: number;
  39746. private _roughness;
  39747. /**
  39748. * Helps to define how blurry the reflections should appears in the material.
  39749. */
  39750. roughness: number;
  39751. /**
  39752. * In case of refraction, define the value of the index of refraction.
  39753. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39754. */
  39755. indexOfRefraction: number;
  39756. /**
  39757. * Invert the refraction texture alongside the y axis.
  39758. * It can be useful with procedural textures or probe for instance.
  39759. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39760. */
  39761. invertRefractionY: boolean;
  39762. /**
  39763. * Defines the alpha limits in alpha test mode.
  39764. */
  39765. alphaCutOff: number;
  39766. private _useLightmapAsShadowmap;
  39767. /**
  39768. * In case of light mapping, define whether the map contains light or shadow informations.
  39769. */
  39770. useLightmapAsShadowmap: boolean;
  39771. private _diffuseFresnelParameters;
  39772. /**
  39773. * Define the diffuse fresnel parameters of the material.
  39774. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39775. */
  39776. diffuseFresnelParameters: FresnelParameters;
  39777. private _opacityFresnelParameters;
  39778. /**
  39779. * Define the opacity fresnel parameters of the material.
  39780. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39781. */
  39782. opacityFresnelParameters: FresnelParameters;
  39783. private _reflectionFresnelParameters;
  39784. /**
  39785. * Define the reflection fresnel parameters of the material.
  39786. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39787. */
  39788. reflectionFresnelParameters: FresnelParameters;
  39789. private _refractionFresnelParameters;
  39790. /**
  39791. * Define the refraction fresnel parameters of the material.
  39792. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39793. */
  39794. refractionFresnelParameters: FresnelParameters;
  39795. private _emissiveFresnelParameters;
  39796. /**
  39797. * Define the emissive fresnel parameters of the material.
  39798. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39799. */
  39800. emissiveFresnelParameters: FresnelParameters;
  39801. private _useReflectionFresnelFromSpecular;
  39802. /**
  39803. * If true automatically deducts the fresnels values from the material specularity.
  39804. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39805. */
  39806. useReflectionFresnelFromSpecular: boolean;
  39807. private _useGlossinessFromSpecularMapAlpha;
  39808. /**
  39809. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39810. */
  39811. useGlossinessFromSpecularMapAlpha: boolean;
  39812. private _maxSimultaneousLights;
  39813. /**
  39814. * Defines the maximum number of lights that can be used in the material
  39815. */
  39816. maxSimultaneousLights: number;
  39817. private _invertNormalMapX;
  39818. /**
  39819. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39820. */
  39821. invertNormalMapX: boolean;
  39822. private _invertNormalMapY;
  39823. /**
  39824. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39825. */
  39826. invertNormalMapY: boolean;
  39827. private _twoSidedLighting;
  39828. /**
  39829. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39830. */
  39831. twoSidedLighting: boolean;
  39832. /**
  39833. * Default configuration related to image processing available in the standard Material.
  39834. */
  39835. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39836. /**
  39837. * Gets the image processing configuration used either in this material.
  39838. */
  39839. /**
  39840. * Sets the Default image processing configuration used either in the this material.
  39841. *
  39842. * If sets to null, the scene one is in use.
  39843. */
  39844. imageProcessingConfiguration: ImageProcessingConfiguration;
  39845. /**
  39846. * Keep track of the image processing observer to allow dispose and replace.
  39847. */
  39848. private _imageProcessingObserver;
  39849. /**
  39850. * Attaches a new image processing configuration to the Standard Material.
  39851. * @param configuration
  39852. */
  39853. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39854. /**
  39855. * Gets wether the color curves effect is enabled.
  39856. */
  39857. /**
  39858. * Sets wether the color curves effect is enabled.
  39859. */
  39860. cameraColorCurvesEnabled: boolean;
  39861. /**
  39862. * Gets wether the color grading effect is enabled.
  39863. */
  39864. /**
  39865. * Gets wether the color grading effect is enabled.
  39866. */
  39867. cameraColorGradingEnabled: boolean;
  39868. /**
  39869. * Gets wether tonemapping is enabled or not.
  39870. */
  39871. /**
  39872. * Sets wether tonemapping is enabled or not
  39873. */
  39874. cameraToneMappingEnabled: boolean;
  39875. /**
  39876. * The camera exposure used on this material.
  39877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39878. * This corresponds to a photographic exposure.
  39879. */
  39880. /**
  39881. * The camera exposure used on this material.
  39882. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39883. * This corresponds to a photographic exposure.
  39884. */
  39885. cameraExposure: number;
  39886. /**
  39887. * Gets The camera contrast used on this material.
  39888. */
  39889. /**
  39890. * Sets The camera contrast used on this material.
  39891. */
  39892. cameraContrast: number;
  39893. /**
  39894. * Gets the Color Grading 2D Lookup Texture.
  39895. */
  39896. /**
  39897. * Sets the Color Grading 2D Lookup Texture.
  39898. */
  39899. cameraColorGradingTexture: Nullable<BaseTexture>;
  39900. /**
  39901. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39902. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39903. * 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;
  39904. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39905. */
  39906. /**
  39907. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39908. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39909. * 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;
  39910. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39911. */
  39912. cameraColorCurves: Nullable<ColorCurves>;
  39913. /**
  39914. * Custom callback helping to override the default shader used in the material.
  39915. */
  39916. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39917. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39918. protected _worldViewProjectionMatrix: Matrix;
  39919. protected _globalAmbientColor: Color3;
  39920. protected _useLogarithmicDepth: boolean;
  39921. protected _rebuildInParallel: boolean;
  39922. /**
  39923. * Instantiates a new standard material.
  39924. * This is the default material used in Babylon. It is the best trade off between quality
  39925. * and performances.
  39926. * @see http://doc.babylonjs.com/babylon101/materials
  39927. * @param name Define the name of the material in the scene
  39928. * @param scene Define the scene the material belong to
  39929. */
  39930. constructor(name: string, scene: Scene);
  39931. /**
  39932. * Gets a boolean indicating that current material needs to register RTT
  39933. */
  39934. readonly hasRenderTargetTextures: boolean;
  39935. /**
  39936. * Gets the current class name of the material e.g. "StandardMaterial"
  39937. * Mainly use in serialization.
  39938. * @returns the class name
  39939. */
  39940. getClassName(): string;
  39941. /**
  39942. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39943. * You can try switching to logarithmic depth.
  39944. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39945. */
  39946. useLogarithmicDepth: boolean;
  39947. /**
  39948. * Specifies if the material will require alpha blending
  39949. * @returns a boolean specifying if alpha blending is needed
  39950. */
  39951. needAlphaBlending(): boolean;
  39952. /**
  39953. * Specifies if this material should be rendered in alpha test mode
  39954. * @returns a boolean specifying if an alpha test is needed.
  39955. */
  39956. needAlphaTesting(): boolean;
  39957. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39958. /**
  39959. * Get the texture used for alpha test purpose.
  39960. * @returns the diffuse texture in case of the standard material.
  39961. */
  39962. getAlphaTestTexture(): Nullable<BaseTexture>;
  39963. /**
  39964. * Get if the submesh is ready to be used and all its information available.
  39965. * Child classes can use it to update shaders
  39966. * @param mesh defines the mesh to check
  39967. * @param subMesh defines which submesh to check
  39968. * @param useInstances specifies that instances should be used
  39969. * @returns a boolean indicating that the submesh is ready or not
  39970. */
  39971. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39972. /**
  39973. * Builds the material UBO layouts.
  39974. * Used internally during the effect preparation.
  39975. */
  39976. buildUniformLayout(): void;
  39977. /**
  39978. * Unbinds the material from the mesh
  39979. */
  39980. unbind(): void;
  39981. /**
  39982. * Binds the submesh to this material by preparing the effect and shader to draw
  39983. * @param world defines the world transformation matrix
  39984. * @param mesh defines the mesh containing the submesh
  39985. * @param subMesh defines the submesh to bind the material to
  39986. */
  39987. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39988. /**
  39989. * Get the list of animatables in the material.
  39990. * @returns the list of animatables object used in the material
  39991. */
  39992. getAnimatables(): IAnimatable[];
  39993. /**
  39994. * Gets the active textures from the material
  39995. * @returns an array of textures
  39996. */
  39997. getActiveTextures(): BaseTexture[];
  39998. /**
  39999. * Specifies if the material uses a texture
  40000. * @param texture defines the texture to check against the material
  40001. * @returns a boolean specifying if the material uses the texture
  40002. */
  40003. hasTexture(texture: BaseTexture): boolean;
  40004. /**
  40005. * Disposes the material
  40006. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40007. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40008. */
  40009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40010. /**
  40011. * Makes a duplicate of the material, and gives it a new name
  40012. * @param name defines the new name for the duplicated material
  40013. * @returns the cloned material
  40014. */
  40015. clone(name: string): StandardMaterial;
  40016. /**
  40017. * Serializes this material in a JSON representation
  40018. * @returns the serialized material object
  40019. */
  40020. serialize(): any;
  40021. /**
  40022. * Creates a standard material from parsed material data
  40023. * @param source defines the JSON representation of the material
  40024. * @param scene defines the hosting scene
  40025. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40026. * @returns a new standard material
  40027. */
  40028. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40029. /**
  40030. * Are diffuse textures enabled in the application.
  40031. */
  40032. static DiffuseTextureEnabled: boolean;
  40033. /**
  40034. * Are ambient textures enabled in the application.
  40035. */
  40036. static AmbientTextureEnabled: boolean;
  40037. /**
  40038. * Are opacity textures enabled in the application.
  40039. */
  40040. static OpacityTextureEnabled: boolean;
  40041. /**
  40042. * Are reflection textures enabled in the application.
  40043. */
  40044. static ReflectionTextureEnabled: boolean;
  40045. /**
  40046. * Are emissive textures enabled in the application.
  40047. */
  40048. static EmissiveTextureEnabled: boolean;
  40049. /**
  40050. * Are specular textures enabled in the application.
  40051. */
  40052. static SpecularTextureEnabled: boolean;
  40053. /**
  40054. * Are bump textures enabled in the application.
  40055. */
  40056. static BumpTextureEnabled: boolean;
  40057. /**
  40058. * Are lightmap textures enabled in the application.
  40059. */
  40060. static LightmapTextureEnabled: boolean;
  40061. /**
  40062. * Are refraction textures enabled in the application.
  40063. */
  40064. static RefractionTextureEnabled: boolean;
  40065. /**
  40066. * Are color grading textures enabled in the application.
  40067. */
  40068. static ColorGradingTextureEnabled: boolean;
  40069. /**
  40070. * Are fresnels enabled in the application.
  40071. */
  40072. static FresnelEnabled: boolean;
  40073. }
  40074. }
  40075. declare module BABYLON {
  40076. /** @hidden */
  40077. export var imageProcessingPixelShader: {
  40078. name: string;
  40079. shader: string;
  40080. };
  40081. }
  40082. declare module BABYLON {
  40083. /**
  40084. * ImageProcessingPostProcess
  40085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40086. */
  40087. export class ImageProcessingPostProcess extends PostProcess {
  40088. /**
  40089. * Default configuration related to image processing available in the PBR Material.
  40090. */
  40091. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40092. /**
  40093. * Gets the image processing configuration used either in this material.
  40094. */
  40095. /**
  40096. * Sets the Default image processing configuration used either in the this material.
  40097. *
  40098. * If sets to null, the scene one is in use.
  40099. */
  40100. imageProcessingConfiguration: ImageProcessingConfiguration;
  40101. /**
  40102. * Keep track of the image processing observer to allow dispose and replace.
  40103. */
  40104. private _imageProcessingObserver;
  40105. /**
  40106. * Attaches a new image processing configuration to the PBR Material.
  40107. * @param configuration
  40108. */
  40109. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40110. /**
  40111. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40112. */
  40113. /**
  40114. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40115. */
  40116. colorCurves: Nullable<ColorCurves>;
  40117. /**
  40118. * Gets wether the color curves effect is enabled.
  40119. */
  40120. /**
  40121. * Sets wether the color curves effect is enabled.
  40122. */
  40123. colorCurvesEnabled: boolean;
  40124. /**
  40125. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40126. */
  40127. /**
  40128. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40129. */
  40130. colorGradingTexture: Nullable<BaseTexture>;
  40131. /**
  40132. * Gets wether the color grading effect is enabled.
  40133. */
  40134. /**
  40135. * Gets wether the color grading effect is enabled.
  40136. */
  40137. colorGradingEnabled: boolean;
  40138. /**
  40139. * Gets exposure used in the effect.
  40140. */
  40141. /**
  40142. * Sets exposure used in the effect.
  40143. */
  40144. exposure: number;
  40145. /**
  40146. * Gets wether tonemapping is enabled or not.
  40147. */
  40148. /**
  40149. * Sets wether tonemapping is enabled or not
  40150. */
  40151. toneMappingEnabled: boolean;
  40152. /**
  40153. * Gets the type of tone mapping effect.
  40154. */
  40155. /**
  40156. * Sets the type of tone mapping effect.
  40157. */
  40158. toneMappingType: number;
  40159. /**
  40160. * Gets contrast used in the effect.
  40161. */
  40162. /**
  40163. * Sets contrast used in the effect.
  40164. */
  40165. contrast: number;
  40166. /**
  40167. * Gets Vignette stretch size.
  40168. */
  40169. /**
  40170. * Sets Vignette stretch size.
  40171. */
  40172. vignetteStretch: number;
  40173. /**
  40174. * Gets Vignette centre X Offset.
  40175. */
  40176. /**
  40177. * Sets Vignette centre X Offset.
  40178. */
  40179. vignetteCentreX: number;
  40180. /**
  40181. * Gets Vignette centre Y Offset.
  40182. */
  40183. /**
  40184. * Sets Vignette centre Y Offset.
  40185. */
  40186. vignetteCentreY: number;
  40187. /**
  40188. * Gets Vignette weight or intensity of the vignette effect.
  40189. */
  40190. /**
  40191. * Sets Vignette weight or intensity of the vignette effect.
  40192. */
  40193. vignetteWeight: number;
  40194. /**
  40195. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40196. * if vignetteEnabled is set to true.
  40197. */
  40198. /**
  40199. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40200. * if vignetteEnabled is set to true.
  40201. */
  40202. vignetteColor: Color4;
  40203. /**
  40204. * Gets Camera field of view used by the Vignette effect.
  40205. */
  40206. /**
  40207. * Sets Camera field of view used by the Vignette effect.
  40208. */
  40209. vignetteCameraFov: number;
  40210. /**
  40211. * Gets the vignette blend mode allowing different kind of effect.
  40212. */
  40213. /**
  40214. * Sets the vignette blend mode allowing different kind of effect.
  40215. */
  40216. vignetteBlendMode: number;
  40217. /**
  40218. * Gets wether the vignette effect is enabled.
  40219. */
  40220. /**
  40221. * Sets wether the vignette effect is enabled.
  40222. */
  40223. vignetteEnabled: boolean;
  40224. private _fromLinearSpace;
  40225. /**
  40226. * Gets wether the input of the processing is in Gamma or Linear Space.
  40227. */
  40228. /**
  40229. * Sets wether the input of the processing is in Gamma or Linear Space.
  40230. */
  40231. fromLinearSpace: boolean;
  40232. /**
  40233. * Defines cache preventing GC.
  40234. */
  40235. private _defines;
  40236. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40237. /**
  40238. * "ImageProcessingPostProcess"
  40239. * @returns "ImageProcessingPostProcess"
  40240. */
  40241. getClassName(): string;
  40242. protected _updateParameters(): void;
  40243. dispose(camera?: Camera): void;
  40244. }
  40245. }
  40246. declare module BABYLON {
  40247. /**
  40248. * Class containing static functions to help procedurally build meshes
  40249. */
  40250. export class GroundBuilder {
  40251. /**
  40252. * Creates a ground mesh
  40253. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40254. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40256. * @param name defines the name of the mesh
  40257. * @param options defines the options used to create the mesh
  40258. * @param scene defines the hosting scene
  40259. * @returns the ground mesh
  40260. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40261. */
  40262. static CreateGround(name: string, options: {
  40263. width?: number;
  40264. height?: number;
  40265. subdivisions?: number;
  40266. subdivisionsX?: number;
  40267. subdivisionsY?: number;
  40268. updatable?: boolean;
  40269. }, scene: any): Mesh;
  40270. /**
  40271. * Creates a tiled ground mesh
  40272. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40273. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40274. * * 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
  40275. * * 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
  40276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40277. * @param name defines the name of the mesh
  40278. * @param options defines the options used to create the mesh
  40279. * @param scene defines the hosting scene
  40280. * @returns the tiled ground mesh
  40281. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40282. */
  40283. static CreateTiledGround(name: string, options: {
  40284. xmin: number;
  40285. zmin: number;
  40286. xmax: number;
  40287. zmax: number;
  40288. subdivisions?: {
  40289. w: number;
  40290. h: number;
  40291. };
  40292. precision?: {
  40293. w: number;
  40294. h: number;
  40295. };
  40296. updatable?: boolean;
  40297. }, scene?: Nullable<Scene>): Mesh;
  40298. /**
  40299. * Creates a ground mesh from a height map
  40300. * * The parameter `url` sets the URL of the height map image resource.
  40301. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40302. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40303. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40304. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40305. * * 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.
  40306. * * 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).
  40307. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40309. * @param name defines the name of the mesh
  40310. * @param url defines the url to the height map
  40311. * @param options defines the options used to create the mesh
  40312. * @param scene defines the hosting scene
  40313. * @returns the ground mesh
  40314. * @see https://doc.babylonjs.com/babylon101/height_map
  40315. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40316. */
  40317. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40318. width?: number;
  40319. height?: number;
  40320. subdivisions?: number;
  40321. minHeight?: number;
  40322. maxHeight?: number;
  40323. colorFilter?: Color3;
  40324. alphaFilter?: number;
  40325. updatable?: boolean;
  40326. onReady?: (mesh: GroundMesh) => void;
  40327. }, scene?: Nullable<Scene>): GroundMesh;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. /**
  40332. * Class containing static functions to help procedurally build meshes
  40333. */
  40334. export class TorusBuilder {
  40335. /**
  40336. * Creates a torus mesh
  40337. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40338. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40339. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40341. * * 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
  40342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40343. * @param name defines the name of the mesh
  40344. * @param options defines the options used to create the mesh
  40345. * @param scene defines the hosting scene
  40346. * @returns the torus mesh
  40347. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40348. */
  40349. static CreateTorus(name: string, options: {
  40350. diameter?: number;
  40351. thickness?: number;
  40352. tessellation?: number;
  40353. updatable?: boolean;
  40354. sideOrientation?: number;
  40355. frontUVs?: Vector4;
  40356. backUVs?: Vector4;
  40357. }, scene: any): Mesh;
  40358. }
  40359. }
  40360. declare module BABYLON {
  40361. /**
  40362. * Class containing static functions to help procedurally build meshes
  40363. */
  40364. export class CylinderBuilder {
  40365. /**
  40366. * Creates a cylinder or a cone mesh
  40367. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40368. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40369. * * 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.
  40370. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40371. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40372. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40373. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40374. * * 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).
  40375. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40376. * * 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).
  40377. * * 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
  40378. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40379. * * 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
  40380. * * 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.
  40381. * * If `enclose` is false, a ring surface is one element.
  40382. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40383. * * 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
  40384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40385. * * 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
  40386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40387. * @param name defines the name of the mesh
  40388. * @param options defines the options used to create the mesh
  40389. * @param scene defines the hosting scene
  40390. * @returns the cylinder mesh
  40391. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40392. */
  40393. static CreateCylinder(name: string, options: {
  40394. height?: number;
  40395. diameterTop?: number;
  40396. diameterBottom?: number;
  40397. diameter?: number;
  40398. tessellation?: number;
  40399. subdivisions?: number;
  40400. arc?: number;
  40401. faceColors?: Color4[];
  40402. faceUV?: Vector4[];
  40403. updatable?: boolean;
  40404. hasRings?: boolean;
  40405. enclose?: boolean;
  40406. cap?: number;
  40407. sideOrientation?: number;
  40408. frontUVs?: Vector4;
  40409. backUVs?: Vector4;
  40410. }, scene: any): Mesh;
  40411. }
  40412. }
  40413. declare module BABYLON {
  40414. /**
  40415. * Options to modify the vr teleportation behavior.
  40416. */
  40417. export interface VRTeleportationOptions {
  40418. /**
  40419. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40420. */
  40421. floorMeshName?: string;
  40422. /**
  40423. * A list of meshes to be used as the teleportation floor. (default: empty)
  40424. */
  40425. floorMeshes?: Mesh[];
  40426. }
  40427. /**
  40428. * Options to modify the vr experience helper's behavior.
  40429. */
  40430. export interface VRExperienceHelperOptions extends WebVROptions {
  40431. /**
  40432. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40433. */
  40434. createDeviceOrientationCamera?: boolean;
  40435. /**
  40436. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40437. */
  40438. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40439. /**
  40440. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40441. */
  40442. laserToggle?: boolean;
  40443. /**
  40444. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40445. */
  40446. floorMeshes?: Mesh[];
  40447. /**
  40448. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40449. */
  40450. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40451. }
  40452. /**
  40453. * Event containing information after VR has been entered
  40454. */
  40455. export class OnAfterEnteringVRObservableEvent {
  40456. /**
  40457. * If entering vr was successful
  40458. */
  40459. success: boolean;
  40460. }
  40461. /**
  40462. * Helps to quickly add VR support to an existing scene.
  40463. * See http://doc.babylonjs.com/how_to/webvr_helper
  40464. */
  40465. export class VRExperienceHelper {
  40466. /** Options to modify the vr experience helper's behavior. */
  40467. webVROptions: VRExperienceHelperOptions;
  40468. private _scene;
  40469. private _position;
  40470. private _btnVR;
  40471. private _btnVRDisplayed;
  40472. private _webVRsupported;
  40473. private _webVRready;
  40474. private _webVRrequesting;
  40475. private _webVRpresenting;
  40476. private _hasEnteredVR;
  40477. private _fullscreenVRpresenting;
  40478. private _canvas;
  40479. private _webVRCamera;
  40480. private _vrDeviceOrientationCamera;
  40481. private _deviceOrientationCamera;
  40482. private _existingCamera;
  40483. private _onKeyDown;
  40484. private _onVrDisplayPresentChange;
  40485. private _onVRDisplayChanged;
  40486. private _onVRRequestPresentStart;
  40487. private _onVRRequestPresentComplete;
  40488. /**
  40489. * 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)
  40490. */
  40491. enableGazeEvenWhenNoPointerLock: boolean;
  40492. /**
  40493. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40494. */
  40495. exitVROnDoubleTap: boolean;
  40496. /**
  40497. * Observable raised right before entering VR.
  40498. */
  40499. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40500. /**
  40501. * Observable raised when entering VR has completed.
  40502. */
  40503. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40504. /**
  40505. * Observable raised when exiting VR.
  40506. */
  40507. onExitingVRObservable: Observable<VRExperienceHelper>;
  40508. /**
  40509. * Observable raised when controller mesh is loaded.
  40510. */
  40511. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40512. /** Return this.onEnteringVRObservable
  40513. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40514. */
  40515. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40516. /** Return this.onExitingVRObservable
  40517. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40518. */
  40519. readonly onExitingVR: Observable<VRExperienceHelper>;
  40520. /** Return this.onControllerMeshLoadedObservable
  40521. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40522. */
  40523. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40524. private _rayLength;
  40525. private _useCustomVRButton;
  40526. private _teleportationRequested;
  40527. private _teleportActive;
  40528. private _floorMeshName;
  40529. private _floorMeshesCollection;
  40530. private _rotationAllowed;
  40531. private _teleportBackwardsVector;
  40532. private _teleportationTarget;
  40533. private _isDefaultTeleportationTarget;
  40534. private _postProcessMove;
  40535. private _teleportationFillColor;
  40536. private _teleportationBorderColor;
  40537. private _rotationAngle;
  40538. private _haloCenter;
  40539. private _cameraGazer;
  40540. private _padSensibilityUp;
  40541. private _padSensibilityDown;
  40542. private _leftController;
  40543. private _rightController;
  40544. /**
  40545. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40546. */
  40547. onNewMeshSelected: Observable<AbstractMesh>;
  40548. /**
  40549. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40550. * This observable will provide the mesh and the controller used to select the mesh
  40551. */
  40552. onMeshSelectedWithController: Observable<{
  40553. mesh: AbstractMesh;
  40554. controller: WebVRController;
  40555. }>;
  40556. /**
  40557. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40558. */
  40559. onNewMeshPicked: Observable<PickingInfo>;
  40560. private _circleEase;
  40561. /**
  40562. * Observable raised before camera teleportation
  40563. */
  40564. onBeforeCameraTeleport: Observable<Vector3>;
  40565. /**
  40566. * Observable raised after camera teleportation
  40567. */
  40568. onAfterCameraTeleport: Observable<Vector3>;
  40569. /**
  40570. * Observable raised when current selected mesh gets unselected
  40571. */
  40572. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40573. private _raySelectionPredicate;
  40574. /**
  40575. * To be optionaly changed by user to define custom ray selection
  40576. */
  40577. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40578. /**
  40579. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40580. */
  40581. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40582. /**
  40583. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40584. */
  40585. teleportationEnabled: boolean;
  40586. private _defaultHeight;
  40587. private _teleportationInitialized;
  40588. private _interactionsEnabled;
  40589. private _interactionsRequested;
  40590. private _displayGaze;
  40591. private _displayLaserPointer;
  40592. /**
  40593. * The mesh used to display where the user is going to teleport.
  40594. */
  40595. /**
  40596. * Sets the mesh to be used to display where the user is going to teleport.
  40597. */
  40598. teleportationTarget: Mesh;
  40599. /**
  40600. * 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
  40601. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40602. * See http://doc.babylonjs.com/resources/baking_transformations
  40603. */
  40604. gazeTrackerMesh: Mesh;
  40605. /**
  40606. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40607. */
  40608. updateGazeTrackerScale: boolean;
  40609. /**
  40610. * If the gaze trackers color should be updated when selecting meshes
  40611. */
  40612. updateGazeTrackerColor: boolean;
  40613. /**
  40614. * If the controller laser color should be updated when selecting meshes
  40615. */
  40616. updateControllerLaserColor: boolean;
  40617. /**
  40618. * The gaze tracking mesh corresponding to the left controller
  40619. */
  40620. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40621. /**
  40622. * The gaze tracking mesh corresponding to the right controller
  40623. */
  40624. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40625. /**
  40626. * If the ray of the gaze should be displayed.
  40627. */
  40628. /**
  40629. * Sets if the ray of the gaze should be displayed.
  40630. */
  40631. displayGaze: boolean;
  40632. /**
  40633. * If the ray of the LaserPointer should be displayed.
  40634. */
  40635. /**
  40636. * Sets if the ray of the LaserPointer should be displayed.
  40637. */
  40638. displayLaserPointer: boolean;
  40639. /**
  40640. * The deviceOrientationCamera used as the camera when not in VR.
  40641. */
  40642. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40643. /**
  40644. * Based on the current WebVR support, returns the current VR camera used.
  40645. */
  40646. readonly currentVRCamera: Nullable<Camera>;
  40647. /**
  40648. * The webVRCamera which is used when in VR.
  40649. */
  40650. readonly webVRCamera: WebVRFreeCamera;
  40651. /**
  40652. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40653. */
  40654. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40655. /**
  40656. * The html button that is used to trigger entering into VR.
  40657. */
  40658. readonly vrButton: Nullable<HTMLButtonElement>;
  40659. private readonly _teleportationRequestInitiated;
  40660. /**
  40661. * Defines wether or not Pointer lock should be requested when switching to
  40662. * full screen.
  40663. */
  40664. requestPointerLockOnFullScreen: boolean;
  40665. /**
  40666. * Instantiates a VRExperienceHelper.
  40667. * Helps to quickly add VR support to an existing scene.
  40668. * @param scene The scene the VRExperienceHelper belongs to.
  40669. * @param webVROptions Options to modify the vr experience helper's behavior.
  40670. */
  40671. constructor(scene: Scene,
  40672. /** Options to modify the vr experience helper's behavior. */
  40673. webVROptions?: VRExperienceHelperOptions);
  40674. private _onDefaultMeshLoaded;
  40675. private _onResize;
  40676. private _onFullscreenChange;
  40677. /**
  40678. * Gets a value indicating if we are currently in VR mode.
  40679. */
  40680. readonly isInVRMode: boolean;
  40681. private onVrDisplayPresentChange;
  40682. private onVRDisplayChanged;
  40683. private moveButtonToBottomRight;
  40684. private displayVRButton;
  40685. private updateButtonVisibility;
  40686. private _cachedAngularSensibility;
  40687. /**
  40688. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40689. * Otherwise, will use the fullscreen API.
  40690. */
  40691. enterVR(): void;
  40692. /**
  40693. * Attempt to exit VR, or fullscreen.
  40694. */
  40695. exitVR(): void;
  40696. /**
  40697. * The position of the vr experience helper.
  40698. */
  40699. /**
  40700. * Sets the position of the vr experience helper.
  40701. */
  40702. position: Vector3;
  40703. /**
  40704. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40705. */
  40706. enableInteractions(): void;
  40707. private readonly _noControllerIsActive;
  40708. private beforeRender;
  40709. private _isTeleportationFloor;
  40710. /**
  40711. * Adds a floor mesh to be used for teleportation.
  40712. * @param floorMesh the mesh to be used for teleportation.
  40713. */
  40714. addFloorMesh(floorMesh: Mesh): void;
  40715. /**
  40716. * Removes a floor mesh from being used for teleportation.
  40717. * @param floorMesh the mesh to be removed.
  40718. */
  40719. removeFloorMesh(floorMesh: Mesh): void;
  40720. /**
  40721. * Enables interactions and teleportation using the VR controllers and gaze.
  40722. * @param vrTeleportationOptions options to modify teleportation behavior.
  40723. */
  40724. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40725. private _onNewGamepadConnected;
  40726. private _tryEnableInteractionOnController;
  40727. private _onNewGamepadDisconnected;
  40728. private _enableInteractionOnController;
  40729. private _checkTeleportWithRay;
  40730. private _checkRotate;
  40731. private _checkTeleportBackwards;
  40732. private _enableTeleportationOnController;
  40733. private _createTeleportationCircles;
  40734. private _displayTeleportationTarget;
  40735. private _hideTeleportationTarget;
  40736. private _rotateCamera;
  40737. private _moveTeleportationSelectorTo;
  40738. private _workingVector;
  40739. private _workingQuaternion;
  40740. private _workingMatrix;
  40741. /**
  40742. * Teleports the users feet to the desired location
  40743. * @param location The location where the user's feet should be placed
  40744. */
  40745. teleportCamera(location: Vector3): void;
  40746. private _convertNormalToDirectionOfRay;
  40747. private _castRayAndSelectObject;
  40748. private _notifySelectedMeshUnselected;
  40749. /**
  40750. * Sets the color of the laser ray from the vr controllers.
  40751. * @param color new color for the ray.
  40752. */
  40753. changeLaserColor(color: Color3): void;
  40754. /**
  40755. * Sets the color of the ray from the vr headsets gaze.
  40756. * @param color new color for the ray.
  40757. */
  40758. changeGazeColor(color: Color3): void;
  40759. /**
  40760. * Exits VR and disposes of the vr experience helper
  40761. */
  40762. dispose(): void;
  40763. /**
  40764. * Gets the name of the VRExperienceHelper class
  40765. * @returns "VRExperienceHelper"
  40766. */
  40767. getClassName(): string;
  40768. }
  40769. }
  40770. declare module BABYLON {
  40771. /**
  40772. * States of the webXR experience
  40773. */
  40774. export enum WebXRState {
  40775. /**
  40776. * Transitioning to being in XR mode
  40777. */
  40778. ENTERING_XR = 0,
  40779. /**
  40780. * Transitioning to non XR mode
  40781. */
  40782. EXITING_XR = 1,
  40783. /**
  40784. * In XR mode and presenting
  40785. */
  40786. IN_XR = 2,
  40787. /**
  40788. * Not entered XR mode
  40789. */
  40790. NOT_IN_XR = 3
  40791. }
  40792. /**
  40793. * Abstraction of the XR render target
  40794. */
  40795. export interface WebXRRenderTarget extends IDisposable {
  40796. /**
  40797. * xrpresent context of the canvas which can be used to display/mirror xr content
  40798. */
  40799. canvasContext: WebGLRenderingContext;
  40800. /**
  40801. * xr layer for the canvas
  40802. */
  40803. xrLayer: Nullable<XRWebGLLayer>;
  40804. /**
  40805. * Initializes the xr layer for the session
  40806. * @param xrSession xr session
  40807. * @returns a promise that will resolve once the XR Layer has been created
  40808. */
  40809. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  40810. }
  40811. }
  40812. declare module BABYLON {
  40813. /**
  40814. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40815. */
  40816. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  40817. private _engine;
  40818. private _canvas;
  40819. /**
  40820. * xrpresent context of the canvas which can be used to display/mirror xr content
  40821. */
  40822. canvasContext: WebGLRenderingContext;
  40823. /**
  40824. * xr layer for the canvas
  40825. */
  40826. xrLayer: Nullable<XRWebGLLayer>;
  40827. /**
  40828. * Initializes the xr layer for the session
  40829. * @param xrSession xr session
  40830. * @returns a promise that will resolve once the XR Layer has been created
  40831. */
  40832. initializeXRLayerAsync(xrSession: any): any;
  40833. /**
  40834. * Initializes the canvas to be added/removed upon entering/exiting xr
  40835. * @param engine the Babylon engine
  40836. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  40837. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40838. */
  40839. constructor(engine: ThinEngine, onStateChangedObservable: Observable<WebXRState>, canvas?: HTMLCanvasElement);
  40840. /**
  40841. * Disposes of the object
  40842. */
  40843. dispose(): void;
  40844. private _setManagedOutputCanvas;
  40845. private _addCanvas;
  40846. private _removeCanvas;
  40847. }
  40848. }
  40849. declare module BABYLON {
  40850. /**
  40851. * Manages an XRSession to work with Babylon's engine
  40852. * @see https://doc.babylonjs.com/how_to/webxr
  40853. */
  40854. export class WebXRSessionManager implements IDisposable {
  40855. private scene;
  40856. /**
  40857. * Fires every time a new xrFrame arrives which can be used to update the camera
  40858. */
  40859. onXRFrameObservable: Observable<any>;
  40860. /**
  40861. * Fires when the xr session is ended either by the device or manually done
  40862. */
  40863. onXRSessionEnded: Observable<any>;
  40864. /**
  40865. * Underlying xr session
  40866. */
  40867. session: XRSession;
  40868. /**
  40869. * Type of reference space used when creating the session
  40870. */
  40871. referenceSpace: XRReferenceSpace;
  40872. /**
  40873. * Current XR frame
  40874. */
  40875. currentFrame: Nullable<XRFrame>;
  40876. private _xrNavigator;
  40877. private baseLayer;
  40878. private _rttProvider;
  40879. private _sessionEnded;
  40880. /**
  40881. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40882. * @param scene The scene which the session should be created for
  40883. */
  40884. constructor(scene: Scene);
  40885. /**
  40886. * Initializes the manager
  40887. * After initialization enterXR can be called to start an XR session
  40888. * @returns Promise which resolves after it is initialized
  40889. */
  40890. initializeAsync(): Promise<void>;
  40891. /**
  40892. * Initializes an xr session
  40893. * @param xrSessionMode mode to initialize
  40894. * @returns a promise which will resolve once the session has been initialized
  40895. */
  40896. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40897. /**
  40898. * Sets the reference space on the xr session
  40899. * @param referenceSpace space to set
  40900. * @returns a promise that will resolve once the reference space has been set
  40901. */
  40902. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40903. /**
  40904. * Updates the render state of the session
  40905. * @param state state to set
  40906. * @returns a promise that resolves once the render state has been updated
  40907. */
  40908. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40909. /**
  40910. * Starts rendering to the xr layer
  40911. * @returns a promise that will resolve once rendering has started
  40912. */
  40913. startRenderingToXRAsync(): Promise<void>;
  40914. /**
  40915. * Gets the correct render target texture to be rendered this frame for this eye
  40916. * @param eye the eye for which to get the render target
  40917. * @returns the render target for the specified eye
  40918. */
  40919. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  40920. /**
  40921. * Stops the xrSession and restores the renderloop
  40922. * @returns Promise which resolves after it exits XR
  40923. */
  40924. exitXRAsync(): Promise<void>;
  40925. /**
  40926. * Checks if a session would be supported for the creation options specified
  40927. * @param sessionMode session mode to check if supported eg. immersive-vr
  40928. * @returns true if supported
  40929. */
  40930. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40931. /**
  40932. * Creates a WebXRRenderTarget object for the XR session
  40933. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  40934. * @returns a WebXR render target to which the session can render
  40935. */
  40936. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  40937. /**
  40938. * @hidden
  40939. * Converts the render layer of xrSession to a render target
  40940. * @param session session to create render target for
  40941. * @param scene scene the new render target should be created for
  40942. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40943. /**
  40944. * Disposes of the session manager
  40945. */
  40946. dispose(): void;
  40947. }
  40948. }
  40949. declare module BABYLON {
  40950. /**
  40951. * WebXR Camera which holds the views for the xrSession
  40952. * @see https://doc.babylonjs.com/how_to/webxr
  40953. */
  40954. export class WebXRCamera extends FreeCamera {
  40955. private static _TmpMatrix;
  40956. /**
  40957. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40958. * @param name the name of the camera
  40959. * @param scene the scene to add the camera to
  40960. */
  40961. constructor(name: string, scene: Scene);
  40962. private _updateNumberOfRigCameras;
  40963. /** @hidden */ private _updateForDualEyeDebugging(): void;
  40964. /**
  40965. * Updates the cameras position from the current pose information of the XR session
  40966. * @param xrSessionManager the session containing pose information
  40967. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40968. */
  40969. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. /**
  40974. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40975. * @see https://doc.babylonjs.com/how_to/webxr
  40976. */
  40977. export class WebXRExperienceHelper implements IDisposable {
  40978. private scene;
  40979. /**
  40980. * 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
  40981. */
  40982. container: AbstractMesh;
  40983. /**
  40984. * Camera used to render xr content
  40985. */
  40986. camera: WebXRCamera;
  40987. /**
  40988. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40989. */
  40990. state: WebXRState;
  40991. private _setState;
  40992. private static _TmpVector;
  40993. /**
  40994. * Fires when the state of the experience helper has changed
  40995. */
  40996. onStateChangedObservable: Observable<WebXRState>;
  40997. /** Session manager used to keep track of xr session */
  40998. sessionManager: WebXRSessionManager;
  40999. private _nonVRCamera;
  41000. private _originalSceneAutoClear;
  41001. private _supported;
  41002. /**
  41003. * Creates the experience helper
  41004. * @param scene the scene to attach the experience helper to
  41005. * @returns a promise for the experience helper
  41006. */
  41007. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41008. /**
  41009. * Creates a WebXRExperienceHelper
  41010. * @param scene The scene the helper should be created in
  41011. */
  41012. private constructor();
  41013. /**
  41014. * Exits XR mode and returns the scene to its original state
  41015. * @returns promise that resolves after xr mode has exited
  41016. */
  41017. exitXRAsync(): Promise<void>;
  41018. /**
  41019. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41020. * @param sessionCreationOptions options for the XR session
  41021. * @param referenceSpaceType frame of reference of the XR session
  41022. * @param renderTarget the output canvas that will be used to enter XR mode
  41023. * @returns promise that resolves after xr mode has entered
  41024. */
  41025. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  41026. /**
  41027. * Updates the global position of the camera by moving the camera's container
  41028. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41029. * @param position The desired global position of the camera
  41030. */
  41031. setPositionOfCameraUsingContainer(position: Vector3): void;
  41032. /**
  41033. * Rotates the xr camera by rotating the camera's container around the camera's position
  41034. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41035. * @param rotation the desired quaternion rotation to apply to the camera
  41036. */
  41037. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41038. /**
  41039. * Disposes of the experience helper
  41040. */
  41041. dispose(): void;
  41042. }
  41043. }
  41044. declare module BABYLON {
  41045. /**
  41046. * Button which can be used to enter a different mode of XR
  41047. */
  41048. export class WebXREnterExitUIButton {
  41049. /** button element */
  41050. element: HTMLElement;
  41051. /** XR initialization options for the button */
  41052. sessionMode: XRSessionMode;
  41053. /** Reference space type */
  41054. referenceSpaceType: XRReferenceSpaceType;
  41055. /**
  41056. * Creates a WebXREnterExitUIButton
  41057. * @param element button element
  41058. * @param sessionMode XR initialization session mode
  41059. * @param referenceSpaceType the type of reference space to be used
  41060. */
  41061. constructor(
  41062. /** button element */
  41063. element: HTMLElement,
  41064. /** XR initialization options for the button */
  41065. sessionMode: XRSessionMode,
  41066. /** Reference space type */
  41067. referenceSpaceType: XRReferenceSpaceType);
  41068. /**
  41069. * Overwritable function which can be used to update the button's visuals when the state changes
  41070. * @param activeButton the current active button in the UI
  41071. */
  41072. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41073. }
  41074. /**
  41075. * Options to create the webXR UI
  41076. */
  41077. export class WebXREnterExitUIOptions {
  41078. /**
  41079. * Context to enter xr with
  41080. */
  41081. renderTarget?: Nullable<WebXRRenderTarget>;
  41082. /**
  41083. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41084. */
  41085. customButtons?: Array<WebXREnterExitUIButton>;
  41086. }
  41087. /**
  41088. * UI to allow the user to enter/exit XR mode
  41089. */
  41090. export class WebXREnterExitUI implements IDisposable {
  41091. private scene;
  41092. private _overlay;
  41093. private _buttons;
  41094. private _activeButton;
  41095. /**
  41096. * Fired every time the active button is changed.
  41097. *
  41098. * When xr is entered via a button that launches xr that button will be the callback parameter
  41099. *
  41100. * When exiting xr the callback parameter will be null)
  41101. */
  41102. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41103. /**
  41104. * Creates UI to allow the user to enter/exit XR mode
  41105. * @param scene the scene to add the ui to
  41106. * @param helper the xr experience helper to enter/exit xr with
  41107. * @param options options to configure the UI
  41108. * @returns the created ui
  41109. */
  41110. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41111. private constructor();
  41112. private _updateButtons;
  41113. /**
  41114. * Disposes of the object
  41115. */
  41116. dispose(): void;
  41117. }
  41118. }
  41119. declare module BABYLON {
  41120. /**
  41121. * Represents an XR input
  41122. */
  41123. export class WebXRController {
  41124. private scene;
  41125. /** The underlying input source for the controller */
  41126. inputSource: XRInputSource;
  41127. private parentContainer;
  41128. /**
  41129. * 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
  41130. */
  41131. grip?: AbstractMesh;
  41132. /**
  41133. * Pointer which can be used to select objects or attach a visible laser to
  41134. */
  41135. pointer: AbstractMesh;
  41136. private _gamepadMode;
  41137. /**
  41138. * If available, this is the gamepad object related to this controller.
  41139. * Using this object it is possible to get click events and trackpad changes of the
  41140. * webxr controller that is currently being used.
  41141. */
  41142. gamepadController?: WebVRController;
  41143. /**
  41144. * Event that fires when the controller is removed/disposed
  41145. */
  41146. onDisposeObservable: Observable<{}>;
  41147. private _tmpMatrix;
  41148. private _tmpQuaternion;
  41149. private _tmpVector;
  41150. /**
  41151. * Creates the controller
  41152. * @see https://doc.babylonjs.com/how_to/webxr
  41153. * @param scene the scene which the controller should be associated to
  41154. * @param inputSource the underlying input source for the controller
  41155. * @param parentContainer parent that the controller meshes should be children of
  41156. */
  41157. constructor(scene: Scene,
  41158. /** The underlying input source for the controller */
  41159. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41160. /**
  41161. * Updates the controller pose based on the given XRFrame
  41162. * @param xrFrame xr frame to update the pose with
  41163. * @param referenceSpace reference space to use
  41164. */
  41165. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41166. /**
  41167. * Gets a world space ray coming from the controller
  41168. * @param result the resulting ray
  41169. */
  41170. getWorldPointerRayToRef(result: Ray): void;
  41171. /**
  41172. * Get the scene associated with this controller
  41173. * @returns the scene object
  41174. */
  41175. getScene(): Scene;
  41176. /**
  41177. * Disposes of the object
  41178. */
  41179. dispose(): void;
  41180. }
  41181. }
  41182. declare module BABYLON {
  41183. /**
  41184. * XR input used to track XR inputs such as controllers/rays
  41185. */
  41186. export class WebXRInput implements IDisposable {
  41187. /**
  41188. * Base experience the input listens to
  41189. */
  41190. baseExperience: WebXRExperienceHelper;
  41191. /**
  41192. * XR controllers being tracked
  41193. */
  41194. controllers: Array<WebXRController>;
  41195. private _frameObserver;
  41196. private _stateObserver;
  41197. /**
  41198. * Event when a controller has been connected/added
  41199. */
  41200. onControllerAddedObservable: Observable<WebXRController>;
  41201. /**
  41202. * Event when a controller has been removed/disconnected
  41203. */
  41204. onControllerRemovedObservable: Observable<WebXRController>;
  41205. /**
  41206. * Initializes the WebXRInput
  41207. * @param baseExperience experience helper which the input should be created for
  41208. */
  41209. constructor(
  41210. /**
  41211. * Base experience the input listens to
  41212. */
  41213. baseExperience: WebXRExperienceHelper);
  41214. private _onInputSourcesChange;
  41215. private _addAndRemoveControllers;
  41216. /**
  41217. * Disposes of the object
  41218. */
  41219. dispose(): void;
  41220. }
  41221. }
  41222. declare module BABYLON {
  41223. /**
  41224. * Enables teleportation
  41225. */
  41226. export class WebXRControllerTeleportation {
  41227. private _teleportationFillColor;
  41228. private _teleportationBorderColor;
  41229. private _tmpRay;
  41230. private _tmpVector;
  41231. /**
  41232. * Creates a WebXRControllerTeleportation
  41233. * @param input input manager to add teleportation to
  41234. * @param floorMeshes floormeshes which can be teleported to
  41235. */
  41236. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41237. }
  41238. }
  41239. declare module BABYLON {
  41240. /**
  41241. * Handles pointer input automatically for the pointer of XR controllers
  41242. */
  41243. export class WebXRControllerPointerSelection {
  41244. private static _idCounter;
  41245. private _tmpRay;
  41246. /**
  41247. * Creates a WebXRControllerPointerSelection
  41248. * @param input input manager to setup pointer selection
  41249. */
  41250. constructor(input: WebXRInput);
  41251. private _convertNormalToDirectionOfRay;
  41252. private _updatePointerDistance;
  41253. }
  41254. }
  41255. declare module BABYLON {
  41256. /**
  41257. * Class used to represent data loading progression
  41258. */
  41259. export class SceneLoaderProgressEvent {
  41260. /** defines if data length to load can be evaluated */
  41261. readonly lengthComputable: boolean;
  41262. /** defines the loaded data length */
  41263. readonly loaded: number;
  41264. /** defines the data length to load */
  41265. readonly total: number;
  41266. /**
  41267. * Create a new progress event
  41268. * @param lengthComputable defines if data length to load can be evaluated
  41269. * @param loaded defines the loaded data length
  41270. * @param total defines the data length to load
  41271. */
  41272. constructor(
  41273. /** defines if data length to load can be evaluated */
  41274. lengthComputable: boolean,
  41275. /** defines the loaded data length */
  41276. loaded: number,
  41277. /** defines the data length to load */
  41278. total: number);
  41279. /**
  41280. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41281. * @param event defines the source event
  41282. * @returns a new SceneLoaderProgressEvent
  41283. */
  41284. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41285. }
  41286. /**
  41287. * Interface used by SceneLoader plugins to define supported file extensions
  41288. */
  41289. export interface ISceneLoaderPluginExtensions {
  41290. /**
  41291. * Defines the list of supported extensions
  41292. */
  41293. [extension: string]: {
  41294. isBinary: boolean;
  41295. };
  41296. }
  41297. /**
  41298. * Interface used by SceneLoader plugin factory
  41299. */
  41300. export interface ISceneLoaderPluginFactory {
  41301. /**
  41302. * Defines the name of the factory
  41303. */
  41304. name: string;
  41305. /**
  41306. * Function called to create a new plugin
  41307. * @return the new plugin
  41308. */
  41309. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41310. /**
  41311. * The callback that returns true if the data can be directly loaded.
  41312. * @param data string containing the file data
  41313. * @returns if the data can be loaded directly
  41314. */
  41315. canDirectLoad?(data: string): boolean;
  41316. }
  41317. /**
  41318. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  41319. */
  41320. export interface ISceneLoaderPluginBase {
  41321. /**
  41322. * The friendly name of this plugin.
  41323. */
  41324. name: string;
  41325. /**
  41326. * The file extensions supported by this plugin.
  41327. */
  41328. extensions: string | ISceneLoaderPluginExtensions;
  41329. /**
  41330. * The callback called when loading from a url.
  41331. * @param scene scene loading this url
  41332. * @param url url to load
  41333. * @param onSuccess callback called when the file successfully loads
  41334. * @param onProgress callback called while file is loading (if the server supports this mode)
  41335. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41336. * @param onError callback called when the file fails to load
  41337. * @returns a file request object
  41338. */
  41339. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  41340. /**
  41341. * The callback called when loading from a file object.
  41342. * @param scene scene loading this file
  41343. * @param file defines the file to load
  41344. * @param onSuccess defines the callback to call when data is loaded
  41345. * @param onProgress defines the callback to call during loading process
  41346. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41347. * @param onError defines the callback to call when an error occurs
  41348. * @returns a file request object
  41349. */
  41350. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  41351. /**
  41352. * The callback that returns true if the data can be directly loaded.
  41353. * @param data string containing the file data
  41354. * @returns if the data can be loaded directly
  41355. */
  41356. canDirectLoad?(data: string): boolean;
  41357. /**
  41358. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  41359. * @param scene scene loading this data
  41360. * @param data string containing the data
  41361. * @returns data to pass to the plugin
  41362. */
  41363. directLoad?(scene: Scene, data: string): any;
  41364. /**
  41365. * The callback that allows custom handling of the root url based on the response url.
  41366. * @param rootUrl the original root url
  41367. * @param responseURL the response url if available
  41368. * @returns the new root url
  41369. */
  41370. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  41371. }
  41372. /**
  41373. * Interface used to define a SceneLoader plugin
  41374. */
  41375. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  41376. /**
  41377. * Import meshes into a scene.
  41378. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41379. * @param scene The scene to import into
  41380. * @param data The data to import
  41381. * @param rootUrl The root url for scene and resources
  41382. * @param meshes The meshes array to import into
  41383. * @param particleSystems The particle systems array to import into
  41384. * @param skeletons The skeletons array to import into
  41385. * @param onError The callback when import fails
  41386. * @returns True if successful or false otherwise
  41387. */
  41388. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41389. /**
  41390. * Load into a scene.
  41391. * @param scene The scene to load into
  41392. * @param data The data to import
  41393. * @param rootUrl The root url for scene and resources
  41394. * @param onError The callback when import fails
  41395. * @returns True if successful or false otherwise
  41396. */
  41397. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41398. /**
  41399. * Load into an asset container.
  41400. * @param scene The scene to load into
  41401. * @param data The data to import
  41402. * @param rootUrl The root url for scene and resources
  41403. * @param onError The callback when import fails
  41404. * @returns The loaded asset container
  41405. */
  41406. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41407. }
  41408. /**
  41409. * Interface used to define an async SceneLoader plugin
  41410. */
  41411. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  41412. /**
  41413. * Import meshes into a scene.
  41414. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41415. * @param scene The scene to import into
  41416. * @param data The data to import
  41417. * @param rootUrl The root url for scene and resources
  41418. * @param onProgress The callback when the load progresses
  41419. * @param fileName Defines the name of the file to load
  41420. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41421. */
  41422. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41423. meshes: AbstractMesh[];
  41424. particleSystems: IParticleSystem[];
  41425. skeletons: Skeleton[];
  41426. animationGroups: AnimationGroup[];
  41427. }>;
  41428. /**
  41429. * Load into a scene.
  41430. * @param scene The scene to load into
  41431. * @param data The data to import
  41432. * @param rootUrl The root url for scene and resources
  41433. * @param onProgress The callback when the load progresses
  41434. * @param fileName Defines the name of the file to load
  41435. * @returns Nothing
  41436. */
  41437. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41438. /**
  41439. * Load into an asset container.
  41440. * @param scene The scene to load into
  41441. * @param data The data to import
  41442. * @param rootUrl The root url for scene and resources
  41443. * @param onProgress The callback when the load progresses
  41444. * @param fileName Defines the name of the file to load
  41445. * @returns The loaded asset container
  41446. */
  41447. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41448. }
  41449. /**
  41450. * Class used to load scene from various file formats using registered plugins
  41451. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41452. */
  41453. export class SceneLoader {
  41454. /**
  41455. * No logging while loading
  41456. */
  41457. static readonly NO_LOGGING: number;
  41458. /**
  41459. * Minimal logging while loading
  41460. */
  41461. static readonly MINIMAL_LOGGING: number;
  41462. /**
  41463. * Summary logging while loading
  41464. */
  41465. static readonly SUMMARY_LOGGING: number;
  41466. /**
  41467. * Detailled logging while loading
  41468. */
  41469. static readonly DETAILED_LOGGING: number;
  41470. /**
  41471. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41472. */
  41473. static ForceFullSceneLoadingForIncremental: boolean;
  41474. /**
  41475. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41476. */
  41477. static ShowLoadingScreen: boolean;
  41478. /**
  41479. * Defines the current logging level (while loading the scene)
  41480. * @ignorenaming
  41481. */
  41482. static loggingLevel: number;
  41483. /**
  41484. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41485. */
  41486. static CleanBoneMatrixWeights: boolean;
  41487. /**
  41488. * Event raised when a plugin is used to load a scene
  41489. */
  41490. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41491. private static _registeredPlugins;
  41492. private static _getDefaultPlugin;
  41493. private static _getPluginForExtension;
  41494. private static _getPluginForDirectLoad;
  41495. private static _getPluginForFilename;
  41496. private static _getDirectLoad;
  41497. private static _loadData;
  41498. private static _getFileInfo;
  41499. /**
  41500. * Gets a plugin that can load the given extension
  41501. * @param extension defines the extension to load
  41502. * @returns a plugin or null if none works
  41503. */
  41504. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41505. /**
  41506. * Gets a boolean indicating that the given extension can be loaded
  41507. * @param extension defines the extension to load
  41508. * @returns true if the extension is supported
  41509. */
  41510. static IsPluginForExtensionAvailable(extension: string): boolean;
  41511. /**
  41512. * Adds a new plugin to the list of registered plugins
  41513. * @param plugin defines the plugin to add
  41514. */
  41515. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41516. /**
  41517. * Import meshes into a scene
  41518. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41519. * @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)
  41520. * @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)
  41521. * @param scene the instance of BABYLON.Scene to append to
  41522. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41523. * @param onProgress a callback with a progress event for each file being loaded
  41524. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41525. * @param pluginExtension the extension used to determine the plugin
  41526. * @returns The loaded plugin
  41527. */
  41528. 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>;
  41529. /**
  41530. * Import meshes into a scene
  41531. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41532. * @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)
  41533. * @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)
  41534. * @param scene the instance of BABYLON.Scene to append to
  41535. * @param onProgress a callback with a progress event for each file being loaded
  41536. * @param pluginExtension the extension used to determine the plugin
  41537. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41538. */
  41539. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41540. meshes: AbstractMesh[];
  41541. particleSystems: IParticleSystem[];
  41542. skeletons: Skeleton[];
  41543. animationGroups: AnimationGroup[];
  41544. }>;
  41545. /**
  41546. * Load a scene
  41547. * @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)
  41548. * @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)
  41549. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41550. * @param onSuccess a callback with the scene when import succeeds
  41551. * @param onProgress a callback with a progress event for each file being loaded
  41552. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41553. * @param pluginExtension the extension used to determine the plugin
  41554. * @returns The loaded plugin
  41555. */
  41556. 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>;
  41557. /**
  41558. * Load a scene
  41559. * @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)
  41560. * @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)
  41561. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41562. * @param onProgress a callback with a progress event for each file being loaded
  41563. * @param pluginExtension the extension used to determine the plugin
  41564. * @returns The loaded scene
  41565. */
  41566. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41567. /**
  41568. * Append a scene
  41569. * @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)
  41570. * @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)
  41571. * @param scene is the instance of BABYLON.Scene to append to
  41572. * @param onSuccess a callback with the scene when import succeeds
  41573. * @param onProgress a callback with a progress event for each file being loaded
  41574. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41575. * @param pluginExtension the extension used to determine the plugin
  41576. * @returns The loaded plugin
  41577. */
  41578. 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>;
  41579. /**
  41580. * Append a scene
  41581. * @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)
  41582. * @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)
  41583. * @param scene is the instance of BABYLON.Scene to append to
  41584. * @param onProgress a callback with a progress event for each file being loaded
  41585. * @param pluginExtension the extension used to determine the plugin
  41586. * @returns The given scene
  41587. */
  41588. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41589. /**
  41590. * Load a scene into an asset container
  41591. * @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)
  41592. * @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)
  41593. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41594. * @param onSuccess a callback with the scene when import succeeds
  41595. * @param onProgress a callback with a progress event for each file being loaded
  41596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41597. * @param pluginExtension the extension used to determine the plugin
  41598. * @returns The loaded plugin
  41599. */
  41600. 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>;
  41601. /**
  41602. * Load a scene into an asset container
  41603. * @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)
  41604. * @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)
  41605. * @param scene is the instance of Scene to append to
  41606. * @param onProgress a callback with a progress event for each file being loaded
  41607. * @param pluginExtension the extension used to determine the plugin
  41608. * @returns The loaded asset container
  41609. */
  41610. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41611. }
  41612. }
  41613. declare module BABYLON {
  41614. /**
  41615. * Generic Controller
  41616. */
  41617. export class GenericController extends WebVRController {
  41618. /**
  41619. * Base Url for the controller model.
  41620. */
  41621. static readonly MODEL_BASE_URL: string;
  41622. /**
  41623. * File name for the controller model.
  41624. */
  41625. static readonly MODEL_FILENAME: string;
  41626. /**
  41627. * Creates a new GenericController from a gamepad
  41628. * @param vrGamepad the gamepad that the controller should be created from
  41629. */
  41630. constructor(vrGamepad: any);
  41631. /**
  41632. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41633. * @param scene scene in which to add meshes
  41634. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41635. */
  41636. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41637. /**
  41638. * Called once for each button that changed state since the last frame
  41639. * @param buttonIdx Which button index changed
  41640. * @param state New state of the button
  41641. * @param changes Which properties on the state changed since last frame
  41642. */
  41643. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41644. }
  41645. }
  41646. declare module BABYLON {
  41647. /**
  41648. * Defines the WindowsMotionController object that the state of the windows motion controller
  41649. */
  41650. export class WindowsMotionController extends WebVRController {
  41651. /**
  41652. * The base url used to load the left and right controller models
  41653. */
  41654. static MODEL_BASE_URL: string;
  41655. /**
  41656. * The name of the left controller model file
  41657. */
  41658. static MODEL_LEFT_FILENAME: string;
  41659. /**
  41660. * The name of the right controller model file
  41661. */
  41662. static MODEL_RIGHT_FILENAME: string;
  41663. /**
  41664. * The controller name prefix for this controller type
  41665. */
  41666. static readonly GAMEPAD_ID_PREFIX: string;
  41667. /**
  41668. * The controller id pattern for this controller type
  41669. */
  41670. private static readonly GAMEPAD_ID_PATTERN;
  41671. private _loadedMeshInfo;
  41672. private readonly _mapping;
  41673. /**
  41674. * Fired when the trackpad on this controller is clicked
  41675. */
  41676. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41677. /**
  41678. * Fired when the trackpad on this controller is modified
  41679. */
  41680. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41681. /**
  41682. * The current x and y values of this controller's trackpad
  41683. */
  41684. trackpad: StickValues;
  41685. /**
  41686. * Creates a new WindowsMotionController from a gamepad
  41687. * @param vrGamepad the gamepad that the controller should be created from
  41688. */
  41689. constructor(vrGamepad: any);
  41690. /**
  41691. * Fired when the trigger on this controller is modified
  41692. */
  41693. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41694. /**
  41695. * Fired when the menu button on this controller is modified
  41696. */
  41697. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41698. /**
  41699. * Fired when the grip button on this controller is modified
  41700. */
  41701. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41702. /**
  41703. * Fired when the thumbstick button on this controller is modified
  41704. */
  41705. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41706. /**
  41707. * Fired when the touchpad button on this controller is modified
  41708. */
  41709. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41710. /**
  41711. * Fired when the touchpad values on this controller are modified
  41712. */
  41713. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41714. private _updateTrackpad;
  41715. /**
  41716. * Called once per frame by the engine.
  41717. */
  41718. update(): void;
  41719. /**
  41720. * Called once for each button that changed state since the last frame
  41721. * @param buttonIdx Which button index changed
  41722. * @param state New state of the button
  41723. * @param changes Which properties on the state changed since last frame
  41724. */
  41725. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41726. /**
  41727. * Moves the buttons on the controller mesh based on their current state
  41728. * @param buttonName the name of the button to move
  41729. * @param buttonValue the value of the button which determines the buttons new position
  41730. */
  41731. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41732. /**
  41733. * Moves the axis on the controller mesh based on its current state
  41734. * @param axis the index of the axis
  41735. * @param axisValue the value of the axis which determines the meshes new position
  41736. * @hidden
  41737. */
  41738. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41739. /**
  41740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41741. * @param scene scene in which to add meshes
  41742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41743. */
  41744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41745. /**
  41746. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41747. * can be transformed by button presses and axes values, based on this._mapping.
  41748. *
  41749. * @param scene scene in which the meshes exist
  41750. * @param meshes list of meshes that make up the controller model to process
  41751. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41752. */
  41753. private processModel;
  41754. private createMeshInfo;
  41755. /**
  41756. * Gets the ray of the controller in the direction the controller is pointing
  41757. * @param length the length the resulting ray should be
  41758. * @returns a ray in the direction the controller is pointing
  41759. */
  41760. getForwardRay(length?: number): Ray;
  41761. /**
  41762. * Disposes of the controller
  41763. */
  41764. dispose(): void;
  41765. }
  41766. }
  41767. declare module BABYLON {
  41768. /**
  41769. * Oculus Touch Controller
  41770. */
  41771. export class OculusTouchController extends WebVRController {
  41772. /**
  41773. * Base Url for the controller model.
  41774. */
  41775. static MODEL_BASE_URL: string;
  41776. /**
  41777. * File name for the left controller model.
  41778. */
  41779. static MODEL_LEFT_FILENAME: string;
  41780. /**
  41781. * File name for the right controller model.
  41782. */
  41783. static MODEL_RIGHT_FILENAME: string;
  41784. /**
  41785. * Base Url for the Quest controller model.
  41786. */
  41787. static QUEST_MODEL_BASE_URL: string;
  41788. /**
  41789. * @hidden
  41790. * If the controllers are running on a device that needs the updated Quest controller models
  41791. */ private static _IsQuest: boolean;
  41792. /**
  41793. * Fired when the secondary trigger on this controller is modified
  41794. */
  41795. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41796. /**
  41797. * Fired when the thumb rest on this controller is modified
  41798. */
  41799. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41800. /**
  41801. * Creates a new OculusTouchController from a gamepad
  41802. * @param vrGamepad the gamepad that the controller should be created from
  41803. */
  41804. constructor(vrGamepad: any);
  41805. /**
  41806. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41807. * @param scene scene in which to add meshes
  41808. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41809. */
  41810. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41811. /**
  41812. * Fired when the A button on this controller is modified
  41813. */
  41814. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41815. /**
  41816. * Fired when the B button on this controller is modified
  41817. */
  41818. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41819. /**
  41820. * Fired when the X button on this controller is modified
  41821. */
  41822. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41823. /**
  41824. * Fired when the Y button on this controller is modified
  41825. */
  41826. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41827. /**
  41828. * Called once for each button that changed state since the last frame
  41829. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41830. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41831. * 2) secondary trigger (same)
  41832. * 3) A (right) X (left), touch, pressed = value
  41833. * 4) B / Y
  41834. * 5) thumb rest
  41835. * @param buttonIdx Which button index changed
  41836. * @param state New state of the button
  41837. * @param changes Which properties on the state changed since last frame
  41838. */
  41839. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41840. }
  41841. }
  41842. declare module BABYLON {
  41843. /**
  41844. * Vive Controller
  41845. */
  41846. export class ViveController extends WebVRController {
  41847. /**
  41848. * Base Url for the controller model.
  41849. */
  41850. static MODEL_BASE_URL: string;
  41851. /**
  41852. * File name for the controller model.
  41853. */
  41854. static MODEL_FILENAME: string;
  41855. /**
  41856. * Creates a new ViveController from a gamepad
  41857. * @param vrGamepad the gamepad that the controller should be created from
  41858. */
  41859. constructor(vrGamepad: any);
  41860. /**
  41861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41862. * @param scene scene in which to add meshes
  41863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41864. */
  41865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41866. /**
  41867. * Fired when the left button on this controller is modified
  41868. */
  41869. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41870. /**
  41871. * Fired when the right button on this controller is modified
  41872. */
  41873. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41874. /**
  41875. * Fired when the menu button on this controller is modified
  41876. */
  41877. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41878. /**
  41879. * Called once for each button that changed state since the last frame
  41880. * Vive mapping:
  41881. * 0: touchpad
  41882. * 1: trigger
  41883. * 2: left AND right buttons
  41884. * 3: menu button
  41885. * @param buttonIdx Which button index changed
  41886. * @param state New state of the button
  41887. * @param changes Which properties on the state changed since last frame
  41888. */
  41889. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41890. }
  41891. }
  41892. declare module BABYLON {
  41893. /**
  41894. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41895. */
  41896. export class WebXRControllerModelLoader {
  41897. /**
  41898. * Creates the WebXRControllerModelLoader
  41899. * @param input xr input that creates the controllers
  41900. */
  41901. constructor(input: WebXRInput);
  41902. }
  41903. }
  41904. declare module BABYLON {
  41905. /**
  41906. * Contains an array of blocks representing the octree
  41907. */
  41908. export interface IOctreeContainer<T> {
  41909. /**
  41910. * Blocks within the octree
  41911. */
  41912. blocks: Array<OctreeBlock<T>>;
  41913. }
  41914. /**
  41915. * Class used to store a cell in an octree
  41916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41917. */
  41918. export class OctreeBlock<T> {
  41919. /**
  41920. * Gets the content of the current block
  41921. */
  41922. entries: T[];
  41923. /**
  41924. * Gets the list of block children
  41925. */
  41926. blocks: Array<OctreeBlock<T>>;
  41927. private _depth;
  41928. private _maxDepth;
  41929. private _capacity;
  41930. private _minPoint;
  41931. private _maxPoint;
  41932. private _boundingVectors;
  41933. private _creationFunc;
  41934. /**
  41935. * Creates a new block
  41936. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41937. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41938. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41939. * @param depth defines the current depth of this block in the octree
  41940. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41941. * @param creationFunc defines a callback to call when an element is added to the block
  41942. */
  41943. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41944. /**
  41945. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41946. */
  41947. readonly capacity: number;
  41948. /**
  41949. * Gets the minimum vector (in world space) of the block's bounding box
  41950. */
  41951. readonly minPoint: Vector3;
  41952. /**
  41953. * Gets the maximum vector (in world space) of the block's bounding box
  41954. */
  41955. readonly maxPoint: Vector3;
  41956. /**
  41957. * Add a new element to this block
  41958. * @param entry defines the element to add
  41959. */
  41960. addEntry(entry: T): void;
  41961. /**
  41962. * Remove an element from this block
  41963. * @param entry defines the element to remove
  41964. */
  41965. removeEntry(entry: T): void;
  41966. /**
  41967. * Add an array of elements to this block
  41968. * @param entries defines the array of elements to add
  41969. */
  41970. addEntries(entries: T[]): void;
  41971. /**
  41972. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41973. * @param frustumPlanes defines the frustum planes to test
  41974. * @param selection defines the array to store current content if selection is positive
  41975. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41976. */
  41977. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41978. /**
  41979. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41980. * @param sphereCenter defines the bounding sphere center
  41981. * @param sphereRadius defines the bounding sphere radius
  41982. * @param selection defines the array to store current content if selection is positive
  41983. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41984. */
  41985. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41986. /**
  41987. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41988. * @param ray defines the ray to test with
  41989. * @param selection defines the array to store current content if selection is positive
  41990. */
  41991. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41992. /**
  41993. * Subdivide the content into child blocks (this block will then be empty)
  41994. */
  41995. createInnerBlocks(): void;
  41996. /**
  41997. * @hidden
  41998. */ 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;
  41999. }
  42000. }
  42001. declare module BABYLON {
  42002. /**
  42003. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42004. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42005. */
  42006. export class Octree<T> {
  42007. /** 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.) */
  42008. maxDepth: number;
  42009. /**
  42010. * Blocks within the octree containing objects
  42011. */
  42012. blocks: Array<OctreeBlock<T>>;
  42013. /**
  42014. * Content stored in the octree
  42015. */
  42016. dynamicContent: T[];
  42017. private _maxBlockCapacity;
  42018. private _selectionContent;
  42019. private _creationFunc;
  42020. /**
  42021. * Creates a octree
  42022. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42023. * @param creationFunc function to be used to instatiate the octree
  42024. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42025. * @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.)
  42026. */
  42027. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42028. /** 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.) */
  42029. maxDepth?: number);
  42030. /**
  42031. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42032. * @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);
  42033. * @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);
  42034. * @param entries meshes to be added to the octree blocks
  42035. */
  42036. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42037. /**
  42038. * Adds a mesh to the octree
  42039. * @param entry Mesh to add to the octree
  42040. */
  42041. addMesh(entry: T): void;
  42042. /**
  42043. * Remove an element from the octree
  42044. * @param entry defines the element to remove
  42045. */
  42046. removeMesh(entry: T): void;
  42047. /**
  42048. * Selects an array of meshes within the frustum
  42049. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42050. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42051. * @returns array of meshes within the frustum
  42052. */
  42053. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42054. /**
  42055. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42056. * @param sphereCenter defines the bounding sphere center
  42057. * @param sphereRadius defines the bounding sphere radius
  42058. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42059. * @returns an array of objects that intersect the sphere
  42060. */
  42061. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42062. /**
  42063. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42064. * @param ray defines the ray to test with
  42065. * @returns array of intersected objects
  42066. */
  42067. intersectsRay(ray: Ray): SmartArray<T>;
  42068. /**
  42069. * Adds a mesh into the octree block if it intersects the block
  42070. */
  42071. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42072. /**
  42073. * Adds a submesh into the octree block if it intersects the block
  42074. */
  42075. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42076. }
  42077. }
  42078. declare module BABYLON {
  42079. interface Scene {
  42080. /**
  42081. * @hidden
  42082. * Backing Filed
  42083. */ private _selectionOctree: Octree<AbstractMesh>;
  42084. /**
  42085. * Gets the octree used to boost mesh selection (picking)
  42086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42087. */
  42088. selectionOctree: Octree<AbstractMesh>;
  42089. /**
  42090. * Creates or updates the octree used to boost selection (picking)
  42091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42092. * @param maxCapacity defines the maximum capacity per leaf
  42093. * @param maxDepth defines the maximum depth of the octree
  42094. * @returns an octree of AbstractMesh
  42095. */
  42096. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42097. }
  42098. interface AbstractMesh {
  42099. /**
  42100. * @hidden
  42101. * Backing Field
  42102. */ private _submeshesOctree: Octree<SubMesh>;
  42103. /**
  42104. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42105. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42106. * @param maxCapacity defines the maximum size of each block (64 by default)
  42107. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42108. * @returns the new octree
  42109. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42111. */
  42112. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42113. }
  42114. /**
  42115. * Defines the octree scene component responsible to manage any octrees
  42116. * in a given scene.
  42117. */
  42118. export class OctreeSceneComponent {
  42119. /**
  42120. * The component name help to identify the component in the list of scene components.
  42121. */
  42122. readonly name: string;
  42123. /**
  42124. * The scene the component belongs to.
  42125. */
  42126. scene: Scene;
  42127. /**
  42128. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42129. */
  42130. readonly checksIsEnabled: boolean;
  42131. /**
  42132. * Creates a new instance of the component for the given scene
  42133. * @param scene Defines the scene to register the component in
  42134. */
  42135. constructor(scene: Scene);
  42136. /**
  42137. * Registers the component in a given scene
  42138. */
  42139. register(): void;
  42140. /**
  42141. * Return the list of active meshes
  42142. * @returns the list of active meshes
  42143. */
  42144. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42145. /**
  42146. * Return the list of active sub meshes
  42147. * @param mesh The mesh to get the candidates sub meshes from
  42148. * @returns the list of active sub meshes
  42149. */
  42150. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42151. private _tempRay;
  42152. /**
  42153. * Return the list of sub meshes intersecting with a given local ray
  42154. * @param mesh defines the mesh to find the submesh for
  42155. * @param localRay defines the ray in local space
  42156. * @returns the list of intersecting sub meshes
  42157. */
  42158. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42159. /**
  42160. * Return the list of sub meshes colliding with a collider
  42161. * @param mesh defines the mesh to find the submesh for
  42162. * @param collider defines the collider to evaluate the collision against
  42163. * @returns the list of colliding sub meshes
  42164. */
  42165. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42166. /**
  42167. * Rebuilds the elements related to this component in case of
  42168. * context lost for instance.
  42169. */
  42170. rebuild(): void;
  42171. /**
  42172. * Disposes the component and the associated ressources.
  42173. */
  42174. dispose(): void;
  42175. }
  42176. }
  42177. declare module BABYLON {
  42178. /**
  42179. * Renders a layer on top of an existing scene
  42180. */
  42181. export class UtilityLayerRenderer implements IDisposable {
  42182. /** the original scene that will be rendered on top of */
  42183. originalScene: Scene;
  42184. private _pointerCaptures;
  42185. private _lastPointerEvents;
  42186. private static _DefaultUtilityLayer;
  42187. private static _DefaultKeepDepthUtilityLayer;
  42188. private _sharedGizmoLight;
  42189. private _renderCamera;
  42190. /**
  42191. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42192. * @returns the camera that is used when rendering the utility layer
  42193. */
  42194. getRenderCamera(): Nullable<Camera>;
  42195. /**
  42196. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42197. * @param cam the camera that should be used when rendering the utility layer
  42198. */
  42199. setRenderCamera(cam: Nullable<Camera>): void;
  42200. /**
  42201. * @hidden
  42202. * Light which used by gizmos to get light shading
  42203. */ private _getSharedGizmoLight(): HemisphericLight;
  42204. /**
  42205. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42206. */
  42207. pickUtilitySceneFirst: boolean;
  42208. /**
  42209. * 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)
  42210. */
  42211. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42212. /**
  42213. * 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)
  42214. */
  42215. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42216. /**
  42217. * The scene that is rendered on top of the original scene
  42218. */
  42219. utilityLayerScene: Scene;
  42220. /**
  42221. * If the utility layer should automatically be rendered on top of existing scene
  42222. */
  42223. shouldRender: boolean;
  42224. /**
  42225. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42226. */
  42227. onlyCheckPointerDownEvents: boolean;
  42228. /**
  42229. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42230. */
  42231. processAllEvents: boolean;
  42232. /**
  42233. * Observable raised when the pointer move from the utility layer scene to the main scene
  42234. */
  42235. onPointerOutObservable: Observable<number>;
  42236. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42237. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42238. private _afterRenderObserver;
  42239. private _sceneDisposeObserver;
  42240. private _originalPointerObserver;
  42241. /**
  42242. * Instantiates a UtilityLayerRenderer
  42243. * @param originalScene the original scene that will be rendered on top of
  42244. * @param handleEvents boolean indicating if the utility layer should handle events
  42245. */
  42246. constructor(
  42247. /** the original scene that will be rendered on top of */
  42248. originalScene: Scene, handleEvents?: boolean);
  42249. private _notifyObservers;
  42250. /**
  42251. * Renders the utility layers scene on top of the original scene
  42252. */
  42253. render(): void;
  42254. /**
  42255. * Disposes of the renderer
  42256. */
  42257. dispose(): void;
  42258. private _updateCamera;
  42259. }
  42260. }
  42261. declare module BABYLON {
  42262. /**
  42263. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42264. */
  42265. export class Gizmo implements IDisposable {
  42266. /** The utility layer the gizmo will be added to */
  42267. gizmoLayer: UtilityLayerRenderer;
  42268. /**
  42269. * The root mesh of the gizmo
  42270. */ private _rootMesh: Mesh;
  42271. private _attachedMesh;
  42272. /**
  42273. * Ratio for the scale of the gizmo (Default: 1)
  42274. */
  42275. scaleRatio: number;
  42276. /**
  42277. * If a custom mesh has been set (Default: false)
  42278. */
  42279. protected _customMeshSet: boolean;
  42280. /**
  42281. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42282. * * When set, interactions will be enabled
  42283. */
  42284. attachedMesh: Nullable<AbstractMesh>;
  42285. /**
  42286. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42287. * @param mesh The mesh to replace the default mesh of the gizmo
  42288. */
  42289. setCustomMesh(mesh: Mesh): void;
  42290. /**
  42291. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42292. */
  42293. updateGizmoRotationToMatchAttachedMesh: boolean;
  42294. /**
  42295. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42296. */
  42297. updateGizmoPositionToMatchAttachedMesh: boolean;
  42298. /**
  42299. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42300. */
  42301. updateScale: boolean;
  42302. protected _interactionsEnabled: boolean;
  42303. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42304. private _beforeRenderObserver;
  42305. private _tempVector;
  42306. /**
  42307. * Creates a gizmo
  42308. * @param gizmoLayer The utility layer the gizmo will be added to
  42309. */
  42310. constructor(
  42311. /** The utility layer the gizmo will be added to */
  42312. gizmoLayer?: UtilityLayerRenderer);
  42313. /**
  42314. * Updates the gizmo to match the attached mesh's position/rotation
  42315. */
  42316. protected _update(): void;
  42317. /**
  42318. * Disposes of the gizmo
  42319. */
  42320. dispose(): void;
  42321. }
  42322. }
  42323. declare module BABYLON {
  42324. /**
  42325. * Single plane drag gizmo
  42326. */
  42327. export class PlaneDragGizmo extends Gizmo {
  42328. /**
  42329. * Drag behavior responsible for the gizmos dragging interactions
  42330. */
  42331. dragBehavior: PointerDragBehavior;
  42332. private _pointerObserver;
  42333. /**
  42334. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42335. */
  42336. snapDistance: number;
  42337. /**
  42338. * Event that fires each time the gizmo snaps to a new location.
  42339. * * snapDistance is the the change in distance
  42340. */
  42341. onSnapObservable: Observable<{
  42342. snapDistance: number;
  42343. }>;
  42344. private _plane;
  42345. private _coloredMaterial;
  42346. private _hoverMaterial;
  42347. private _isEnabled;
  42348. private _parent;
  42349. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42350. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42351. /**
  42352. * Creates a PlaneDragGizmo
  42353. * @param gizmoLayer The utility layer the gizmo will be added to
  42354. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42355. * @param color The color of the gizmo
  42356. */
  42357. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42358. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42359. /**
  42360. * If the gizmo is enabled
  42361. */
  42362. isEnabled: boolean;
  42363. /**
  42364. * Disposes of the gizmo
  42365. */
  42366. dispose(): void;
  42367. }
  42368. }
  42369. declare module BABYLON {
  42370. /**
  42371. * Gizmo that enables dragging a mesh along 3 axis
  42372. */
  42373. export class PositionGizmo extends Gizmo {
  42374. /**
  42375. * Internal gizmo used for interactions on the x axis
  42376. */
  42377. xGizmo: AxisDragGizmo;
  42378. /**
  42379. * Internal gizmo used for interactions on the y axis
  42380. */
  42381. yGizmo: AxisDragGizmo;
  42382. /**
  42383. * Internal gizmo used for interactions on the z axis
  42384. */
  42385. zGizmo: AxisDragGizmo;
  42386. /**
  42387. * Internal gizmo used for interactions on the yz plane
  42388. */
  42389. xPlaneGizmo: PlaneDragGizmo;
  42390. /**
  42391. * Internal gizmo used for interactions on the xz plane
  42392. */
  42393. yPlaneGizmo: PlaneDragGizmo;
  42394. /**
  42395. * Internal gizmo used for interactions on the xy plane
  42396. */
  42397. zPlaneGizmo: PlaneDragGizmo;
  42398. /**
  42399. * private variables
  42400. */
  42401. private _meshAttached;
  42402. private _updateGizmoRotationToMatchAttachedMesh;
  42403. private _snapDistance;
  42404. private _scaleRatio;
  42405. /** Fires an event when any of it's sub gizmos are dragged */
  42406. onDragStartObservable: Observable<unknown>;
  42407. /** Fires an event when any of it's sub gizmos are released from dragging */
  42408. onDragEndObservable: Observable<unknown>;
  42409. /**
  42410. * If set to true, planar drag is enabled
  42411. */
  42412. private _planarGizmoEnabled;
  42413. attachedMesh: Nullable<AbstractMesh>;
  42414. /**
  42415. * Creates a PositionGizmo
  42416. * @param gizmoLayer The utility layer the gizmo will be added to
  42417. */
  42418. constructor(gizmoLayer?: UtilityLayerRenderer);
  42419. /**
  42420. * If the planar drag gizmo is enabled
  42421. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42422. */
  42423. planarGizmoEnabled: boolean;
  42424. updateGizmoRotationToMatchAttachedMesh: boolean;
  42425. /**
  42426. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42427. */
  42428. snapDistance: number;
  42429. /**
  42430. * Ratio for the scale of the gizmo (Default: 1)
  42431. */
  42432. scaleRatio: number;
  42433. /**
  42434. * Disposes of the gizmo
  42435. */
  42436. dispose(): void;
  42437. /**
  42438. * CustomMeshes are not supported by this gizmo
  42439. * @param mesh The mesh to replace the default mesh of the gizmo
  42440. */
  42441. setCustomMesh(mesh: Mesh): void;
  42442. }
  42443. }
  42444. declare module BABYLON {
  42445. /**
  42446. * Single axis drag gizmo
  42447. */
  42448. export class AxisDragGizmo extends Gizmo {
  42449. /**
  42450. * Drag behavior responsible for the gizmos dragging interactions
  42451. */
  42452. dragBehavior: PointerDragBehavior;
  42453. private _pointerObserver;
  42454. /**
  42455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42456. */
  42457. snapDistance: number;
  42458. /**
  42459. * Event that fires each time the gizmo snaps to a new location.
  42460. * * snapDistance is the the change in distance
  42461. */
  42462. onSnapObservable: Observable<{
  42463. snapDistance: number;
  42464. }>;
  42465. private _isEnabled;
  42466. private _parent;
  42467. private _arrow;
  42468. private _coloredMaterial;
  42469. private _hoverMaterial;
  42470. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42471. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42472. /**
  42473. * Creates an AxisDragGizmo
  42474. * @param gizmoLayer The utility layer the gizmo will be added to
  42475. * @param dragAxis The axis which the gizmo will be able to drag on
  42476. * @param color The color of the gizmo
  42477. */
  42478. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42479. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42480. /**
  42481. * If the gizmo is enabled
  42482. */
  42483. isEnabled: boolean;
  42484. /**
  42485. * Disposes of the gizmo
  42486. */
  42487. dispose(): void;
  42488. }
  42489. }
  42490. declare module BABYLON.Debug {
  42491. /**
  42492. * The Axes viewer will show 3 axes in a specific point in space
  42493. */
  42494. export class AxesViewer {
  42495. private _xAxis;
  42496. private _yAxis;
  42497. private _zAxis;
  42498. private _scaleLinesFactor;
  42499. private _instanced;
  42500. /**
  42501. * Gets the hosting scene
  42502. */
  42503. scene: Scene;
  42504. /**
  42505. * Gets or sets a number used to scale line length
  42506. */
  42507. scaleLines: number;
  42508. /** Gets the node hierarchy used to render x-axis */
  42509. readonly xAxis: TransformNode;
  42510. /** Gets the node hierarchy used to render y-axis */
  42511. readonly yAxis: TransformNode;
  42512. /** Gets the node hierarchy used to render z-axis */
  42513. readonly zAxis: TransformNode;
  42514. /**
  42515. * Creates a new AxesViewer
  42516. * @param scene defines the hosting scene
  42517. * @param scaleLines defines a number used to scale line length (1 by default)
  42518. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42519. * @param xAxis defines the node hierarchy used to render the x-axis
  42520. * @param yAxis defines the node hierarchy used to render the y-axis
  42521. * @param zAxis defines the node hierarchy used to render the z-axis
  42522. */
  42523. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42524. /**
  42525. * Force the viewer to update
  42526. * @param position defines the position of the viewer
  42527. * @param xaxis defines the x axis of the viewer
  42528. * @param yaxis defines the y axis of the viewer
  42529. * @param zaxis defines the z axis of the viewer
  42530. */
  42531. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42532. /**
  42533. * Creates an instance of this axes viewer.
  42534. * @returns a new axes viewer with instanced meshes
  42535. */
  42536. createInstance(): AxesViewer;
  42537. /** Releases resources */
  42538. dispose(): void;
  42539. private static _SetRenderingGroupId;
  42540. }
  42541. }
  42542. declare module BABYLON.Debug {
  42543. /**
  42544. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42545. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42546. */
  42547. export class BoneAxesViewer extends AxesViewer {
  42548. /**
  42549. * Gets or sets the target mesh where to display the axes viewer
  42550. */
  42551. mesh: Nullable<Mesh>;
  42552. /**
  42553. * Gets or sets the target bone where to display the axes viewer
  42554. */
  42555. bone: Nullable<Bone>;
  42556. /** Gets current position */
  42557. pos: Vector3;
  42558. /** Gets direction of X axis */
  42559. xaxis: Vector3;
  42560. /** Gets direction of Y axis */
  42561. yaxis: Vector3;
  42562. /** Gets direction of Z axis */
  42563. zaxis: Vector3;
  42564. /**
  42565. * Creates a new BoneAxesViewer
  42566. * @param scene defines the hosting scene
  42567. * @param bone defines the target bone
  42568. * @param mesh defines the target mesh
  42569. * @param scaleLines defines a scaling factor for line length (1 by default)
  42570. */
  42571. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42572. /**
  42573. * Force the viewer to update
  42574. */
  42575. update(): void;
  42576. /** Releases resources */
  42577. dispose(): void;
  42578. }
  42579. }
  42580. declare module BABYLON {
  42581. /**
  42582. * Interface used to define scene explorer extensibility option
  42583. */
  42584. export interface IExplorerExtensibilityOption {
  42585. /**
  42586. * Define the option label
  42587. */
  42588. label: string;
  42589. /**
  42590. * Defines the action to execute on click
  42591. */
  42592. action: (entity: any) => void;
  42593. }
  42594. /**
  42595. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42596. */
  42597. export interface IExplorerExtensibilityGroup {
  42598. /**
  42599. * Defines a predicate to test if a given type mut be extended
  42600. */
  42601. predicate: (entity: any) => boolean;
  42602. /**
  42603. * Gets the list of options added to a type
  42604. */
  42605. entries: IExplorerExtensibilityOption[];
  42606. }
  42607. /**
  42608. * Interface used to define the options to use to create the Inspector
  42609. */
  42610. export interface IInspectorOptions {
  42611. /**
  42612. * Display in overlay mode (default: false)
  42613. */
  42614. overlay?: boolean;
  42615. /**
  42616. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42617. */
  42618. globalRoot?: HTMLElement;
  42619. /**
  42620. * Display the Scene explorer
  42621. */
  42622. showExplorer?: boolean;
  42623. /**
  42624. * Display the property inspector
  42625. */
  42626. showInspector?: boolean;
  42627. /**
  42628. * Display in embed mode (both panes on the right)
  42629. */
  42630. embedMode?: boolean;
  42631. /**
  42632. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42633. */
  42634. handleResize?: boolean;
  42635. /**
  42636. * Allow the panes to popup (default: true)
  42637. */
  42638. enablePopup?: boolean;
  42639. /**
  42640. * Allow the panes to be closed by users (default: true)
  42641. */
  42642. enableClose?: boolean;
  42643. /**
  42644. * Optional list of extensibility entries
  42645. */
  42646. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42647. /**
  42648. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42649. */
  42650. inspectorURL?: string;
  42651. }
  42652. interface Scene {
  42653. /**
  42654. * @hidden
  42655. * Backing field
  42656. */ private _debugLayer: DebugLayer;
  42657. /**
  42658. * Gets the debug layer (aka Inspector) associated with the scene
  42659. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42660. */
  42661. debugLayer: DebugLayer;
  42662. }
  42663. /**
  42664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42665. * what is happening in your scene
  42666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42667. */
  42668. export class DebugLayer {
  42669. /**
  42670. * Define the url to get the inspector script from.
  42671. * By default it uses the babylonjs CDN.
  42672. * @ignoreNaming
  42673. */
  42674. static InspectorURL: string;
  42675. private _scene;
  42676. private BJSINSPECTOR;
  42677. private _onPropertyChangedObservable?;
  42678. /**
  42679. * Observable triggered when a property is changed through the inspector.
  42680. */
  42681. readonly onPropertyChangedObservable: any;
  42682. /**
  42683. * Instantiates a new debug layer.
  42684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42685. * what is happening in your scene
  42686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42687. * @param scene Defines the scene to inspect
  42688. */
  42689. constructor(scene: Scene);
  42690. /** Creates the inspector window. */
  42691. private _createInspector;
  42692. /**
  42693. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42694. * @param entity defines the entity to select
  42695. * @param lineContainerTitle defines the specific block to highlight
  42696. */
  42697. select(entity: any, lineContainerTitle?: string): void;
  42698. /** Get the inspector from bundle or global */
  42699. private _getGlobalInspector;
  42700. /**
  42701. * Get if the inspector is visible or not.
  42702. * @returns true if visible otherwise, false
  42703. */
  42704. isVisible(): boolean;
  42705. /**
  42706. * Hide the inspector and close its window.
  42707. */
  42708. hide(): void;
  42709. /**
  42710. * Launch the debugLayer.
  42711. * @param config Define the configuration of the inspector
  42712. * @return a promise fulfilled when the debug layer is visible
  42713. */
  42714. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42715. }
  42716. }
  42717. declare module BABYLON {
  42718. /**
  42719. * Class containing static functions to help procedurally build meshes
  42720. */
  42721. export class BoxBuilder {
  42722. /**
  42723. * Creates a box mesh
  42724. * * The parameter `size` sets the size (float) of each box side (default 1)
  42725. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42726. * * 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)
  42727. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42729. * * 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
  42730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42731. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42732. * @param name defines the name of the mesh
  42733. * @param options defines the options used to create the mesh
  42734. * @param scene defines the hosting scene
  42735. * @returns the box mesh
  42736. */
  42737. static CreateBox(name: string, options: {
  42738. size?: number;
  42739. width?: number;
  42740. height?: number;
  42741. depth?: number;
  42742. faceUV?: Vector4[];
  42743. faceColors?: Color4[];
  42744. sideOrientation?: number;
  42745. frontUVs?: Vector4;
  42746. backUVs?: Vector4;
  42747. wrap?: boolean;
  42748. topBaseAt?: number;
  42749. bottomBaseAt?: number;
  42750. updatable?: boolean;
  42751. }, scene?: Nullable<Scene>): Mesh;
  42752. }
  42753. }
  42754. declare module BABYLON {
  42755. /**
  42756. * Class containing static functions to help procedurally build meshes
  42757. */
  42758. export class SphereBuilder {
  42759. /**
  42760. * Creates a sphere mesh
  42761. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42762. * * 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`)
  42763. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42764. * * 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
  42765. * * 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)
  42766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42767. * * 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
  42768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42769. * @param name defines the name of the mesh
  42770. * @param options defines the options used to create the mesh
  42771. * @param scene defines the hosting scene
  42772. * @returns the sphere mesh
  42773. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42774. */
  42775. static CreateSphere(name: string, options: {
  42776. segments?: number;
  42777. diameter?: number;
  42778. diameterX?: number;
  42779. diameterY?: number;
  42780. diameterZ?: number;
  42781. arc?: number;
  42782. slice?: number;
  42783. sideOrientation?: number;
  42784. frontUVs?: Vector4;
  42785. backUVs?: Vector4;
  42786. updatable?: boolean;
  42787. }, scene?: Nullable<Scene>): Mesh;
  42788. }
  42789. }
  42790. declare module BABYLON.Debug {
  42791. /**
  42792. * Used to show the physics impostor around the specific mesh
  42793. */
  42794. export class PhysicsViewer {
  42795. /** @hidden */
  42796. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42797. /** @hidden */
  42798. protected _meshes: Array<Nullable<AbstractMesh>>;
  42799. /** @hidden */
  42800. protected _scene: Nullable<Scene>;
  42801. /** @hidden */
  42802. protected _numMeshes: number;
  42803. /** @hidden */
  42804. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42805. private _renderFunction;
  42806. private _utilityLayer;
  42807. private _debugBoxMesh;
  42808. private _debugSphereMesh;
  42809. private _debugCylinderMesh;
  42810. private _debugMaterial;
  42811. private _debugMeshMeshes;
  42812. /**
  42813. * Creates a new PhysicsViewer
  42814. * @param scene defines the hosting scene
  42815. */
  42816. constructor(scene: Scene);
  42817. /** @hidden */
  42818. protected _updateDebugMeshes(): void;
  42819. /**
  42820. * Renders a specified physic impostor
  42821. * @param impostor defines the impostor to render
  42822. * @param targetMesh defines the mesh represented by the impostor
  42823. * @returns the new debug mesh used to render the impostor
  42824. */
  42825. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42826. /**
  42827. * Hides a specified physic impostor
  42828. * @param impostor defines the impostor to hide
  42829. */
  42830. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42831. private _getDebugMaterial;
  42832. private _getDebugBoxMesh;
  42833. private _getDebugSphereMesh;
  42834. private _getDebugCylinderMesh;
  42835. private _getDebugMeshMesh;
  42836. private _getDebugMesh;
  42837. /** Releases all resources */
  42838. dispose(): void;
  42839. }
  42840. }
  42841. declare module BABYLON {
  42842. /**
  42843. * Class containing static functions to help procedurally build meshes
  42844. */
  42845. export class LinesBuilder {
  42846. /**
  42847. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42848. * * 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
  42849. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42850. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42851. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42852. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42853. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42854. * * 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
  42855. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42858. * @param name defines the name of the new line system
  42859. * @param options defines the options used to create the line system
  42860. * @param scene defines the hosting scene
  42861. * @returns a new line system mesh
  42862. */
  42863. static CreateLineSystem(name: string, options: {
  42864. lines: Vector3[][];
  42865. updatable?: boolean;
  42866. instance?: Nullable<LinesMesh>;
  42867. colors?: Nullable<Color4[][]>;
  42868. useVertexAlpha?: boolean;
  42869. }, scene: Nullable<Scene>): LinesMesh;
  42870. /**
  42871. * Creates a line mesh
  42872. * 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
  42873. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42874. * * The parameter `points` is an array successive Vector3
  42875. * * 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
  42876. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42877. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42878. * * When updating an instance, remember that only point positions can change, not the number of points
  42879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42881. * @param name defines the name of the new line system
  42882. * @param options defines the options used to create the line system
  42883. * @param scene defines the hosting scene
  42884. * @returns a new line mesh
  42885. */
  42886. static CreateLines(name: string, options: {
  42887. points: Vector3[];
  42888. updatable?: boolean;
  42889. instance?: Nullable<LinesMesh>;
  42890. colors?: Color4[];
  42891. useVertexAlpha?: boolean;
  42892. }, scene?: Nullable<Scene>): LinesMesh;
  42893. /**
  42894. * Creates a dashed line mesh
  42895. * * 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
  42896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42897. * * The parameter `points` is an array successive Vector3
  42898. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42899. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42900. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42901. * * 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
  42902. * * When updating an instance, remember that only point positions can change, not the number of points
  42903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42904. * @param name defines the name of the mesh
  42905. * @param options defines the options used to create the mesh
  42906. * @param scene defines the hosting scene
  42907. * @returns the dashed line mesh
  42908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42909. */
  42910. static CreateDashedLines(name: string, options: {
  42911. points: Vector3[];
  42912. dashSize?: number;
  42913. gapSize?: number;
  42914. dashNb?: number;
  42915. updatable?: boolean;
  42916. instance?: LinesMesh;
  42917. }, scene?: Nullable<Scene>): LinesMesh;
  42918. }
  42919. }
  42920. declare module BABYLON {
  42921. /**
  42922. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42923. * in order to better appreciate the issue one might have.
  42924. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42925. */
  42926. export class RayHelper {
  42927. /**
  42928. * Defines the ray we are currently tryin to visualize.
  42929. */
  42930. ray: Nullable<Ray>;
  42931. private _renderPoints;
  42932. private _renderLine;
  42933. private _renderFunction;
  42934. private _scene;
  42935. private _updateToMeshFunction;
  42936. private _attachedToMesh;
  42937. private _meshSpaceDirection;
  42938. private _meshSpaceOrigin;
  42939. /**
  42940. * Helper function to create a colored helper in a scene in one line.
  42941. * @param ray Defines the ray we are currently tryin to visualize
  42942. * @param scene Defines the scene the ray is used in
  42943. * @param color Defines the color we want to see the ray in
  42944. * @returns The newly created ray helper.
  42945. */
  42946. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42947. /**
  42948. * Instantiate a new ray helper.
  42949. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42950. * in order to better appreciate the issue one might have.
  42951. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42952. * @param ray Defines the ray we are currently tryin to visualize
  42953. */
  42954. constructor(ray: Ray);
  42955. /**
  42956. * Shows the ray we are willing to debug.
  42957. * @param scene Defines the scene the ray needs to be rendered in
  42958. * @param color Defines the color the ray needs to be rendered in
  42959. */
  42960. show(scene: Scene, color?: Color3): void;
  42961. /**
  42962. * Hides the ray we are debugging.
  42963. */
  42964. hide(): void;
  42965. private _render;
  42966. /**
  42967. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42968. * @param mesh Defines the mesh we want the helper attached to
  42969. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42970. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42971. * @param length Defines the length of the ray
  42972. */
  42973. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42974. /**
  42975. * Detach the ray helper from the mesh it has previously been attached to.
  42976. */
  42977. detachFromMesh(): void;
  42978. private _updateToMesh;
  42979. /**
  42980. * Dispose the helper and release its associated resources.
  42981. */
  42982. dispose(): void;
  42983. }
  42984. }
  42985. declare module BABYLON.Debug {
  42986. /**
  42987. * Class used to render a debug view of a given skeleton
  42988. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42989. */
  42990. export class SkeletonViewer {
  42991. /** defines the skeleton to render */
  42992. skeleton: Skeleton;
  42993. /** defines the mesh attached to the skeleton */
  42994. mesh: AbstractMesh;
  42995. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42996. autoUpdateBonesMatrices: boolean;
  42997. /** defines the rendering group id to use with the viewer */
  42998. renderingGroupId: number;
  42999. /** Gets or sets the color used to render the skeleton */
  43000. color: Color3;
  43001. private _scene;
  43002. private _debugLines;
  43003. private _debugMesh;
  43004. private _isEnabled;
  43005. private _renderFunction;
  43006. private _utilityLayer;
  43007. /**
  43008. * Returns the mesh used to render the bones
  43009. */
  43010. readonly debugMesh: Nullable<LinesMesh>;
  43011. /**
  43012. * Creates a new SkeletonViewer
  43013. * @param skeleton defines the skeleton to render
  43014. * @param mesh defines the mesh attached to the skeleton
  43015. * @param scene defines the hosting scene
  43016. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43017. * @param renderingGroupId defines the rendering group id to use with the viewer
  43018. */
  43019. constructor(
  43020. /** defines the skeleton to render */
  43021. skeleton: Skeleton,
  43022. /** defines the mesh attached to the skeleton */
  43023. mesh: AbstractMesh, scene: Scene,
  43024. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43025. autoUpdateBonesMatrices?: boolean,
  43026. /** defines the rendering group id to use with the viewer */
  43027. renderingGroupId?: number);
  43028. /** Gets or sets a boolean indicating if the viewer is enabled */
  43029. isEnabled: boolean;
  43030. private _getBonePosition;
  43031. private _getLinesForBonesWithLength;
  43032. private _getLinesForBonesNoLength;
  43033. /** Update the viewer to sync with current skeleton state */
  43034. update(): void;
  43035. /** Release associated resources */
  43036. dispose(): void;
  43037. }
  43038. }
  43039. declare module BABYLON {
  43040. /**
  43041. * Options to create the null engine
  43042. */
  43043. export class NullEngineOptions {
  43044. /**
  43045. * Render width (Default: 512)
  43046. */
  43047. renderWidth: number;
  43048. /**
  43049. * Render height (Default: 256)
  43050. */
  43051. renderHeight: number;
  43052. /**
  43053. * Texture size (Default: 512)
  43054. */
  43055. textureSize: number;
  43056. /**
  43057. * If delta time between frames should be constant
  43058. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43059. */
  43060. deterministicLockstep: boolean;
  43061. /**
  43062. * Maximum about of steps between frames (Default: 4)
  43063. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43064. */
  43065. lockstepMaxSteps: number;
  43066. }
  43067. /**
  43068. * The null engine class provides support for headless version of babylon.js.
  43069. * This can be used in server side scenario or for testing purposes
  43070. */
  43071. export class NullEngine extends Engine {
  43072. private _options;
  43073. /**
  43074. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43075. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43076. * @returns true if engine is in deterministic lock step mode
  43077. */
  43078. isDeterministicLockStep(): boolean;
  43079. /**
  43080. * Gets the max steps when engine is running in deterministic lock step
  43081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43082. * @returns the max steps
  43083. */
  43084. getLockstepMaxSteps(): number;
  43085. /**
  43086. * Gets the current hardware scaling level.
  43087. * By default the hardware scaling level is computed from the window device ratio.
  43088. * 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.
  43089. * @returns a number indicating the current hardware scaling level
  43090. */
  43091. getHardwareScalingLevel(): number;
  43092. constructor(options?: NullEngineOptions);
  43093. /**
  43094. * Creates a vertex buffer
  43095. * @param vertices the data for the vertex buffer
  43096. * @returns the new WebGL static buffer
  43097. */
  43098. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43099. /**
  43100. * Creates a new index buffer
  43101. * @param indices defines the content of the index buffer
  43102. * @param updatable defines if the index buffer must be updatable
  43103. * @returns a new webGL buffer
  43104. */
  43105. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43106. /**
  43107. * Clear the current render buffer or the current render target (if any is set up)
  43108. * @param color defines the color to use
  43109. * @param backBuffer defines if the back buffer must be cleared
  43110. * @param depth defines if the depth buffer must be cleared
  43111. * @param stencil defines if the stencil buffer must be cleared
  43112. */
  43113. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43114. /**
  43115. * Gets the current render width
  43116. * @param useScreen defines if screen size must be used (or the current render target if any)
  43117. * @returns a number defining the current render width
  43118. */
  43119. getRenderWidth(useScreen?: boolean): number;
  43120. /**
  43121. * Gets the current render height
  43122. * @param useScreen defines if screen size must be used (or the current render target if any)
  43123. * @returns a number defining the current render height
  43124. */
  43125. getRenderHeight(useScreen?: boolean): number;
  43126. /**
  43127. * Set the WebGL's viewport
  43128. * @param viewport defines the viewport element to be used
  43129. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43130. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43131. */
  43132. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43133. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43134. /**
  43135. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43136. * @param pipelineContext defines the pipeline context to use
  43137. * @param uniformsNames defines the list of uniform names
  43138. * @returns an array of webGL uniform locations
  43139. */
  43140. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43141. /**
  43142. * Gets the lsit of active attributes for a given webGL program
  43143. * @param pipelineContext defines the pipeline context to use
  43144. * @param attributesNames defines the list of attribute names to get
  43145. * @returns an array of indices indicating the offset of each attribute
  43146. */
  43147. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43148. /**
  43149. * Binds an effect to the webGL context
  43150. * @param effect defines the effect to bind
  43151. */
  43152. bindSamplers(effect: Effect): void;
  43153. /**
  43154. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43155. * @param effect defines the effect to activate
  43156. */
  43157. enableEffect(effect: Effect): void;
  43158. /**
  43159. * Set various states to the webGL context
  43160. * @param culling defines backface culling state
  43161. * @param zOffset defines the value to apply to zOffset (0 by default)
  43162. * @param force defines if states must be applied even if cache is up to date
  43163. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43164. */
  43165. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43166. /**
  43167. * Set the value of an uniform to an array of int32
  43168. * @param uniform defines the webGL uniform location where to store the value
  43169. * @param array defines the array of int32 to store
  43170. */
  43171. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43172. /**
  43173. * Set the value of an uniform to an array of int32 (stored as vec2)
  43174. * @param uniform defines the webGL uniform location where to store the value
  43175. * @param array defines the array of int32 to store
  43176. */
  43177. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43178. /**
  43179. * Set the value of an uniform to an array of int32 (stored as vec3)
  43180. * @param uniform defines the webGL uniform location where to store the value
  43181. * @param array defines the array of int32 to store
  43182. */
  43183. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43184. /**
  43185. * Set the value of an uniform to an array of int32 (stored as vec4)
  43186. * @param uniform defines the webGL uniform location where to store the value
  43187. * @param array defines the array of int32 to store
  43188. */
  43189. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43190. /**
  43191. * Set the value of an uniform to an array of float32
  43192. * @param uniform defines the webGL uniform location where to store the value
  43193. * @param array defines the array of float32 to store
  43194. */
  43195. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43196. /**
  43197. * Set the value of an uniform to an array of float32 (stored as vec2)
  43198. * @param uniform defines the webGL uniform location where to store the value
  43199. * @param array defines the array of float32 to store
  43200. */
  43201. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43202. /**
  43203. * Set the value of an uniform to an array of float32 (stored as vec3)
  43204. * @param uniform defines the webGL uniform location where to store the value
  43205. * @param array defines the array of float32 to store
  43206. */
  43207. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43208. /**
  43209. * Set the value of an uniform to an array of float32 (stored as vec4)
  43210. * @param uniform defines the webGL uniform location where to store the value
  43211. * @param array defines the array of float32 to store
  43212. */
  43213. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43214. /**
  43215. * Set the value of an uniform to an array of number
  43216. * @param uniform defines the webGL uniform location where to store the value
  43217. * @param array defines the array of number to store
  43218. */
  43219. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43220. /**
  43221. * Set the value of an uniform to an array of number (stored as vec2)
  43222. * @param uniform defines the webGL uniform location where to store the value
  43223. * @param array defines the array of number to store
  43224. */
  43225. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43226. /**
  43227. * Set the value of an uniform to an array of number (stored as vec3)
  43228. * @param uniform defines the webGL uniform location where to store the value
  43229. * @param array defines the array of number to store
  43230. */
  43231. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43232. /**
  43233. * Set the value of an uniform to an array of number (stored as vec4)
  43234. * @param uniform defines the webGL uniform location where to store the value
  43235. * @param array defines the array of number to store
  43236. */
  43237. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43238. /**
  43239. * Set the value of an uniform to an array of float32 (stored as matrices)
  43240. * @param uniform defines the webGL uniform location where to store the value
  43241. * @param matrices defines the array of float32 to store
  43242. */
  43243. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43244. /**
  43245. * Set the value of an uniform to a matrix (3x3)
  43246. * @param uniform defines the webGL uniform location where to store the value
  43247. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43248. */
  43249. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43250. /**
  43251. * Set the value of an uniform to a matrix (2x2)
  43252. * @param uniform defines the webGL uniform location where to store the value
  43253. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43254. */
  43255. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43256. /**
  43257. * Set the value of an uniform to a number (float)
  43258. * @param uniform defines the webGL uniform location where to store the value
  43259. * @param value defines the float number to store
  43260. */
  43261. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43262. /**
  43263. * Set the value of an uniform to a vec2
  43264. * @param uniform defines the webGL uniform location where to store the value
  43265. * @param x defines the 1st component of the value
  43266. * @param y defines the 2nd component of the value
  43267. */
  43268. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43269. /**
  43270. * Set the value of an uniform to a vec3
  43271. * @param uniform defines the webGL uniform location where to store the value
  43272. * @param x defines the 1st component of the value
  43273. * @param y defines the 2nd component of the value
  43274. * @param z defines the 3rd component of the value
  43275. */
  43276. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43277. /**
  43278. * Set the value of an uniform to a boolean
  43279. * @param uniform defines the webGL uniform location where to store the value
  43280. * @param bool defines the boolean to store
  43281. */
  43282. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43283. /**
  43284. * Set the value of an uniform to a vec4
  43285. * @param uniform defines the webGL uniform location where to store the value
  43286. * @param x defines the 1st component of the value
  43287. * @param y defines the 2nd component of the value
  43288. * @param z defines the 3rd component of the value
  43289. * @param w defines the 4th component of the value
  43290. */
  43291. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43292. /**
  43293. * Sets the current alpha mode
  43294. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43295. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43296. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43297. */
  43298. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43299. /**
  43300. * Bind webGl buffers directly to the webGL context
  43301. * @param vertexBuffers defines the vertex buffer to bind
  43302. * @param indexBuffer defines the index buffer to bind
  43303. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43304. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43305. * @param effect defines the effect associated with the vertex buffer
  43306. */
  43307. bindBuffers(vertexBuffers: {
  43308. [key: string]: VertexBuffer;
  43309. }, indexBuffer: DataBuffer, effect: Effect): void;
  43310. /**
  43311. * Force the entire cache to be cleared
  43312. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43313. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43314. */
  43315. wipeCaches(bruteForce?: boolean): void;
  43316. /**
  43317. * Send a draw order
  43318. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43319. * @param indexStart defines the starting index
  43320. * @param indexCount defines the number of index to draw
  43321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43322. */
  43323. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  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. /** @hidden */ private _createTexture(): WebGLTexture;
  43341. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  43342. /**
  43343. * Usually called from Texture.ts.
  43344. * Passed information to create a WebGLTexture
  43345. * @param urlArg defines a value which contains one of the following:
  43346. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43347. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43348. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43349. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43350. * @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)
  43351. * @param scene needed for loading to the correct scene
  43352. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43353. * @param onLoad optional callback to be called upon successful completion
  43354. * @param onError optional callback to be called upon failure
  43355. * @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
  43356. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43357. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43358. * @param forcedExtension defines the extension to use to pick the right loader
  43359. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43360. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43361. */
  43362. 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;
  43363. /**
  43364. * Creates a new render target texture
  43365. * @param size defines the size of the texture
  43366. * @param options defines the options used to create the texture
  43367. * @returns a new render target texture stored in an InternalTexture
  43368. */
  43369. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43370. /**
  43371. * Update the sampling mode of a given texture
  43372. * @param samplingMode defines the required sampling mode
  43373. * @param texture defines the texture to update
  43374. */
  43375. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43376. /**
  43377. * Binds the frame buffer to the specified texture.
  43378. * @param texture The texture to render to or null for the default canvas
  43379. * @param faceIndex The face of the texture to render to in case of cube texture
  43380. * @param requiredWidth The width of the target to render to
  43381. * @param requiredHeight The height of the target to render to
  43382. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43383. * @param depthStencilTexture The depth stencil texture to use to render
  43384. * @param lodLevel defines le lod level to bind to the frame buffer
  43385. */
  43386. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43387. /**
  43388. * Unbind the current render target texture from the webGL context
  43389. * @param texture defines the render target texture to unbind
  43390. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43391. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43392. */
  43393. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43394. /**
  43395. * Creates a dynamic vertex buffer
  43396. * @param vertices the data for the dynamic vertex buffer
  43397. * @returns the new WebGL dynamic buffer
  43398. */
  43399. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43400. /**
  43401. * Update the content of a dynamic texture
  43402. * @param texture defines the texture to update
  43403. * @param canvas defines the canvas containing the source
  43404. * @param invertY defines if data must be stored with Y axis inverted
  43405. * @param premulAlpha defines if alpha is stored as premultiplied
  43406. * @param format defines the format of the data
  43407. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43408. */
  43409. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43410. /**
  43411. * Gets a boolean indicating if all created effects are ready
  43412. * @returns true if all effects are ready
  43413. */
  43414. areAllEffectsReady(): boolean;
  43415. /**
  43416. * @hidden
  43417. * Get the current error code of the webGL context
  43418. * @returns the error code
  43419. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43420. */
  43421. getError(): number;
  43422. /** @hidden */ private _getUnpackAlignement(): number;
  43423. /** @hidden */ private _unpackFlipY(value: boolean): void;
  43424. /**
  43425. * Update a dynamic index buffer
  43426. * @param indexBuffer defines the target index buffer
  43427. * @param indices defines the data to update
  43428. * @param offset defines the offset in the target index buffer where update should start
  43429. */
  43430. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43431. /**
  43432. * Updates a dynamic vertex buffer.
  43433. * @param vertexBuffer the vertex buffer to update
  43434. * @param vertices the data used to update the vertex buffer
  43435. * @param byteOffset the byte offset of the data (optional)
  43436. * @param byteLength the byte length of the data (optional)
  43437. */
  43438. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43439. /** @hidden */ private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43440. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43441. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43442. /**
  43443. * 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
  43444. */
  43445. releaseEffects(): void;
  43446. displayLoadingUI(): void;
  43447. hideLoadingUI(): void;
  43448. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43449. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43450. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43451. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43452. }
  43453. }
  43454. declare module BABYLON {
  43455. /** @hidden */
  43456. export class _OcclusionDataStorage {
  43457. /** @hidden */
  43458. occlusionInternalRetryCounter: number;
  43459. /** @hidden */
  43460. isOcclusionQueryInProgress: boolean;
  43461. /** @hidden */
  43462. isOccluded: boolean;
  43463. /** @hidden */
  43464. occlusionRetryCount: number;
  43465. /** @hidden */
  43466. occlusionType: number;
  43467. /** @hidden */
  43468. occlusionQueryAlgorithmType: number;
  43469. }
  43470. interface Engine {
  43471. /**
  43472. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43473. * @return the new query
  43474. */
  43475. createQuery(): WebGLQuery;
  43476. /**
  43477. * Delete and release a webGL query
  43478. * @param query defines the query to delete
  43479. * @return the current engine
  43480. */
  43481. deleteQuery(query: WebGLQuery): Engine;
  43482. /**
  43483. * Check if a given query has resolved and got its value
  43484. * @param query defines the query to check
  43485. * @returns true if the query got its value
  43486. */
  43487. isQueryResultAvailable(query: WebGLQuery): boolean;
  43488. /**
  43489. * Gets the value of a given query
  43490. * @param query defines the query to check
  43491. * @returns the value of the query
  43492. */
  43493. getQueryResult(query: WebGLQuery): number;
  43494. /**
  43495. * Initiates an occlusion query
  43496. * @param algorithmType defines the algorithm to use
  43497. * @param query defines the query to use
  43498. * @returns the current engine
  43499. * @see http://doc.babylonjs.com/features/occlusionquery
  43500. */
  43501. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43502. /**
  43503. * Ends an occlusion query
  43504. * @see http://doc.babylonjs.com/features/occlusionquery
  43505. * @param algorithmType defines the algorithm to use
  43506. * @returns the current engine
  43507. */
  43508. endOcclusionQuery(algorithmType: number): Engine;
  43509. /**
  43510. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43511. * Please note that only one query can be issued at a time
  43512. * @returns a time token used to track the time span
  43513. */
  43514. startTimeQuery(): Nullable<_TimeToken>;
  43515. /**
  43516. * Ends a time query
  43517. * @param token defines the token used to measure the time span
  43518. * @returns the time spent (in ns)
  43519. */
  43520. endTimeQuery(token: _TimeToken): int;
  43521. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  43522. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  43523. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  43524. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  43525. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  43526. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  43527. }
  43528. interface AbstractMesh {
  43529. /**
  43530. * Backing filed
  43531. * @hidden
  43532. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43533. /**
  43534. * Access property
  43535. * @hidden
  43536. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43537. /**
  43538. * 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.
  43539. * The default value is -1 which means don't break the query and wait till the result
  43540. * @see http://doc.babylonjs.com/features/occlusionquery
  43541. */
  43542. occlusionRetryCount: number;
  43543. /**
  43544. * 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:
  43545. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43546. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43547. * * 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.
  43548. * @see http://doc.babylonjs.com/features/occlusionquery
  43549. */
  43550. occlusionType: number;
  43551. /**
  43552. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43553. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43554. * * 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.
  43555. * @see http://doc.babylonjs.com/features/occlusionquery
  43556. */
  43557. occlusionQueryAlgorithmType: number;
  43558. /**
  43559. * 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
  43560. * @see http://doc.babylonjs.com/features/occlusionquery
  43561. */
  43562. isOccluded: boolean;
  43563. /**
  43564. * Flag to check the progress status of the query
  43565. * @see http://doc.babylonjs.com/features/occlusionquery
  43566. */
  43567. isOcclusionQueryInProgress: boolean;
  43568. }
  43569. }
  43570. declare module BABYLON {
  43571. /** @hidden */
  43572. export var _forceTransformFeedbackToBundle: boolean;
  43573. interface Engine {
  43574. /**
  43575. * Creates a webGL transform feedback object
  43576. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43577. * @returns the webGL transform feedback object
  43578. */
  43579. createTransformFeedback(): WebGLTransformFeedback;
  43580. /**
  43581. * Delete a webGL transform feedback object
  43582. * @param value defines the webGL transform feedback object to delete
  43583. */
  43584. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43585. /**
  43586. * Bind a webGL transform feedback object to the webgl context
  43587. * @param value defines the webGL transform feedback object to bind
  43588. */
  43589. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43590. /**
  43591. * Begins a transform feedback operation
  43592. * @param usePoints defines if points or triangles must be used
  43593. */
  43594. beginTransformFeedback(usePoints: boolean): void;
  43595. /**
  43596. * Ends a transform feedback operation
  43597. */
  43598. endTransformFeedback(): void;
  43599. /**
  43600. * Specify the varyings to use with transform feedback
  43601. * @param program defines the associated webGL program
  43602. * @param value defines the list of strings representing the varying names
  43603. */
  43604. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43605. /**
  43606. * Bind a webGL buffer for a transform feedback operation
  43607. * @param value defines the webGL buffer to bind
  43608. */
  43609. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43610. }
  43611. }
  43612. declare module BABYLON {
  43613. /**
  43614. * Creation options of the multi render target texture.
  43615. */
  43616. export interface IMultiRenderTargetOptions {
  43617. /**
  43618. * Define if the texture needs to create mip maps after render.
  43619. */
  43620. generateMipMaps?: boolean;
  43621. /**
  43622. * Define the types of all the draw buffers we want to create
  43623. */
  43624. types?: number[];
  43625. /**
  43626. * Define the sampling modes of all the draw buffers we want to create
  43627. */
  43628. samplingModes?: number[];
  43629. /**
  43630. * Define if a depth buffer is required
  43631. */
  43632. generateDepthBuffer?: boolean;
  43633. /**
  43634. * Define if a stencil buffer is required
  43635. */
  43636. generateStencilBuffer?: boolean;
  43637. /**
  43638. * Define if a depth texture is required instead of a depth buffer
  43639. */
  43640. generateDepthTexture?: boolean;
  43641. /**
  43642. * Define the number of desired draw buffers
  43643. */
  43644. textureCount?: number;
  43645. /**
  43646. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43647. */
  43648. doNotChangeAspectRatio?: boolean;
  43649. /**
  43650. * Define the default type of the buffers we are creating
  43651. */
  43652. defaultType?: number;
  43653. }
  43654. /**
  43655. * A multi render target, like a render target provides the ability to render to a texture.
  43656. * Unlike the render target, it can render to several draw buffers in one draw.
  43657. * This is specially interesting in deferred rendering or for any effects requiring more than
  43658. * just one color from a single pass.
  43659. */
  43660. export class MultiRenderTarget extends RenderTargetTexture {
  43661. private _internalTextures;
  43662. private _textures;
  43663. private _multiRenderTargetOptions;
  43664. /**
  43665. * Get if draw buffers are currently supported by the used hardware and browser.
  43666. */
  43667. readonly isSupported: boolean;
  43668. /**
  43669. * Get the list of textures generated by the multi render target.
  43670. */
  43671. readonly textures: Texture[];
  43672. /**
  43673. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43674. */
  43675. readonly depthTexture: Texture;
  43676. /**
  43677. * Set the wrapping mode on U of all the textures we are rendering to.
  43678. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43679. */
  43680. wrapU: number;
  43681. /**
  43682. * Set the wrapping mode on V of all the textures we are rendering to.
  43683. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43684. */
  43685. wrapV: number;
  43686. /**
  43687. * Instantiate a new multi render target texture.
  43688. * A multi render target, like a render target provides the ability to render to a texture.
  43689. * Unlike the render target, it can render to several draw buffers in one draw.
  43690. * This is specially interesting in deferred rendering or for any effects requiring more than
  43691. * just one color from a single pass.
  43692. * @param name Define the name of the texture
  43693. * @param size Define the size of the buffers to render to
  43694. * @param count Define the number of target we are rendering into
  43695. * @param scene Define the scene the texture belongs to
  43696. * @param options Define the options used to create the multi render target
  43697. */
  43698. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43699. /** @hidden */ private _rebuild(): void;
  43700. private _createInternalTextures;
  43701. private _createTextures;
  43702. /**
  43703. * Define the number of samples used if MSAA is enabled.
  43704. */
  43705. samples: number;
  43706. /**
  43707. * Resize all the textures in the multi render target.
  43708. * Be carrefull as it will recreate all the data in the new texture.
  43709. * @param size Define the new size
  43710. */
  43711. resize(size: any): void;
  43712. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43713. /**
  43714. * Dispose the render targets and their associated resources
  43715. */
  43716. dispose(): void;
  43717. /**
  43718. * Release all the underlying texture used as draw buffers.
  43719. */
  43720. releaseInternalTextures(): void;
  43721. }
  43722. }
  43723. declare module BABYLON {
  43724. interface ThinEngine {
  43725. /**
  43726. * Unbind a list of render target textures from the webGL context
  43727. * This is used only when drawBuffer extension or webGL2 are active
  43728. * @param textures defines the render target textures to unbind
  43729. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43730. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43731. */
  43732. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43733. /**
  43734. * Create a multi render target texture
  43735. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43736. * @param size defines the size of the texture
  43737. * @param options defines the creation options
  43738. * @returns the cube texture as an InternalTexture
  43739. */
  43740. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43741. /**
  43742. * Update the sample count for a given multiple render target texture
  43743. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43744. * @param textures defines the textures to update
  43745. * @param samples defines the sample count to set
  43746. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43747. */
  43748. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43749. }
  43750. }
  43751. declare module BABYLON {
  43752. /**
  43753. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  43754. */
  43755. export interface CubeMapInfo {
  43756. /**
  43757. * The pixel array for the front face.
  43758. * This is stored in format, left to right, up to down format.
  43759. */
  43760. front: Nullable<ArrayBufferView>;
  43761. /**
  43762. * The pixel array for the back face.
  43763. * This is stored in format, left to right, up to down format.
  43764. */
  43765. back: Nullable<ArrayBufferView>;
  43766. /**
  43767. * The pixel array for the left face.
  43768. * This is stored in format, left to right, up to down format.
  43769. */
  43770. left: Nullable<ArrayBufferView>;
  43771. /**
  43772. * The pixel array for the right face.
  43773. * This is stored in format, left to right, up to down format.
  43774. */
  43775. right: Nullable<ArrayBufferView>;
  43776. /**
  43777. * The pixel array for the up face.
  43778. * This is stored in format, left to right, up to down format.
  43779. */
  43780. up: Nullable<ArrayBufferView>;
  43781. /**
  43782. * The pixel array for the down face.
  43783. * This is stored in format, left to right, up to down format.
  43784. */
  43785. down: Nullable<ArrayBufferView>;
  43786. /**
  43787. * The size of the cubemap stored.
  43788. *
  43789. * Each faces will be size * size pixels.
  43790. */
  43791. size: number;
  43792. /**
  43793. * The format of the texture.
  43794. *
  43795. * RGBA, RGB.
  43796. */
  43797. format: number;
  43798. /**
  43799. * The type of the texture data.
  43800. *
  43801. * UNSIGNED_INT, FLOAT.
  43802. */
  43803. type: number;
  43804. /**
  43805. * Specifies whether the texture is in gamma space.
  43806. */
  43807. gammaSpace: boolean;
  43808. }
  43809. /**
  43810. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  43811. */
  43812. export class PanoramaToCubeMapTools {
  43813. private static FACE_FRONT;
  43814. private static FACE_BACK;
  43815. private static FACE_RIGHT;
  43816. private static FACE_LEFT;
  43817. private static FACE_DOWN;
  43818. private static FACE_UP;
  43819. /**
  43820. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  43821. *
  43822. * @param float32Array The source data.
  43823. * @param inputWidth The width of the input panorama.
  43824. * @param inputHeight The height of the input panorama.
  43825. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  43826. * @return The cubemap data
  43827. */
  43828. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  43829. private static CreateCubemapTexture;
  43830. private static CalcProjectionSpherical;
  43831. }
  43832. }
  43833. declare module BABYLON {
  43834. /**
  43835. * Helper class dealing with the extraction of spherical polynomial dataArray
  43836. * from a cube map.
  43837. */
  43838. export class CubeMapToSphericalPolynomialTools {
  43839. private static FileFaces;
  43840. /**
  43841. * Converts a texture to the according Spherical Polynomial data.
  43842. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43843. *
  43844. * @param texture The texture to extract the information from.
  43845. * @return The Spherical Polynomial data.
  43846. */
  43847. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  43848. /**
  43849. * Converts a cubemap to the according Spherical Polynomial data.
  43850. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43851. *
  43852. * @param cubeInfo The Cube map to extract the information from.
  43853. * @return The Spherical Polynomial data.
  43854. */
  43855. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  43856. }
  43857. }
  43858. declare module BABYLON {
  43859. interface BaseTexture {
  43860. /**
  43861. * Get the polynomial representation of the texture data.
  43862. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  43863. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  43864. */
  43865. sphericalPolynomial: Nullable<SphericalPolynomial>;
  43866. }
  43867. }
  43868. declare module BABYLON {
  43869. /** @hidden */
  43870. export var rgbdEncodePixelShader: {
  43871. name: string;
  43872. shader: string;
  43873. };
  43874. }
  43875. declare module BABYLON {
  43876. /** @hidden */
  43877. export var rgbdDecodePixelShader: {
  43878. name: string;
  43879. shader: string;
  43880. };
  43881. }
  43882. declare module BABYLON {
  43883. /**
  43884. * Raw texture data and descriptor sufficient for WebGL texture upload
  43885. */
  43886. export interface EnvironmentTextureInfo {
  43887. /**
  43888. * Version of the environment map
  43889. */
  43890. version: number;
  43891. /**
  43892. * Width of image
  43893. */
  43894. width: number;
  43895. /**
  43896. * Irradiance information stored in the file.
  43897. */
  43898. irradiance: any;
  43899. /**
  43900. * Specular information stored in the file.
  43901. */
  43902. specular: any;
  43903. }
  43904. /**
  43905. * Defines One Image in the file. It requires only the position in the file
  43906. * as well as the length.
  43907. */
  43908. interface BufferImageData {
  43909. /**
  43910. * Length of the image data.
  43911. */
  43912. length: number;
  43913. /**
  43914. * Position of the data from the null terminator delimiting the end of the JSON.
  43915. */
  43916. position: number;
  43917. }
  43918. /**
  43919. * Defines the specular data enclosed in the file.
  43920. * This corresponds to the version 1 of the data.
  43921. */
  43922. export interface EnvironmentTextureSpecularInfoV1 {
  43923. /**
  43924. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43925. */
  43926. specularDataPosition?: number;
  43927. /**
  43928. * This contains all the images data needed to reconstruct the cubemap.
  43929. */
  43930. mipmaps: Array<BufferImageData>;
  43931. /**
  43932. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43933. */
  43934. lodGenerationScale: number;
  43935. }
  43936. /**
  43937. * Sets of helpers addressing the serialization and deserialization of environment texture
  43938. * stored in a BabylonJS env file.
  43939. * Those files are usually stored as .env files.
  43940. */
  43941. export class EnvironmentTextureTools {
  43942. /**
  43943. * Magic number identifying the env file.
  43944. */
  43945. private static _MagicBytes;
  43946. /**
  43947. * Gets the environment info from an env file.
  43948. * @param data The array buffer containing the .env bytes.
  43949. * @returns the environment file info (the json header) if successfully parsed.
  43950. */
  43951. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43952. /**
  43953. * Creates an environment texture from a loaded cube texture.
  43954. * @param texture defines the cube texture to convert in env file
  43955. * @return a promise containing the environment data if succesfull.
  43956. */
  43957. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43958. /**
  43959. * Creates a JSON representation of the spherical data.
  43960. * @param texture defines the texture containing the polynomials
  43961. * @return the JSON representation of the spherical info
  43962. */
  43963. private static _CreateEnvTextureIrradiance;
  43964. /**
  43965. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43966. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43967. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43968. * @return the views described by info providing access to the underlying buffer
  43969. */
  43970. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43971. /**
  43972. * Uploads the texture info contained in the env file to the GPU.
  43973. * @param texture defines the internal texture to upload to
  43974. * @param arrayBuffer defines the buffer cotaining the data to load
  43975. * @param info defines the texture info retrieved through the GetEnvInfo method
  43976. * @returns a promise
  43977. */
  43978. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43979. private static _OnImageReadyAsync;
  43980. /**
  43981. * Uploads the levels of image data to the GPU.
  43982. * @param texture defines the internal texture to upload to
  43983. * @param imageData defines the array buffer views of image data [mipmap][face]
  43984. * @returns a promise
  43985. */
  43986. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43987. /**
  43988. * Uploads spherical polynomials information to the texture.
  43989. * @param texture defines the texture we are trying to upload the information to
  43990. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43991. */
  43992. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43993. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43994. }
  43995. }
  43996. declare module BABYLON {
  43997. /**
  43998. * Contains position and normal vectors for a vertex
  43999. */
  44000. export class PositionNormalVertex {
  44001. /** the position of the vertex (defaut: 0,0,0) */
  44002. position: Vector3;
  44003. /** the normal of the vertex (defaut: 0,1,0) */
  44004. normal: Vector3;
  44005. /**
  44006. * Creates a PositionNormalVertex
  44007. * @param position the position of the vertex (defaut: 0,0,0)
  44008. * @param normal the normal of the vertex (defaut: 0,1,0)
  44009. */
  44010. constructor(
  44011. /** the position of the vertex (defaut: 0,0,0) */
  44012. position?: Vector3,
  44013. /** the normal of the vertex (defaut: 0,1,0) */
  44014. normal?: Vector3);
  44015. /**
  44016. * Clones the PositionNormalVertex
  44017. * @returns the cloned PositionNormalVertex
  44018. */
  44019. clone(): PositionNormalVertex;
  44020. }
  44021. /**
  44022. * Contains position, normal and uv vectors for a vertex
  44023. */
  44024. export class PositionNormalTextureVertex {
  44025. /** the position of the vertex (defaut: 0,0,0) */
  44026. position: Vector3;
  44027. /** the normal of the vertex (defaut: 0,1,0) */
  44028. normal: Vector3;
  44029. /** the uv of the vertex (default: 0,0) */
  44030. uv: Vector2;
  44031. /**
  44032. * Creates a PositionNormalTextureVertex
  44033. * @param position the position of the vertex (defaut: 0,0,0)
  44034. * @param normal the normal of the vertex (defaut: 0,1,0)
  44035. * @param uv the uv of the vertex (default: 0,0)
  44036. */
  44037. constructor(
  44038. /** the position of the vertex (defaut: 0,0,0) */
  44039. position?: Vector3,
  44040. /** the normal of the vertex (defaut: 0,1,0) */
  44041. normal?: Vector3,
  44042. /** the uv of the vertex (default: 0,0) */
  44043. uv?: Vector2);
  44044. /**
  44045. * Clones the PositionNormalTextureVertex
  44046. * @returns the cloned PositionNormalTextureVertex
  44047. */
  44048. clone(): PositionNormalTextureVertex;
  44049. }
  44050. }
  44051. declare module BABYLON {
  44052. /** @hidden */
  44053. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44054. private _genericAttributeLocation;
  44055. private _varyingLocationCount;
  44056. private _varyingLocationMap;
  44057. private _replacements;
  44058. private _textureCount;
  44059. private _uniforms;
  44060. lineProcessor(line: string): string;
  44061. attributeProcessor(attribute: string): string;
  44062. varyingProcessor(varying: string, isFragment: boolean): string;
  44063. uniformProcessor(uniform: string): string;
  44064. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44065. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44066. }
  44067. }
  44068. declare module BABYLON {
  44069. /**
  44070. * Container for accessors for natively-stored mesh data buffers.
  44071. */
  44072. class NativeDataBuffer extends DataBuffer {
  44073. /**
  44074. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44075. */
  44076. nativeIndexBuffer?: any;
  44077. /**
  44078. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44079. */
  44080. nativeVertexBuffer?: any;
  44081. }
  44082. /** @hidden */
  44083. class NativeTexture extends InternalTexture {
  44084. getInternalTexture(): InternalTexture;
  44085. getViewCount(): number;
  44086. }
  44087. /** @hidden */
  44088. export class NativeEngine extends Engine {
  44089. private readonly _native;
  44090. getHardwareScalingLevel(): number;
  44091. constructor();
  44092. /**
  44093. * Can be used to override the current requestAnimationFrame requester.
  44094. * @hidden
  44095. */
  44096. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  44097. /**
  44098. * Override default engine behavior.
  44099. * @param color
  44100. * @param backBuffer
  44101. * @param depth
  44102. * @param stencil
  44103. */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  44104. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44105. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44106. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44107. recordVertexArrayObject(vertexBuffers: {
  44108. [key: string]: VertexBuffer;
  44109. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44110. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44111. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44112. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44113. /**
  44114. * Draw a list of indexed primitives
  44115. * @param fillMode defines the primitive to use
  44116. * @param indexStart defines the starting index
  44117. * @param indexCount defines the number of index to draw
  44118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44119. */
  44120. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44121. /**
  44122. * Draw a list of unindexed primitives
  44123. * @param fillMode defines the primitive to use
  44124. * @param verticesStart defines the index of first vertex to draw
  44125. * @param verticesCount defines the count of vertices to draw
  44126. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44127. */
  44128. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44129. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44130. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44131. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44132. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44133. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44134. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44135. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44136. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44137. bindSamplers(effect: Effect): void;
  44138. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44139. getRenderWidth(useScreen?: boolean): number;
  44140. getRenderHeight(useScreen?: boolean): number;
  44141. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44142. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44143. /**
  44144. * Set the z offset to apply to current rendering
  44145. * @param value defines the offset to apply
  44146. */
  44147. setZOffset(value: number): void;
  44148. /**
  44149. * Gets the current value of the zOffset
  44150. * @returns the current zOffset state
  44151. */
  44152. getZOffset(): number;
  44153. /**
  44154. * Enable or disable depth buffering
  44155. * @param enable defines the state to set
  44156. */
  44157. setDepthBuffer(enable: boolean): void;
  44158. /**
  44159. * Gets a boolean indicating if depth writing is enabled
  44160. * @returns the current depth writing state
  44161. */
  44162. getDepthWrite(): boolean;
  44163. /**
  44164. * Enable or disable depth writing
  44165. * @param enable defines the state to set
  44166. */
  44167. setDepthWrite(enable: boolean): void;
  44168. /**
  44169. * Enable or disable color writing
  44170. * @param enable defines the state to set
  44171. */
  44172. setColorWrite(enable: boolean): void;
  44173. /**
  44174. * Gets a boolean indicating if color writing is enabled
  44175. * @returns the current color writing state
  44176. */
  44177. getColorWrite(): boolean;
  44178. /**
  44179. * Sets alpha constants used by some alpha blending modes
  44180. * @param r defines the red component
  44181. * @param g defines the green component
  44182. * @param b defines the blue component
  44183. * @param a defines the alpha component
  44184. */
  44185. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44186. /**
  44187. * Sets the current alpha mode
  44188. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44189. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44190. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44191. */
  44192. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44193. /**
  44194. * Gets the current alpha mode
  44195. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44196. * @returns the current alpha mode
  44197. */
  44198. getAlphaMode(): number;
  44199. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44200. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44201. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44202. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44203. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44204. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44205. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44206. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44207. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44208. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44209. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44210. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44211. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44212. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44213. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44214. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44215. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44216. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44217. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44218. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44219. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44220. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44221. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  44222. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44223. /**
  44224. * Usually called from BABYLON.Texture.ts.
  44225. * Passed information to create a WebGLTexture
  44226. * @param urlArg defines a value which contains one of the following:
  44227. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44228. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44229. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44230. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44231. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44232. * @param scene needed for loading to the correct scene
  44233. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44234. * @param onLoad optional callback to be called upon successful completion
  44235. * @param onError optional callback to be called upon failure
  44236. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44237. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44238. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44239. * @param forcedExtension defines the extension to use to pick the right loader
  44240. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44241. */
  44242. 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;
  44243. /**
  44244. * Creates a cube texture
  44245. * @param rootUrl defines the url where the files to load is located
  44246. * @param scene defines the current scene
  44247. * @param files defines the list of files to load (1 per face)
  44248. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44249. * @param onLoad defines an optional callback raised when the texture is loaded
  44250. * @param onError defines an optional callback raised if there is an issue to load the texture
  44251. * @param format defines the format of the data
  44252. * @param forcedExtension defines the extension to use to pick the right loader
  44253. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44254. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44255. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44256. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44257. * @returns the cube texture as an InternalTexture
  44258. */
  44259. 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;
  44260. private _getSamplingFilter;
  44261. private static _GetNativeTextureFormat;
  44262. createRenderTargetTexture(size: number | {
  44263. width: number;
  44264. height: number;
  44265. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  44266. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44267. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44268. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44269. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44270. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44271. /**
  44272. * Updates a dynamic vertex buffer.
  44273. * @param vertexBuffer the vertex buffer to update
  44274. * @param data the data used to update the vertex buffer
  44275. * @param byteOffset the byte offset of the data (optional)
  44276. * @param byteLength the byte length of the data (optional)
  44277. */
  44278. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44279. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44280. private _updateAnisotropicLevel;
  44281. private _getAddressMode;
  44282. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  44283. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44284. releaseEffects(): void;
  44285. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44286. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44287. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44288. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44289. }
  44290. }
  44291. declare module BABYLON {
  44292. /**
  44293. * Gather the list of clipboard event types as constants.
  44294. */
  44295. export class ClipboardEventTypes {
  44296. /**
  44297. * The clipboard event is fired when a copy command is active (pressed).
  44298. */
  44299. static readonly COPY: number;
  44300. /**
  44301. * The clipboard event is fired when a cut command is active (pressed).
  44302. */
  44303. static readonly CUT: number;
  44304. /**
  44305. * The clipboard event is fired when a paste command is active (pressed).
  44306. */
  44307. static readonly PASTE: number;
  44308. }
  44309. /**
  44310. * This class is used to store clipboard related info for the onClipboardObservable event.
  44311. */
  44312. export class ClipboardInfo {
  44313. /**
  44314. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44315. */
  44316. type: number;
  44317. /**
  44318. * Defines the related dom event
  44319. */
  44320. event: ClipboardEvent;
  44321. /**
  44322. *Creates an instance of ClipboardInfo.
  44323. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44324. * @param event Defines the related dom event
  44325. */
  44326. constructor(
  44327. /**
  44328. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44329. */
  44330. type: number,
  44331. /**
  44332. * Defines the related dom event
  44333. */
  44334. event: ClipboardEvent);
  44335. /**
  44336. * Get the clipboard event's type from the keycode.
  44337. * @param keyCode Defines the keyCode for the current keyboard event.
  44338. * @return {number}
  44339. */
  44340. static GetTypeFromCharacter(keyCode: number): number;
  44341. }
  44342. }
  44343. declare module BABYLON {
  44344. /**
  44345. * Google Daydream controller
  44346. */
  44347. export class DaydreamController extends WebVRController {
  44348. /**
  44349. * Base Url for the controller model.
  44350. */
  44351. static MODEL_BASE_URL: string;
  44352. /**
  44353. * File name for the controller model.
  44354. */
  44355. static MODEL_FILENAME: string;
  44356. /**
  44357. * Gamepad Id prefix used to identify Daydream Controller.
  44358. */
  44359. static readonly GAMEPAD_ID_PREFIX: string;
  44360. /**
  44361. * Creates a new DaydreamController from a gamepad
  44362. * @param vrGamepad the gamepad that the controller should be created from
  44363. */
  44364. constructor(vrGamepad: any);
  44365. /**
  44366. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44367. * @param scene scene in which to add meshes
  44368. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44369. */
  44370. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44371. /**
  44372. * Called once for each button that changed state since the last frame
  44373. * @param buttonIdx Which button index changed
  44374. * @param state New state of the button
  44375. * @param changes Which properties on the state changed since last frame
  44376. */
  44377. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44378. }
  44379. }
  44380. declare module BABYLON {
  44381. /**
  44382. * Gear VR Controller
  44383. */
  44384. export class GearVRController extends WebVRController {
  44385. /**
  44386. * Base Url for the controller model.
  44387. */
  44388. static MODEL_BASE_URL: string;
  44389. /**
  44390. * File name for the controller model.
  44391. */
  44392. static MODEL_FILENAME: string;
  44393. /**
  44394. * Gamepad Id prefix used to identify this controller.
  44395. */
  44396. static readonly GAMEPAD_ID_PREFIX: string;
  44397. private readonly _buttonIndexToObservableNameMap;
  44398. /**
  44399. * Creates a new GearVRController from a gamepad
  44400. * @param vrGamepad the gamepad that the controller should be created from
  44401. */
  44402. constructor(vrGamepad: any);
  44403. /**
  44404. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44405. * @param scene scene in which to add meshes
  44406. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44407. */
  44408. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44409. /**
  44410. * Called once for each button that changed state since the last frame
  44411. * @param buttonIdx Which button index changed
  44412. * @param state New state of the button
  44413. * @param changes Which properties on the state changed since last frame
  44414. */
  44415. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44416. }
  44417. }
  44418. declare module BABYLON {
  44419. /**
  44420. * Class containing static functions to help procedurally build meshes
  44421. */
  44422. export class PolyhedronBuilder {
  44423. /**
  44424. * Creates a polyhedron mesh
  44425. * * 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
  44426. * * The parameter `size` (positive float, default 1) sets the polygon size
  44427. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44428. * * 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`
  44429. * * 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
  44430. * * 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)`)
  44431. * * 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
  44432. * * 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
  44433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44434. * * 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
  44435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44436. * @param name defines the name of the mesh
  44437. * @param options defines the options used to create the mesh
  44438. * @param scene defines the hosting scene
  44439. * @returns the polyhedron mesh
  44440. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44441. */
  44442. static CreatePolyhedron(name: string, options: {
  44443. type?: number;
  44444. size?: number;
  44445. sizeX?: number;
  44446. sizeY?: number;
  44447. sizeZ?: number;
  44448. custom?: any;
  44449. faceUV?: Vector4[];
  44450. faceColors?: Color4[];
  44451. flat?: boolean;
  44452. updatable?: boolean;
  44453. sideOrientation?: number;
  44454. frontUVs?: Vector4;
  44455. backUVs?: Vector4;
  44456. }, scene?: Nullable<Scene>): Mesh;
  44457. }
  44458. }
  44459. declare module BABYLON {
  44460. /**
  44461. * Gizmo that enables scaling a mesh along 3 axis
  44462. */
  44463. export class ScaleGizmo extends Gizmo {
  44464. /**
  44465. * Internal gizmo used for interactions on the x axis
  44466. */
  44467. xGizmo: AxisScaleGizmo;
  44468. /**
  44469. * Internal gizmo used for interactions on the y axis
  44470. */
  44471. yGizmo: AxisScaleGizmo;
  44472. /**
  44473. * Internal gizmo used for interactions on the z axis
  44474. */
  44475. zGizmo: AxisScaleGizmo;
  44476. /**
  44477. * Internal gizmo used to scale all axis equally
  44478. */
  44479. uniformScaleGizmo: AxisScaleGizmo;
  44480. private _meshAttached;
  44481. private _updateGizmoRotationToMatchAttachedMesh;
  44482. private _snapDistance;
  44483. private _scaleRatio;
  44484. private _uniformScalingMesh;
  44485. private _octahedron;
  44486. /** Fires an event when any of it's sub gizmos are dragged */
  44487. onDragStartObservable: Observable<unknown>;
  44488. /** Fires an event when any of it's sub gizmos are released from dragging */
  44489. onDragEndObservable: Observable<unknown>;
  44490. attachedMesh: Nullable<AbstractMesh>;
  44491. /**
  44492. * Creates a ScaleGizmo
  44493. * @param gizmoLayer The utility layer the gizmo will be added to
  44494. */
  44495. constructor(gizmoLayer?: UtilityLayerRenderer);
  44496. updateGizmoRotationToMatchAttachedMesh: boolean;
  44497. /**
  44498. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44499. */
  44500. snapDistance: number;
  44501. /**
  44502. * Ratio for the scale of the gizmo (Default: 1)
  44503. */
  44504. scaleRatio: number;
  44505. /**
  44506. * Disposes of the gizmo
  44507. */
  44508. dispose(): void;
  44509. }
  44510. }
  44511. declare module BABYLON {
  44512. /**
  44513. * Single axis scale gizmo
  44514. */
  44515. export class AxisScaleGizmo extends Gizmo {
  44516. /**
  44517. * Drag behavior responsible for the gizmos dragging interactions
  44518. */
  44519. dragBehavior: PointerDragBehavior;
  44520. private _pointerObserver;
  44521. /**
  44522. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44523. */
  44524. snapDistance: number;
  44525. /**
  44526. * Event that fires each time the gizmo snaps to a new location.
  44527. * * snapDistance is the the change in distance
  44528. */
  44529. onSnapObservable: Observable<{
  44530. snapDistance: number;
  44531. }>;
  44532. /**
  44533. * If the scaling operation should be done on all axis (default: false)
  44534. */
  44535. uniformScaling: boolean;
  44536. private _isEnabled;
  44537. private _parent;
  44538. private _arrow;
  44539. private _coloredMaterial;
  44540. private _hoverMaterial;
  44541. /**
  44542. * Creates an AxisScaleGizmo
  44543. * @param gizmoLayer The utility layer the gizmo will be added to
  44544. * @param dragAxis The axis which the gizmo will be able to scale on
  44545. * @param color The color of the gizmo
  44546. */
  44547. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44549. /**
  44550. * If the gizmo is enabled
  44551. */
  44552. isEnabled: boolean;
  44553. /**
  44554. * Disposes of the gizmo
  44555. */
  44556. dispose(): void;
  44557. /**
  44558. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44559. * @param mesh The mesh to replace the default mesh of the gizmo
  44560. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44561. */
  44562. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44563. }
  44564. }
  44565. declare module BABYLON {
  44566. /**
  44567. * Bounding box gizmo
  44568. */
  44569. export class BoundingBoxGizmo extends Gizmo {
  44570. private _lineBoundingBox;
  44571. private _rotateSpheresParent;
  44572. private _scaleBoxesParent;
  44573. private _boundingDimensions;
  44574. private _renderObserver;
  44575. private _pointerObserver;
  44576. private _scaleDragSpeed;
  44577. private _tmpQuaternion;
  44578. private _tmpVector;
  44579. private _tmpRotationMatrix;
  44580. /**
  44581. * 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)
  44582. */
  44583. ignoreChildren: boolean;
  44584. /**
  44585. * 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)
  44586. */
  44587. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44588. /**
  44589. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44590. */
  44591. rotationSphereSize: number;
  44592. /**
  44593. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44594. */
  44595. scaleBoxSize: number;
  44596. /**
  44597. * 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)
  44598. */
  44599. fixedDragMeshScreenSize: boolean;
  44600. /**
  44601. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44602. */
  44603. fixedDragMeshScreenSizeDistanceFactor: number;
  44604. /**
  44605. * Fired when a rotation sphere or scale box is dragged
  44606. */
  44607. onDragStartObservable: Observable<{}>;
  44608. /**
  44609. * Fired when a scale box is dragged
  44610. */
  44611. onScaleBoxDragObservable: Observable<{}>;
  44612. /**
  44613. * Fired when a scale box drag is ended
  44614. */
  44615. onScaleBoxDragEndObservable: Observable<{}>;
  44616. /**
  44617. * Fired when a rotation sphere is dragged
  44618. */
  44619. onRotationSphereDragObservable: Observable<{}>;
  44620. /**
  44621. * Fired when a rotation sphere drag is ended
  44622. */
  44623. onRotationSphereDragEndObservable: Observable<{}>;
  44624. /**
  44625. * 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)
  44626. */
  44627. scalePivot: Nullable<Vector3>;
  44628. /**
  44629. * Mesh used as a pivot to rotate the attached mesh
  44630. */
  44631. private _anchorMesh;
  44632. private _existingMeshScale;
  44633. private _dragMesh;
  44634. private pointerDragBehavior;
  44635. private coloredMaterial;
  44636. private hoverColoredMaterial;
  44637. /**
  44638. * Sets the color of the bounding box gizmo
  44639. * @param color the color to set
  44640. */
  44641. setColor(color: Color3): void;
  44642. /**
  44643. * Creates an BoundingBoxGizmo
  44644. * @param gizmoLayer The utility layer the gizmo will be added to
  44645. * @param color The color of the gizmo
  44646. */
  44647. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44648. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44649. private _selectNode;
  44650. /**
  44651. * Updates the bounding box information for the Gizmo
  44652. */
  44653. updateBoundingBox(): void;
  44654. private _updateRotationSpheres;
  44655. private _updateScaleBoxes;
  44656. /**
  44657. * Enables rotation on the specified axis and disables rotation on the others
  44658. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44659. */
  44660. setEnabledRotationAxis(axis: string): void;
  44661. /**
  44662. * Enables/disables scaling
  44663. * @param enable if scaling should be enabled
  44664. */
  44665. setEnabledScaling(enable: boolean): void;
  44666. private _updateDummy;
  44667. /**
  44668. * Enables a pointer drag behavior on the bounding box of the gizmo
  44669. */
  44670. enableDragBehavior(): void;
  44671. /**
  44672. * Disposes of the gizmo
  44673. */
  44674. dispose(): void;
  44675. /**
  44676. * 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)
  44677. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44678. * @returns the bounding box mesh with the passed in mesh as a child
  44679. */
  44680. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44681. /**
  44682. * CustomMeshes are not supported by this gizmo
  44683. * @param mesh The mesh to replace the default mesh of the gizmo
  44684. */
  44685. setCustomMesh(mesh: Mesh): void;
  44686. }
  44687. }
  44688. declare module BABYLON {
  44689. /**
  44690. * Single plane rotation gizmo
  44691. */
  44692. export class PlaneRotationGizmo extends Gizmo {
  44693. /**
  44694. * Drag behavior responsible for the gizmos dragging interactions
  44695. */
  44696. dragBehavior: PointerDragBehavior;
  44697. private _pointerObserver;
  44698. /**
  44699. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44700. */
  44701. snapDistance: number;
  44702. /**
  44703. * Event that fires each time the gizmo snaps to a new location.
  44704. * * snapDistance is the the change in distance
  44705. */
  44706. onSnapObservable: Observable<{
  44707. snapDistance: number;
  44708. }>;
  44709. private _isEnabled;
  44710. private _parent;
  44711. /**
  44712. * Creates a PlaneRotationGizmo
  44713. * @param gizmoLayer The utility layer the gizmo will be added to
  44714. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44715. * @param color The color of the gizmo
  44716. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44717. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44718. */
  44719. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44720. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44721. /**
  44722. * If the gizmo is enabled
  44723. */
  44724. isEnabled: boolean;
  44725. /**
  44726. * Disposes of the gizmo
  44727. */
  44728. dispose(): void;
  44729. }
  44730. }
  44731. declare module BABYLON {
  44732. /**
  44733. * Gizmo that enables rotating a mesh along 3 axis
  44734. */
  44735. export class RotationGizmo extends Gizmo {
  44736. /**
  44737. * Internal gizmo used for interactions on the x axis
  44738. */
  44739. xGizmo: PlaneRotationGizmo;
  44740. /**
  44741. * Internal gizmo used for interactions on the y axis
  44742. */
  44743. yGizmo: PlaneRotationGizmo;
  44744. /**
  44745. * Internal gizmo used for interactions on the z axis
  44746. */
  44747. zGizmo: PlaneRotationGizmo;
  44748. /** Fires an event when any of it's sub gizmos are dragged */
  44749. onDragStartObservable: Observable<unknown>;
  44750. /** Fires an event when any of it's sub gizmos are released from dragging */
  44751. onDragEndObservable: Observable<unknown>;
  44752. private _meshAttached;
  44753. attachedMesh: Nullable<AbstractMesh>;
  44754. /**
  44755. * Creates a RotationGizmo
  44756. * @param gizmoLayer The utility layer the gizmo will be added to
  44757. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44758. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44759. */
  44760. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44761. updateGizmoRotationToMatchAttachedMesh: boolean;
  44762. /**
  44763. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44764. */
  44765. snapDistance: number;
  44766. /**
  44767. * Ratio for the scale of the gizmo (Default: 1)
  44768. */
  44769. scaleRatio: number;
  44770. /**
  44771. * Disposes of the gizmo
  44772. */
  44773. dispose(): void;
  44774. /**
  44775. * CustomMeshes are not supported by this gizmo
  44776. * @param mesh The mesh to replace the default mesh of the gizmo
  44777. */
  44778. setCustomMesh(mesh: Mesh): void;
  44779. }
  44780. }
  44781. declare module BABYLON {
  44782. /**
  44783. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44784. */
  44785. export class GizmoManager implements IDisposable {
  44786. private scene;
  44787. /**
  44788. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44789. */
  44790. gizmos: {
  44791. positionGizmo: Nullable<PositionGizmo>;
  44792. rotationGizmo: Nullable<RotationGizmo>;
  44793. scaleGizmo: Nullable<ScaleGizmo>;
  44794. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44795. };
  44796. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44797. clearGizmoOnEmptyPointerEvent: boolean;
  44798. /** Fires an event when the manager is attached to a mesh */
  44799. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44800. private _gizmosEnabled;
  44801. private _pointerObserver;
  44802. private _attachedMesh;
  44803. private _boundingBoxColor;
  44804. private _defaultUtilityLayer;
  44805. private _defaultKeepDepthUtilityLayer;
  44806. /**
  44807. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44808. */
  44809. boundingBoxDragBehavior: SixDofDragBehavior;
  44810. /**
  44811. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44812. */
  44813. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44814. /**
  44815. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44816. */
  44817. usePointerToAttachGizmos: boolean;
  44818. /**
  44819. * Utility layer that the bounding box gizmo belongs to
  44820. */
  44821. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44822. /**
  44823. * Utility layer that all gizmos besides bounding box belong to
  44824. */
  44825. readonly utilityLayer: UtilityLayerRenderer;
  44826. /**
  44827. * Instatiates a gizmo manager
  44828. * @param scene the scene to overlay the gizmos on top of
  44829. */
  44830. constructor(scene: Scene);
  44831. /**
  44832. * Attaches a set of gizmos to the specified mesh
  44833. * @param mesh The mesh the gizmo's should be attached to
  44834. */
  44835. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44836. /**
  44837. * If the position gizmo is enabled
  44838. */
  44839. positionGizmoEnabled: boolean;
  44840. /**
  44841. * If the rotation gizmo is enabled
  44842. */
  44843. rotationGizmoEnabled: boolean;
  44844. /**
  44845. * If the scale gizmo is enabled
  44846. */
  44847. scaleGizmoEnabled: boolean;
  44848. /**
  44849. * If the boundingBox gizmo is enabled
  44850. */
  44851. boundingBoxGizmoEnabled: boolean;
  44852. /**
  44853. * Disposes of the gizmo manager
  44854. */
  44855. dispose(): void;
  44856. }
  44857. }
  44858. declare module BABYLON {
  44859. /**
  44860. * A directional light is defined by a direction (what a surprise!).
  44861. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44862. * 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.
  44863. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44864. */
  44865. export class DirectionalLight extends ShadowLight {
  44866. private _shadowFrustumSize;
  44867. /**
  44868. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44869. */
  44870. /**
  44871. * Specifies a fix frustum size for the shadow generation.
  44872. */
  44873. shadowFrustumSize: number;
  44874. private _shadowOrthoScale;
  44875. /**
  44876. * Gets the shadow projection scale against the optimal computed one.
  44877. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44878. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44879. */
  44880. /**
  44881. * Sets the shadow projection scale against the optimal computed one.
  44882. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44883. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44884. */
  44885. shadowOrthoScale: number;
  44886. /**
  44887. * Automatically compute the projection matrix to best fit (including all the casters)
  44888. * on each frame.
  44889. */
  44890. autoUpdateExtends: boolean;
  44891. private _orthoLeft;
  44892. private _orthoRight;
  44893. private _orthoTop;
  44894. private _orthoBottom;
  44895. /**
  44896. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44897. * The directional light is emitted from everywhere in the given direction.
  44898. * It can cast shadows.
  44899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44900. * @param name The friendly name of the light
  44901. * @param direction The direction of the light
  44902. * @param scene The scene the light belongs to
  44903. */
  44904. constructor(name: string, direction: Vector3, scene: Scene);
  44905. /**
  44906. * Returns the string "DirectionalLight".
  44907. * @return The class name
  44908. */
  44909. getClassName(): string;
  44910. /**
  44911. * Returns the integer 1.
  44912. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44913. */
  44914. getTypeID(): number;
  44915. /**
  44916. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44917. * Returns the DirectionalLight Shadow projection matrix.
  44918. */
  44919. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44920. /**
  44921. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44922. * Returns the DirectionalLight Shadow projection matrix.
  44923. */
  44924. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44925. /**
  44926. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44927. * Returns the DirectionalLight Shadow projection matrix.
  44928. */
  44929. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44930. protected _buildUniformLayout(): void;
  44931. /**
  44932. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44933. * @param effect The effect to update
  44934. * @param lightIndex The index of the light in the effect to update
  44935. * @returns The directional light
  44936. */
  44937. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44938. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44939. /**
  44940. * Gets the minZ used for shadow according to both the scene and the light.
  44941. *
  44942. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44943. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44944. * @param activeCamera The camera we are returning the min for
  44945. * @returns the depth min z
  44946. */
  44947. getDepthMinZ(activeCamera: Camera): number;
  44948. /**
  44949. * Gets the maxZ used for shadow according to both the scene and the light.
  44950. *
  44951. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44952. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44953. * @param activeCamera The camera we are returning the max for
  44954. * @returns the depth max z
  44955. */
  44956. getDepthMaxZ(activeCamera: Camera): number;
  44957. /**
  44958. * Prepares the list of defines specific to the light type.
  44959. * @param defines the list of defines
  44960. * @param lightIndex defines the index of the light for the effect
  44961. */
  44962. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44963. }
  44964. }
  44965. declare module BABYLON {
  44966. /**
  44967. * Class containing static functions to help procedurally build meshes
  44968. */
  44969. export class HemisphereBuilder {
  44970. /**
  44971. * Creates a hemisphere mesh
  44972. * @param name defines the name of the mesh
  44973. * @param options defines the options used to create the mesh
  44974. * @param scene defines the hosting scene
  44975. * @returns the hemisphere mesh
  44976. */
  44977. static CreateHemisphere(name: string, options: {
  44978. segments?: number;
  44979. diameter?: number;
  44980. sideOrientation?: number;
  44981. }, scene: any): Mesh;
  44982. }
  44983. }
  44984. declare module BABYLON {
  44985. /**
  44986. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44987. * These values define a cone of light starting from the position, emitting toward the direction.
  44988. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44989. * and the exponent defines the speed of the decay of the light with distance (reach).
  44990. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44991. */
  44992. export class SpotLight extends ShadowLight {
  44993. private _angle;
  44994. private _innerAngle;
  44995. private _cosHalfAngle;
  44996. private _lightAngleScale;
  44997. private _lightAngleOffset;
  44998. /**
  44999. * Gets the cone angle of the spot light in Radians.
  45000. */
  45001. /**
  45002. * Sets the cone angle of the spot light in Radians.
  45003. */
  45004. angle: number;
  45005. /**
  45006. * Only used in gltf falloff mode, this defines the angle where
  45007. * the directional falloff will start before cutting at angle which could be seen
  45008. * as outer angle.
  45009. */
  45010. /**
  45011. * Only used in gltf falloff mode, this defines the angle where
  45012. * the directional falloff will start before cutting at angle which could be seen
  45013. * as outer angle.
  45014. */
  45015. innerAngle: number;
  45016. private _shadowAngleScale;
  45017. /**
  45018. * Allows scaling the angle of the light for shadow generation only.
  45019. */
  45020. /**
  45021. * Allows scaling the angle of the light for shadow generation only.
  45022. */
  45023. shadowAngleScale: number;
  45024. /**
  45025. * The light decay speed with the distance from the emission spot.
  45026. */
  45027. exponent: number;
  45028. private _projectionTextureMatrix;
  45029. /**
  45030. * Allows reading the projecton texture
  45031. */
  45032. readonly projectionTextureMatrix: Matrix;
  45033. protected _projectionTextureLightNear: number;
  45034. /**
  45035. * Gets the near clip of the Spotlight for texture projection.
  45036. */
  45037. /**
  45038. * Sets the near clip of the Spotlight for texture projection.
  45039. */
  45040. projectionTextureLightNear: number;
  45041. protected _projectionTextureLightFar: number;
  45042. /**
  45043. * Gets the far clip of the Spotlight for texture projection.
  45044. */
  45045. /**
  45046. * Sets the far clip of the Spotlight for texture projection.
  45047. */
  45048. projectionTextureLightFar: number;
  45049. protected _projectionTextureUpDirection: Vector3;
  45050. /**
  45051. * Gets the Up vector of the Spotlight for texture projection.
  45052. */
  45053. /**
  45054. * Sets the Up vector of the Spotlight for texture projection.
  45055. */
  45056. projectionTextureUpDirection: Vector3;
  45057. private _projectionTexture;
  45058. /**
  45059. * Gets the projection texture of the light.
  45060. */
  45061. /**
  45062. * Sets the projection texture of the light.
  45063. */
  45064. projectionTexture: Nullable<BaseTexture>;
  45065. private _projectionTextureViewLightDirty;
  45066. private _projectionTextureProjectionLightDirty;
  45067. private _projectionTextureDirty;
  45068. private _projectionTextureViewTargetVector;
  45069. private _projectionTextureViewLightMatrix;
  45070. private _projectionTextureProjectionLightMatrix;
  45071. private _projectionTextureScalingMatrix;
  45072. /**
  45073. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45074. * It can cast shadows.
  45075. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45076. * @param name The light friendly name
  45077. * @param position The position of the spot light in the scene
  45078. * @param direction The direction of the light in the scene
  45079. * @param angle The cone angle of the light in Radians
  45080. * @param exponent The light decay speed with the distance from the emission spot
  45081. * @param scene The scene the lights belongs to
  45082. */
  45083. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45084. /**
  45085. * Returns the string "SpotLight".
  45086. * @returns the class name
  45087. */
  45088. getClassName(): string;
  45089. /**
  45090. * Returns the integer 2.
  45091. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45092. */
  45093. getTypeID(): number;
  45094. /**
  45095. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45096. */
  45097. protected _setDirection(value: Vector3): void;
  45098. /**
  45099. * Overrides the position setter to recompute the projection texture view light Matrix.
  45100. */
  45101. protected _setPosition(value: Vector3): void;
  45102. /**
  45103. * 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.
  45104. * Returns the SpotLight.
  45105. */
  45106. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45107. protected _computeProjectionTextureViewLightMatrix(): void;
  45108. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45109. /**
  45110. * Main function for light texture projection matrix computing.
  45111. */
  45112. protected _computeProjectionTextureMatrix(): void;
  45113. protected _buildUniformLayout(): void;
  45114. private _computeAngleValues;
  45115. /**
  45116. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45117. * @param effect The effect to update
  45118. * @param lightIndex The index of the light in the effect to update
  45119. * @returns The spot light
  45120. */
  45121. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45122. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45123. /**
  45124. * Disposes the light and the associated resources.
  45125. */
  45126. dispose(): void;
  45127. /**
  45128. * Prepares the list of defines specific to the light type.
  45129. * @param defines the list of defines
  45130. * @param lightIndex defines the index of the light for the effect
  45131. */
  45132. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45133. }
  45134. }
  45135. declare module BABYLON {
  45136. /**
  45137. * Gizmo that enables viewing a light
  45138. */
  45139. export class LightGizmo extends Gizmo {
  45140. private _lightMesh;
  45141. private _material;
  45142. private cachedPosition;
  45143. private cachedForward;
  45144. /**
  45145. * Creates a LightGizmo
  45146. * @param gizmoLayer The utility layer the gizmo will be added to
  45147. */
  45148. constructor(gizmoLayer?: UtilityLayerRenderer);
  45149. private _light;
  45150. /**
  45151. * The light that the gizmo is attached to
  45152. */
  45153. light: Nullable<Light>;
  45154. /**
  45155. * Gets the material used to render the light gizmo
  45156. */
  45157. readonly material: StandardMaterial;
  45158. /**
  45159. * @hidden
  45160. * Updates the gizmo to match the attached mesh's position/rotation
  45161. */
  45162. protected _update(): void;
  45163. private static _Scale;
  45164. /**
  45165. * Creates the lines for a light mesh
  45166. */
  45167. private static _createLightLines;
  45168. /**
  45169. * Disposes of the light gizmo
  45170. */
  45171. dispose(): void;
  45172. private static _CreateHemisphericLightMesh;
  45173. private static _CreatePointLightMesh;
  45174. private static _CreateSpotLightMesh;
  45175. private static _CreateDirectionalLightMesh;
  45176. }
  45177. }
  45178. declare module BABYLON {
  45179. /** @hidden */
  45180. export var backgroundFragmentDeclaration: {
  45181. name: string;
  45182. shader: string;
  45183. };
  45184. }
  45185. declare module BABYLON {
  45186. /** @hidden */
  45187. export var backgroundUboDeclaration: {
  45188. name: string;
  45189. shader: string;
  45190. };
  45191. }
  45192. declare module BABYLON {
  45193. /** @hidden */
  45194. export var backgroundPixelShader: {
  45195. name: string;
  45196. shader: string;
  45197. };
  45198. }
  45199. declare module BABYLON {
  45200. /** @hidden */
  45201. export var backgroundVertexDeclaration: {
  45202. name: string;
  45203. shader: string;
  45204. };
  45205. }
  45206. declare module BABYLON {
  45207. /** @hidden */
  45208. export var backgroundVertexShader: {
  45209. name: string;
  45210. shader: string;
  45211. };
  45212. }
  45213. declare module BABYLON {
  45214. /**
  45215. * Background material used to create an efficient environement around your scene.
  45216. */
  45217. export class BackgroundMaterial extends PushMaterial {
  45218. /**
  45219. * Standard reflectance value at parallel view angle.
  45220. */
  45221. static StandardReflectance0: number;
  45222. /**
  45223. * Standard reflectance value at grazing angle.
  45224. */
  45225. static StandardReflectance90: number;
  45226. protected _primaryColor: Color3;
  45227. /**
  45228. * Key light Color (multiply against the environement texture)
  45229. */
  45230. primaryColor: Color3;
  45231. protected __perceptualColor: Nullable<Color3>;
  45232. /**
  45233. * Experimental Internal Use Only.
  45234. *
  45235. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45236. * This acts as a helper to set the primary color to a more "human friendly" value.
  45237. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45238. * output color as close as possible from the chosen value.
  45239. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45240. * part of lighting setup.)
  45241. */ private _perceptualColor: Nullable<Color3>;
  45242. protected _primaryColorShadowLevel: float;
  45243. /**
  45244. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45245. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45246. */
  45247. primaryColorShadowLevel: float;
  45248. protected _primaryColorHighlightLevel: float;
  45249. /**
  45250. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45251. * The primary color is used at the level chosen to define what the white area would look.
  45252. */
  45253. primaryColorHighlightLevel: float;
  45254. protected _reflectionTexture: Nullable<BaseTexture>;
  45255. /**
  45256. * Reflection Texture used in the material.
  45257. * Should be author in a specific way for the best result (refer to the documentation).
  45258. */
  45259. reflectionTexture: Nullable<BaseTexture>;
  45260. protected _reflectionBlur: float;
  45261. /**
  45262. * Reflection Texture level of blur.
  45263. *
  45264. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45265. * texture twice.
  45266. */
  45267. reflectionBlur: float;
  45268. protected _diffuseTexture: Nullable<BaseTexture>;
  45269. /**
  45270. * Diffuse Texture used in the material.
  45271. * Should be author in a specific way for the best result (refer to the documentation).
  45272. */
  45273. diffuseTexture: Nullable<BaseTexture>;
  45274. protected _shadowLights: Nullable<IShadowLight[]>;
  45275. /**
  45276. * Specify the list of lights casting shadow on the material.
  45277. * All scene shadow lights will be included if null.
  45278. */
  45279. shadowLights: Nullable<IShadowLight[]>;
  45280. protected _shadowLevel: float;
  45281. /**
  45282. * Helps adjusting the shadow to a softer level if required.
  45283. * 0 means black shadows and 1 means no shadows.
  45284. */
  45285. shadowLevel: float;
  45286. protected _sceneCenter: Vector3;
  45287. /**
  45288. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45289. * It is usually zero but might be interesting to modify according to your setup.
  45290. */
  45291. sceneCenter: Vector3;
  45292. protected _opacityFresnel: boolean;
  45293. /**
  45294. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45295. * This helps ensuring a nice transition when the camera goes under the ground.
  45296. */
  45297. opacityFresnel: boolean;
  45298. protected _reflectionFresnel: boolean;
  45299. /**
  45300. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45301. * This helps adding a mirror texture on the ground.
  45302. */
  45303. reflectionFresnel: boolean;
  45304. protected _reflectionFalloffDistance: number;
  45305. /**
  45306. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45307. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45308. */
  45309. reflectionFalloffDistance: number;
  45310. protected _reflectionAmount: number;
  45311. /**
  45312. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45313. */
  45314. reflectionAmount: number;
  45315. protected _reflectionReflectance0: number;
  45316. /**
  45317. * This specifies the weight of the reflection at grazing angle.
  45318. */
  45319. reflectionReflectance0: number;
  45320. protected _reflectionReflectance90: number;
  45321. /**
  45322. * This specifies the weight of the reflection at a perpendicular point of view.
  45323. */
  45324. reflectionReflectance90: number;
  45325. /**
  45326. * Sets the reflection reflectance fresnel values according to the default standard
  45327. * empirically know to work well :-)
  45328. */
  45329. reflectionStandardFresnelWeight: number;
  45330. protected _useRGBColor: boolean;
  45331. /**
  45332. * Helps to directly use the maps channels instead of their level.
  45333. */
  45334. useRGBColor: boolean;
  45335. protected _enableNoise: boolean;
  45336. /**
  45337. * This helps reducing the banding effect that could occur on the background.
  45338. */
  45339. enableNoise: boolean;
  45340. /**
  45341. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45342. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45343. * Recommended to be keep at 1.0 except for special cases.
  45344. */
  45345. fovMultiplier: number;
  45346. private _fovMultiplier;
  45347. /**
  45348. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45349. */
  45350. useEquirectangularFOV: boolean;
  45351. private _maxSimultaneousLights;
  45352. /**
  45353. * Number of Simultaneous lights allowed on the material.
  45354. */
  45355. maxSimultaneousLights: int;
  45356. /**
  45357. * Default configuration related to image processing available in the Background Material.
  45358. */
  45359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45360. /**
  45361. * Keep track of the image processing observer to allow dispose and replace.
  45362. */
  45363. private _imageProcessingObserver;
  45364. /**
  45365. * Attaches a new image processing configuration to the PBR Material.
  45366. * @param configuration (if null the scene configuration will be use)
  45367. */
  45368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45369. /**
  45370. * Gets the image processing configuration used either in this material.
  45371. */
  45372. /**
  45373. * Sets the Default image processing configuration used either in the this material.
  45374. *
  45375. * If sets to null, the scene one is in use.
  45376. */
  45377. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45378. /**
  45379. * Gets wether the color curves effect is enabled.
  45380. */
  45381. /**
  45382. * Sets wether the color curves effect is enabled.
  45383. */
  45384. cameraColorCurvesEnabled: boolean;
  45385. /**
  45386. * Gets wether the color grading effect is enabled.
  45387. */
  45388. /**
  45389. * Gets wether the color grading effect is enabled.
  45390. */
  45391. cameraColorGradingEnabled: boolean;
  45392. /**
  45393. * Gets wether tonemapping is enabled or not.
  45394. */
  45395. /**
  45396. * Sets wether tonemapping is enabled or not
  45397. */
  45398. cameraToneMappingEnabled: boolean;
  45399. /**
  45400. * The camera exposure used on this material.
  45401. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45402. * This corresponds to a photographic exposure.
  45403. */
  45404. /**
  45405. * The camera exposure used on this material.
  45406. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45407. * This corresponds to a photographic exposure.
  45408. */
  45409. cameraExposure: float;
  45410. /**
  45411. * Gets The camera contrast used on this material.
  45412. */
  45413. /**
  45414. * Sets The camera contrast used on this material.
  45415. */
  45416. cameraContrast: float;
  45417. /**
  45418. * Gets the Color Grading 2D Lookup Texture.
  45419. */
  45420. /**
  45421. * Sets the Color Grading 2D Lookup Texture.
  45422. */
  45423. cameraColorGradingTexture: Nullable<BaseTexture>;
  45424. /**
  45425. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45426. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45427. * 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;
  45428. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45429. */
  45430. /**
  45431. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45432. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45433. * 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;
  45434. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45435. */
  45436. cameraColorCurves: Nullable<ColorCurves>;
  45437. /**
  45438. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45439. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45440. */
  45441. switchToBGR: boolean;
  45442. private _renderTargets;
  45443. private _reflectionControls;
  45444. private _white;
  45445. private _primaryShadowColor;
  45446. private _primaryHighlightColor;
  45447. /**
  45448. * Instantiates a Background Material in the given scene
  45449. * @param name The friendly name of the material
  45450. * @param scene The scene to add the material to
  45451. */
  45452. constructor(name: string, scene: Scene);
  45453. /**
  45454. * Gets a boolean indicating that current material needs to register RTT
  45455. */
  45456. readonly hasRenderTargetTextures: boolean;
  45457. /**
  45458. * The entire material has been created in order to prevent overdraw.
  45459. * @returns false
  45460. */
  45461. needAlphaTesting(): boolean;
  45462. /**
  45463. * The entire material has been created in order to prevent overdraw.
  45464. * @returns true if blending is enable
  45465. */
  45466. needAlphaBlending(): boolean;
  45467. /**
  45468. * Checks wether the material is ready to be rendered for a given mesh.
  45469. * @param mesh The mesh to render
  45470. * @param subMesh The submesh to check against
  45471. * @param useInstances Specify wether or not the material is used with instances
  45472. * @returns true if all the dependencies are ready (Textures, Effects...)
  45473. */
  45474. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45475. /**
  45476. * Compute the primary color according to the chosen perceptual color.
  45477. */
  45478. private _computePrimaryColorFromPerceptualColor;
  45479. /**
  45480. * Compute the highlights and shadow colors according to their chosen levels.
  45481. */
  45482. private _computePrimaryColors;
  45483. /**
  45484. * Build the uniform buffer used in the material.
  45485. */
  45486. buildUniformLayout(): void;
  45487. /**
  45488. * Unbind the material.
  45489. */
  45490. unbind(): void;
  45491. /**
  45492. * Bind only the world matrix to the material.
  45493. * @param world The world matrix to bind.
  45494. */
  45495. bindOnlyWorldMatrix(world: Matrix): void;
  45496. /**
  45497. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45498. * @param world The world matrix to bind.
  45499. * @param subMesh The submesh to bind for.
  45500. */
  45501. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45502. /**
  45503. * Checks to see if a texture is used in the material.
  45504. * @param texture - Base texture to use.
  45505. * @returns - Boolean specifying if a texture is used in the material.
  45506. */
  45507. hasTexture(texture: BaseTexture): boolean;
  45508. /**
  45509. * Dispose the material.
  45510. * @param forceDisposeEffect Force disposal of the associated effect.
  45511. * @param forceDisposeTextures Force disposal of the associated textures.
  45512. */
  45513. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45514. /**
  45515. * Clones the material.
  45516. * @param name The cloned name.
  45517. * @returns The cloned material.
  45518. */
  45519. clone(name: string): BackgroundMaterial;
  45520. /**
  45521. * Serializes the current material to its JSON representation.
  45522. * @returns The JSON representation.
  45523. */
  45524. serialize(): any;
  45525. /**
  45526. * Gets the class name of the material
  45527. * @returns "BackgroundMaterial"
  45528. */
  45529. getClassName(): string;
  45530. /**
  45531. * Parse a JSON input to create back a background material.
  45532. * @param source The JSON data to parse
  45533. * @param scene The scene to create the parsed material in
  45534. * @param rootUrl The root url of the assets the material depends upon
  45535. * @returns the instantiated BackgroundMaterial.
  45536. */
  45537. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45538. }
  45539. }
  45540. declare module BABYLON {
  45541. /**
  45542. * Represents the different options available during the creation of
  45543. * a Environment helper.
  45544. *
  45545. * This can control the default ground, skybox and image processing setup of your scene.
  45546. */
  45547. export interface IEnvironmentHelperOptions {
  45548. /**
  45549. * Specifies wether or not to create a ground.
  45550. * True by default.
  45551. */
  45552. createGround: boolean;
  45553. /**
  45554. * Specifies the ground size.
  45555. * 15 by default.
  45556. */
  45557. groundSize: number;
  45558. /**
  45559. * The texture used on the ground for the main color.
  45560. * Comes from the BabylonJS CDN by default.
  45561. *
  45562. * Remarks: Can be either a texture or a url.
  45563. */
  45564. groundTexture: string | BaseTexture;
  45565. /**
  45566. * The color mixed in the ground texture by default.
  45567. * BabylonJS clearColor by default.
  45568. */
  45569. groundColor: Color3;
  45570. /**
  45571. * Specifies the ground opacity.
  45572. * 1 by default.
  45573. */
  45574. groundOpacity: number;
  45575. /**
  45576. * Enables the ground to receive shadows.
  45577. * True by default.
  45578. */
  45579. enableGroundShadow: boolean;
  45580. /**
  45581. * Helps preventing the shadow to be fully black on the ground.
  45582. * 0.5 by default.
  45583. */
  45584. groundShadowLevel: number;
  45585. /**
  45586. * Creates a mirror texture attach to the ground.
  45587. * false by default.
  45588. */
  45589. enableGroundMirror: boolean;
  45590. /**
  45591. * Specifies the ground mirror size ratio.
  45592. * 0.3 by default as the default kernel is 64.
  45593. */
  45594. groundMirrorSizeRatio: number;
  45595. /**
  45596. * Specifies the ground mirror blur kernel size.
  45597. * 64 by default.
  45598. */
  45599. groundMirrorBlurKernel: number;
  45600. /**
  45601. * Specifies the ground mirror visibility amount.
  45602. * 1 by default
  45603. */
  45604. groundMirrorAmount: number;
  45605. /**
  45606. * Specifies the ground mirror reflectance weight.
  45607. * This uses the standard weight of the background material to setup the fresnel effect
  45608. * of the mirror.
  45609. * 1 by default.
  45610. */
  45611. groundMirrorFresnelWeight: number;
  45612. /**
  45613. * Specifies the ground mirror Falloff distance.
  45614. * This can helps reducing the size of the reflection.
  45615. * 0 by Default.
  45616. */
  45617. groundMirrorFallOffDistance: number;
  45618. /**
  45619. * Specifies the ground mirror texture type.
  45620. * Unsigned Int by Default.
  45621. */
  45622. groundMirrorTextureType: number;
  45623. /**
  45624. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45625. * the shown objects.
  45626. */
  45627. groundYBias: number;
  45628. /**
  45629. * Specifies wether or not to create a skybox.
  45630. * True by default.
  45631. */
  45632. createSkybox: boolean;
  45633. /**
  45634. * Specifies the skybox size.
  45635. * 20 by default.
  45636. */
  45637. skyboxSize: number;
  45638. /**
  45639. * The texture used on the skybox for the main color.
  45640. * Comes from the BabylonJS CDN by default.
  45641. *
  45642. * Remarks: Can be either a texture or a url.
  45643. */
  45644. skyboxTexture: string | BaseTexture;
  45645. /**
  45646. * The color mixed in the skybox texture by default.
  45647. * BabylonJS clearColor by default.
  45648. */
  45649. skyboxColor: Color3;
  45650. /**
  45651. * The background rotation around the Y axis of the scene.
  45652. * This helps aligning the key lights of your scene with the background.
  45653. * 0 by default.
  45654. */
  45655. backgroundYRotation: number;
  45656. /**
  45657. * Compute automatically the size of the elements to best fit with the scene.
  45658. */
  45659. sizeAuto: boolean;
  45660. /**
  45661. * Default position of the rootMesh if autoSize is not true.
  45662. */
  45663. rootPosition: Vector3;
  45664. /**
  45665. * Sets up the image processing in the scene.
  45666. * true by default.
  45667. */
  45668. setupImageProcessing: boolean;
  45669. /**
  45670. * The texture used as your environment texture in the scene.
  45671. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45672. *
  45673. * Remarks: Can be either a texture or a url.
  45674. */
  45675. environmentTexture: string | BaseTexture;
  45676. /**
  45677. * The value of the exposure to apply to the scene.
  45678. * 0.6 by default if setupImageProcessing is true.
  45679. */
  45680. cameraExposure: number;
  45681. /**
  45682. * The value of the contrast to apply to the scene.
  45683. * 1.6 by default if setupImageProcessing is true.
  45684. */
  45685. cameraContrast: number;
  45686. /**
  45687. * Specifies wether or not tonemapping should be enabled in the scene.
  45688. * true by default if setupImageProcessing is true.
  45689. */
  45690. toneMappingEnabled: boolean;
  45691. }
  45692. /**
  45693. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45694. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45695. * It also helps with the default setup of your imageProcessing configuration.
  45696. */
  45697. export class EnvironmentHelper {
  45698. /**
  45699. * Default ground texture URL.
  45700. */
  45701. private static _groundTextureCDNUrl;
  45702. /**
  45703. * Default skybox texture URL.
  45704. */
  45705. private static _skyboxTextureCDNUrl;
  45706. /**
  45707. * Default environment texture URL.
  45708. */
  45709. private static _environmentTextureCDNUrl;
  45710. /**
  45711. * Creates the default options for the helper.
  45712. */
  45713. private static _getDefaultOptions;
  45714. private _rootMesh;
  45715. /**
  45716. * Gets the root mesh created by the helper.
  45717. */
  45718. readonly rootMesh: Mesh;
  45719. private _skybox;
  45720. /**
  45721. * Gets the skybox created by the helper.
  45722. */
  45723. readonly skybox: Nullable<Mesh>;
  45724. private _skyboxTexture;
  45725. /**
  45726. * Gets the skybox texture created by the helper.
  45727. */
  45728. readonly skyboxTexture: Nullable<BaseTexture>;
  45729. private _skyboxMaterial;
  45730. /**
  45731. * Gets the skybox material created by the helper.
  45732. */
  45733. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45734. private _ground;
  45735. /**
  45736. * Gets the ground mesh created by the helper.
  45737. */
  45738. readonly ground: Nullable<Mesh>;
  45739. private _groundTexture;
  45740. /**
  45741. * Gets the ground texture created by the helper.
  45742. */
  45743. readonly groundTexture: Nullable<BaseTexture>;
  45744. private _groundMirror;
  45745. /**
  45746. * Gets the ground mirror created by the helper.
  45747. */
  45748. readonly groundMirror: Nullable<MirrorTexture>;
  45749. /**
  45750. * Gets the ground mirror render list to helps pushing the meshes
  45751. * you wish in the ground reflection.
  45752. */
  45753. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45754. private _groundMaterial;
  45755. /**
  45756. * Gets the ground material created by the helper.
  45757. */
  45758. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45759. /**
  45760. * Stores the creation options.
  45761. */
  45762. private readonly _scene;
  45763. private _options;
  45764. /**
  45765. * This observable will be notified with any error during the creation of the environment,
  45766. * mainly texture creation errors.
  45767. */
  45768. onErrorObservable: Observable<{
  45769. message?: string;
  45770. exception?: any;
  45771. }>;
  45772. /**
  45773. * constructor
  45774. * @param options Defines the options we want to customize the helper
  45775. * @param scene The scene to add the material to
  45776. */
  45777. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45778. /**
  45779. * Updates the background according to the new options
  45780. * @param options
  45781. */
  45782. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45783. /**
  45784. * Sets the primary color of all the available elements.
  45785. * @param color the main color to affect to the ground and the background
  45786. */
  45787. setMainColor(color: Color3): void;
  45788. /**
  45789. * Setup the image processing according to the specified options.
  45790. */
  45791. private _setupImageProcessing;
  45792. /**
  45793. * Setup the environment texture according to the specified options.
  45794. */
  45795. private _setupEnvironmentTexture;
  45796. /**
  45797. * Setup the background according to the specified options.
  45798. */
  45799. private _setupBackground;
  45800. /**
  45801. * Get the scene sizes according to the setup.
  45802. */
  45803. private _getSceneSize;
  45804. /**
  45805. * Setup the ground according to the specified options.
  45806. */
  45807. private _setupGround;
  45808. /**
  45809. * Setup the ground material according to the specified options.
  45810. */
  45811. private _setupGroundMaterial;
  45812. /**
  45813. * Setup the ground diffuse texture according to the specified options.
  45814. */
  45815. private _setupGroundDiffuseTexture;
  45816. /**
  45817. * Setup the ground mirror texture according to the specified options.
  45818. */
  45819. private _setupGroundMirrorTexture;
  45820. /**
  45821. * Setup the ground to receive the mirror texture.
  45822. */
  45823. private _setupMirrorInGroundMaterial;
  45824. /**
  45825. * Setup the skybox according to the specified options.
  45826. */
  45827. private _setupSkybox;
  45828. /**
  45829. * Setup the skybox material according to the specified options.
  45830. */
  45831. private _setupSkyboxMaterial;
  45832. /**
  45833. * Setup the skybox reflection texture according to the specified options.
  45834. */
  45835. private _setupSkyboxReflectionTexture;
  45836. private _errorHandler;
  45837. /**
  45838. * Dispose all the elements created by the Helper.
  45839. */
  45840. dispose(): void;
  45841. }
  45842. }
  45843. declare module BABYLON {
  45844. /**
  45845. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45846. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45847. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45848. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45849. */
  45850. export class PhotoDome extends TransformNode {
  45851. /**
  45852. * Define the image as a Monoscopic panoramic 360 image.
  45853. */
  45854. static readonly MODE_MONOSCOPIC: number;
  45855. /**
  45856. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45857. */
  45858. static readonly MODE_TOPBOTTOM: number;
  45859. /**
  45860. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45861. */
  45862. static readonly MODE_SIDEBYSIDE: number;
  45863. private _useDirectMapping;
  45864. /**
  45865. * The texture being displayed on the sphere
  45866. */
  45867. protected _photoTexture: Texture;
  45868. /**
  45869. * Gets or sets the texture being displayed on the sphere
  45870. */
  45871. photoTexture: Texture;
  45872. /**
  45873. * Observable raised when an error occured while loading the 360 image
  45874. */
  45875. onLoadErrorObservable: Observable<string>;
  45876. /**
  45877. * The skybox material
  45878. */
  45879. protected _material: BackgroundMaterial;
  45880. /**
  45881. * The surface used for the skybox
  45882. */
  45883. protected _mesh: Mesh;
  45884. /**
  45885. * Gets the mesh used for the skybox.
  45886. */
  45887. readonly mesh: Mesh;
  45888. /**
  45889. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45890. * Also see the options.resolution property.
  45891. */
  45892. fovMultiplier: number;
  45893. private _imageMode;
  45894. /**
  45895. * Gets or set the current video mode for the video. It can be:
  45896. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45897. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45898. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45899. */
  45900. imageMode: number;
  45901. /**
  45902. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45903. * @param name Element's name, child elements will append suffixes for their own names.
  45904. * @param urlsOfPhoto defines the url of the photo to display
  45905. * @param options defines an object containing optional or exposed sub element properties
  45906. * @param onError defines a callback called when an error occured while loading the texture
  45907. */
  45908. constructor(name: string, urlOfPhoto: string, options: {
  45909. resolution?: number;
  45910. size?: number;
  45911. useDirectMapping?: boolean;
  45912. faceForward?: boolean;
  45913. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45914. private _onBeforeCameraRenderObserver;
  45915. private _changeImageMode;
  45916. /**
  45917. * Releases resources associated with this node.
  45918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45920. */
  45921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45922. }
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * Class used to host RGBD texture specific utilities
  45927. */
  45928. export class RGBDTextureTools {
  45929. /**
  45930. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45931. * @param texture the texture to expand.
  45932. */
  45933. static ExpandRGBDTexture(texture: Texture): void;
  45934. }
  45935. }
  45936. declare module BABYLON {
  45937. /**
  45938. * Class used to host texture specific utilities
  45939. */
  45940. export class BRDFTextureTools {
  45941. /**
  45942. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45943. * @param scene defines the hosting scene
  45944. * @returns the environment BRDF texture
  45945. */
  45946. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45947. private static _environmentBRDFBase64Texture;
  45948. }
  45949. }
  45950. declare module BABYLON {
  45951. /**
  45952. * @hidden
  45953. */
  45954. export interface IMaterialClearCoatDefines {
  45955. CLEARCOAT: boolean;
  45956. CLEARCOAT_DEFAULTIOR: boolean;
  45957. CLEARCOAT_TEXTURE: boolean;
  45958. CLEARCOAT_TEXTUREDIRECTUV: number;
  45959. CLEARCOAT_BUMP: boolean;
  45960. CLEARCOAT_BUMPDIRECTUV: number;
  45961. CLEARCOAT_TINT: boolean;
  45962. CLEARCOAT_TINT_TEXTURE: boolean;
  45963. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45964. /** @hidden */ private _areTexturesDirty: boolean;
  45965. }
  45966. /**
  45967. * Define the code related to the clear coat parameters of the pbr material.
  45968. */
  45969. export class PBRClearCoatConfiguration {
  45970. /**
  45971. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45972. * The default fits with a polyurethane material.
  45973. */
  45974. private static readonly _DefaultIndexOfRefraction;
  45975. private _isEnabled;
  45976. /**
  45977. * Defines if the clear coat is enabled in the material.
  45978. */
  45979. isEnabled: boolean;
  45980. /**
  45981. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45982. */
  45983. intensity: number;
  45984. /**
  45985. * Defines the clear coat layer roughness.
  45986. */
  45987. roughness: number;
  45988. private _indexOfRefraction;
  45989. /**
  45990. * Defines the index of refraction of the clear coat.
  45991. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45992. * The default fits with a polyurethane material.
  45993. * Changing the default value is more performance intensive.
  45994. */
  45995. indexOfRefraction: number;
  45996. private _texture;
  45997. /**
  45998. * Stores the clear coat values in a texture.
  45999. */
  46000. texture: Nullable<BaseTexture>;
  46001. private _bumpTexture;
  46002. /**
  46003. * Define the clear coat specific bump texture.
  46004. */
  46005. bumpTexture: Nullable<BaseTexture>;
  46006. private _isTintEnabled;
  46007. /**
  46008. * Defines if the clear coat tint is enabled in the material.
  46009. */
  46010. isTintEnabled: boolean;
  46011. /**
  46012. * Defines the clear coat tint of the material.
  46013. * This is only use if tint is enabled
  46014. */
  46015. tintColor: Color3;
  46016. /**
  46017. * Defines the distance at which the tint color should be found in the
  46018. * clear coat media.
  46019. * This is only use if tint is enabled
  46020. */
  46021. tintColorAtDistance: number;
  46022. /**
  46023. * Defines the clear coat layer thickness.
  46024. * This is only use if tint is enabled
  46025. */
  46026. tintThickness: number;
  46027. private _tintTexture;
  46028. /**
  46029. * Stores the clear tint values in a texture.
  46030. * rgb is tint
  46031. * a is a thickness factor
  46032. */
  46033. tintTexture: Nullable<BaseTexture>;
  46034. /** @hidden */
  46035. private _internalMarkAllSubMeshesAsTexturesDirty;
  46036. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46037. /**
  46038. * Instantiate a new istance of clear coat configuration.
  46039. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46040. */
  46041. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46042. /**
  46043. * Gets wehter the submesh is ready to be used or not.
  46044. * @param defines the list of "defines" to update.
  46045. * @param scene defines the scene the material belongs to.
  46046. * @param engine defines the engine the material belongs to.
  46047. * @param disableBumpMap defines wether the material disables bump or not.
  46048. * @returns - boolean indicating that the submesh is ready or not.
  46049. */
  46050. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46051. /**
  46052. * Checks to see if a texture is used in the material.
  46053. * @param defines the list of "defines" to update.
  46054. * @param scene defines the scene to the material belongs to.
  46055. */
  46056. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46057. /**
  46058. * Binds the material data.
  46059. * @param uniformBuffer defines the Uniform buffer to fill in.
  46060. * @param scene defines the scene the material belongs to.
  46061. * @param engine defines the engine the material belongs to.
  46062. * @param disableBumpMap defines wether the material disables bump or not.
  46063. * @param isFrozen defines wether the material is frozen or not.
  46064. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46065. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46066. */
  46067. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46068. /**
  46069. * Checks to see if a texture is used in the material.
  46070. * @param texture - Base texture to use.
  46071. * @returns - Boolean specifying if a texture is used in the material.
  46072. */
  46073. hasTexture(texture: BaseTexture): boolean;
  46074. /**
  46075. * Returns an array of the actively used textures.
  46076. * @param activeTextures Array of BaseTextures
  46077. */
  46078. getActiveTextures(activeTextures: BaseTexture[]): void;
  46079. /**
  46080. * Returns the animatable textures.
  46081. * @param animatables Array of animatable textures.
  46082. */
  46083. getAnimatables(animatables: IAnimatable[]): void;
  46084. /**
  46085. * Disposes the resources of the material.
  46086. * @param forceDisposeTextures - Forces the disposal of all textures.
  46087. */
  46088. dispose(forceDisposeTextures?: boolean): void;
  46089. /**
  46090. * Get the current class name of the texture useful for serialization or dynamic coding.
  46091. * @returns "PBRClearCoatConfiguration"
  46092. */
  46093. getClassName(): string;
  46094. /**
  46095. * Add fallbacks to the effect fallbacks list.
  46096. * @param defines defines the Base texture to use.
  46097. * @param fallbacks defines the current fallback list.
  46098. * @param currentRank defines the current fallback rank.
  46099. * @returns the new fallback rank.
  46100. */
  46101. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46102. /**
  46103. * Add the required uniforms to the current list.
  46104. * @param uniforms defines the current uniform list.
  46105. */
  46106. static AddUniforms(uniforms: string[]): void;
  46107. /**
  46108. * Add the required samplers to the current list.
  46109. * @param samplers defines the current sampler list.
  46110. */
  46111. static AddSamplers(samplers: string[]): void;
  46112. /**
  46113. * Add the required uniforms to the current buffer.
  46114. * @param uniformBuffer defines the current uniform buffer.
  46115. */
  46116. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46117. /**
  46118. * Makes a duplicate of the current configuration into another one.
  46119. * @param clearCoatConfiguration define the config where to copy the info
  46120. */
  46121. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46122. /**
  46123. * Serializes this clear coat configuration.
  46124. * @returns - An object with the serialized config.
  46125. */
  46126. serialize(): any;
  46127. /**
  46128. * Parses a anisotropy Configuration from a serialized object.
  46129. * @param source - Serialized object.
  46130. * @param scene Defines the scene we are parsing for
  46131. * @param rootUrl Defines the rootUrl to load from
  46132. */
  46133. parse(source: any, scene: Scene, rootUrl: string): void;
  46134. }
  46135. }
  46136. declare module BABYLON {
  46137. /**
  46138. * @hidden
  46139. */
  46140. export interface IMaterialAnisotropicDefines {
  46141. ANISOTROPIC: boolean;
  46142. ANISOTROPIC_TEXTURE: boolean;
  46143. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46144. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  46145. }
  46146. /**
  46147. * Define the code related to the anisotropic parameters of the pbr material.
  46148. */
  46149. export class PBRAnisotropicConfiguration {
  46150. private _isEnabled;
  46151. /**
  46152. * Defines if the anisotropy is enabled in the material.
  46153. */
  46154. isEnabled: boolean;
  46155. /**
  46156. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46157. */
  46158. intensity: number;
  46159. /**
  46160. * Defines if the effect is along the tangents, bitangents or in between.
  46161. * By default, the effect is "strectching" the highlights along the tangents.
  46162. */
  46163. direction: Vector2;
  46164. private _texture;
  46165. /**
  46166. * Stores the anisotropy values in a texture.
  46167. * rg is direction (like normal from -1 to 1)
  46168. * b is a intensity
  46169. */
  46170. texture: Nullable<BaseTexture>;
  46171. /** @hidden */
  46172. private _internalMarkAllSubMeshesAsTexturesDirty;
  46173. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46174. /**
  46175. * Instantiate a new istance of anisotropy configuration.
  46176. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46177. */
  46178. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46179. /**
  46180. * Specifies that the submesh is ready to be used.
  46181. * @param defines the list of "defines" to update.
  46182. * @param scene defines the scene the material belongs to.
  46183. * @returns - boolean indicating that the submesh is ready or not.
  46184. */
  46185. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46186. /**
  46187. * Checks to see if a texture is used in the material.
  46188. * @param defines the list of "defines" to update.
  46189. * @param mesh the mesh we are preparing the defines for.
  46190. * @param scene defines the scene the material belongs to.
  46191. */
  46192. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46193. /**
  46194. * Binds the material data.
  46195. * @param uniformBuffer defines the Uniform buffer to fill in.
  46196. * @param scene defines the scene the material belongs to.
  46197. * @param isFrozen defines wether the material is frozen or not.
  46198. */
  46199. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46200. /**
  46201. * Checks to see if a texture is used in the material.
  46202. * @param texture - Base texture to use.
  46203. * @returns - Boolean specifying if a texture is used in the material.
  46204. */
  46205. hasTexture(texture: BaseTexture): boolean;
  46206. /**
  46207. * Returns an array of the actively used textures.
  46208. * @param activeTextures Array of BaseTextures
  46209. */
  46210. getActiveTextures(activeTextures: BaseTexture[]): void;
  46211. /**
  46212. * Returns the animatable textures.
  46213. * @param animatables Array of animatable textures.
  46214. */
  46215. getAnimatables(animatables: IAnimatable[]): void;
  46216. /**
  46217. * Disposes the resources of the material.
  46218. * @param forceDisposeTextures - Forces the disposal of all textures.
  46219. */
  46220. dispose(forceDisposeTextures?: boolean): void;
  46221. /**
  46222. * Get the current class name of the texture useful for serialization or dynamic coding.
  46223. * @returns "PBRAnisotropicConfiguration"
  46224. */
  46225. getClassName(): string;
  46226. /**
  46227. * Add fallbacks to the effect fallbacks list.
  46228. * @param defines defines the Base texture to use.
  46229. * @param fallbacks defines the current fallback list.
  46230. * @param currentRank defines the current fallback rank.
  46231. * @returns the new fallback rank.
  46232. */
  46233. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46234. /**
  46235. * Add the required uniforms to the current list.
  46236. * @param uniforms defines the current uniform list.
  46237. */
  46238. static AddUniforms(uniforms: string[]): void;
  46239. /**
  46240. * Add the required uniforms to the current buffer.
  46241. * @param uniformBuffer defines the current uniform buffer.
  46242. */
  46243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46244. /**
  46245. * Add the required samplers to the current list.
  46246. * @param samplers defines the current sampler list.
  46247. */
  46248. static AddSamplers(samplers: string[]): void;
  46249. /**
  46250. * Makes a duplicate of the current configuration into another one.
  46251. * @param anisotropicConfiguration define the config where to copy the info
  46252. */
  46253. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46254. /**
  46255. * Serializes this anisotropy configuration.
  46256. * @returns - An object with the serialized config.
  46257. */
  46258. serialize(): any;
  46259. /**
  46260. * Parses a anisotropy Configuration from a serialized object.
  46261. * @param source - Serialized object.
  46262. * @param scene Defines the scene we are parsing for
  46263. * @param rootUrl Defines the rootUrl to load from
  46264. */
  46265. parse(source: any, scene: Scene, rootUrl: string): void;
  46266. }
  46267. }
  46268. declare module BABYLON {
  46269. /**
  46270. * @hidden
  46271. */
  46272. export interface IMaterialBRDFDefines {
  46273. BRDF_V_HEIGHT_CORRELATED: boolean;
  46274. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46275. SPHERICAL_HARMONICS: boolean;
  46276. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46277. /** @hidden */ private _areMiscDirty: boolean;
  46278. }
  46279. /**
  46280. * Define the code related to the BRDF parameters of the pbr material.
  46281. */
  46282. export class PBRBRDFConfiguration {
  46283. /**
  46284. * Default value used for the energy conservation.
  46285. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46286. */
  46287. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46288. /**
  46289. * Default value used for the Smith Visibility Height Correlated mode.
  46290. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46291. */
  46292. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46293. /**
  46294. * Default value used for the IBL diffuse part.
  46295. * This can help switching back to the polynomials mode globally which is a tiny bit
  46296. * less GPU intensive at the drawback of a lower quality.
  46297. */
  46298. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46299. /**
  46300. * Default value used for activating energy conservation for the specular workflow.
  46301. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46302. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46303. */
  46304. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46305. private _useEnergyConservation;
  46306. /**
  46307. * Defines if the material uses energy conservation.
  46308. */
  46309. useEnergyConservation: boolean;
  46310. private _useSmithVisibilityHeightCorrelated;
  46311. /**
  46312. * LEGACY Mode set to false
  46313. * Defines if the material uses height smith correlated visibility term.
  46314. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46315. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46316. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46317. * Not relying on height correlated will also disable energy conservation.
  46318. */
  46319. useSmithVisibilityHeightCorrelated: boolean;
  46320. private _useSphericalHarmonics;
  46321. /**
  46322. * LEGACY Mode set to false
  46323. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46324. * diffuse part of the IBL.
  46325. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46326. * to the ground truth.
  46327. */
  46328. useSphericalHarmonics: boolean;
  46329. private _useSpecularGlossinessInputEnergyConservation;
  46330. /**
  46331. * Defines if the material uses energy conservation, when the specular workflow is active.
  46332. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46333. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46334. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46335. */
  46336. useSpecularGlossinessInputEnergyConservation: boolean;
  46337. /** @hidden */
  46338. private _internalMarkAllSubMeshesAsMiscDirty;
  46339. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  46340. /**
  46341. * Instantiate a new istance of clear coat configuration.
  46342. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46343. */
  46344. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46345. /**
  46346. * Checks to see if a texture is used in the material.
  46347. * @param defines the list of "defines" to update.
  46348. */
  46349. prepareDefines(defines: IMaterialBRDFDefines): void;
  46350. /**
  46351. * Get the current class name of the texture useful for serialization or dynamic coding.
  46352. * @returns "PBRClearCoatConfiguration"
  46353. */
  46354. getClassName(): string;
  46355. /**
  46356. * Makes a duplicate of the current configuration into another one.
  46357. * @param brdfConfiguration define the config where to copy the info
  46358. */
  46359. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46360. /**
  46361. * Serializes this BRDF configuration.
  46362. * @returns - An object with the serialized config.
  46363. */
  46364. serialize(): any;
  46365. /**
  46366. * Parses a anisotropy Configuration from a serialized object.
  46367. * @param source - Serialized object.
  46368. * @param scene Defines the scene we are parsing for
  46369. * @param rootUrl Defines the rootUrl to load from
  46370. */
  46371. parse(source: any, scene: Scene, rootUrl: string): void;
  46372. }
  46373. }
  46374. declare module BABYLON {
  46375. /**
  46376. * @hidden
  46377. */
  46378. export interface IMaterialSheenDefines {
  46379. SHEEN: boolean;
  46380. SHEEN_TEXTURE: boolean;
  46381. SHEEN_TEXTUREDIRECTUV: number;
  46382. SHEEN_LINKWITHALBEDO: boolean;
  46383. /** @hidden */ private _areTexturesDirty: boolean;
  46384. }
  46385. /**
  46386. * Define the code related to the Sheen parameters of the pbr material.
  46387. */
  46388. export class PBRSheenConfiguration {
  46389. private _isEnabled;
  46390. /**
  46391. * Defines if the material uses sheen.
  46392. */
  46393. isEnabled: boolean;
  46394. private _linkSheenWithAlbedo;
  46395. /**
  46396. * Defines if the sheen is linked to the sheen color.
  46397. */
  46398. linkSheenWithAlbedo: boolean;
  46399. /**
  46400. * Defines the sheen intensity.
  46401. */
  46402. intensity: number;
  46403. /**
  46404. * Defines the sheen color.
  46405. */
  46406. color: Color3;
  46407. private _texture;
  46408. /**
  46409. * Stores the sheen tint values in a texture.
  46410. * rgb is tint
  46411. * a is a intensity
  46412. */
  46413. texture: Nullable<BaseTexture>;
  46414. /** @hidden */
  46415. private _internalMarkAllSubMeshesAsTexturesDirty;
  46416. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46417. /**
  46418. * Instantiate a new istance of clear coat configuration.
  46419. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46420. */
  46421. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46422. /**
  46423. * Specifies that the submesh is ready to be used.
  46424. * @param defines the list of "defines" to update.
  46425. * @param scene defines the scene the material belongs to.
  46426. * @returns - boolean indicating that the submesh is ready or not.
  46427. */
  46428. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46429. /**
  46430. * Checks to see if a texture is used in the material.
  46431. * @param defines the list of "defines" to update.
  46432. * @param scene defines the scene the material belongs to.
  46433. */
  46434. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46435. /**
  46436. * Binds the material data.
  46437. * @param uniformBuffer defines the Uniform buffer to fill in.
  46438. * @param scene defines the scene the material belongs to.
  46439. * @param isFrozen defines wether the material is frozen or not.
  46440. */
  46441. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46442. /**
  46443. * Checks to see if a texture is used in the material.
  46444. * @param texture - Base texture to use.
  46445. * @returns - Boolean specifying if a texture is used in the material.
  46446. */
  46447. hasTexture(texture: BaseTexture): boolean;
  46448. /**
  46449. * Returns an array of the actively used textures.
  46450. * @param activeTextures Array of BaseTextures
  46451. */
  46452. getActiveTextures(activeTextures: BaseTexture[]): void;
  46453. /**
  46454. * Returns the animatable textures.
  46455. * @param animatables Array of animatable textures.
  46456. */
  46457. getAnimatables(animatables: IAnimatable[]): void;
  46458. /**
  46459. * Disposes the resources of the material.
  46460. * @param forceDisposeTextures - Forces the disposal of all textures.
  46461. */
  46462. dispose(forceDisposeTextures?: boolean): void;
  46463. /**
  46464. * Get the current class name of the texture useful for serialization or dynamic coding.
  46465. * @returns "PBRSheenConfiguration"
  46466. */
  46467. getClassName(): string;
  46468. /**
  46469. * Add fallbacks to the effect fallbacks list.
  46470. * @param defines defines the Base texture to use.
  46471. * @param fallbacks defines the current fallback list.
  46472. * @param currentRank defines the current fallback rank.
  46473. * @returns the new fallback rank.
  46474. */
  46475. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46476. /**
  46477. * Add the required uniforms to the current list.
  46478. * @param uniforms defines the current uniform list.
  46479. */
  46480. static AddUniforms(uniforms: string[]): void;
  46481. /**
  46482. * Add the required uniforms to the current buffer.
  46483. * @param uniformBuffer defines the current uniform buffer.
  46484. */
  46485. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46486. /**
  46487. * Add the required samplers to the current list.
  46488. * @param samplers defines the current sampler list.
  46489. */
  46490. static AddSamplers(samplers: string[]): void;
  46491. /**
  46492. * Makes a duplicate of the current configuration into another one.
  46493. * @param sheenConfiguration define the config where to copy the info
  46494. */
  46495. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46496. /**
  46497. * Serializes this BRDF configuration.
  46498. * @returns - An object with the serialized config.
  46499. */
  46500. serialize(): any;
  46501. /**
  46502. * Parses a anisotropy Configuration from a serialized object.
  46503. * @param source - Serialized object.
  46504. * @param scene Defines the scene we are parsing for
  46505. * @param rootUrl Defines the rootUrl to load from
  46506. */
  46507. parse(source: any, scene: Scene, rootUrl: string): void;
  46508. }
  46509. }
  46510. declare module BABYLON {
  46511. /**
  46512. * @hidden
  46513. */
  46514. export interface IMaterialSubSurfaceDefines {
  46515. SUBSURFACE: boolean;
  46516. SS_REFRACTION: boolean;
  46517. SS_TRANSLUCENCY: boolean;
  46518. SS_SCATERRING: boolean;
  46519. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46520. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46521. SS_REFRACTIONMAP_3D: boolean;
  46522. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46523. SS_LODINREFRACTIONALPHA: boolean;
  46524. SS_GAMMAREFRACTION: boolean;
  46525. SS_RGBDREFRACTION: boolean;
  46526. SS_LINEARSPECULARREFRACTION: boolean;
  46527. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46528. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46529. /** @hidden */ private _areTexturesDirty: boolean;
  46530. }
  46531. /**
  46532. * Define the code related to the sub surface parameters of the pbr material.
  46533. */
  46534. export class PBRSubSurfaceConfiguration {
  46535. private _isRefractionEnabled;
  46536. /**
  46537. * Defines if the refraction is enabled in the material.
  46538. */
  46539. isRefractionEnabled: boolean;
  46540. private _isTranslucencyEnabled;
  46541. /**
  46542. * Defines if the translucency is enabled in the material.
  46543. */
  46544. isTranslucencyEnabled: boolean;
  46545. private _isScatteringEnabled;
  46546. /**
  46547. * Defines the refraction intensity of the material.
  46548. * The refraction when enabled replaces the Diffuse part of the material.
  46549. * The intensity helps transitionning between diffuse and refraction.
  46550. */
  46551. refractionIntensity: number;
  46552. /**
  46553. * Defines the translucency intensity of the material.
  46554. * When translucency has been enabled, this defines how much of the "translucency"
  46555. * is addded to the diffuse part of the material.
  46556. */
  46557. translucencyIntensity: number;
  46558. /**
  46559. * Defines the scattering intensity of the material.
  46560. * When scattering has been enabled, this defines how much of the "scattered light"
  46561. * is addded to the diffuse part of the material.
  46562. */
  46563. scatteringIntensity: number;
  46564. private _thicknessTexture;
  46565. /**
  46566. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46567. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46568. * 0 would mean minimumThickness
  46569. * 1 would mean maximumThickness
  46570. * The other channels might be use as a mask to vary the different effects intensity.
  46571. */
  46572. thicknessTexture: Nullable<BaseTexture>;
  46573. private _refractionTexture;
  46574. /**
  46575. * Defines the texture to use for refraction.
  46576. */
  46577. refractionTexture: Nullable<BaseTexture>;
  46578. private _indexOfRefraction;
  46579. /**
  46580. * Defines the index of refraction used in the material.
  46581. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46582. */
  46583. indexOfRefraction: number;
  46584. private _invertRefractionY;
  46585. /**
  46586. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46587. */
  46588. invertRefractionY: boolean;
  46589. private _linkRefractionWithTransparency;
  46590. /**
  46591. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46592. * Materials half opaque for instance using refraction could benefit from this control.
  46593. */
  46594. linkRefractionWithTransparency: boolean;
  46595. /**
  46596. * Defines the minimum thickness stored in the thickness map.
  46597. * If no thickness map is defined, this value will be used to simulate thickness.
  46598. */
  46599. minimumThickness: number;
  46600. /**
  46601. * Defines the maximum thickness stored in the thickness map.
  46602. */
  46603. maximumThickness: number;
  46604. /**
  46605. * Defines the volume tint of the material.
  46606. * This is used for both translucency and scattering.
  46607. */
  46608. tintColor: Color3;
  46609. /**
  46610. * Defines the distance at which the tint color should be found in the media.
  46611. * This is used for refraction only.
  46612. */
  46613. tintColorAtDistance: number;
  46614. /**
  46615. * Defines how far each channel transmit through the media.
  46616. * It is defined as a color to simplify it selection.
  46617. */
  46618. diffusionDistance: Color3;
  46619. private _useMaskFromThicknessTexture;
  46620. /**
  46621. * Stores the intensity of the different subsurface effects in the thickness texture.
  46622. * * the green channel is the translucency intensity.
  46623. * * the blue channel is the scattering intensity.
  46624. * * the alpha channel is the refraction intensity.
  46625. */
  46626. useMaskFromThicknessTexture: boolean;
  46627. /** @hidden */
  46628. private _internalMarkAllSubMeshesAsTexturesDirty;
  46629. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46630. /**
  46631. * Instantiate a new istance of sub surface configuration.
  46632. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46633. */
  46634. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46635. /**
  46636. * Gets wehter the submesh is ready to be used or not.
  46637. * @param defines the list of "defines" to update.
  46638. * @param scene defines the scene the material belongs to.
  46639. * @returns - boolean indicating that the submesh is ready or not.
  46640. */
  46641. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46642. /**
  46643. * Checks to see if a texture is used in the material.
  46644. * @param defines the list of "defines" to update.
  46645. * @param scene defines the scene to the material belongs to.
  46646. */
  46647. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46648. /**
  46649. * Binds the material data.
  46650. * @param uniformBuffer defines the Uniform buffer to fill in.
  46651. * @param scene defines the scene the material belongs to.
  46652. * @param engine defines the engine the material belongs to.
  46653. * @param isFrozen defines wether the material is frozen or not.
  46654. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46655. */
  46656. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46657. /**
  46658. * Unbinds the material from the mesh.
  46659. * @param activeEffect defines the effect that should be unbound from.
  46660. * @returns true if unbound, otherwise false
  46661. */
  46662. unbind(activeEffect: Effect): boolean;
  46663. /**
  46664. * Returns the texture used for refraction or null if none is used.
  46665. * @param scene defines the scene the material belongs to.
  46666. * @returns - Refraction texture if present. If no refraction texture and refraction
  46667. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46668. */
  46669. private _getRefractionTexture;
  46670. /**
  46671. * Returns true if alpha blending should be disabled.
  46672. */
  46673. readonly disableAlphaBlending: boolean;
  46674. /**
  46675. * Fills the list of render target textures.
  46676. * @param renderTargets the list of render targets to update
  46677. */
  46678. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46679. /**
  46680. * Checks to see if a texture is used in the material.
  46681. * @param texture - Base texture to use.
  46682. * @returns - Boolean specifying if a texture is used in the material.
  46683. */
  46684. hasTexture(texture: BaseTexture): boolean;
  46685. /**
  46686. * Gets a boolean indicating that current material needs to register RTT
  46687. * @returns true if this uses a render target otherwise false.
  46688. */
  46689. hasRenderTargetTextures(): boolean;
  46690. /**
  46691. * Returns an array of the actively used textures.
  46692. * @param activeTextures Array of BaseTextures
  46693. */
  46694. getActiveTextures(activeTextures: BaseTexture[]): void;
  46695. /**
  46696. * Returns the animatable textures.
  46697. * @param animatables Array of animatable textures.
  46698. */
  46699. getAnimatables(animatables: IAnimatable[]): void;
  46700. /**
  46701. * Disposes the resources of the material.
  46702. * @param forceDisposeTextures - Forces the disposal of all textures.
  46703. */
  46704. dispose(forceDisposeTextures?: boolean): void;
  46705. /**
  46706. * Get the current class name of the texture useful for serialization or dynamic coding.
  46707. * @returns "PBRSubSurfaceConfiguration"
  46708. */
  46709. getClassName(): string;
  46710. /**
  46711. * Add fallbacks to the effect fallbacks list.
  46712. * @param defines defines the Base texture to use.
  46713. * @param fallbacks defines the current fallback list.
  46714. * @param currentRank defines the current fallback rank.
  46715. * @returns the new fallback rank.
  46716. */
  46717. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46718. /**
  46719. * Add the required uniforms to the current list.
  46720. * @param uniforms defines the current uniform list.
  46721. */
  46722. static AddUniforms(uniforms: string[]): void;
  46723. /**
  46724. * Add the required samplers to the current list.
  46725. * @param samplers defines the current sampler list.
  46726. */
  46727. static AddSamplers(samplers: string[]): void;
  46728. /**
  46729. * Add the required uniforms to the current buffer.
  46730. * @param uniformBuffer defines the current uniform buffer.
  46731. */
  46732. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46733. /**
  46734. * Makes a duplicate of the current configuration into another one.
  46735. * @param configuration define the config where to copy the info
  46736. */
  46737. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46738. /**
  46739. * Serializes this Sub Surface configuration.
  46740. * @returns - An object with the serialized config.
  46741. */
  46742. serialize(): any;
  46743. /**
  46744. * Parses a anisotropy Configuration from a serialized object.
  46745. * @param source - Serialized object.
  46746. * @param scene Defines the scene we are parsing for
  46747. * @param rootUrl Defines the rootUrl to load from
  46748. */
  46749. parse(source: any, scene: Scene, rootUrl: string): void;
  46750. }
  46751. }
  46752. declare module BABYLON {
  46753. /** @hidden */
  46754. export var pbrFragmentDeclaration: {
  46755. name: string;
  46756. shader: string;
  46757. };
  46758. }
  46759. declare module BABYLON {
  46760. /** @hidden */
  46761. export var pbrUboDeclaration: {
  46762. name: string;
  46763. shader: string;
  46764. };
  46765. }
  46766. declare module BABYLON {
  46767. /** @hidden */
  46768. export var pbrFragmentExtraDeclaration: {
  46769. name: string;
  46770. shader: string;
  46771. };
  46772. }
  46773. declare module BABYLON {
  46774. /** @hidden */
  46775. export var pbrFragmentSamplersDeclaration: {
  46776. name: string;
  46777. shader: string;
  46778. };
  46779. }
  46780. declare module BABYLON {
  46781. /** @hidden */
  46782. export var pbrHelperFunctions: {
  46783. name: string;
  46784. shader: string;
  46785. };
  46786. }
  46787. declare module BABYLON {
  46788. /** @hidden */
  46789. export var harmonicsFunctions: {
  46790. name: string;
  46791. shader: string;
  46792. };
  46793. }
  46794. declare module BABYLON {
  46795. /** @hidden */
  46796. export var pbrDirectLightingSetupFunctions: {
  46797. name: string;
  46798. shader: string;
  46799. };
  46800. }
  46801. declare module BABYLON {
  46802. /** @hidden */
  46803. export var pbrDirectLightingFalloffFunctions: {
  46804. name: string;
  46805. shader: string;
  46806. };
  46807. }
  46808. declare module BABYLON {
  46809. /** @hidden */
  46810. export var pbrBRDFFunctions: {
  46811. name: string;
  46812. shader: string;
  46813. };
  46814. }
  46815. declare module BABYLON {
  46816. /** @hidden */
  46817. export var pbrDirectLightingFunctions: {
  46818. name: string;
  46819. shader: string;
  46820. };
  46821. }
  46822. declare module BABYLON {
  46823. /** @hidden */
  46824. export var pbrIBLFunctions: {
  46825. name: string;
  46826. shader: string;
  46827. };
  46828. }
  46829. declare module BABYLON {
  46830. /** @hidden */
  46831. export var pbrDebug: {
  46832. name: string;
  46833. shader: string;
  46834. };
  46835. }
  46836. declare module BABYLON {
  46837. /** @hidden */
  46838. export var pbrPixelShader: {
  46839. name: string;
  46840. shader: string;
  46841. };
  46842. }
  46843. declare module BABYLON {
  46844. /** @hidden */
  46845. export var pbrVertexDeclaration: {
  46846. name: string;
  46847. shader: string;
  46848. };
  46849. }
  46850. declare module BABYLON {
  46851. /** @hidden */
  46852. export var pbrVertexShader: {
  46853. name: string;
  46854. shader: string;
  46855. };
  46856. }
  46857. declare module BABYLON {
  46858. /**
  46859. * Manages the defines for the PBR Material.
  46860. * @hidden
  46861. */
  46862. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46863. PBR: boolean;
  46864. MAINUV1: boolean;
  46865. MAINUV2: boolean;
  46866. UV1: boolean;
  46867. UV2: boolean;
  46868. ALBEDO: boolean;
  46869. ALBEDODIRECTUV: number;
  46870. VERTEXCOLOR: boolean;
  46871. AMBIENT: boolean;
  46872. AMBIENTDIRECTUV: number;
  46873. AMBIENTINGRAYSCALE: boolean;
  46874. OPACITY: boolean;
  46875. VERTEXALPHA: boolean;
  46876. OPACITYDIRECTUV: number;
  46877. OPACITYRGB: boolean;
  46878. ALPHATEST: boolean;
  46879. DEPTHPREPASS: boolean;
  46880. ALPHABLEND: boolean;
  46881. ALPHAFROMALBEDO: boolean;
  46882. ALPHATESTVALUE: string;
  46883. SPECULAROVERALPHA: boolean;
  46884. RADIANCEOVERALPHA: boolean;
  46885. ALPHAFRESNEL: boolean;
  46886. LINEARALPHAFRESNEL: boolean;
  46887. PREMULTIPLYALPHA: boolean;
  46888. EMISSIVE: boolean;
  46889. EMISSIVEDIRECTUV: number;
  46890. REFLECTIVITY: boolean;
  46891. REFLECTIVITYDIRECTUV: number;
  46892. SPECULARTERM: boolean;
  46893. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46894. MICROSURFACEAUTOMATIC: boolean;
  46895. LODBASEDMICROSFURACE: boolean;
  46896. MICROSURFACEMAP: boolean;
  46897. MICROSURFACEMAPDIRECTUV: number;
  46898. METALLICWORKFLOW: boolean;
  46899. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46900. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46901. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46902. AOSTOREINMETALMAPRED: boolean;
  46903. ENVIRONMENTBRDF: boolean;
  46904. ENVIRONMENTBRDF_RGBD: boolean;
  46905. NORMAL: boolean;
  46906. TANGENT: boolean;
  46907. BUMP: boolean;
  46908. BUMPDIRECTUV: number;
  46909. OBJECTSPACE_NORMALMAP: boolean;
  46910. PARALLAX: boolean;
  46911. PARALLAXOCCLUSION: boolean;
  46912. NORMALXYSCALE: boolean;
  46913. LIGHTMAP: boolean;
  46914. LIGHTMAPDIRECTUV: number;
  46915. USELIGHTMAPASSHADOWMAP: boolean;
  46916. GAMMALIGHTMAP: boolean;
  46917. RGBDLIGHTMAP: boolean;
  46918. REFLECTION: boolean;
  46919. REFLECTIONMAP_3D: boolean;
  46920. REFLECTIONMAP_SPHERICAL: boolean;
  46921. REFLECTIONMAP_PLANAR: boolean;
  46922. REFLECTIONMAP_CUBIC: boolean;
  46923. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46924. REFLECTIONMAP_PROJECTION: boolean;
  46925. REFLECTIONMAP_SKYBOX: boolean;
  46926. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46927. REFLECTIONMAP_EXPLICIT: boolean;
  46928. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46929. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46930. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46931. INVERTCUBICMAP: boolean;
  46932. USESPHERICALFROMREFLECTIONMAP: boolean;
  46933. USEIRRADIANCEMAP: boolean;
  46934. SPHERICAL_HARMONICS: boolean;
  46935. USESPHERICALINVERTEX: boolean;
  46936. REFLECTIONMAP_OPPOSITEZ: boolean;
  46937. LODINREFLECTIONALPHA: boolean;
  46938. GAMMAREFLECTION: boolean;
  46939. RGBDREFLECTION: boolean;
  46940. LINEARSPECULARREFLECTION: boolean;
  46941. RADIANCEOCCLUSION: boolean;
  46942. HORIZONOCCLUSION: boolean;
  46943. INSTANCES: boolean;
  46944. NUM_BONE_INFLUENCERS: number;
  46945. BonesPerMesh: number;
  46946. BONETEXTURE: boolean;
  46947. NONUNIFORMSCALING: boolean;
  46948. MORPHTARGETS: boolean;
  46949. MORPHTARGETS_NORMAL: boolean;
  46950. MORPHTARGETS_TANGENT: boolean;
  46951. MORPHTARGETS_UV: boolean;
  46952. NUM_MORPH_INFLUENCERS: number;
  46953. IMAGEPROCESSING: boolean;
  46954. VIGNETTE: boolean;
  46955. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46956. VIGNETTEBLENDMODEOPAQUE: boolean;
  46957. TONEMAPPING: boolean;
  46958. TONEMAPPING_ACES: boolean;
  46959. CONTRAST: boolean;
  46960. COLORCURVES: boolean;
  46961. COLORGRADING: boolean;
  46962. COLORGRADING3D: boolean;
  46963. SAMPLER3DGREENDEPTH: boolean;
  46964. SAMPLER3DBGRMAP: boolean;
  46965. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46966. EXPOSURE: boolean;
  46967. MULTIVIEW: boolean;
  46968. USEPHYSICALLIGHTFALLOFF: boolean;
  46969. USEGLTFLIGHTFALLOFF: boolean;
  46970. TWOSIDEDLIGHTING: boolean;
  46971. SHADOWFLOAT: boolean;
  46972. CLIPPLANE: boolean;
  46973. CLIPPLANE2: boolean;
  46974. CLIPPLANE3: boolean;
  46975. CLIPPLANE4: boolean;
  46976. POINTSIZE: boolean;
  46977. FOG: boolean;
  46978. LOGARITHMICDEPTH: boolean;
  46979. FORCENORMALFORWARD: boolean;
  46980. SPECULARAA: boolean;
  46981. CLEARCOAT: boolean;
  46982. CLEARCOAT_DEFAULTIOR: boolean;
  46983. CLEARCOAT_TEXTURE: boolean;
  46984. CLEARCOAT_TEXTUREDIRECTUV: number;
  46985. CLEARCOAT_BUMP: boolean;
  46986. CLEARCOAT_BUMPDIRECTUV: number;
  46987. CLEARCOAT_TINT: boolean;
  46988. CLEARCOAT_TINT_TEXTURE: boolean;
  46989. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46990. ANISOTROPIC: boolean;
  46991. ANISOTROPIC_TEXTURE: boolean;
  46992. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46993. BRDF_V_HEIGHT_CORRELATED: boolean;
  46994. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46995. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46996. SHEEN: boolean;
  46997. SHEEN_TEXTURE: boolean;
  46998. SHEEN_TEXTUREDIRECTUV: number;
  46999. SHEEN_LINKWITHALBEDO: boolean;
  47000. SUBSURFACE: boolean;
  47001. SS_REFRACTION: boolean;
  47002. SS_TRANSLUCENCY: boolean;
  47003. SS_SCATERRING: boolean;
  47004. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47005. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47006. SS_REFRACTIONMAP_3D: boolean;
  47007. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47008. SS_LODINREFRACTIONALPHA: boolean;
  47009. SS_GAMMAREFRACTION: boolean;
  47010. SS_RGBDREFRACTION: boolean;
  47011. SS_LINEARSPECULARREFRACTION: boolean;
  47012. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47013. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47014. UNLIT: boolean;
  47015. DEBUGMODE: number;
  47016. /**
  47017. * Initializes the PBR Material defines.
  47018. */
  47019. constructor();
  47020. /**
  47021. * Resets the PBR Material defines.
  47022. */
  47023. reset(): void;
  47024. }
  47025. /**
  47026. * The Physically based material base class of BJS.
  47027. *
  47028. * This offers the main features of a standard PBR material.
  47029. * For more information, please refer to the documentation :
  47030. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47031. */
  47032. export abstract class PBRBaseMaterial extends PushMaterial {
  47033. /**
  47034. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47035. */
  47036. static readonly PBRMATERIAL_OPAQUE: number;
  47037. /**
  47038. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47039. */
  47040. static readonly PBRMATERIAL_ALPHATEST: number;
  47041. /**
  47042. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47043. */
  47044. static readonly PBRMATERIAL_ALPHABLEND: number;
  47045. /**
  47046. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47047. * They are also discarded below the alpha cutoff threshold to improve performances.
  47048. */
  47049. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47050. /**
  47051. * Defines the default value of how much AO map is occluding the analytical lights
  47052. * (point spot...).
  47053. */
  47054. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47055. /**
  47056. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47057. */
  47058. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47059. /**
  47060. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47061. * to enhance interoperability with other engines.
  47062. */
  47063. static readonly LIGHTFALLOFF_GLTF: number;
  47064. /**
  47065. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47066. * to enhance interoperability with other materials.
  47067. */
  47068. static readonly LIGHTFALLOFF_STANDARD: number;
  47069. /**
  47070. * Intensity of the direct lights e.g. the four lights available in your scene.
  47071. * This impacts both the direct diffuse and specular highlights.
  47072. */
  47073. protected _directIntensity: number;
  47074. /**
  47075. * Intensity of the emissive part of the material.
  47076. * This helps controlling the emissive effect without modifying the emissive color.
  47077. */
  47078. protected _emissiveIntensity: number;
  47079. /**
  47080. * Intensity of the environment e.g. how much the environment will light the object
  47081. * either through harmonics for rough material or through the refelction for shiny ones.
  47082. */
  47083. protected _environmentIntensity: number;
  47084. /**
  47085. * This is a special control allowing the reduction of the specular highlights coming from the
  47086. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47087. */
  47088. protected _specularIntensity: number;
  47089. /**
  47090. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47091. */
  47092. private _lightingInfos;
  47093. /**
  47094. * Debug Control allowing disabling the bump map on this material.
  47095. */
  47096. protected _disableBumpMap: boolean;
  47097. /**
  47098. * AKA Diffuse Texture in standard nomenclature.
  47099. */
  47100. protected _albedoTexture: Nullable<BaseTexture>;
  47101. /**
  47102. * AKA Occlusion Texture in other nomenclature.
  47103. */
  47104. protected _ambientTexture: Nullable<BaseTexture>;
  47105. /**
  47106. * AKA Occlusion Texture Intensity in other nomenclature.
  47107. */
  47108. protected _ambientTextureStrength: number;
  47109. /**
  47110. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47111. * 1 means it completely occludes it
  47112. * 0 mean it has no impact
  47113. */
  47114. protected _ambientTextureImpactOnAnalyticalLights: number;
  47115. /**
  47116. * Stores the alpha values in a texture.
  47117. */
  47118. protected _opacityTexture: Nullable<BaseTexture>;
  47119. /**
  47120. * Stores the reflection values in a texture.
  47121. */
  47122. protected _reflectionTexture: Nullable<BaseTexture>;
  47123. /**
  47124. * Stores the emissive values in a texture.
  47125. */
  47126. protected _emissiveTexture: Nullable<BaseTexture>;
  47127. /**
  47128. * AKA Specular texture in other nomenclature.
  47129. */
  47130. protected _reflectivityTexture: Nullable<BaseTexture>;
  47131. /**
  47132. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47133. */
  47134. protected _metallicTexture: Nullable<BaseTexture>;
  47135. /**
  47136. * Specifies the metallic scalar of the metallic/roughness workflow.
  47137. * Can also be used to scale the metalness values of the metallic texture.
  47138. */
  47139. protected _metallic: Nullable<number>;
  47140. /**
  47141. * Specifies the roughness scalar of the metallic/roughness workflow.
  47142. * Can also be used to scale the roughness values of the metallic texture.
  47143. */
  47144. protected _roughness: Nullable<number>;
  47145. /**
  47146. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47147. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47148. */
  47149. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47150. /**
  47151. * Stores surface normal data used to displace a mesh in a texture.
  47152. */
  47153. protected _bumpTexture: Nullable<BaseTexture>;
  47154. /**
  47155. * Stores the pre-calculated light information of a mesh in a texture.
  47156. */
  47157. protected _lightmapTexture: Nullable<BaseTexture>;
  47158. /**
  47159. * The color of a material in ambient lighting.
  47160. */
  47161. protected _ambientColor: Color3;
  47162. /**
  47163. * AKA Diffuse Color in other nomenclature.
  47164. */
  47165. protected _albedoColor: Color3;
  47166. /**
  47167. * AKA Specular Color in other nomenclature.
  47168. */
  47169. protected _reflectivityColor: Color3;
  47170. /**
  47171. * The color applied when light is reflected from a material.
  47172. */
  47173. protected _reflectionColor: Color3;
  47174. /**
  47175. * The color applied when light is emitted from a material.
  47176. */
  47177. protected _emissiveColor: Color3;
  47178. /**
  47179. * AKA Glossiness in other nomenclature.
  47180. */
  47181. protected _microSurface: number;
  47182. /**
  47183. * Specifies that the material will use the light map as a show map.
  47184. */
  47185. protected _useLightmapAsShadowmap: boolean;
  47186. /**
  47187. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47188. * makes the reflect vector face the model (under horizon).
  47189. */
  47190. protected _useHorizonOcclusion: boolean;
  47191. /**
  47192. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47193. * too much the area relying on ambient texture to define their ambient occlusion.
  47194. */
  47195. protected _useRadianceOcclusion: boolean;
  47196. /**
  47197. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47198. */
  47199. protected _useAlphaFromAlbedoTexture: boolean;
  47200. /**
  47201. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47202. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47203. */
  47204. protected _useSpecularOverAlpha: boolean;
  47205. /**
  47206. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47207. */
  47208. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47209. /**
  47210. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47211. */
  47212. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47213. /**
  47214. * Specifies if the metallic texture contains the roughness information in its green channel.
  47215. */
  47216. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47217. /**
  47218. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47219. */
  47220. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47221. /**
  47222. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47223. */
  47224. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47225. /**
  47226. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47227. */
  47228. protected _useAmbientInGrayScale: boolean;
  47229. /**
  47230. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47231. * The material will try to infer what glossiness each pixel should be.
  47232. */
  47233. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47234. /**
  47235. * Defines the falloff type used in this material.
  47236. * It by default is Physical.
  47237. */
  47238. protected _lightFalloff: number;
  47239. /**
  47240. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47241. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47242. */
  47243. protected _useRadianceOverAlpha: boolean;
  47244. /**
  47245. * Allows using an object space normal map (instead of tangent space).
  47246. */
  47247. protected _useObjectSpaceNormalMap: boolean;
  47248. /**
  47249. * Allows using the bump map in parallax mode.
  47250. */
  47251. protected _useParallax: boolean;
  47252. /**
  47253. * Allows using the bump map in parallax occlusion mode.
  47254. */
  47255. protected _useParallaxOcclusion: boolean;
  47256. /**
  47257. * Controls the scale bias of the parallax mode.
  47258. */
  47259. protected _parallaxScaleBias: number;
  47260. /**
  47261. * If sets to true, disables all the lights affecting the material.
  47262. */
  47263. protected _disableLighting: boolean;
  47264. /**
  47265. * Number of Simultaneous lights allowed on the material.
  47266. */
  47267. protected _maxSimultaneousLights: number;
  47268. /**
  47269. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47270. */
  47271. protected _invertNormalMapX: boolean;
  47272. /**
  47273. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47274. */
  47275. protected _invertNormalMapY: boolean;
  47276. /**
  47277. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47278. */
  47279. protected _twoSidedLighting: boolean;
  47280. /**
  47281. * Defines the alpha limits in alpha test mode.
  47282. */
  47283. protected _alphaCutOff: number;
  47284. /**
  47285. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47286. */
  47287. protected _forceAlphaTest: boolean;
  47288. /**
  47289. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47290. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47291. */
  47292. protected _useAlphaFresnel: boolean;
  47293. /**
  47294. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47295. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47296. */
  47297. protected _useLinearAlphaFresnel: boolean;
  47298. /**
  47299. * The transparency mode of the material.
  47300. */
  47301. protected _transparencyMode: Nullable<number>;
  47302. /**
  47303. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47304. * from cos thetav and roughness:
  47305. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47306. */
  47307. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47308. /**
  47309. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47310. */
  47311. protected _forceIrradianceInFragment: boolean;
  47312. /**
  47313. * Force normal to face away from face.
  47314. */
  47315. protected _forceNormalForward: boolean;
  47316. /**
  47317. * Enables specular anti aliasing in the PBR shader.
  47318. * It will both interacts on the Geometry for analytical and IBL lighting.
  47319. * It also prefilter the roughness map based on the bump values.
  47320. */
  47321. protected _enableSpecularAntiAliasing: boolean;
  47322. /**
  47323. * Default configuration related to image processing available in the PBR Material.
  47324. */
  47325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47326. /**
  47327. * Keep track of the image processing observer to allow dispose and replace.
  47328. */
  47329. private _imageProcessingObserver;
  47330. /**
  47331. * Attaches a new image processing configuration to the PBR Material.
  47332. * @param configuration
  47333. */
  47334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47335. /**
  47336. * Stores the available render targets.
  47337. */
  47338. private _renderTargets;
  47339. /**
  47340. * Sets the global ambient color for the material used in lighting calculations.
  47341. */
  47342. private _globalAmbientColor;
  47343. /**
  47344. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47345. */
  47346. private _useLogarithmicDepth;
  47347. /**
  47348. * If set to true, no lighting calculations will be applied.
  47349. */
  47350. private _unlit;
  47351. private _debugMode;
  47352. /**
  47353. * @hidden
  47354. * This is reserved for the inspector.
  47355. * Defines the material debug mode.
  47356. * It helps seeing only some components of the material while troubleshooting.
  47357. */
  47358. debugMode: number;
  47359. /**
  47360. * @hidden
  47361. * This is reserved for the inspector.
  47362. * Specify from where on screen the debug mode should start.
  47363. * The value goes from -1 (full screen) to 1 (not visible)
  47364. * It helps with side by side comparison against the final render
  47365. * This defaults to -1
  47366. */
  47367. private debugLimit;
  47368. /**
  47369. * @hidden
  47370. * This is reserved for the inspector.
  47371. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47372. * You can use the factor to better multiply the final value.
  47373. */
  47374. private debugFactor;
  47375. /**
  47376. * Defines the clear coat layer parameters for the material.
  47377. */
  47378. readonly clearCoat: PBRClearCoatConfiguration;
  47379. /**
  47380. * Defines the anisotropic parameters for the material.
  47381. */
  47382. readonly anisotropy: PBRAnisotropicConfiguration;
  47383. /**
  47384. * Defines the BRDF parameters for the material.
  47385. */
  47386. readonly brdf: PBRBRDFConfiguration;
  47387. /**
  47388. * Defines the Sheen parameters for the material.
  47389. */
  47390. readonly sheen: PBRSheenConfiguration;
  47391. /**
  47392. * Defines the SubSurface parameters for the material.
  47393. */
  47394. readonly subSurface: PBRSubSurfaceConfiguration;
  47395. /**
  47396. * Custom callback helping to override the default shader used in the material.
  47397. */
  47398. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47399. protected _rebuildInParallel: boolean;
  47400. /**
  47401. * Instantiates a new PBRMaterial instance.
  47402. *
  47403. * @param name The material name
  47404. * @param scene The scene the material will be use in.
  47405. */
  47406. constructor(name: string, scene: Scene);
  47407. /**
  47408. * Gets a boolean indicating that current material needs to register RTT
  47409. */
  47410. readonly hasRenderTargetTextures: boolean;
  47411. /**
  47412. * Gets the name of the material class.
  47413. */
  47414. getClassName(): string;
  47415. /**
  47416. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47417. */
  47418. /**
  47419. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47420. */
  47421. useLogarithmicDepth: boolean;
  47422. /**
  47423. * Gets the current transparency mode.
  47424. */
  47425. /**
  47426. * Sets the transparency mode of the material.
  47427. *
  47428. * | Value | Type | Description |
  47429. * | ----- | ----------------------------------- | ----------- |
  47430. * | 0 | OPAQUE | |
  47431. * | 1 | ALPHATEST | |
  47432. * | 2 | ALPHABLEND | |
  47433. * | 3 | ALPHATESTANDBLEND | |
  47434. *
  47435. */
  47436. transparencyMode: Nullable<number>;
  47437. /**
  47438. * Returns true if alpha blending should be disabled.
  47439. */
  47440. private readonly _disableAlphaBlending;
  47441. /**
  47442. * Specifies whether or not this material should be rendered in alpha blend mode.
  47443. */
  47444. needAlphaBlending(): boolean;
  47445. /**
  47446. * Specifies if the mesh will require alpha blending.
  47447. * @param mesh - BJS mesh.
  47448. */
  47449. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47450. /**
  47451. * Specifies whether or not this material should be rendered in alpha test mode.
  47452. */
  47453. needAlphaTesting(): boolean;
  47454. /**
  47455. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47456. */
  47457. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47458. /**
  47459. * Gets the texture used for the alpha test.
  47460. */
  47461. getAlphaTestTexture(): Nullable<BaseTexture>;
  47462. /**
  47463. * Specifies that the submesh is ready to be used.
  47464. * @param mesh - BJS mesh.
  47465. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47466. * @param useInstances - Specifies that instances should be used.
  47467. * @returns - boolean indicating that the submesh is ready or not.
  47468. */
  47469. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47470. /**
  47471. * Specifies if the material uses metallic roughness workflow.
  47472. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47473. */
  47474. isMetallicWorkflow(): boolean;
  47475. private _prepareEffect;
  47476. private _prepareDefines;
  47477. /**
  47478. * Force shader compilation
  47479. */
  47480. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  47481. /**
  47482. * Initializes the uniform buffer layout for the shader.
  47483. */
  47484. buildUniformLayout(): void;
  47485. /**
  47486. * Unbinds the material from the mesh
  47487. */
  47488. unbind(): void;
  47489. /**
  47490. * Binds the submesh data.
  47491. * @param world - The world matrix.
  47492. * @param mesh - The BJS mesh.
  47493. * @param subMesh - A submesh of the BJS mesh.
  47494. */
  47495. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47496. /**
  47497. * Returns the animatable textures.
  47498. * @returns - Array of animatable textures.
  47499. */
  47500. getAnimatables(): IAnimatable[];
  47501. /**
  47502. * Returns the texture used for reflections.
  47503. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47504. */
  47505. private _getReflectionTexture;
  47506. /**
  47507. * Returns an array of the actively used textures.
  47508. * @returns - Array of BaseTextures
  47509. */
  47510. getActiveTextures(): BaseTexture[];
  47511. /**
  47512. * Checks to see if a texture is used in the material.
  47513. * @param texture - Base texture to use.
  47514. * @returns - Boolean specifying if a texture is used in the material.
  47515. */
  47516. hasTexture(texture: BaseTexture): boolean;
  47517. /**
  47518. * Disposes the resources of the material.
  47519. * @param forceDisposeEffect - Forces the disposal of effects.
  47520. * @param forceDisposeTextures - Forces the disposal of all textures.
  47521. */
  47522. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47523. }
  47524. }
  47525. declare module BABYLON {
  47526. /**
  47527. * The Physically based material of BJS.
  47528. *
  47529. * This offers the main features of a standard PBR material.
  47530. * For more information, please refer to the documentation :
  47531. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47532. */
  47533. export class PBRMaterial extends PBRBaseMaterial {
  47534. /**
  47535. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47536. */
  47537. static readonly PBRMATERIAL_OPAQUE: number;
  47538. /**
  47539. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47540. */
  47541. static readonly PBRMATERIAL_ALPHATEST: number;
  47542. /**
  47543. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47544. */
  47545. static readonly PBRMATERIAL_ALPHABLEND: number;
  47546. /**
  47547. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47548. * They are also discarded below the alpha cutoff threshold to improve performances.
  47549. */
  47550. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47551. /**
  47552. * Defines the default value of how much AO map is occluding the analytical lights
  47553. * (point spot...).
  47554. */
  47555. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47556. /**
  47557. * Intensity of the direct lights e.g. the four lights available in your scene.
  47558. * This impacts both the direct diffuse and specular highlights.
  47559. */
  47560. directIntensity: number;
  47561. /**
  47562. * Intensity of the emissive part of the material.
  47563. * This helps controlling the emissive effect without modifying the emissive color.
  47564. */
  47565. emissiveIntensity: number;
  47566. /**
  47567. * Intensity of the environment e.g. how much the environment will light the object
  47568. * either through harmonics for rough material or through the refelction for shiny ones.
  47569. */
  47570. environmentIntensity: number;
  47571. /**
  47572. * This is a special control allowing the reduction of the specular highlights coming from the
  47573. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47574. */
  47575. specularIntensity: number;
  47576. /**
  47577. * Debug Control allowing disabling the bump map on this material.
  47578. */
  47579. disableBumpMap: boolean;
  47580. /**
  47581. * AKA Diffuse Texture in standard nomenclature.
  47582. */
  47583. albedoTexture: BaseTexture;
  47584. /**
  47585. * AKA Occlusion Texture in other nomenclature.
  47586. */
  47587. ambientTexture: BaseTexture;
  47588. /**
  47589. * AKA Occlusion Texture Intensity in other nomenclature.
  47590. */
  47591. ambientTextureStrength: number;
  47592. /**
  47593. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47594. * 1 means it completely occludes it
  47595. * 0 mean it has no impact
  47596. */
  47597. ambientTextureImpactOnAnalyticalLights: number;
  47598. /**
  47599. * Stores the alpha values in a texture.
  47600. */
  47601. opacityTexture: BaseTexture;
  47602. /**
  47603. * Stores the reflection values in a texture.
  47604. */
  47605. reflectionTexture: Nullable<BaseTexture>;
  47606. /**
  47607. * Stores the emissive values in a texture.
  47608. */
  47609. emissiveTexture: BaseTexture;
  47610. /**
  47611. * AKA Specular texture in other nomenclature.
  47612. */
  47613. reflectivityTexture: BaseTexture;
  47614. /**
  47615. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47616. */
  47617. metallicTexture: BaseTexture;
  47618. /**
  47619. * Specifies the metallic scalar of the metallic/roughness workflow.
  47620. * Can also be used to scale the metalness values of the metallic texture.
  47621. */
  47622. metallic: Nullable<number>;
  47623. /**
  47624. * Specifies the roughness scalar of the metallic/roughness workflow.
  47625. * Can also be used to scale the roughness values of the metallic texture.
  47626. */
  47627. roughness: Nullable<number>;
  47628. /**
  47629. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47630. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47631. */
  47632. microSurfaceTexture: BaseTexture;
  47633. /**
  47634. * Stores surface normal data used to displace a mesh in a texture.
  47635. */
  47636. bumpTexture: BaseTexture;
  47637. /**
  47638. * Stores the pre-calculated light information of a mesh in a texture.
  47639. */
  47640. lightmapTexture: BaseTexture;
  47641. /**
  47642. * Stores the refracted light information in a texture.
  47643. */
  47644. refractionTexture: Nullable<BaseTexture>;
  47645. /**
  47646. * The color of a material in ambient lighting.
  47647. */
  47648. ambientColor: Color3;
  47649. /**
  47650. * AKA Diffuse Color in other nomenclature.
  47651. */
  47652. albedoColor: Color3;
  47653. /**
  47654. * AKA Specular Color in other nomenclature.
  47655. */
  47656. reflectivityColor: Color3;
  47657. /**
  47658. * The color reflected from the material.
  47659. */
  47660. reflectionColor: Color3;
  47661. /**
  47662. * The color emitted from the material.
  47663. */
  47664. emissiveColor: Color3;
  47665. /**
  47666. * AKA Glossiness in other nomenclature.
  47667. */
  47668. microSurface: number;
  47669. /**
  47670. * source material index of refraction (IOR)' / 'destination material IOR.
  47671. */
  47672. indexOfRefraction: number;
  47673. /**
  47674. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47675. */
  47676. invertRefractionY: boolean;
  47677. /**
  47678. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47679. * Materials half opaque for instance using refraction could benefit from this control.
  47680. */
  47681. linkRefractionWithTransparency: boolean;
  47682. /**
  47683. * If true, the light map contains occlusion information instead of lighting info.
  47684. */
  47685. useLightmapAsShadowmap: boolean;
  47686. /**
  47687. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47688. */
  47689. useAlphaFromAlbedoTexture: boolean;
  47690. /**
  47691. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47692. */
  47693. forceAlphaTest: boolean;
  47694. /**
  47695. * Defines the alpha limits in alpha test mode.
  47696. */
  47697. alphaCutOff: number;
  47698. /**
  47699. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47700. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47701. */
  47702. useSpecularOverAlpha: boolean;
  47703. /**
  47704. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47705. */
  47706. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47707. /**
  47708. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47709. */
  47710. useRoughnessFromMetallicTextureAlpha: boolean;
  47711. /**
  47712. * Specifies if the metallic texture contains the roughness information in its green channel.
  47713. */
  47714. useRoughnessFromMetallicTextureGreen: boolean;
  47715. /**
  47716. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47717. */
  47718. useMetallnessFromMetallicTextureBlue: boolean;
  47719. /**
  47720. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47721. */
  47722. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47723. /**
  47724. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47725. */
  47726. useAmbientInGrayScale: boolean;
  47727. /**
  47728. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47729. * The material will try to infer what glossiness each pixel should be.
  47730. */
  47731. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47732. /**
  47733. * BJS is using an harcoded light falloff based on a manually sets up range.
  47734. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47735. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47736. */
  47737. /**
  47738. * BJS is using an harcoded light falloff based on a manually sets up range.
  47739. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47740. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47741. */
  47742. usePhysicalLightFalloff: boolean;
  47743. /**
  47744. * In order to support the falloff compatibility with gltf, a special mode has been added
  47745. * to reproduce the gltf light falloff.
  47746. */
  47747. /**
  47748. * In order to support the falloff compatibility with gltf, a special mode has been added
  47749. * to reproduce the gltf light falloff.
  47750. */
  47751. useGLTFLightFalloff: boolean;
  47752. /**
  47753. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47754. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47755. */
  47756. useRadianceOverAlpha: boolean;
  47757. /**
  47758. * Allows using an object space normal map (instead of tangent space).
  47759. */
  47760. useObjectSpaceNormalMap: boolean;
  47761. /**
  47762. * Allows using the bump map in parallax mode.
  47763. */
  47764. useParallax: boolean;
  47765. /**
  47766. * Allows using the bump map in parallax occlusion mode.
  47767. */
  47768. useParallaxOcclusion: boolean;
  47769. /**
  47770. * Controls the scale bias of the parallax mode.
  47771. */
  47772. parallaxScaleBias: number;
  47773. /**
  47774. * If sets to true, disables all the lights affecting the material.
  47775. */
  47776. disableLighting: boolean;
  47777. /**
  47778. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47779. */
  47780. forceIrradianceInFragment: boolean;
  47781. /**
  47782. * Number of Simultaneous lights allowed on the material.
  47783. */
  47784. maxSimultaneousLights: number;
  47785. /**
  47786. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47787. */
  47788. invertNormalMapX: boolean;
  47789. /**
  47790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47791. */
  47792. invertNormalMapY: boolean;
  47793. /**
  47794. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47795. */
  47796. twoSidedLighting: boolean;
  47797. /**
  47798. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47799. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47800. */
  47801. useAlphaFresnel: boolean;
  47802. /**
  47803. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47804. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47805. */
  47806. useLinearAlphaFresnel: boolean;
  47807. /**
  47808. * Let user defines the brdf lookup texture used for IBL.
  47809. * A default 8bit version is embedded but you could point at :
  47810. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47811. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47812. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47813. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47814. */
  47815. environmentBRDFTexture: Nullable<BaseTexture>;
  47816. /**
  47817. * Force normal to face away from face.
  47818. */
  47819. forceNormalForward: boolean;
  47820. /**
  47821. * Enables specular anti aliasing in the PBR shader.
  47822. * It will both interacts on the Geometry for analytical and IBL lighting.
  47823. * It also prefilter the roughness map based on the bump values.
  47824. */
  47825. enableSpecularAntiAliasing: boolean;
  47826. /**
  47827. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47828. * makes the reflect vector face the model (under horizon).
  47829. */
  47830. useHorizonOcclusion: boolean;
  47831. /**
  47832. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47833. * too much the area relying on ambient texture to define their ambient occlusion.
  47834. */
  47835. useRadianceOcclusion: boolean;
  47836. /**
  47837. * If set to true, no lighting calculations will be applied.
  47838. */
  47839. unlit: boolean;
  47840. /**
  47841. * Gets the image processing configuration used either in this material.
  47842. */
  47843. /**
  47844. * Sets the Default image processing configuration used either in the this material.
  47845. *
  47846. * If sets to null, the scene one is in use.
  47847. */
  47848. imageProcessingConfiguration: ImageProcessingConfiguration;
  47849. /**
  47850. * Gets wether the color curves effect is enabled.
  47851. */
  47852. /**
  47853. * Sets wether the color curves effect is enabled.
  47854. */
  47855. cameraColorCurvesEnabled: boolean;
  47856. /**
  47857. * Gets wether the color grading effect is enabled.
  47858. */
  47859. /**
  47860. * Gets wether the color grading effect is enabled.
  47861. */
  47862. cameraColorGradingEnabled: boolean;
  47863. /**
  47864. * Gets wether tonemapping is enabled or not.
  47865. */
  47866. /**
  47867. * Sets wether tonemapping is enabled or not
  47868. */
  47869. cameraToneMappingEnabled: boolean;
  47870. /**
  47871. * The camera exposure used on this material.
  47872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47873. * This corresponds to a photographic exposure.
  47874. */
  47875. /**
  47876. * The camera exposure used on this material.
  47877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47878. * This corresponds to a photographic exposure.
  47879. */
  47880. cameraExposure: number;
  47881. /**
  47882. * Gets The camera contrast used on this material.
  47883. */
  47884. /**
  47885. * Sets The camera contrast used on this material.
  47886. */
  47887. cameraContrast: number;
  47888. /**
  47889. * Gets the Color Grading 2D Lookup Texture.
  47890. */
  47891. /**
  47892. * Sets the Color Grading 2D Lookup Texture.
  47893. */
  47894. cameraColorGradingTexture: Nullable<BaseTexture>;
  47895. /**
  47896. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47897. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47898. * 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;
  47899. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47900. */
  47901. /**
  47902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47904. * 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;
  47905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47906. */
  47907. cameraColorCurves: Nullable<ColorCurves>;
  47908. /**
  47909. * Instantiates a new PBRMaterial instance.
  47910. *
  47911. * @param name The material name
  47912. * @param scene The scene the material will be use in.
  47913. */
  47914. constructor(name: string, scene: Scene);
  47915. /**
  47916. * Returns the name of this material class.
  47917. */
  47918. getClassName(): string;
  47919. /**
  47920. * Makes a duplicate of the current material.
  47921. * @param name - name to use for the new material.
  47922. */
  47923. clone(name: string): PBRMaterial;
  47924. /**
  47925. * Serializes this PBR Material.
  47926. * @returns - An object with the serialized material.
  47927. */
  47928. serialize(): any;
  47929. /**
  47930. * Parses a PBR Material from a serialized object.
  47931. * @param source - Serialized object.
  47932. * @param scene - BJS scene instance.
  47933. * @param rootUrl - url for the scene object
  47934. * @returns - PBRMaterial
  47935. */
  47936. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47937. }
  47938. }
  47939. declare module BABYLON {
  47940. /**
  47941. * Direct draw surface info
  47942. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47943. */
  47944. export interface DDSInfo {
  47945. /**
  47946. * Width of the texture
  47947. */
  47948. width: number;
  47949. /**
  47950. * Width of the texture
  47951. */
  47952. height: number;
  47953. /**
  47954. * Number of Mipmaps for the texture
  47955. * @see https://en.wikipedia.org/wiki/Mipmap
  47956. */
  47957. mipmapCount: number;
  47958. /**
  47959. * If the textures format is a known fourCC format
  47960. * @see https://www.fourcc.org/
  47961. */
  47962. isFourCC: boolean;
  47963. /**
  47964. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47965. */
  47966. isRGB: boolean;
  47967. /**
  47968. * If the texture is a lumincance format
  47969. */
  47970. isLuminance: boolean;
  47971. /**
  47972. * If this is a cube texture
  47973. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47974. */
  47975. isCube: boolean;
  47976. /**
  47977. * If the texture is a compressed format eg. FOURCC_DXT1
  47978. */
  47979. isCompressed: boolean;
  47980. /**
  47981. * The dxgiFormat of the texture
  47982. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47983. */
  47984. dxgiFormat: number;
  47985. /**
  47986. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47987. */
  47988. textureType: number;
  47989. /**
  47990. * Sphericle polynomial created for the dds texture
  47991. */
  47992. sphericalPolynomial?: SphericalPolynomial;
  47993. }
  47994. /**
  47995. * Class used to provide DDS decompression tools
  47996. */
  47997. export class DDSTools {
  47998. /**
  47999. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48000. */
  48001. static StoreLODInAlphaChannel: boolean;
  48002. /**
  48003. * Gets DDS information from an array buffer
  48004. * @param arrayBuffer defines the array buffer to read data from
  48005. * @returns the DDS information
  48006. */
  48007. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48008. private static _FloatView;
  48009. private static _Int32View;
  48010. private static _ToHalfFloat;
  48011. private static _FromHalfFloat;
  48012. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48013. private static _GetHalfFloatRGBAArrayBuffer;
  48014. private static _GetFloatRGBAArrayBuffer;
  48015. private static _GetFloatAsUIntRGBAArrayBuffer;
  48016. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48017. private static _GetRGBAArrayBuffer;
  48018. private static _ExtractLongWordOrder;
  48019. private static _GetRGBArrayBuffer;
  48020. private static _GetLuminanceArrayBuffer;
  48021. /**
  48022. * Uploads DDS Levels to a Babylon Texture
  48023. * @hidden
  48024. */
  48025. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48026. }
  48027. interface ThinEngine {
  48028. /**
  48029. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48030. * @param rootUrl defines the url where the file to load is located
  48031. * @param scene defines the current scene
  48032. * @param lodScale defines scale to apply to the mip map selection
  48033. * @param lodOffset defines offset to apply to the mip map selection
  48034. * @param onLoad defines an optional callback raised when the texture is loaded
  48035. * @param onError defines an optional callback raised if there is an issue to load the texture
  48036. * @param format defines the format of the data
  48037. * @param forcedExtension defines the extension to use to pick the right loader
  48038. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48039. * @returns the cube texture as an InternalTexture
  48040. */
  48041. 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;
  48042. }
  48043. }
  48044. declare module BABYLON {
  48045. /**
  48046. * Implementation of the DDS Texture Loader.
  48047. * @hidden
  48048. */
  48049. export class _DDSTextureLoader implements IInternalTextureLoader {
  48050. /**
  48051. * Defines wether the loader supports cascade loading the different faces.
  48052. */
  48053. readonly supportCascades: boolean;
  48054. /**
  48055. * This returns if the loader support the current file information.
  48056. * @param extension defines the file extension of the file being loaded
  48057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48058. * @param fallback defines the fallback internal texture if any
  48059. * @param isBase64 defines whether the texture is encoded as a base64
  48060. * @param isBuffer defines whether the texture data are stored as a buffer
  48061. * @returns true if the loader can load the specified file
  48062. */
  48063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48064. /**
  48065. * Transform the url before loading if required.
  48066. * @param rootUrl the url of the texture
  48067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48068. * @returns the transformed texture
  48069. */
  48070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48071. /**
  48072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48073. * @param rootUrl the url of the texture
  48074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48075. * @returns the fallback texture
  48076. */
  48077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48078. /**
  48079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48080. * @param data contains the texture data
  48081. * @param texture defines the BabylonJS internal texture
  48082. * @param createPolynomials will be true if polynomials have been requested
  48083. * @param onLoad defines the callback to trigger once the texture is ready
  48084. * @param onError defines the callback to trigger in case of error
  48085. */
  48086. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48087. /**
  48088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48089. * @param data contains the texture data
  48090. * @param texture defines the BabylonJS internal texture
  48091. * @param callback defines the method to call once ready to upload
  48092. */
  48093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48094. }
  48095. }
  48096. declare module BABYLON {
  48097. /**
  48098. * Implementation of the ENV Texture Loader.
  48099. * @hidden
  48100. */
  48101. export class _ENVTextureLoader implements IInternalTextureLoader {
  48102. /**
  48103. * Defines wether the loader supports cascade loading the different faces.
  48104. */
  48105. readonly supportCascades: boolean;
  48106. /**
  48107. * This returns if the loader support the current file information.
  48108. * @param extension defines the file extension of the file being loaded
  48109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48110. * @param fallback defines the fallback internal texture if any
  48111. * @param isBase64 defines whether the texture is encoded as a base64
  48112. * @param isBuffer defines whether the texture data are stored as a buffer
  48113. * @returns true if the loader can load the specified file
  48114. */
  48115. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48116. /**
  48117. * Transform the url before loading if required.
  48118. * @param rootUrl the url of the texture
  48119. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48120. * @returns the transformed texture
  48121. */
  48122. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48123. /**
  48124. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48125. * @param rootUrl the url of the texture
  48126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48127. * @returns the fallback texture
  48128. */
  48129. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48130. /**
  48131. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48132. * @param data contains the texture data
  48133. * @param texture defines the BabylonJS internal texture
  48134. * @param createPolynomials will be true if polynomials have been requested
  48135. * @param onLoad defines the callback to trigger once the texture is ready
  48136. * @param onError defines the callback to trigger in case of error
  48137. */
  48138. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48139. /**
  48140. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48141. * @param data contains the texture data
  48142. * @param texture defines the BabylonJS internal texture
  48143. * @param callback defines the method to call once ready to upload
  48144. */
  48145. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48146. }
  48147. }
  48148. declare module BABYLON {
  48149. /**
  48150. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48151. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48152. */
  48153. export class KhronosTextureContainer {
  48154. /** contents of the KTX container file */
  48155. arrayBuffer: any;
  48156. private static HEADER_LEN;
  48157. private static COMPRESSED_2D;
  48158. private static COMPRESSED_3D;
  48159. private static TEX_2D;
  48160. private static TEX_3D;
  48161. /**
  48162. * Gets the openGL type
  48163. */
  48164. glType: number;
  48165. /**
  48166. * Gets the openGL type size
  48167. */
  48168. glTypeSize: number;
  48169. /**
  48170. * Gets the openGL format
  48171. */
  48172. glFormat: number;
  48173. /**
  48174. * Gets the openGL internal format
  48175. */
  48176. glInternalFormat: number;
  48177. /**
  48178. * Gets the base internal format
  48179. */
  48180. glBaseInternalFormat: number;
  48181. /**
  48182. * Gets image width in pixel
  48183. */
  48184. pixelWidth: number;
  48185. /**
  48186. * Gets image height in pixel
  48187. */
  48188. pixelHeight: number;
  48189. /**
  48190. * Gets image depth in pixels
  48191. */
  48192. pixelDepth: number;
  48193. /**
  48194. * Gets the number of array elements
  48195. */
  48196. numberOfArrayElements: number;
  48197. /**
  48198. * Gets the number of faces
  48199. */
  48200. numberOfFaces: number;
  48201. /**
  48202. * Gets the number of mipmap levels
  48203. */
  48204. numberOfMipmapLevels: number;
  48205. /**
  48206. * Gets the bytes of key value data
  48207. */
  48208. bytesOfKeyValueData: number;
  48209. /**
  48210. * Gets the load type
  48211. */
  48212. loadType: number;
  48213. /**
  48214. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48215. */
  48216. isInvalid: boolean;
  48217. /**
  48218. * Creates a new KhronosTextureContainer
  48219. * @param arrayBuffer contents of the KTX container file
  48220. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48221. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48222. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48223. */
  48224. constructor(
  48225. /** contents of the KTX container file */
  48226. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48227. /**
  48228. * Uploads KTX content to a Babylon Texture.
  48229. * It is assumed that the texture has already been created & is currently bound
  48230. * @hidden
  48231. */
  48232. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48233. private _upload2DCompressedLevels;
  48234. }
  48235. }
  48236. declare module BABYLON {
  48237. /**
  48238. * Implementation of the KTX Texture Loader.
  48239. * @hidden
  48240. */
  48241. export class _KTXTextureLoader implements IInternalTextureLoader {
  48242. /**
  48243. * Defines wether the loader supports cascade loading the different faces.
  48244. */
  48245. readonly supportCascades: boolean;
  48246. /**
  48247. * This returns if the loader support the current file information.
  48248. * @param extension defines the file extension of the file being loaded
  48249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48250. * @param fallback defines the fallback internal texture if any
  48251. * @param isBase64 defines whether the texture is encoded as a base64
  48252. * @param isBuffer defines whether the texture data are stored as a buffer
  48253. * @returns true if the loader can load the specified file
  48254. */
  48255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48256. /**
  48257. * Transform the url before loading if required.
  48258. * @param rootUrl the url of the texture
  48259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48260. * @returns the transformed texture
  48261. */
  48262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48263. /**
  48264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48265. * @param rootUrl the url of the texture
  48266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48267. * @returns the fallback texture
  48268. */
  48269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48270. /**
  48271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48272. * @param data contains the texture data
  48273. * @param texture defines the BabylonJS internal texture
  48274. * @param createPolynomials will be true if polynomials have been requested
  48275. * @param onLoad defines the callback to trigger once the texture is ready
  48276. * @param onError defines the callback to trigger in case of error
  48277. */
  48278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48279. /**
  48280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48281. * @param data contains the texture data
  48282. * @param texture defines the BabylonJS internal texture
  48283. * @param callback defines the method to call once ready to upload
  48284. */
  48285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48286. }
  48287. }
  48288. declare module BABYLON {
  48289. /**
  48290. * Options for the default xr helper
  48291. */
  48292. export class WebXRDefaultExperienceOptions {
  48293. /**
  48294. * Floor meshes that should be used for teleporting
  48295. */
  48296. floorMeshes: Array<AbstractMesh>;
  48297. /**
  48298. * Enable or disable default UI to enter XR
  48299. */
  48300. disableDefaultUI: boolean;
  48301. }
  48302. /**
  48303. * Default experience which provides a similar setup to the previous webVRExperience
  48304. */
  48305. export class WebXRDefaultExperience {
  48306. /**
  48307. * Base experience
  48308. */
  48309. baseExperience: WebXRExperienceHelper;
  48310. /**
  48311. * Input experience extension
  48312. */
  48313. input: WebXRInput;
  48314. /**
  48315. * Loads the controller models
  48316. */
  48317. controllerModelLoader: WebXRControllerModelLoader;
  48318. /**
  48319. * Enables laser pointer and selection
  48320. */
  48321. pointerSelection: WebXRControllerPointerSelection;
  48322. /**
  48323. * Enables teleportation
  48324. */
  48325. teleportation: WebXRControllerTeleportation;
  48326. /**
  48327. * Enables ui for enetering/exiting xr
  48328. */
  48329. enterExitUI: WebXREnterExitUI;
  48330. /**
  48331. * Default target xr should render to
  48332. */
  48333. renderTarget: WebXRRenderTarget;
  48334. /**
  48335. * Creates the default xr experience
  48336. * @param scene scene
  48337. * @param options options for basic configuration
  48338. * @returns resulting WebXRDefaultExperience
  48339. */
  48340. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48341. private constructor();
  48342. /**
  48343. * DIsposes of the experience helper
  48344. */
  48345. dispose(): void;
  48346. }
  48347. }
  48348. declare module BABYLON {
  48349. /** @hidden */
  48350. export var _forceSceneHelpersToBundle: boolean;
  48351. interface Scene {
  48352. /**
  48353. * Creates a default light for the scene.
  48354. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48355. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48356. */
  48357. createDefaultLight(replace?: boolean): void;
  48358. /**
  48359. * Creates a default camera for the scene.
  48360. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48361. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48362. * @param replace has default false, when true replaces the active camera in the scene
  48363. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48364. */
  48365. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48366. /**
  48367. * Creates a default camera and a default light.
  48368. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48369. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48370. * @param replace has the default false, when true replaces the active camera/light in the scene
  48371. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48372. */
  48373. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48374. /**
  48375. * Creates a new sky box
  48376. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48377. * @param environmentTexture defines the texture to use as environment texture
  48378. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48379. * @param scale defines the overall scale of the skybox
  48380. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48381. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48382. * @returns a new mesh holding the sky box
  48383. */
  48384. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48385. /**
  48386. * Creates a new environment
  48387. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48388. * @param options defines the options you can use to configure the environment
  48389. * @returns the new EnvironmentHelper
  48390. */
  48391. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48392. /**
  48393. * Creates a new VREXperienceHelper
  48394. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48395. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48396. * @returns a new VREXperienceHelper
  48397. */
  48398. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48399. /**
  48400. * Creates a new WebXRDefaultExperience
  48401. * @see http://doc.babylonjs.com/how_to/webxr
  48402. * @param options experience options
  48403. * @returns a promise for a new WebXRDefaultExperience
  48404. */
  48405. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48406. }
  48407. }
  48408. declare module BABYLON {
  48409. /**
  48410. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48411. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48412. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48413. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48414. */
  48415. export class VideoDome extends TransformNode {
  48416. /**
  48417. * Define the video source as a Monoscopic panoramic 360 video.
  48418. */
  48419. static readonly MODE_MONOSCOPIC: number;
  48420. /**
  48421. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48422. */
  48423. static readonly MODE_TOPBOTTOM: number;
  48424. /**
  48425. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48426. */
  48427. static readonly MODE_SIDEBYSIDE: number;
  48428. private _halfDome;
  48429. private _useDirectMapping;
  48430. /**
  48431. * The video texture being displayed on the sphere
  48432. */
  48433. protected _videoTexture: VideoTexture;
  48434. /**
  48435. * Gets the video texture being displayed on the sphere
  48436. */
  48437. readonly videoTexture: VideoTexture;
  48438. /**
  48439. * The skybox material
  48440. */
  48441. protected _material: BackgroundMaterial;
  48442. /**
  48443. * The surface used for the skybox
  48444. */
  48445. protected _mesh: Mesh;
  48446. /**
  48447. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48448. */
  48449. private _halfDomeMask;
  48450. /**
  48451. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48452. * Also see the options.resolution property.
  48453. */
  48454. fovMultiplier: number;
  48455. private _videoMode;
  48456. /**
  48457. * Gets or set the current video mode for the video. It can be:
  48458. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48459. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48460. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48461. */
  48462. videoMode: number;
  48463. /**
  48464. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48465. *
  48466. */
  48467. /**
  48468. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48469. */
  48470. halfDome: boolean;
  48471. /**
  48472. * Oberserver used in Stereoscopic VR Mode.
  48473. */
  48474. private _onBeforeCameraRenderObserver;
  48475. /**
  48476. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48477. * @param name Element's name, child elements will append suffixes for their own names.
  48478. * @param urlsOrVideo defines the url(s) or the video element to use
  48479. * @param options An object containing optional or exposed sub element properties
  48480. */
  48481. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48482. resolution?: number;
  48483. clickToPlay?: boolean;
  48484. autoPlay?: boolean;
  48485. loop?: boolean;
  48486. size?: number;
  48487. poster?: string;
  48488. faceForward?: boolean;
  48489. useDirectMapping?: boolean;
  48490. halfDomeMode?: boolean;
  48491. }, scene: Scene);
  48492. private _changeVideoMode;
  48493. /**
  48494. * Releases resources associated with this node.
  48495. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48496. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48497. */
  48498. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48499. }
  48500. }
  48501. declare module BABYLON {
  48502. /**
  48503. * This class can be used to get instrumentation data from a Babylon engine
  48504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48505. */
  48506. export class EngineInstrumentation implements IDisposable {
  48507. /**
  48508. * Define the instrumented engine.
  48509. */
  48510. engine: Engine;
  48511. private _captureGPUFrameTime;
  48512. private _gpuFrameTimeToken;
  48513. private _gpuFrameTime;
  48514. private _captureShaderCompilationTime;
  48515. private _shaderCompilationTime;
  48516. private _onBeginFrameObserver;
  48517. private _onEndFrameObserver;
  48518. private _onBeforeShaderCompilationObserver;
  48519. private _onAfterShaderCompilationObserver;
  48520. /**
  48521. * Gets the perf counter used for GPU frame time
  48522. */
  48523. readonly gpuFrameTimeCounter: PerfCounter;
  48524. /**
  48525. * Gets the GPU frame time capture status
  48526. */
  48527. /**
  48528. * Enable or disable the GPU frame time capture
  48529. */
  48530. captureGPUFrameTime: boolean;
  48531. /**
  48532. * Gets the perf counter used for shader compilation time
  48533. */
  48534. readonly shaderCompilationTimeCounter: PerfCounter;
  48535. /**
  48536. * Gets the shader compilation time capture status
  48537. */
  48538. /**
  48539. * Enable or disable the shader compilation time capture
  48540. */
  48541. captureShaderCompilationTime: boolean;
  48542. /**
  48543. * Instantiates a new engine instrumentation.
  48544. * This class can be used to get instrumentation data from a Babylon engine
  48545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48546. * @param engine Defines the engine to instrument
  48547. */
  48548. constructor(
  48549. /**
  48550. * Define the instrumented engine.
  48551. */
  48552. engine: Engine);
  48553. /**
  48554. * Dispose and release associated resources.
  48555. */
  48556. dispose(): void;
  48557. }
  48558. }
  48559. declare module BABYLON {
  48560. /**
  48561. * This class can be used to get instrumentation data from a Babylon engine
  48562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48563. */
  48564. export class SceneInstrumentation implements IDisposable {
  48565. /**
  48566. * Defines the scene to instrument
  48567. */
  48568. scene: Scene;
  48569. private _captureActiveMeshesEvaluationTime;
  48570. private _activeMeshesEvaluationTime;
  48571. private _captureRenderTargetsRenderTime;
  48572. private _renderTargetsRenderTime;
  48573. private _captureFrameTime;
  48574. private _frameTime;
  48575. private _captureRenderTime;
  48576. private _renderTime;
  48577. private _captureInterFrameTime;
  48578. private _interFrameTime;
  48579. private _captureParticlesRenderTime;
  48580. private _particlesRenderTime;
  48581. private _captureSpritesRenderTime;
  48582. private _spritesRenderTime;
  48583. private _capturePhysicsTime;
  48584. private _physicsTime;
  48585. private _captureAnimationsTime;
  48586. private _animationsTime;
  48587. private _captureCameraRenderTime;
  48588. private _cameraRenderTime;
  48589. private _onBeforeActiveMeshesEvaluationObserver;
  48590. private _onAfterActiveMeshesEvaluationObserver;
  48591. private _onBeforeRenderTargetsRenderObserver;
  48592. private _onAfterRenderTargetsRenderObserver;
  48593. private _onAfterRenderObserver;
  48594. private _onBeforeDrawPhaseObserver;
  48595. private _onAfterDrawPhaseObserver;
  48596. private _onBeforeAnimationsObserver;
  48597. private _onBeforeParticlesRenderingObserver;
  48598. private _onAfterParticlesRenderingObserver;
  48599. private _onBeforeSpritesRenderingObserver;
  48600. private _onAfterSpritesRenderingObserver;
  48601. private _onBeforePhysicsObserver;
  48602. private _onAfterPhysicsObserver;
  48603. private _onAfterAnimationsObserver;
  48604. private _onBeforeCameraRenderObserver;
  48605. private _onAfterCameraRenderObserver;
  48606. /**
  48607. * Gets the perf counter used for active meshes evaluation time
  48608. */
  48609. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48610. /**
  48611. * Gets the active meshes evaluation time capture status
  48612. */
  48613. /**
  48614. * Enable or disable the active meshes evaluation time capture
  48615. */
  48616. captureActiveMeshesEvaluationTime: boolean;
  48617. /**
  48618. * Gets the perf counter used for render targets render time
  48619. */
  48620. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48621. /**
  48622. * Gets the render targets render time capture status
  48623. */
  48624. /**
  48625. * Enable or disable the render targets render time capture
  48626. */
  48627. captureRenderTargetsRenderTime: boolean;
  48628. /**
  48629. * Gets the perf counter used for particles render time
  48630. */
  48631. readonly particlesRenderTimeCounter: PerfCounter;
  48632. /**
  48633. * Gets the particles render time capture status
  48634. */
  48635. /**
  48636. * Enable or disable the particles render time capture
  48637. */
  48638. captureParticlesRenderTime: boolean;
  48639. /**
  48640. * Gets the perf counter used for sprites render time
  48641. */
  48642. readonly spritesRenderTimeCounter: PerfCounter;
  48643. /**
  48644. * Gets the sprites render time capture status
  48645. */
  48646. /**
  48647. * Enable or disable the sprites render time capture
  48648. */
  48649. captureSpritesRenderTime: boolean;
  48650. /**
  48651. * Gets the perf counter used for physics time
  48652. */
  48653. readonly physicsTimeCounter: PerfCounter;
  48654. /**
  48655. * Gets the physics time capture status
  48656. */
  48657. /**
  48658. * Enable or disable the physics time capture
  48659. */
  48660. capturePhysicsTime: boolean;
  48661. /**
  48662. * Gets the perf counter used for animations time
  48663. */
  48664. readonly animationsTimeCounter: PerfCounter;
  48665. /**
  48666. * Gets the animations time capture status
  48667. */
  48668. /**
  48669. * Enable or disable the animations time capture
  48670. */
  48671. captureAnimationsTime: boolean;
  48672. /**
  48673. * Gets the perf counter used for frame time capture
  48674. */
  48675. readonly frameTimeCounter: PerfCounter;
  48676. /**
  48677. * Gets the frame time capture status
  48678. */
  48679. /**
  48680. * Enable or disable the frame time capture
  48681. */
  48682. captureFrameTime: boolean;
  48683. /**
  48684. * Gets the perf counter used for inter-frames time capture
  48685. */
  48686. readonly interFrameTimeCounter: PerfCounter;
  48687. /**
  48688. * Gets the inter-frames time capture status
  48689. */
  48690. /**
  48691. * Enable or disable the inter-frames time capture
  48692. */
  48693. captureInterFrameTime: boolean;
  48694. /**
  48695. * Gets the perf counter used for render time capture
  48696. */
  48697. readonly renderTimeCounter: PerfCounter;
  48698. /**
  48699. * Gets the render time capture status
  48700. */
  48701. /**
  48702. * Enable or disable the render time capture
  48703. */
  48704. captureRenderTime: boolean;
  48705. /**
  48706. * Gets the perf counter used for camera render time capture
  48707. */
  48708. readonly cameraRenderTimeCounter: PerfCounter;
  48709. /**
  48710. * Gets the camera render time capture status
  48711. */
  48712. /**
  48713. * Enable or disable the camera render time capture
  48714. */
  48715. captureCameraRenderTime: boolean;
  48716. /**
  48717. * Gets the perf counter used for draw calls
  48718. */
  48719. readonly drawCallsCounter: PerfCounter;
  48720. /**
  48721. * Instantiates a new scene instrumentation.
  48722. * This class can be used to get instrumentation data from a Babylon engine
  48723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48724. * @param scene Defines the scene to instrument
  48725. */
  48726. constructor(
  48727. /**
  48728. * Defines the scene to instrument
  48729. */
  48730. scene: Scene);
  48731. /**
  48732. * Dispose and release associated resources.
  48733. */
  48734. dispose(): void;
  48735. }
  48736. }
  48737. declare module BABYLON {
  48738. /** @hidden */
  48739. export var glowMapGenerationPixelShader: {
  48740. name: string;
  48741. shader: string;
  48742. };
  48743. }
  48744. declare module BABYLON {
  48745. /** @hidden */
  48746. export var glowMapGenerationVertexShader: {
  48747. name: string;
  48748. shader: string;
  48749. };
  48750. }
  48751. declare module BABYLON {
  48752. /**
  48753. * Effect layer options. This helps customizing the behaviour
  48754. * of the effect layer.
  48755. */
  48756. export interface IEffectLayerOptions {
  48757. /**
  48758. * Multiplication factor apply to the canvas size to compute the render target size
  48759. * used to generated the objects (the smaller the faster).
  48760. */
  48761. mainTextureRatio: number;
  48762. /**
  48763. * Enforces a fixed size texture to ensure effect stability across devices.
  48764. */
  48765. mainTextureFixedSize?: number;
  48766. /**
  48767. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48768. */
  48769. alphaBlendingMode: number;
  48770. /**
  48771. * The camera attached to the layer.
  48772. */
  48773. camera: Nullable<Camera>;
  48774. /**
  48775. * The rendering group to draw the layer in.
  48776. */
  48777. renderingGroupId: number;
  48778. }
  48779. /**
  48780. * The effect layer Helps adding post process effect blended with the main pass.
  48781. *
  48782. * This can be for instance use to generate glow or higlight effects on the scene.
  48783. *
  48784. * The effect layer class can not be used directly and is intented to inherited from to be
  48785. * customized per effects.
  48786. */
  48787. export abstract class EffectLayer {
  48788. private _vertexBuffers;
  48789. private _indexBuffer;
  48790. private _cachedDefines;
  48791. private _effectLayerMapGenerationEffect;
  48792. private _effectLayerOptions;
  48793. private _mergeEffect;
  48794. protected _scene: Scene;
  48795. protected _engine: Engine;
  48796. protected _maxSize: number;
  48797. protected _mainTextureDesiredSize: ISize;
  48798. protected _mainTexture: RenderTargetTexture;
  48799. protected _shouldRender: boolean;
  48800. protected _postProcesses: PostProcess[];
  48801. protected _textures: BaseTexture[];
  48802. protected _emissiveTextureAndColor: {
  48803. texture: Nullable<BaseTexture>;
  48804. color: Color4;
  48805. };
  48806. /**
  48807. * The name of the layer
  48808. */
  48809. name: string;
  48810. /**
  48811. * The clear color of the texture used to generate the glow map.
  48812. */
  48813. neutralColor: Color4;
  48814. /**
  48815. * Specifies wether the highlight layer is enabled or not.
  48816. */
  48817. isEnabled: boolean;
  48818. /**
  48819. * Gets the camera attached to the layer.
  48820. */
  48821. readonly camera: Nullable<Camera>;
  48822. /**
  48823. * Gets the rendering group id the layer should render in.
  48824. */
  48825. renderingGroupId: number;
  48826. /**
  48827. * An event triggered when the effect layer has been disposed.
  48828. */
  48829. onDisposeObservable: Observable<EffectLayer>;
  48830. /**
  48831. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48832. */
  48833. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48834. /**
  48835. * An event triggered when the generated texture is being merged in the scene.
  48836. */
  48837. onBeforeComposeObservable: Observable<EffectLayer>;
  48838. /**
  48839. * An event triggered when the mesh is rendered into the effect render target.
  48840. */
  48841. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  48842. /**
  48843. * An event triggered after the mesh has been rendered into the effect render target.
  48844. */
  48845. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  48846. /**
  48847. * An event triggered when the generated texture has been merged in the scene.
  48848. */
  48849. onAfterComposeObservable: Observable<EffectLayer>;
  48850. /**
  48851. * An event triggered when the efffect layer changes its size.
  48852. */
  48853. onSizeChangedObservable: Observable<EffectLayer>;
  48854. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48855. /**
  48856. * Instantiates a new effect Layer and references it in the scene.
  48857. * @param name The name of the layer
  48858. * @param scene The scene to use the layer in
  48859. */
  48860. constructor(
  48861. /** The Friendly of the effect in the scene */
  48862. name: string, scene: Scene);
  48863. /**
  48864. * Get the effect name of the layer.
  48865. * @return The effect name
  48866. */
  48867. abstract getEffectName(): string;
  48868. /**
  48869. * Checks for the readiness of the element composing the layer.
  48870. * @param subMesh the mesh to check for
  48871. * @param useInstances specify wether or not to use instances to render the mesh
  48872. * @return true if ready otherwise, false
  48873. */
  48874. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48875. /**
  48876. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48877. * @returns true if the effect requires stencil during the main canvas render pass.
  48878. */
  48879. abstract needStencil(): boolean;
  48880. /**
  48881. * Create the merge effect. This is the shader use to blit the information back
  48882. * to the main canvas at the end of the scene rendering.
  48883. * @returns The effect containing the shader used to merge the effect on the main canvas
  48884. */
  48885. protected abstract _createMergeEffect(): Effect;
  48886. /**
  48887. * Creates the render target textures and post processes used in the effect layer.
  48888. */
  48889. protected abstract _createTextureAndPostProcesses(): void;
  48890. /**
  48891. * Implementation specific of rendering the generating effect on the main canvas.
  48892. * @param effect The effect used to render through
  48893. */
  48894. protected abstract _internalRender(effect: Effect): void;
  48895. /**
  48896. * Sets the required values for both the emissive texture and and the main color.
  48897. */
  48898. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48899. /**
  48900. * Free any resources and references associated to a mesh.
  48901. * Internal use
  48902. * @param mesh The mesh to free.
  48903. */
  48904. abstract _disposeMesh(mesh: Mesh): void;
  48905. /**
  48906. * Serializes this layer (Glow or Highlight for example)
  48907. * @returns a serialized layer object
  48908. */
  48909. abstract serialize?(): any;
  48910. /**
  48911. * Initializes the effect layer with the required options.
  48912. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48913. */
  48914. protected _init(options: Partial<IEffectLayerOptions>): void;
  48915. /**
  48916. * Generates the index buffer of the full screen quad blending to the main canvas.
  48917. */
  48918. private _generateIndexBuffer;
  48919. /**
  48920. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48921. */
  48922. private _generateVertexBuffer;
  48923. /**
  48924. * Sets the main texture desired size which is the closest power of two
  48925. * of the engine canvas size.
  48926. */
  48927. private _setMainTextureSize;
  48928. /**
  48929. * Creates the main texture for the effect layer.
  48930. */
  48931. protected _createMainTexture(): void;
  48932. /**
  48933. * Adds specific effects defines.
  48934. * @param defines The defines to add specifics to.
  48935. */
  48936. protected _addCustomEffectDefines(defines: string[]): void;
  48937. /**
  48938. * Checks for the readiness of the element composing the layer.
  48939. * @param subMesh the mesh to check for
  48940. * @param useInstances specify wether or not to use instances to render the mesh
  48941. * @param emissiveTexture the associated emissive texture used to generate the glow
  48942. * @return true if ready otherwise, false
  48943. */
  48944. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48945. /**
  48946. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48947. */
  48948. render(): void;
  48949. /**
  48950. * Determine if a given mesh will be used in the current effect.
  48951. * @param mesh mesh to test
  48952. * @returns true if the mesh will be used
  48953. */
  48954. hasMesh(mesh: AbstractMesh): boolean;
  48955. /**
  48956. * Returns true if the layer contains information to display, otherwise false.
  48957. * @returns true if the glow layer should be rendered
  48958. */
  48959. shouldRender(): boolean;
  48960. /**
  48961. * Returns true if the mesh should render, otherwise false.
  48962. * @param mesh The mesh to render
  48963. * @returns true if it should render otherwise false
  48964. */
  48965. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48966. /**
  48967. * Returns true if the mesh can be rendered, otherwise false.
  48968. * @param mesh The mesh to render
  48969. * @param material The material used on the mesh
  48970. * @returns true if it can be rendered otherwise false
  48971. */
  48972. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48973. /**
  48974. * Returns true if the mesh should render, otherwise false.
  48975. * @param mesh The mesh to render
  48976. * @returns true if it should render otherwise false
  48977. */
  48978. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48979. /**
  48980. * Renders the submesh passed in parameter to the generation map.
  48981. */
  48982. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48983. /**
  48984. * Defines wether the current material of the mesh should be use to render the effect.
  48985. * @param mesh defines the current mesh to render
  48986. */
  48987. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  48988. /**
  48989. * Rebuild the required buffers.
  48990. * @hidden Internal use only.
  48991. */ private _rebuild(): void;
  48992. /**
  48993. * Dispose only the render target textures and post process.
  48994. */
  48995. private _disposeTextureAndPostProcesses;
  48996. /**
  48997. * Dispose the highlight layer and free resources.
  48998. */
  48999. dispose(): void;
  49000. /**
  49001. * Gets the class name of the effect layer
  49002. * @returns the string with the class name of the effect layer
  49003. */
  49004. getClassName(): string;
  49005. /**
  49006. * Creates an effect layer from parsed effect layer data
  49007. * @param parsedEffectLayer defines effect layer data
  49008. * @param scene defines the current scene
  49009. * @param rootUrl defines the root URL containing the effect layer information
  49010. * @returns a parsed effect Layer
  49011. */
  49012. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49013. }
  49014. }
  49015. declare module BABYLON {
  49016. interface AbstractScene {
  49017. /**
  49018. * The list of effect layers (highlights/glow) added to the scene
  49019. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49020. * @see http://doc.babylonjs.com/how_to/glow_layer
  49021. */
  49022. effectLayers: Array<EffectLayer>;
  49023. /**
  49024. * Removes the given effect layer from this scene.
  49025. * @param toRemove defines the effect layer to remove
  49026. * @returns the index of the removed effect layer
  49027. */
  49028. removeEffectLayer(toRemove: EffectLayer): number;
  49029. /**
  49030. * Adds the given effect layer to this scene
  49031. * @param newEffectLayer defines the effect layer to add
  49032. */
  49033. addEffectLayer(newEffectLayer: EffectLayer): void;
  49034. }
  49035. /**
  49036. * Defines the layer scene component responsible to manage any effect layers
  49037. * in a given scene.
  49038. */
  49039. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49040. /**
  49041. * The component name helpfull to identify the component in the list of scene components.
  49042. */
  49043. readonly name: string;
  49044. /**
  49045. * The scene the component belongs to.
  49046. */
  49047. scene: Scene;
  49048. private _engine;
  49049. private _renderEffects;
  49050. private _needStencil;
  49051. private _previousStencilState;
  49052. /**
  49053. * Creates a new instance of the component for the given scene
  49054. * @param scene Defines the scene to register the component in
  49055. */
  49056. constructor(scene: Scene);
  49057. /**
  49058. * Registers the component in a given scene
  49059. */
  49060. register(): void;
  49061. /**
  49062. * Rebuilds the elements related to this component in case of
  49063. * context lost for instance.
  49064. */
  49065. rebuild(): void;
  49066. /**
  49067. * Serializes the component data to the specified json object
  49068. * @param serializationObject The object to serialize to
  49069. */
  49070. serialize(serializationObject: any): void;
  49071. /**
  49072. * Adds all the elements from the container to the scene
  49073. * @param container the container holding the elements
  49074. */
  49075. addFromContainer(container: AbstractScene): void;
  49076. /**
  49077. * Removes all the elements in the container from the scene
  49078. * @param container contains the elements to remove
  49079. * @param dispose if the removed element should be disposed (default: false)
  49080. */
  49081. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49082. /**
  49083. * Disposes the component and the associated ressources.
  49084. */
  49085. dispose(): void;
  49086. private _isReadyForMesh;
  49087. private _renderMainTexture;
  49088. private _setStencil;
  49089. private _setStencilBack;
  49090. private _draw;
  49091. private _drawCamera;
  49092. private _drawRenderingGroup;
  49093. }
  49094. }
  49095. declare module BABYLON {
  49096. /** @hidden */
  49097. export var glowMapMergePixelShader: {
  49098. name: string;
  49099. shader: string;
  49100. };
  49101. }
  49102. declare module BABYLON {
  49103. /** @hidden */
  49104. export var glowMapMergeVertexShader: {
  49105. name: string;
  49106. shader: string;
  49107. };
  49108. }
  49109. declare module BABYLON {
  49110. interface AbstractScene {
  49111. /**
  49112. * Return a the first highlight layer of the scene with a given name.
  49113. * @param name The name of the highlight layer to look for.
  49114. * @return The highlight layer if found otherwise null.
  49115. */
  49116. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49117. }
  49118. /**
  49119. * Glow layer options. This helps customizing the behaviour
  49120. * of the glow layer.
  49121. */
  49122. export interface IGlowLayerOptions {
  49123. /**
  49124. * Multiplication factor apply to the canvas size to compute the render target size
  49125. * used to generated the glowing objects (the smaller the faster).
  49126. */
  49127. mainTextureRatio: number;
  49128. /**
  49129. * Enforces a fixed size texture to ensure resize independant blur.
  49130. */
  49131. mainTextureFixedSize?: number;
  49132. /**
  49133. * How big is the kernel of the blur texture.
  49134. */
  49135. blurKernelSize: number;
  49136. /**
  49137. * The camera attached to the layer.
  49138. */
  49139. camera: Nullable<Camera>;
  49140. /**
  49141. * Enable MSAA by chosing the number of samples.
  49142. */
  49143. mainTextureSamples?: number;
  49144. /**
  49145. * The rendering group to draw the layer in.
  49146. */
  49147. renderingGroupId: number;
  49148. }
  49149. /**
  49150. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49151. *
  49152. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  49153. *
  49154. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49155. */
  49156. export class GlowLayer extends EffectLayer {
  49157. /**
  49158. * Effect Name of the layer.
  49159. */
  49160. static readonly EffectName: string;
  49161. /**
  49162. * The default blur kernel size used for the glow.
  49163. */
  49164. static DefaultBlurKernelSize: number;
  49165. /**
  49166. * The default texture size ratio used for the glow.
  49167. */
  49168. static DefaultTextureRatio: number;
  49169. /**
  49170. * Sets the kernel size of the blur.
  49171. */
  49172. /**
  49173. * Gets the kernel size of the blur.
  49174. */
  49175. blurKernelSize: number;
  49176. /**
  49177. * Sets the glow intensity.
  49178. */
  49179. /**
  49180. * Gets the glow intensity.
  49181. */
  49182. intensity: number;
  49183. private _options;
  49184. private _intensity;
  49185. private _horizontalBlurPostprocess1;
  49186. private _verticalBlurPostprocess1;
  49187. private _horizontalBlurPostprocess2;
  49188. private _verticalBlurPostprocess2;
  49189. private _blurTexture1;
  49190. private _blurTexture2;
  49191. private _postProcesses1;
  49192. private _postProcesses2;
  49193. private _includedOnlyMeshes;
  49194. private _excludedMeshes;
  49195. private _meshesUsingTheirOwnMaterials;
  49196. /**
  49197. * Callback used to let the user override the color selection on a per mesh basis
  49198. */
  49199. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49200. /**
  49201. * Callback used to let the user override the texture selection on a per mesh basis
  49202. */
  49203. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49204. /**
  49205. * Instantiates a new glow Layer and references it to the scene.
  49206. * @param name The name of the layer
  49207. * @param scene The scene to use the layer in
  49208. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49209. */
  49210. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49211. /**
  49212. * Get the effect name of the layer.
  49213. * @return The effect name
  49214. */
  49215. getEffectName(): string;
  49216. /**
  49217. * Create the merge effect. This is the shader use to blit the information back
  49218. * to the main canvas at the end of the scene rendering.
  49219. */
  49220. protected _createMergeEffect(): Effect;
  49221. /**
  49222. * Creates the render target textures and post processes used in the glow layer.
  49223. */
  49224. protected _createTextureAndPostProcesses(): void;
  49225. /**
  49226. * Checks for the readiness of the element composing the layer.
  49227. * @param subMesh the mesh to check for
  49228. * @param useInstances specify wether or not to use instances to render the mesh
  49229. * @param emissiveTexture the associated emissive texture used to generate the glow
  49230. * @return true if ready otherwise, false
  49231. */
  49232. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49233. /**
  49234. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49235. */
  49236. needStencil(): boolean;
  49237. /**
  49238. * Returns true if the mesh can be rendered, otherwise false.
  49239. * @param mesh The mesh to render
  49240. * @param material The material used on the mesh
  49241. * @returns true if it can be rendered otherwise false
  49242. */
  49243. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49244. /**
  49245. * Implementation specific of rendering the generating effect on the main canvas.
  49246. * @param effect The effect used to render through
  49247. */
  49248. protected _internalRender(effect: Effect): void;
  49249. /**
  49250. * Sets the required values for both the emissive texture and and the main color.
  49251. */
  49252. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49253. /**
  49254. * Returns true if the mesh should render, otherwise false.
  49255. * @param mesh The mesh to render
  49256. * @returns true if it should render otherwise false
  49257. */
  49258. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49259. /**
  49260. * Adds specific effects defines.
  49261. * @param defines The defines to add specifics to.
  49262. */
  49263. protected _addCustomEffectDefines(defines: string[]): void;
  49264. /**
  49265. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49266. * @param mesh The mesh to exclude from the glow layer
  49267. */
  49268. addExcludedMesh(mesh: Mesh): void;
  49269. /**
  49270. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49271. * @param mesh The mesh to remove
  49272. */
  49273. removeExcludedMesh(mesh: Mesh): void;
  49274. /**
  49275. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49276. * @param mesh The mesh to include in the glow layer
  49277. */
  49278. addIncludedOnlyMesh(mesh: Mesh): void;
  49279. /**
  49280. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49281. * @param mesh The mesh to remove
  49282. */
  49283. removeIncludedOnlyMesh(mesh: Mesh): void;
  49284. /**
  49285. * Determine if a given mesh will be used in the glow layer
  49286. * @param mesh The mesh to test
  49287. * @returns true if the mesh will be highlighted by the current glow layer
  49288. */
  49289. hasMesh(mesh: AbstractMesh): boolean;
  49290. /**
  49291. * Defines wether the current material of the mesh should be use to render the effect.
  49292. * @param mesh defines the current mesh to render
  49293. */
  49294. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  49295. /**
  49296. * Add a mesh to be rendered through its own material and not with emissive only.
  49297. * @param mesh The mesh for which we need to use its material
  49298. */
  49299. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  49300. /**
  49301. * Remove a mesh from being rendered through its own material and not with emissive only.
  49302. * @param mesh The mesh for which we need to not use its material
  49303. */
  49304. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  49305. /**
  49306. * Free any resources and references associated to a mesh.
  49307. * Internal use
  49308. * @param mesh The mesh to free.
  49309. * @hidden
  49310. */ private _disposeMesh(mesh: Mesh): void;
  49311. /**
  49312. * Gets the class name of the effect layer
  49313. * @returns the string with the class name of the effect layer
  49314. */
  49315. getClassName(): string;
  49316. /**
  49317. * Serializes this glow layer
  49318. * @returns a serialized glow layer object
  49319. */
  49320. serialize(): any;
  49321. /**
  49322. * Creates a Glow Layer from parsed glow layer data
  49323. * @param parsedGlowLayer defines glow layer data
  49324. * @param scene defines the current scene
  49325. * @param rootUrl defines the root URL containing the glow layer information
  49326. * @returns a parsed Glow Layer
  49327. */
  49328. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49329. }
  49330. }
  49331. declare module BABYLON {
  49332. /** @hidden */
  49333. export var glowBlurPostProcessPixelShader: {
  49334. name: string;
  49335. shader: string;
  49336. };
  49337. }
  49338. declare module BABYLON {
  49339. interface AbstractScene {
  49340. /**
  49341. * Return a the first highlight layer of the scene with a given name.
  49342. * @param name The name of the highlight layer to look for.
  49343. * @return The highlight layer if found otherwise null.
  49344. */
  49345. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49346. }
  49347. /**
  49348. * Highlight layer options. This helps customizing the behaviour
  49349. * of the highlight layer.
  49350. */
  49351. export interface IHighlightLayerOptions {
  49352. /**
  49353. * Multiplication factor apply to the canvas size to compute the render target size
  49354. * used to generated the glowing objects (the smaller the faster).
  49355. */
  49356. mainTextureRatio: number;
  49357. /**
  49358. * Enforces a fixed size texture to ensure resize independant blur.
  49359. */
  49360. mainTextureFixedSize?: number;
  49361. /**
  49362. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49363. * of the picture to blur (the smaller the faster).
  49364. */
  49365. blurTextureSizeRatio: number;
  49366. /**
  49367. * How big in texel of the blur texture is the vertical blur.
  49368. */
  49369. blurVerticalSize: number;
  49370. /**
  49371. * How big in texel of the blur texture is the horizontal blur.
  49372. */
  49373. blurHorizontalSize: number;
  49374. /**
  49375. * Alpha blending mode used to apply the blur. Default is combine.
  49376. */
  49377. alphaBlendingMode: number;
  49378. /**
  49379. * The camera attached to the layer.
  49380. */
  49381. camera: Nullable<Camera>;
  49382. /**
  49383. * Should we display highlight as a solid stroke?
  49384. */
  49385. isStroke?: boolean;
  49386. /**
  49387. * The rendering group to draw the layer in.
  49388. */
  49389. renderingGroupId: number;
  49390. }
  49391. /**
  49392. * The highlight layer Helps adding a glow effect around a mesh.
  49393. *
  49394. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  49395. * glowy meshes to your scene.
  49396. *
  49397. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49398. */
  49399. export class HighlightLayer extends EffectLayer {
  49400. name: string;
  49401. /**
  49402. * Effect Name of the highlight layer.
  49403. */
  49404. static readonly EffectName: string;
  49405. /**
  49406. * The neutral color used during the preparation of the glow effect.
  49407. * This is black by default as the blend operation is a blend operation.
  49408. */
  49409. static NeutralColor: Color4;
  49410. /**
  49411. * Stencil value used for glowing meshes.
  49412. */
  49413. static GlowingMeshStencilReference: number;
  49414. /**
  49415. * Stencil value used for the other meshes in the scene.
  49416. */
  49417. static NormalMeshStencilReference: number;
  49418. /**
  49419. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49420. */
  49421. innerGlow: boolean;
  49422. /**
  49423. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49424. */
  49425. outerGlow: boolean;
  49426. /**
  49427. * Specifies the horizontal size of the blur.
  49428. */
  49429. /**
  49430. * Gets the horizontal size of the blur.
  49431. */
  49432. blurHorizontalSize: number;
  49433. /**
  49434. * Specifies the vertical size of the blur.
  49435. */
  49436. /**
  49437. * Gets the vertical size of the blur.
  49438. */
  49439. blurVerticalSize: number;
  49440. /**
  49441. * An event triggered when the highlight layer is being blurred.
  49442. */
  49443. onBeforeBlurObservable: Observable<HighlightLayer>;
  49444. /**
  49445. * An event triggered when the highlight layer has been blurred.
  49446. */
  49447. onAfterBlurObservable: Observable<HighlightLayer>;
  49448. private _instanceGlowingMeshStencilReference;
  49449. private _options;
  49450. private _downSamplePostprocess;
  49451. private _horizontalBlurPostprocess;
  49452. private _verticalBlurPostprocess;
  49453. private _blurTexture;
  49454. private _meshes;
  49455. private _excludedMeshes;
  49456. /**
  49457. * Instantiates a new highlight Layer and references it to the scene..
  49458. * @param name The name of the layer
  49459. * @param scene The scene to use the layer in
  49460. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49461. */
  49462. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49463. /**
  49464. * Get the effect name of the layer.
  49465. * @return The effect name
  49466. */
  49467. getEffectName(): string;
  49468. /**
  49469. * Create the merge effect. This is the shader use to blit the information back
  49470. * to the main canvas at the end of the scene rendering.
  49471. */
  49472. protected _createMergeEffect(): Effect;
  49473. /**
  49474. * Creates the render target textures and post processes used in the highlight layer.
  49475. */
  49476. protected _createTextureAndPostProcesses(): void;
  49477. /**
  49478. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49479. */
  49480. needStencil(): boolean;
  49481. /**
  49482. * Checks for the readiness of the element composing the layer.
  49483. * @param subMesh the mesh to check for
  49484. * @param useInstances specify wether or not to use instances to render the mesh
  49485. * @param emissiveTexture the associated emissive texture used to generate the glow
  49486. * @return true if ready otherwise, false
  49487. */
  49488. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49489. /**
  49490. * Implementation specific of rendering the generating effect on the main canvas.
  49491. * @param effect The effect used to render through
  49492. */
  49493. protected _internalRender(effect: Effect): void;
  49494. /**
  49495. * Returns true if the layer contains information to display, otherwise false.
  49496. */
  49497. shouldRender(): boolean;
  49498. /**
  49499. * Returns true if the mesh should render, otherwise false.
  49500. * @param mesh The mesh to render
  49501. * @returns true if it should render otherwise false
  49502. */
  49503. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49504. /**
  49505. * Sets the required values for both the emissive texture and and the main color.
  49506. */
  49507. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49508. /**
  49509. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49510. * @param mesh The mesh to exclude from the highlight layer
  49511. */
  49512. addExcludedMesh(mesh: Mesh): void;
  49513. /**
  49514. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49515. * @param mesh The mesh to highlight
  49516. */
  49517. removeExcludedMesh(mesh: Mesh): void;
  49518. /**
  49519. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49520. * @param mesh mesh to test
  49521. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49522. */
  49523. hasMesh(mesh: AbstractMesh): boolean;
  49524. /**
  49525. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49526. * @param mesh The mesh to highlight
  49527. * @param color The color of the highlight
  49528. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49529. */
  49530. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49531. /**
  49532. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49533. * @param mesh The mesh to highlight
  49534. */
  49535. removeMesh(mesh: Mesh): void;
  49536. /**
  49537. * Force the stencil to the normal expected value for none glowing parts
  49538. */
  49539. private _defaultStencilReference;
  49540. /**
  49541. * Free any resources and references associated to a mesh.
  49542. * Internal use
  49543. * @param mesh The mesh to free.
  49544. * @hidden
  49545. */ private _disposeMesh(mesh: Mesh): void;
  49546. /**
  49547. * Dispose the highlight layer and free resources.
  49548. */
  49549. dispose(): void;
  49550. /**
  49551. * Gets the class name of the effect layer
  49552. * @returns the string with the class name of the effect layer
  49553. */
  49554. getClassName(): string;
  49555. /**
  49556. * Serializes this Highlight layer
  49557. * @returns a serialized Highlight layer object
  49558. */
  49559. serialize(): any;
  49560. /**
  49561. * Creates a Highlight layer from parsed Highlight layer data
  49562. * @param parsedHightlightLayer defines the Highlight layer data
  49563. * @param scene defines the current scene
  49564. * @param rootUrl defines the root URL containing the Highlight layer information
  49565. * @returns a parsed Highlight layer
  49566. */
  49567. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49568. }
  49569. }
  49570. declare module BABYLON {
  49571. interface AbstractScene {
  49572. /**
  49573. * The list of layers (background and foreground) of the scene
  49574. */
  49575. layers: Array<Layer>;
  49576. }
  49577. /**
  49578. * Defines the layer scene component responsible to manage any layers
  49579. * in a given scene.
  49580. */
  49581. export class LayerSceneComponent implements ISceneComponent {
  49582. /**
  49583. * The component name helpfull to identify the component in the list of scene components.
  49584. */
  49585. readonly name: string;
  49586. /**
  49587. * The scene the component belongs to.
  49588. */
  49589. scene: Scene;
  49590. private _engine;
  49591. /**
  49592. * Creates a new instance of the component for the given scene
  49593. * @param scene Defines the scene to register the component in
  49594. */
  49595. constructor(scene: Scene);
  49596. /**
  49597. * Registers the component in a given scene
  49598. */
  49599. register(): void;
  49600. /**
  49601. * Rebuilds the elements related to this component in case of
  49602. * context lost for instance.
  49603. */
  49604. rebuild(): void;
  49605. /**
  49606. * Disposes the component and the associated ressources.
  49607. */
  49608. dispose(): void;
  49609. private _draw;
  49610. private _drawCameraPredicate;
  49611. private _drawCameraBackground;
  49612. private _drawCameraForeground;
  49613. private _drawRenderTargetPredicate;
  49614. private _drawRenderTargetBackground;
  49615. private _drawRenderTargetForeground;
  49616. /**
  49617. * Adds all the elements from the container to the scene
  49618. * @param container the container holding the elements
  49619. */
  49620. addFromContainer(container: AbstractScene): void;
  49621. /**
  49622. * Removes all the elements in the container from the scene
  49623. * @param container contains the elements to remove
  49624. * @param dispose if the removed element should be disposed (default: false)
  49625. */
  49626. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49627. }
  49628. }
  49629. declare module BABYLON {
  49630. /** @hidden */
  49631. export var layerPixelShader: {
  49632. name: string;
  49633. shader: string;
  49634. };
  49635. }
  49636. declare module BABYLON {
  49637. /** @hidden */
  49638. export var layerVertexShader: {
  49639. name: string;
  49640. shader: string;
  49641. };
  49642. }
  49643. declare module BABYLON {
  49644. /**
  49645. * This represents a full screen 2d layer.
  49646. * This can be useful to display a picture in the background of your scene for instance.
  49647. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49648. */
  49649. export class Layer {
  49650. /**
  49651. * Define the name of the layer.
  49652. */
  49653. name: string;
  49654. /**
  49655. * Define the texture the layer should display.
  49656. */
  49657. texture: Nullable<Texture>;
  49658. /**
  49659. * Is the layer in background or foreground.
  49660. */
  49661. isBackground: boolean;
  49662. /**
  49663. * Define the color of the layer (instead of texture).
  49664. */
  49665. color: Color4;
  49666. /**
  49667. * Define the scale of the layer in order to zoom in out of the texture.
  49668. */
  49669. scale: Vector2;
  49670. /**
  49671. * Define an offset for the layer in order to shift the texture.
  49672. */
  49673. offset: Vector2;
  49674. /**
  49675. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49676. */
  49677. alphaBlendingMode: number;
  49678. /**
  49679. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49680. * Alpha test will not mix with the background color in case of transparency.
  49681. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49682. */
  49683. alphaTest: boolean;
  49684. /**
  49685. * Define a mask to restrict the layer to only some of the scene cameras.
  49686. */
  49687. layerMask: number;
  49688. /**
  49689. * Define the list of render target the layer is visible into.
  49690. */
  49691. renderTargetTextures: RenderTargetTexture[];
  49692. /**
  49693. * Define if the layer is only used in renderTarget or if it also
  49694. * renders in the main frame buffer of the canvas.
  49695. */
  49696. renderOnlyInRenderTargetTextures: boolean;
  49697. private _scene;
  49698. private _vertexBuffers;
  49699. private _indexBuffer;
  49700. private _effect;
  49701. private _alphaTestEffect;
  49702. /**
  49703. * An event triggered when the layer is disposed.
  49704. */
  49705. onDisposeObservable: Observable<Layer>;
  49706. private _onDisposeObserver;
  49707. /**
  49708. * Back compatibility with callback before the onDisposeObservable existed.
  49709. * The set callback will be triggered when the layer has been disposed.
  49710. */
  49711. onDispose: () => void;
  49712. /**
  49713. * An event triggered before rendering the scene
  49714. */
  49715. onBeforeRenderObservable: Observable<Layer>;
  49716. private _onBeforeRenderObserver;
  49717. /**
  49718. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49719. * The set callback will be triggered just before rendering the layer.
  49720. */
  49721. onBeforeRender: () => void;
  49722. /**
  49723. * An event triggered after rendering the scene
  49724. */
  49725. onAfterRenderObservable: Observable<Layer>;
  49726. private _onAfterRenderObserver;
  49727. /**
  49728. * Back compatibility with callback before the onAfterRenderObservable existed.
  49729. * The set callback will be triggered just after rendering the layer.
  49730. */
  49731. onAfterRender: () => void;
  49732. /**
  49733. * Instantiates a new layer.
  49734. * This represents a full screen 2d layer.
  49735. * This can be useful to display a picture in the background of your scene for instance.
  49736. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49737. * @param name Define the name of the layer in the scene
  49738. * @param imgUrl Define the url of the texture to display in the layer
  49739. * @param scene Define the scene the layer belongs to
  49740. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49741. * @param color Defines a color for the layer
  49742. */
  49743. constructor(
  49744. /**
  49745. * Define the name of the layer.
  49746. */
  49747. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49748. private _createIndexBuffer;
  49749. /** @hidden */ private _rebuild(): void;
  49750. /**
  49751. * Renders the layer in the scene.
  49752. */
  49753. render(): void;
  49754. /**
  49755. * Disposes and releases the associated ressources.
  49756. */
  49757. dispose(): void;
  49758. }
  49759. }
  49760. declare module BABYLON {
  49761. /** @hidden */
  49762. export var lensFlarePixelShader: {
  49763. name: string;
  49764. shader: string;
  49765. };
  49766. }
  49767. declare module BABYLON {
  49768. /** @hidden */
  49769. export var lensFlareVertexShader: {
  49770. name: string;
  49771. shader: string;
  49772. };
  49773. }
  49774. declare module BABYLON {
  49775. /**
  49776. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49777. * It is usually composed of several `lensFlare`.
  49778. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49779. */
  49780. export class LensFlareSystem {
  49781. /**
  49782. * Define the name of the lens flare system
  49783. */
  49784. name: string;
  49785. /**
  49786. * List of lens flares used in this system.
  49787. */
  49788. lensFlares: LensFlare[];
  49789. /**
  49790. * Define a limit from the border the lens flare can be visible.
  49791. */
  49792. borderLimit: number;
  49793. /**
  49794. * Define a viewport border we do not want to see the lens flare in.
  49795. */
  49796. viewportBorder: number;
  49797. /**
  49798. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49799. */
  49800. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49801. /**
  49802. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49803. */
  49804. layerMask: number;
  49805. /**
  49806. * Define the id of the lens flare system in the scene.
  49807. * (equal to name by default)
  49808. */
  49809. id: string;
  49810. private _scene;
  49811. private _emitter;
  49812. private _vertexBuffers;
  49813. private _indexBuffer;
  49814. private _effect;
  49815. private _positionX;
  49816. private _positionY;
  49817. private _isEnabled;
  49818. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49819. /**
  49820. * Instantiates a lens flare system.
  49821. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49822. * It is usually composed of several `lensFlare`.
  49823. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49824. * @param name Define the name of the lens flare system in the scene
  49825. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49826. * @param scene Define the scene the lens flare system belongs to
  49827. */
  49828. constructor(
  49829. /**
  49830. * Define the name of the lens flare system
  49831. */
  49832. name: string, emitter: any, scene: Scene);
  49833. /**
  49834. * Define if the lens flare system is enabled.
  49835. */
  49836. isEnabled: boolean;
  49837. /**
  49838. * Get the scene the effects belongs to.
  49839. * @returns the scene holding the lens flare system
  49840. */
  49841. getScene(): Scene;
  49842. /**
  49843. * Get the emitter of the lens flare system.
  49844. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49845. * @returns the emitter of the lens flare system
  49846. */
  49847. getEmitter(): any;
  49848. /**
  49849. * Set the emitter of the lens flare system.
  49850. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49851. * @param newEmitter Define the new emitter of the system
  49852. */
  49853. setEmitter(newEmitter: any): void;
  49854. /**
  49855. * Get the lens flare system emitter position.
  49856. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49857. * @returns the position
  49858. */
  49859. getEmitterPosition(): Vector3;
  49860. /**
  49861. * @hidden
  49862. */
  49863. computeEffectivePosition(globalViewport: Viewport): boolean;
  49864. /** @hidden */ private _isVisible(): boolean;
  49865. /**
  49866. * @hidden
  49867. */
  49868. render(): boolean;
  49869. /**
  49870. * Dispose and release the lens flare with its associated resources.
  49871. */
  49872. dispose(): void;
  49873. /**
  49874. * Parse a lens flare system from a JSON repressentation
  49875. * @param parsedLensFlareSystem Define the JSON to parse
  49876. * @param scene Define the scene the parsed system should be instantiated in
  49877. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49878. * @returns the parsed system
  49879. */
  49880. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49881. /**
  49882. * Serialize the current Lens Flare System into a JSON representation.
  49883. * @returns the serialized JSON
  49884. */
  49885. serialize(): any;
  49886. }
  49887. }
  49888. declare module BABYLON {
  49889. /**
  49890. * This represents one of the lens effect in a `lensFlareSystem`.
  49891. * It controls one of the indiviual texture used in the effect.
  49892. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49893. */
  49894. export class LensFlare {
  49895. /**
  49896. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49897. */
  49898. size: number;
  49899. /**
  49900. * 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.
  49901. */
  49902. position: number;
  49903. /**
  49904. * Define the lens color.
  49905. */
  49906. color: Color3;
  49907. /**
  49908. * Define the lens texture.
  49909. */
  49910. texture: Nullable<Texture>;
  49911. /**
  49912. * Define the alpha mode to render this particular lens.
  49913. */
  49914. alphaMode: number;
  49915. private _system;
  49916. /**
  49917. * Creates a new Lens Flare.
  49918. * This represents one of the lens effect in a `lensFlareSystem`.
  49919. * It controls one of the indiviual texture used in the effect.
  49920. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49921. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49922. * @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.
  49923. * @param color Define the lens color
  49924. * @param imgUrl Define the lens texture url
  49925. * @param system Define the `lensFlareSystem` this flare is part of
  49926. * @returns The newly created Lens Flare
  49927. */
  49928. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49929. /**
  49930. * Instantiates a new Lens Flare.
  49931. * This represents one of the lens effect in a `lensFlareSystem`.
  49932. * It controls one of the indiviual texture used in the effect.
  49933. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49934. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49935. * @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.
  49936. * @param color Define the lens color
  49937. * @param imgUrl Define the lens texture url
  49938. * @param system Define the `lensFlareSystem` this flare is part of
  49939. */
  49940. constructor(
  49941. /**
  49942. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49943. */
  49944. size: number,
  49945. /**
  49946. * 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.
  49947. */
  49948. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49949. /**
  49950. * Dispose and release the lens flare with its associated resources.
  49951. */
  49952. dispose(): void;
  49953. }
  49954. }
  49955. declare module BABYLON {
  49956. interface AbstractScene {
  49957. /**
  49958. * The list of lens flare system added to the scene
  49959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49960. */
  49961. lensFlareSystems: Array<LensFlareSystem>;
  49962. /**
  49963. * Removes the given lens flare system from this scene.
  49964. * @param toRemove The lens flare system to remove
  49965. * @returns The index of the removed lens flare system
  49966. */
  49967. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49968. /**
  49969. * Adds the given lens flare system to this scene
  49970. * @param newLensFlareSystem The lens flare system to add
  49971. */
  49972. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49973. /**
  49974. * Gets a lens flare system using its name
  49975. * @param name defines the name to look for
  49976. * @returns the lens flare system or null if not found
  49977. */
  49978. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49979. /**
  49980. * Gets a lens flare system using its id
  49981. * @param id defines the id to look for
  49982. * @returns the lens flare system or null if not found
  49983. */
  49984. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49985. }
  49986. /**
  49987. * Defines the lens flare scene component responsible to manage any lens flares
  49988. * in a given scene.
  49989. */
  49990. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49991. /**
  49992. * The component name helpfull to identify the component in the list of scene components.
  49993. */
  49994. readonly name: string;
  49995. /**
  49996. * The scene the component belongs to.
  49997. */
  49998. scene: Scene;
  49999. /**
  50000. * Creates a new instance of the component for the given scene
  50001. * @param scene Defines the scene to register the component in
  50002. */
  50003. constructor(scene: Scene);
  50004. /**
  50005. * Registers the component in a given scene
  50006. */
  50007. register(): void;
  50008. /**
  50009. * Rebuilds the elements related to this component in case of
  50010. * context lost for instance.
  50011. */
  50012. rebuild(): void;
  50013. /**
  50014. * Adds all the elements from the container to the scene
  50015. * @param container the container holding the elements
  50016. */
  50017. addFromContainer(container: AbstractScene): void;
  50018. /**
  50019. * Removes all the elements in the container from the scene
  50020. * @param container contains the elements to remove
  50021. * @param dispose if the removed element should be disposed (default: false)
  50022. */
  50023. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50024. /**
  50025. * Serializes the component data to the specified json object
  50026. * @param serializationObject The object to serialize to
  50027. */
  50028. serialize(serializationObject: any): void;
  50029. /**
  50030. * Disposes the component and the associated ressources.
  50031. */
  50032. dispose(): void;
  50033. private _draw;
  50034. }
  50035. }
  50036. declare module BABYLON {
  50037. /**
  50038. * Defines the shadow generator component responsible to manage any shadow generators
  50039. * in a given scene.
  50040. */
  50041. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50042. /**
  50043. * The component name helpfull to identify the component in the list of scene components.
  50044. */
  50045. readonly name: string;
  50046. /**
  50047. * The scene the component belongs to.
  50048. */
  50049. scene: Scene;
  50050. /**
  50051. * Creates a new instance of the component for the given scene
  50052. * @param scene Defines the scene to register the component in
  50053. */
  50054. constructor(scene: Scene);
  50055. /**
  50056. * Registers the component in a given scene
  50057. */
  50058. register(): void;
  50059. /**
  50060. * Rebuilds the elements related to this component in case of
  50061. * context lost for instance.
  50062. */
  50063. rebuild(): void;
  50064. /**
  50065. * Serializes the component data to the specified json object
  50066. * @param serializationObject The object to serialize to
  50067. */
  50068. serialize(serializationObject: any): void;
  50069. /**
  50070. * Adds all the elements from the container to the scene
  50071. * @param container the container holding the elements
  50072. */
  50073. addFromContainer(container: AbstractScene): void;
  50074. /**
  50075. * Removes all the elements in the container from the scene
  50076. * @param container contains the elements to remove
  50077. * @param dispose if the removed element should be disposed (default: false)
  50078. */
  50079. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50080. /**
  50081. * Rebuilds the elements related to this component in case of
  50082. * context lost for instance.
  50083. */
  50084. dispose(): void;
  50085. private _gatherRenderTargets;
  50086. }
  50087. }
  50088. declare module BABYLON {
  50089. /**
  50090. * A point light is a light defined by an unique point in world space.
  50091. * The light is emitted in every direction from this point.
  50092. * A good example of a point light is a standard light bulb.
  50093. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50094. */
  50095. export class PointLight extends ShadowLight {
  50096. private _shadowAngle;
  50097. /**
  50098. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50099. * This specifies what angle the shadow will use to be created.
  50100. *
  50101. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50102. */
  50103. /**
  50104. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50105. * This specifies what angle the shadow will use to be created.
  50106. *
  50107. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50108. */
  50109. shadowAngle: number;
  50110. /**
  50111. * Gets the direction if it has been set.
  50112. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50113. */
  50114. /**
  50115. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50116. */
  50117. direction: Vector3;
  50118. /**
  50119. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50120. * A PointLight emits the light in every direction.
  50121. * It can cast shadows.
  50122. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50123. * ```javascript
  50124. * var pointLight = new PointLight("pl", camera.position, scene);
  50125. * ```
  50126. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50127. * @param name The light friendly name
  50128. * @param position The position of the point light in the scene
  50129. * @param scene The scene the lights belongs to
  50130. */
  50131. constructor(name: string, position: Vector3, scene: Scene);
  50132. /**
  50133. * Returns the string "PointLight"
  50134. * @returns the class name
  50135. */
  50136. getClassName(): string;
  50137. /**
  50138. * Returns the integer 0.
  50139. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50140. */
  50141. getTypeID(): number;
  50142. /**
  50143. * Specifies wether or not the shadowmap should be a cube texture.
  50144. * @returns true if the shadowmap needs to be a cube texture.
  50145. */
  50146. needCube(): boolean;
  50147. /**
  50148. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50149. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50150. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50151. */
  50152. getShadowDirection(faceIndex?: number): Vector3;
  50153. /**
  50154. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50155. * - fov = PI / 2
  50156. * - aspect ratio : 1.0
  50157. * - z-near and far equal to the active camera minZ and maxZ.
  50158. * Returns the PointLight.
  50159. */
  50160. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50161. protected _buildUniformLayout(): void;
  50162. /**
  50163. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50164. * @param effect The effect to update
  50165. * @param lightIndex The index of the light in the effect to update
  50166. * @returns The point light
  50167. */
  50168. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50169. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50170. /**
  50171. * Prepares the list of defines specific to the light type.
  50172. * @param defines the list of defines
  50173. * @param lightIndex defines the index of the light for the effect
  50174. */
  50175. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50176. }
  50177. }
  50178. declare module BABYLON {
  50179. /**
  50180. * Header information of HDR texture files.
  50181. */
  50182. export interface HDRInfo {
  50183. /**
  50184. * The height of the texture in pixels.
  50185. */
  50186. height: number;
  50187. /**
  50188. * The width of the texture in pixels.
  50189. */
  50190. width: number;
  50191. /**
  50192. * The index of the beginning of the data in the binary file.
  50193. */
  50194. dataPosition: number;
  50195. }
  50196. /**
  50197. * This groups tools to convert HDR texture to native colors array.
  50198. */
  50199. export class HDRTools {
  50200. private static Ldexp;
  50201. private static Rgbe2float;
  50202. private static readStringLine;
  50203. /**
  50204. * Reads header information from an RGBE texture stored in a native array.
  50205. * More information on this format are available here:
  50206. * https://en.wikipedia.org/wiki/RGBE_image_format
  50207. *
  50208. * @param uint8array The binary file stored in native array.
  50209. * @return The header information.
  50210. */
  50211. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50212. /**
  50213. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50214. * This RGBE texture needs to store the information as a panorama.
  50215. *
  50216. * More information on this format are available here:
  50217. * https://en.wikipedia.org/wiki/RGBE_image_format
  50218. *
  50219. * @param buffer The binary file stored in an array buffer.
  50220. * @param size The expected size of the extracted cubemap.
  50221. * @return The Cube Map information.
  50222. */
  50223. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50224. /**
  50225. * Returns the pixels data extracted from an RGBE texture.
  50226. * This pixels will be stored left to right up to down in the R G B order in one array.
  50227. *
  50228. * More information on this format are available here:
  50229. * https://en.wikipedia.org/wiki/RGBE_image_format
  50230. *
  50231. * @param uint8array The binary file stored in an array buffer.
  50232. * @param hdrInfo The header information of the file.
  50233. * @return The pixels data in RGB right to left up to down order.
  50234. */
  50235. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50236. private static RGBE_ReadPixels_RLE;
  50237. }
  50238. }
  50239. declare module BABYLON {
  50240. /**
  50241. * This represents a texture coming from an HDR input.
  50242. *
  50243. * The only supported format is currently panorama picture stored in RGBE format.
  50244. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50245. */
  50246. export class HDRCubeTexture extends BaseTexture {
  50247. private static _facesMapping;
  50248. private _generateHarmonics;
  50249. private _noMipmap;
  50250. private _textureMatrix;
  50251. private _size;
  50252. private _onLoad;
  50253. private _onError;
  50254. /**
  50255. * The texture URL.
  50256. */
  50257. url: string;
  50258. /**
  50259. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50260. */
  50261. coordinatesMode: number;
  50262. protected _isBlocking: boolean;
  50263. /**
  50264. * Sets wether or not the texture is blocking during loading.
  50265. */
  50266. /**
  50267. * Gets wether or not the texture is blocking during loading.
  50268. */
  50269. isBlocking: boolean;
  50270. protected _rotationY: number;
  50271. /**
  50272. * Sets texture matrix rotation angle around Y axis in radians.
  50273. */
  50274. /**
  50275. * Gets texture matrix rotation angle around Y axis radians.
  50276. */
  50277. rotationY: number;
  50278. /**
  50279. * Gets or sets the center of the bounding box associated with the cube texture
  50280. * It must define where the camera used to render the texture was set
  50281. */
  50282. boundingBoxPosition: Vector3;
  50283. private _boundingBoxSize;
  50284. /**
  50285. * Gets or sets the size of the bounding box associated with the cube texture
  50286. * When defined, the cubemap will switch to local mode
  50287. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50288. * @example https://www.babylonjs-playground.com/#RNASML
  50289. */
  50290. boundingBoxSize: Vector3;
  50291. /**
  50292. * Instantiates an HDRTexture from the following parameters.
  50293. *
  50294. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50295. * @param scene The scene the texture will be used in
  50296. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50297. * @param noMipmap Forces to not generate the mipmap if true
  50298. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50299. * @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)
  50300. * @param reserved Reserved flag for internal use.
  50301. */
  50302. 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>);
  50303. /**
  50304. * Get the current class name of the texture useful for serialization or dynamic coding.
  50305. * @returns "HDRCubeTexture"
  50306. */
  50307. getClassName(): string;
  50308. /**
  50309. * Occurs when the file is raw .hdr file.
  50310. */
  50311. private loadTexture;
  50312. clone(): HDRCubeTexture;
  50313. delayLoad(): void;
  50314. /**
  50315. * Get the texture reflection matrix used to rotate/transform the reflection.
  50316. * @returns the reflection matrix
  50317. */
  50318. getReflectionTextureMatrix(): Matrix;
  50319. /**
  50320. * Set the texture reflection matrix used to rotate/transform the reflection.
  50321. * @param value Define the reflection matrix to set
  50322. */
  50323. setReflectionTextureMatrix(value: Matrix): void;
  50324. /**
  50325. * Parses a JSON representation of an HDR Texture in order to create the texture
  50326. * @param parsedTexture Define the JSON representation
  50327. * @param scene Define the scene the texture should be created in
  50328. * @param rootUrl Define the root url in case we need to load relative dependencies
  50329. * @returns the newly created texture after parsing
  50330. */
  50331. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50332. serialize(): any;
  50333. }
  50334. }
  50335. declare module BABYLON {
  50336. /**
  50337. * Class used to control physics engine
  50338. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50339. */
  50340. export class PhysicsEngine implements IPhysicsEngine {
  50341. private _physicsPlugin;
  50342. /**
  50343. * Global value used to control the smallest number supported by the simulation
  50344. */
  50345. static Epsilon: number;
  50346. private _impostors;
  50347. private _joints;
  50348. /**
  50349. * Gets the gravity vector used by the simulation
  50350. */
  50351. gravity: Vector3;
  50352. /**
  50353. * Factory used to create the default physics plugin.
  50354. * @returns The default physics plugin
  50355. */
  50356. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50357. /**
  50358. * Creates a new Physics Engine
  50359. * @param gravity defines the gravity vector used by the simulation
  50360. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50361. */
  50362. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50363. /**
  50364. * Sets the gravity vector used by the simulation
  50365. * @param gravity defines the gravity vector to use
  50366. */
  50367. setGravity(gravity: Vector3): void;
  50368. /**
  50369. * Set the time step of the physics engine.
  50370. * Default is 1/60.
  50371. * To slow it down, enter 1/600 for example.
  50372. * To speed it up, 1/30
  50373. * @param newTimeStep defines the new timestep to apply to this world.
  50374. */
  50375. setTimeStep(newTimeStep?: number): void;
  50376. /**
  50377. * Get the time step of the physics engine.
  50378. * @returns the current time step
  50379. */
  50380. getTimeStep(): number;
  50381. /**
  50382. * Release all resources
  50383. */
  50384. dispose(): void;
  50385. /**
  50386. * Gets the name of the current physics plugin
  50387. * @returns the name of the plugin
  50388. */
  50389. getPhysicsPluginName(): string;
  50390. /**
  50391. * Adding a new impostor for the impostor tracking.
  50392. * This will be done by the impostor itself.
  50393. * @param impostor the impostor to add
  50394. */
  50395. addImpostor(impostor: PhysicsImpostor): void;
  50396. /**
  50397. * Remove an impostor from the engine.
  50398. * This impostor and its mesh will not longer be updated by the physics engine.
  50399. * @param impostor the impostor to remove
  50400. */
  50401. removeImpostor(impostor: PhysicsImpostor): void;
  50402. /**
  50403. * Add a joint to the physics engine
  50404. * @param mainImpostor defines the main impostor to which the joint is added.
  50405. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50406. * @param joint defines the joint that will connect both impostors.
  50407. */
  50408. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50409. /**
  50410. * Removes a joint from the simulation
  50411. * @param mainImpostor defines the impostor used with the joint
  50412. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50413. * @param joint defines the joint to remove
  50414. */
  50415. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50416. /**
  50417. * Called by the scene. No need to call it.
  50418. * @param delta defines the timespam between frames
  50419. */ private _step(delta: number): void;
  50420. /**
  50421. * Gets the current plugin used to run the simulation
  50422. * @returns current plugin
  50423. */
  50424. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50425. /**
  50426. * Gets the list of physic impostors
  50427. * @returns an array of PhysicsImpostor
  50428. */
  50429. getImpostors(): Array<PhysicsImpostor>;
  50430. /**
  50431. * Gets the impostor for a physics enabled object
  50432. * @param object defines the object impersonated by the impostor
  50433. * @returns the PhysicsImpostor or null if not found
  50434. */
  50435. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50436. /**
  50437. * Gets the impostor for a physics body object
  50438. * @param body defines physics body used by the impostor
  50439. * @returns the PhysicsImpostor or null if not found
  50440. */
  50441. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50442. /**
  50443. * Does a raycast in the physics world
  50444. * @param from when should the ray start?
  50445. * @param to when should the ray end?
  50446. * @returns PhysicsRaycastResult
  50447. */
  50448. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50449. }
  50450. }
  50451. declare module BABYLON {
  50452. /** @hidden */
  50453. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50454. private _useDeltaForWorldStep;
  50455. world: any;
  50456. name: string;
  50457. private _physicsMaterials;
  50458. private _fixedTimeStep;
  50459. private _cannonRaycastResult;
  50460. private _raycastResult;
  50461. private _physicsBodysToRemoveAfterStep;
  50462. BJSCANNON: any;
  50463. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50464. setGravity(gravity: Vector3): void;
  50465. setTimeStep(timeStep: number): void;
  50466. getTimeStep(): number;
  50467. executeStep(delta: number): void;
  50468. private _removeMarkedPhysicsBodiesFromWorld;
  50469. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50470. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50471. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50472. private _processChildMeshes;
  50473. removePhysicsBody(impostor: PhysicsImpostor): void;
  50474. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50475. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50476. private _addMaterial;
  50477. private _checkWithEpsilon;
  50478. private _createShape;
  50479. private _createHeightmap;
  50480. private _minus90X;
  50481. private _plus90X;
  50482. private _tmpPosition;
  50483. private _tmpDeltaPosition;
  50484. private _tmpUnityRotation;
  50485. private _updatePhysicsBodyTransformation;
  50486. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50487. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50488. isSupported(): boolean;
  50489. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50490. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50491. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50492. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50493. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50494. getBodyMass(impostor: PhysicsImpostor): number;
  50495. getBodyFriction(impostor: PhysicsImpostor): number;
  50496. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50497. getBodyRestitution(impostor: PhysicsImpostor): number;
  50498. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50499. sleepBody(impostor: PhysicsImpostor): void;
  50500. wakeUpBody(impostor: PhysicsImpostor): void;
  50501. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50502. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50503. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50504. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50505. getRadius(impostor: PhysicsImpostor): number;
  50506. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50507. dispose(): void;
  50508. private _extendNamespace;
  50509. /**
  50510. * Does a raycast in the physics world
  50511. * @param from when should the ray start?
  50512. * @param to when should the ray end?
  50513. * @returns PhysicsRaycastResult
  50514. */
  50515. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50516. }
  50517. }
  50518. declare module BABYLON {
  50519. /** @hidden */
  50520. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50521. world: any;
  50522. name: string;
  50523. BJSOIMO: any;
  50524. private _raycastResult;
  50525. constructor(iterations?: number, oimoInjection?: any);
  50526. setGravity(gravity: Vector3): void;
  50527. setTimeStep(timeStep: number): void;
  50528. getTimeStep(): number;
  50529. private _tmpImpostorsArray;
  50530. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50532. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50534. private _tmpPositionVector;
  50535. removePhysicsBody(impostor: PhysicsImpostor): void;
  50536. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50537. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50538. isSupported(): boolean;
  50539. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50540. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50541. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50542. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50543. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50544. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50546. getBodyMass(impostor: PhysicsImpostor): number;
  50547. getBodyFriction(impostor: PhysicsImpostor): number;
  50548. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50549. getBodyRestitution(impostor: PhysicsImpostor): number;
  50550. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50551. sleepBody(impostor: PhysicsImpostor): void;
  50552. wakeUpBody(impostor: PhysicsImpostor): void;
  50553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50554. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50557. getRadius(impostor: PhysicsImpostor): number;
  50558. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50559. dispose(): void;
  50560. /**
  50561. * Does a raycast in the physics world
  50562. * @param from when should the ray start?
  50563. * @param to when should the ray end?
  50564. * @returns PhysicsRaycastResult
  50565. */
  50566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50567. }
  50568. }
  50569. declare module BABYLON {
  50570. /**
  50571. * Class containing static functions to help procedurally build meshes
  50572. */
  50573. export class RibbonBuilder {
  50574. /**
  50575. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50576. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50577. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50578. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50579. * * 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
  50580. * * 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
  50581. * * 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
  50582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50583. * * 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
  50584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50585. * * 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
  50586. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50587. * * 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
  50588. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50590. * @param name defines the name of the mesh
  50591. * @param options defines the options used to create the mesh
  50592. * @param scene defines the hosting scene
  50593. * @returns the ribbon mesh
  50594. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50595. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50596. */
  50597. static CreateRibbon(name: string, options: {
  50598. pathArray: Vector3[][];
  50599. closeArray?: boolean;
  50600. closePath?: boolean;
  50601. offset?: number;
  50602. updatable?: boolean;
  50603. sideOrientation?: number;
  50604. frontUVs?: Vector4;
  50605. backUVs?: Vector4;
  50606. instance?: Mesh;
  50607. invertUV?: boolean;
  50608. uvs?: Vector2[];
  50609. colors?: Color4[];
  50610. }, scene?: Nullable<Scene>): Mesh;
  50611. }
  50612. }
  50613. declare module BABYLON {
  50614. /**
  50615. * Class containing static functions to help procedurally build meshes
  50616. */
  50617. export class ShapeBuilder {
  50618. /**
  50619. * 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.
  50620. * * 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.
  50621. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50622. * * 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.
  50623. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50624. * * 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
  50625. * * 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
  50626. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50628. * * 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
  50629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50631. * @param name defines the name of the mesh
  50632. * @param options defines the options used to create the mesh
  50633. * @param scene defines the hosting scene
  50634. * @returns the extruded shape mesh
  50635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50637. */
  50638. static ExtrudeShape(name: string, options: {
  50639. shape: Vector3[];
  50640. path: Vector3[];
  50641. scale?: number;
  50642. rotation?: number;
  50643. cap?: number;
  50644. updatable?: boolean;
  50645. sideOrientation?: number;
  50646. frontUVs?: Vector4;
  50647. backUVs?: Vector4;
  50648. instance?: Mesh;
  50649. invertUV?: boolean;
  50650. }, scene?: Nullable<Scene>): Mesh;
  50651. /**
  50652. * Creates an custom extruded shape mesh.
  50653. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50654. * * 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.
  50655. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50656. * * 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
  50657. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50658. * * 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
  50659. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50660. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50661. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50662. * * 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
  50663. * * 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
  50664. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50666. * * 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
  50667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50669. * @param name defines the name of the mesh
  50670. * @param options defines the options used to create the mesh
  50671. * @param scene defines the hosting scene
  50672. * @returns the custom extruded shape mesh
  50673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50676. */
  50677. static ExtrudeShapeCustom(name: string, options: {
  50678. shape: Vector3[];
  50679. path: Vector3[];
  50680. scaleFunction?: any;
  50681. rotationFunction?: any;
  50682. ribbonCloseArray?: boolean;
  50683. ribbonClosePath?: boolean;
  50684. cap?: number;
  50685. updatable?: boolean;
  50686. sideOrientation?: number;
  50687. frontUVs?: Vector4;
  50688. backUVs?: Vector4;
  50689. instance?: Mesh;
  50690. invertUV?: boolean;
  50691. }, scene?: Nullable<Scene>): Mesh;
  50692. private static _ExtrudeShapeGeneric;
  50693. }
  50694. }
  50695. declare module BABYLON {
  50696. /**
  50697. * AmmoJS Physics plugin
  50698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50699. * @see https://github.com/kripken/ammo.js/
  50700. */
  50701. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50702. private _useDeltaForWorldStep;
  50703. /**
  50704. * Reference to the Ammo library
  50705. */
  50706. bjsAMMO: any;
  50707. /**
  50708. * Created ammoJS world which physics bodies are added to
  50709. */
  50710. world: any;
  50711. /**
  50712. * Name of the plugin
  50713. */
  50714. name: string;
  50715. private _timeStep;
  50716. private _fixedTimeStep;
  50717. private _maxSteps;
  50718. private _tmpQuaternion;
  50719. private _tmpAmmoTransform;
  50720. private _tmpAmmoQuaternion;
  50721. private _tmpAmmoConcreteContactResultCallback;
  50722. private _collisionConfiguration;
  50723. private _dispatcher;
  50724. private _overlappingPairCache;
  50725. private _solver;
  50726. private _softBodySolver;
  50727. private _tmpAmmoVectorA;
  50728. private _tmpAmmoVectorB;
  50729. private _tmpAmmoVectorC;
  50730. private _tmpAmmoVectorD;
  50731. private _tmpContactCallbackResult;
  50732. private _tmpAmmoVectorRCA;
  50733. private _tmpAmmoVectorRCB;
  50734. private _raycastResult;
  50735. private static readonly DISABLE_COLLISION_FLAG;
  50736. private static readonly KINEMATIC_FLAG;
  50737. private static readonly DISABLE_DEACTIVATION_FLAG;
  50738. /**
  50739. * Initializes the ammoJS plugin
  50740. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50741. * @param ammoInjection can be used to inject your own ammo reference
  50742. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50743. */
  50744. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50745. /**
  50746. * Sets the gravity of the physics world (m/(s^2))
  50747. * @param gravity Gravity to set
  50748. */
  50749. setGravity(gravity: Vector3): void;
  50750. /**
  50751. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50752. * @param timeStep timestep to use in seconds
  50753. */
  50754. setTimeStep(timeStep: number): void;
  50755. /**
  50756. * 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)
  50757. * @param fixedTimeStep fixedTimeStep to use in seconds
  50758. */
  50759. setFixedTimeStep(fixedTimeStep: number): void;
  50760. /**
  50761. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50762. * @param maxSteps the maximum number of steps by the physics engine per frame
  50763. */
  50764. setMaxSteps(maxSteps: number): void;
  50765. /**
  50766. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50767. * @returns the current timestep in seconds
  50768. */
  50769. getTimeStep(): number;
  50770. private _isImpostorInContact;
  50771. private _isImpostorPairInContact;
  50772. private _stepSimulation;
  50773. /**
  50774. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50775. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50776. * After the step the babylon meshes are set to the position of the physics imposters
  50777. * @param delta amount of time to step forward
  50778. * @param impostors array of imposters to update before/after the step
  50779. */
  50780. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50781. /**
  50782. * Update babylon mesh to match physics world object
  50783. * @param impostor imposter to match
  50784. */
  50785. private _afterSoftStep;
  50786. /**
  50787. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50788. * @param impostor imposter to match
  50789. */
  50790. private _ropeStep;
  50791. /**
  50792. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50793. * @param impostor imposter to match
  50794. */
  50795. private _softbodyOrClothStep;
  50796. private _tmpVector;
  50797. private _tmpMatrix;
  50798. /**
  50799. * Applies an impulse on the imposter
  50800. * @param impostor imposter to apply impulse to
  50801. * @param force amount of force to be applied to the imposter
  50802. * @param contactPoint the location to apply the impulse on the imposter
  50803. */
  50804. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50805. /**
  50806. * Applies a force on the imposter
  50807. * @param impostor imposter to apply force
  50808. * @param force amount of force to be applied to the imposter
  50809. * @param contactPoint the location to apply the force on the imposter
  50810. */
  50811. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50812. /**
  50813. * Creates a physics body using the plugin
  50814. * @param impostor the imposter to create the physics body on
  50815. */
  50816. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50817. /**
  50818. * Removes the physics body from the imposter and disposes of the body's memory
  50819. * @param impostor imposter to remove the physics body from
  50820. */
  50821. removePhysicsBody(impostor: PhysicsImpostor): void;
  50822. /**
  50823. * Generates a joint
  50824. * @param impostorJoint the imposter joint to create the joint with
  50825. */
  50826. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50827. /**
  50828. * Removes a joint
  50829. * @param impostorJoint the imposter joint to remove the joint from
  50830. */
  50831. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50832. private _addMeshVerts;
  50833. /**
  50834. * Initialise the soft body vertices to match its object's (mesh) vertices
  50835. * Softbody vertices (nodes) are in world space and to match this
  50836. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50837. * @param impostor to create the softbody for
  50838. */
  50839. private _softVertexData;
  50840. /**
  50841. * Create an impostor's soft body
  50842. * @param impostor to create the softbody for
  50843. */
  50844. private _createSoftbody;
  50845. /**
  50846. * Create cloth for an impostor
  50847. * @param impostor to create the softbody for
  50848. */
  50849. private _createCloth;
  50850. /**
  50851. * Create rope for an impostor
  50852. * @param impostor to create the softbody for
  50853. */
  50854. private _createRope;
  50855. private _addHullVerts;
  50856. private _createShape;
  50857. /**
  50858. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50859. * @param impostor imposter containing the physics body and babylon object
  50860. */
  50861. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50862. /**
  50863. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50864. * @param impostor imposter containing the physics body and babylon object
  50865. * @param newPosition new position
  50866. * @param newRotation new rotation
  50867. */
  50868. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50869. /**
  50870. * If this plugin is supported
  50871. * @returns true if its supported
  50872. */
  50873. isSupported(): boolean;
  50874. /**
  50875. * Sets the linear velocity of the physics body
  50876. * @param impostor imposter to set the velocity on
  50877. * @param velocity velocity to set
  50878. */
  50879. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50880. /**
  50881. * Sets the angular velocity of the physics body
  50882. * @param impostor imposter to set the velocity on
  50883. * @param velocity velocity to set
  50884. */
  50885. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50886. /**
  50887. * gets the linear velocity
  50888. * @param impostor imposter to get linear velocity from
  50889. * @returns linear velocity
  50890. */
  50891. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50892. /**
  50893. * gets the angular velocity
  50894. * @param impostor imposter to get angular velocity from
  50895. * @returns angular velocity
  50896. */
  50897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50898. /**
  50899. * Sets the mass of physics body
  50900. * @param impostor imposter to set the mass on
  50901. * @param mass mass to set
  50902. */
  50903. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50904. /**
  50905. * Gets the mass of the physics body
  50906. * @param impostor imposter to get the mass from
  50907. * @returns mass
  50908. */
  50909. getBodyMass(impostor: PhysicsImpostor): number;
  50910. /**
  50911. * Gets friction of the impostor
  50912. * @param impostor impostor to get friction from
  50913. * @returns friction value
  50914. */
  50915. getBodyFriction(impostor: PhysicsImpostor): number;
  50916. /**
  50917. * Sets friction of the impostor
  50918. * @param impostor impostor to set friction on
  50919. * @param friction friction value
  50920. */
  50921. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50922. /**
  50923. * Gets restitution of the impostor
  50924. * @param impostor impostor to get restitution from
  50925. * @returns restitution value
  50926. */
  50927. getBodyRestitution(impostor: PhysicsImpostor): number;
  50928. /**
  50929. * Sets resitution of the impostor
  50930. * @param impostor impostor to set resitution on
  50931. * @param restitution resitution value
  50932. */
  50933. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50934. /**
  50935. * Gets pressure inside the impostor
  50936. * @param impostor impostor to get pressure from
  50937. * @returns pressure value
  50938. */
  50939. getBodyPressure(impostor: PhysicsImpostor): number;
  50940. /**
  50941. * Sets pressure inside a soft body impostor
  50942. * Cloth and rope must remain 0 pressure
  50943. * @param impostor impostor to set pressure on
  50944. * @param pressure pressure value
  50945. */
  50946. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50947. /**
  50948. * Gets stiffness of the impostor
  50949. * @param impostor impostor to get stiffness from
  50950. * @returns pressure value
  50951. */
  50952. getBodyStiffness(impostor: PhysicsImpostor): number;
  50953. /**
  50954. * Sets stiffness of the impostor
  50955. * @param impostor impostor to set stiffness on
  50956. * @param stiffness stiffness value from 0 to 1
  50957. */
  50958. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50959. /**
  50960. * Gets velocityIterations of the impostor
  50961. * @param impostor impostor to get velocity iterations from
  50962. * @returns velocityIterations value
  50963. */
  50964. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50965. /**
  50966. * Sets velocityIterations of the impostor
  50967. * @param impostor impostor to set velocity iterations on
  50968. * @param velocityIterations velocityIterations value
  50969. */
  50970. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50971. /**
  50972. * Gets positionIterations of the impostor
  50973. * @param impostor impostor to get position iterations from
  50974. * @returns positionIterations value
  50975. */
  50976. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50977. /**
  50978. * Sets positionIterations of the impostor
  50979. * @param impostor impostor to set position on
  50980. * @param positionIterations positionIterations value
  50981. */
  50982. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50983. /**
  50984. * Append an anchor to a cloth object
  50985. * @param impostor is the cloth impostor to add anchor to
  50986. * @param otherImpostor is the rigid impostor to anchor to
  50987. * @param width ratio across width from 0 to 1
  50988. * @param height ratio up height from 0 to 1
  50989. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50990. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50991. */
  50992. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50993. /**
  50994. * Append an hook to a rope object
  50995. * @param impostor is the rope impostor to add hook to
  50996. * @param otherImpostor is the rigid impostor to hook to
  50997. * @param length ratio along the rope from 0 to 1
  50998. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50999. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51000. */
  51001. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51002. /**
  51003. * Sleeps the physics body and stops it from being active
  51004. * @param impostor impostor to sleep
  51005. */
  51006. sleepBody(impostor: PhysicsImpostor): void;
  51007. /**
  51008. * Activates the physics body
  51009. * @param impostor impostor to activate
  51010. */
  51011. wakeUpBody(impostor: PhysicsImpostor): void;
  51012. /**
  51013. * Updates the distance parameters of the joint
  51014. * @param joint joint to update
  51015. * @param maxDistance maximum distance of the joint
  51016. * @param minDistance minimum distance of the joint
  51017. */
  51018. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51019. /**
  51020. * Sets a motor on the joint
  51021. * @param joint joint to set motor on
  51022. * @param speed speed of the motor
  51023. * @param maxForce maximum force of the motor
  51024. * @param motorIndex index of the motor
  51025. */
  51026. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51027. /**
  51028. * Sets the motors limit
  51029. * @param joint joint to set limit on
  51030. * @param upperLimit upper limit
  51031. * @param lowerLimit lower limit
  51032. */
  51033. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51034. /**
  51035. * Syncs the position and rotation of a mesh with the impostor
  51036. * @param mesh mesh to sync
  51037. * @param impostor impostor to update the mesh with
  51038. */
  51039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51040. /**
  51041. * Gets the radius of the impostor
  51042. * @param impostor impostor to get radius from
  51043. * @returns the radius
  51044. */
  51045. getRadius(impostor: PhysicsImpostor): number;
  51046. /**
  51047. * Gets the box size of the impostor
  51048. * @param impostor impostor to get box size from
  51049. * @param result the resulting box size
  51050. */
  51051. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51052. /**
  51053. * Disposes of the impostor
  51054. */
  51055. dispose(): void;
  51056. /**
  51057. * Does a raycast in the physics world
  51058. * @param from when should the ray start?
  51059. * @param to when should the ray end?
  51060. * @returns PhysicsRaycastResult
  51061. */
  51062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51063. }
  51064. }
  51065. declare module BABYLON {
  51066. interface AbstractScene {
  51067. /**
  51068. * The list of reflection probes added to the scene
  51069. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51070. */
  51071. reflectionProbes: Array<ReflectionProbe>;
  51072. /**
  51073. * Removes the given reflection probe from this scene.
  51074. * @param toRemove The reflection probe to remove
  51075. * @returns The index of the removed reflection probe
  51076. */
  51077. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51078. /**
  51079. * Adds the given reflection probe to this scene.
  51080. * @param newReflectionProbe The reflection probe to add
  51081. */
  51082. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51083. }
  51084. /**
  51085. * Class used to generate realtime reflection / refraction cube textures
  51086. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51087. */
  51088. export class ReflectionProbe {
  51089. /** defines the name of the probe */
  51090. name: string;
  51091. private _scene;
  51092. private _renderTargetTexture;
  51093. private _projectionMatrix;
  51094. private _viewMatrix;
  51095. private _target;
  51096. private _add;
  51097. private _attachedMesh;
  51098. private _invertYAxis;
  51099. /** Gets or sets probe position (center of the cube map) */
  51100. position: Vector3;
  51101. /**
  51102. * Creates a new reflection probe
  51103. * @param name defines the name of the probe
  51104. * @param size defines the texture resolution (for each face)
  51105. * @param scene defines the hosting scene
  51106. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51107. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51108. */
  51109. constructor(
  51110. /** defines the name of the probe */
  51111. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51112. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51113. samples: number;
  51114. /** Gets or sets the refresh rate to use (on every frame by default) */
  51115. refreshRate: number;
  51116. /**
  51117. * Gets the hosting scene
  51118. * @returns a Scene
  51119. */
  51120. getScene(): Scene;
  51121. /** Gets the internal CubeTexture used to render to */
  51122. readonly cubeTexture: RenderTargetTexture;
  51123. /** Gets the list of meshes to render */
  51124. readonly renderList: Nullable<AbstractMesh[]>;
  51125. /**
  51126. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51127. * @param mesh defines the mesh to attach to
  51128. */
  51129. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51130. /**
  51131. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51132. * @param renderingGroupId The rendering group id corresponding to its index
  51133. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51134. */
  51135. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51136. /**
  51137. * Clean all associated resources
  51138. */
  51139. dispose(): void;
  51140. /**
  51141. * Converts the reflection probe information to a readable string for debug purpose.
  51142. * @param fullDetails Supports for multiple levels of logging within scene loading
  51143. * @returns the human readable reflection probe info
  51144. */
  51145. toString(fullDetails?: boolean): string;
  51146. /**
  51147. * Get the class name of the relfection probe.
  51148. * @returns "ReflectionProbe"
  51149. */
  51150. getClassName(): string;
  51151. /**
  51152. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51153. * @returns The JSON representation of the texture
  51154. */
  51155. serialize(): any;
  51156. /**
  51157. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51158. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51159. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51160. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51161. * @returns The parsed reflection probe if successful
  51162. */
  51163. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51164. }
  51165. }
  51166. declare module BABYLON {
  51167. /** @hidden */
  51168. export var _BabylonLoaderRegistered: boolean;
  51169. }
  51170. declare module BABYLON {
  51171. /**
  51172. * The Physically based simple base material of BJS.
  51173. *
  51174. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51175. * It is used as the base class for both the specGloss and metalRough conventions.
  51176. */
  51177. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51178. /**
  51179. * Number of Simultaneous lights allowed on the material.
  51180. */
  51181. maxSimultaneousLights: number;
  51182. /**
  51183. * If sets to true, disables all the lights affecting the material.
  51184. */
  51185. disableLighting: boolean;
  51186. /**
  51187. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51188. */
  51189. environmentTexture: BaseTexture;
  51190. /**
  51191. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51192. */
  51193. invertNormalMapX: boolean;
  51194. /**
  51195. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51196. */
  51197. invertNormalMapY: boolean;
  51198. /**
  51199. * Normal map used in the model.
  51200. */
  51201. normalTexture: BaseTexture;
  51202. /**
  51203. * Emissivie color used to self-illuminate the model.
  51204. */
  51205. emissiveColor: Color3;
  51206. /**
  51207. * Emissivie texture used to self-illuminate the model.
  51208. */
  51209. emissiveTexture: BaseTexture;
  51210. /**
  51211. * Occlusion Channel Strenght.
  51212. */
  51213. occlusionStrength: number;
  51214. /**
  51215. * Occlusion Texture of the material (adding extra occlusion effects).
  51216. */
  51217. occlusionTexture: BaseTexture;
  51218. /**
  51219. * Defines the alpha limits in alpha test mode.
  51220. */
  51221. alphaCutOff: number;
  51222. /**
  51223. * Gets the current double sided mode.
  51224. */
  51225. /**
  51226. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51227. */
  51228. doubleSided: boolean;
  51229. /**
  51230. * Stores the pre-calculated light information of a mesh in a texture.
  51231. */
  51232. lightmapTexture: BaseTexture;
  51233. /**
  51234. * If true, the light map contains occlusion information instead of lighting info.
  51235. */
  51236. useLightmapAsShadowmap: boolean;
  51237. /**
  51238. * Instantiates a new PBRMaterial instance.
  51239. *
  51240. * @param name The material name
  51241. * @param scene The scene the material will be use in.
  51242. */
  51243. constructor(name: string, scene: Scene);
  51244. getClassName(): string;
  51245. }
  51246. }
  51247. declare module BABYLON {
  51248. /**
  51249. * The PBR material of BJS following the metal roughness convention.
  51250. *
  51251. * This fits to the PBR convention in the GLTF definition:
  51252. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51253. */
  51254. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51255. /**
  51256. * The base color has two different interpretations depending on the value of metalness.
  51257. * When the material is a metal, the base color is the specific measured reflectance value
  51258. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51259. * of the material.
  51260. */
  51261. baseColor: Color3;
  51262. /**
  51263. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51264. * well as opacity information in the alpha channel.
  51265. */
  51266. baseTexture: BaseTexture;
  51267. /**
  51268. * Specifies the metallic scalar value of the material.
  51269. * Can also be used to scale the metalness values of the metallic texture.
  51270. */
  51271. metallic: number;
  51272. /**
  51273. * Specifies the roughness scalar value of the material.
  51274. * Can also be used to scale the roughness values of the metallic texture.
  51275. */
  51276. roughness: number;
  51277. /**
  51278. * Texture containing both the metallic value in the B channel and the
  51279. * roughness value in the G channel to keep better precision.
  51280. */
  51281. metallicRoughnessTexture: BaseTexture;
  51282. /**
  51283. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51284. *
  51285. * @param name The material name
  51286. * @param scene The scene the material will be use in.
  51287. */
  51288. constructor(name: string, scene: Scene);
  51289. /**
  51290. * Return the currrent class name of the material.
  51291. */
  51292. getClassName(): string;
  51293. /**
  51294. * Makes a duplicate of the current material.
  51295. * @param name - name to use for the new material.
  51296. */
  51297. clone(name: string): PBRMetallicRoughnessMaterial;
  51298. /**
  51299. * Serialize the material to a parsable JSON object.
  51300. */
  51301. serialize(): any;
  51302. /**
  51303. * Parses a JSON object correponding to the serialize function.
  51304. */
  51305. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51306. }
  51307. }
  51308. declare module BABYLON {
  51309. /**
  51310. * The PBR material of BJS following the specular glossiness convention.
  51311. *
  51312. * This fits to the PBR convention in the GLTF definition:
  51313. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51314. */
  51315. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51316. /**
  51317. * Specifies the diffuse color of the material.
  51318. */
  51319. diffuseColor: Color3;
  51320. /**
  51321. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51322. * channel.
  51323. */
  51324. diffuseTexture: BaseTexture;
  51325. /**
  51326. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51327. */
  51328. specularColor: Color3;
  51329. /**
  51330. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51331. */
  51332. glossiness: number;
  51333. /**
  51334. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51335. */
  51336. specularGlossinessTexture: BaseTexture;
  51337. /**
  51338. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51339. *
  51340. * @param name The material name
  51341. * @param scene The scene the material will be use in.
  51342. */
  51343. constructor(name: string, scene: Scene);
  51344. /**
  51345. * Return the currrent class name of the material.
  51346. */
  51347. getClassName(): string;
  51348. /**
  51349. * Makes a duplicate of the current material.
  51350. * @param name - name to use for the new material.
  51351. */
  51352. clone(name: string): PBRSpecularGlossinessMaterial;
  51353. /**
  51354. * Serialize the material to a parsable JSON object.
  51355. */
  51356. serialize(): any;
  51357. /**
  51358. * Parses a JSON object correponding to the serialize function.
  51359. */
  51360. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51361. }
  51362. }
  51363. declare module BABYLON {
  51364. /**
  51365. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51366. * It can help converting any input color in a desired output one. This can then be used to create effects
  51367. * from sepia, black and white to sixties or futuristic rendering...
  51368. *
  51369. * The only supported format is currently 3dl.
  51370. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51371. */
  51372. export class ColorGradingTexture extends BaseTexture {
  51373. /**
  51374. * The current texture matrix. (will always be identity in color grading texture)
  51375. */
  51376. private _textureMatrix;
  51377. /**
  51378. * The texture URL.
  51379. */
  51380. url: string;
  51381. /**
  51382. * Empty line regex stored for GC.
  51383. */
  51384. private static _noneEmptyLineRegex;
  51385. private _engine;
  51386. /**
  51387. * Instantiates a ColorGradingTexture from the following parameters.
  51388. *
  51389. * @param url The location of the color gradind data (currently only supporting 3dl)
  51390. * @param scene The scene the texture will be used in
  51391. */
  51392. constructor(url: string, scene: Scene);
  51393. /**
  51394. * Returns the texture matrix used in most of the material.
  51395. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51396. */
  51397. getTextureMatrix(): Matrix;
  51398. /**
  51399. * Occurs when the file being loaded is a .3dl LUT file.
  51400. */
  51401. private load3dlTexture;
  51402. /**
  51403. * Starts the loading process of the texture.
  51404. */
  51405. private loadTexture;
  51406. /**
  51407. * Clones the color gradind texture.
  51408. */
  51409. clone(): ColorGradingTexture;
  51410. /**
  51411. * Called during delayed load for textures.
  51412. */
  51413. delayLoad(): void;
  51414. /**
  51415. * Parses a color grading texture serialized by Babylon.
  51416. * @param parsedTexture The texture information being parsedTexture
  51417. * @param scene The scene to load the texture in
  51418. * @param rootUrl The root url of the data assets to load
  51419. * @return A color gradind texture
  51420. */
  51421. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51422. /**
  51423. * Serializes the LUT texture to json format.
  51424. */
  51425. serialize(): any;
  51426. }
  51427. }
  51428. declare module BABYLON {
  51429. /**
  51430. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51431. */
  51432. export class EquiRectangularCubeTexture extends BaseTexture {
  51433. /** The six faces of the cube. */
  51434. private static _FacesMapping;
  51435. private _noMipmap;
  51436. private _onLoad;
  51437. private _onError;
  51438. /** The size of the cubemap. */
  51439. private _size;
  51440. /** The buffer of the image. */
  51441. private _buffer;
  51442. /** The width of the input image. */
  51443. private _width;
  51444. /** The height of the input image. */
  51445. private _height;
  51446. /** The URL to the image. */
  51447. url: string;
  51448. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51449. coordinatesMode: number;
  51450. /**
  51451. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51452. * @param url The location of the image
  51453. * @param scene The scene the texture will be used in
  51454. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51455. * @param noMipmap Forces to not generate the mipmap if true
  51456. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51457. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51458. * @param onLoad — defines a callback called when texture is loaded
  51459. * @param onError — defines a callback called if there is an error
  51460. */
  51461. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51462. /**
  51463. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51464. */
  51465. private loadImage;
  51466. /**
  51467. * Convert the image buffer into a cubemap and create a CubeTexture.
  51468. */
  51469. private loadTexture;
  51470. /**
  51471. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51472. * @param buffer The ArrayBuffer that should be converted.
  51473. * @returns The buffer as Float32Array.
  51474. */
  51475. private getFloat32ArrayFromArrayBuffer;
  51476. /**
  51477. * Get the current class name of the texture useful for serialization or dynamic coding.
  51478. * @returns "EquiRectangularCubeTexture"
  51479. */
  51480. getClassName(): string;
  51481. /**
  51482. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51483. * @returns A clone of the current EquiRectangularCubeTexture.
  51484. */
  51485. clone(): EquiRectangularCubeTexture;
  51486. }
  51487. }
  51488. declare module BABYLON {
  51489. /**
  51490. * Based on jsTGALoader - Javascript loader for TGA file
  51491. * By Vincent Thibault
  51492. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51493. */
  51494. export class TGATools {
  51495. private static _TYPE_INDEXED;
  51496. private static _TYPE_RGB;
  51497. private static _TYPE_GREY;
  51498. private static _TYPE_RLE_INDEXED;
  51499. private static _TYPE_RLE_RGB;
  51500. private static _TYPE_RLE_GREY;
  51501. private static _ORIGIN_MASK;
  51502. private static _ORIGIN_SHIFT;
  51503. private static _ORIGIN_BL;
  51504. private static _ORIGIN_BR;
  51505. private static _ORIGIN_UL;
  51506. private static _ORIGIN_UR;
  51507. /**
  51508. * Gets the header of a TGA file
  51509. * @param data defines the TGA data
  51510. * @returns the header
  51511. */
  51512. static GetTGAHeader(data: Uint8Array): any;
  51513. /**
  51514. * Uploads TGA content to a Babylon Texture
  51515. * @hidden
  51516. */
  51517. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51518. /** @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;
  51519. /** @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;
  51520. /** @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;
  51521. /** @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;
  51522. /** @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;
  51523. /** @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;
  51524. }
  51525. }
  51526. declare module BABYLON {
  51527. /**
  51528. * Implementation of the TGA Texture Loader.
  51529. * @hidden
  51530. */
  51531. export class _TGATextureLoader implements IInternalTextureLoader {
  51532. /**
  51533. * Defines wether the loader supports cascade loading the different faces.
  51534. */
  51535. readonly supportCascades: boolean;
  51536. /**
  51537. * This returns if the loader support the current file information.
  51538. * @param extension defines the file extension of the file being loaded
  51539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51540. * @param fallback defines the fallback internal texture if any
  51541. * @param isBase64 defines whether the texture is encoded as a base64
  51542. * @param isBuffer defines whether the texture data are stored as a buffer
  51543. * @returns true if the loader can load the specified file
  51544. */
  51545. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51546. /**
  51547. * Transform the url before loading if required.
  51548. * @param rootUrl the url of the texture
  51549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51550. * @returns the transformed texture
  51551. */
  51552. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51553. /**
  51554. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51555. * @param rootUrl the url of the texture
  51556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51557. * @returns the fallback texture
  51558. */
  51559. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51560. /**
  51561. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51562. * @param data contains the texture data
  51563. * @param texture defines the BabylonJS internal texture
  51564. * @param createPolynomials will be true if polynomials have been requested
  51565. * @param onLoad defines the callback to trigger once the texture is ready
  51566. * @param onError defines the callback to trigger in case of error
  51567. */
  51568. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51569. /**
  51570. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51571. * @param data contains the texture data
  51572. * @param texture defines the BabylonJS internal texture
  51573. * @param callback defines the method to call once ready to upload
  51574. */
  51575. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51576. }
  51577. }
  51578. declare module BABYLON {
  51579. /**
  51580. * Info about the .basis files
  51581. */
  51582. class BasisFileInfo {
  51583. /**
  51584. * If the file has alpha
  51585. */
  51586. hasAlpha: boolean;
  51587. /**
  51588. * Info about each image of the basis file
  51589. */
  51590. images: Array<{
  51591. levels: Array<{
  51592. width: number;
  51593. height: number;
  51594. transcodedPixels: ArrayBufferView;
  51595. }>;
  51596. }>;
  51597. }
  51598. /**
  51599. * Result of transcoding a basis file
  51600. */
  51601. class TranscodeResult {
  51602. /**
  51603. * Info about the .basis file
  51604. */
  51605. fileInfo: BasisFileInfo;
  51606. /**
  51607. * Format to use when loading the file
  51608. */
  51609. format: number;
  51610. }
  51611. /**
  51612. * Configuration options for the Basis transcoder
  51613. */
  51614. export class BasisTranscodeConfiguration {
  51615. /**
  51616. * Supported compression formats used to determine the supported output format of the transcoder
  51617. */
  51618. supportedCompressionFormats?: {
  51619. /**
  51620. * etc1 compression format
  51621. */
  51622. etc1?: boolean;
  51623. /**
  51624. * s3tc compression format
  51625. */
  51626. s3tc?: boolean;
  51627. /**
  51628. * pvrtc compression format
  51629. */
  51630. pvrtc?: boolean;
  51631. /**
  51632. * etc2 compression format
  51633. */
  51634. etc2?: boolean;
  51635. };
  51636. /**
  51637. * If mipmap levels should be loaded for transcoded images (Default: true)
  51638. */
  51639. loadMipmapLevels?: boolean;
  51640. /**
  51641. * Index of a single image to load (Default: all images)
  51642. */
  51643. loadSingleImage?: number;
  51644. }
  51645. /**
  51646. * Used to load .Basis files
  51647. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51648. */
  51649. export class BasisTools {
  51650. private static _IgnoreSupportedFormats;
  51651. /**
  51652. * URL to use when loading the basis transcoder
  51653. */
  51654. static JSModuleURL: string;
  51655. /**
  51656. * URL to use when loading the wasm module for the transcoder
  51657. */
  51658. static WasmModuleURL: string;
  51659. /**
  51660. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51661. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51662. * @returns internal format corresponding to the Basis format
  51663. */
  51664. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51665. private static _WorkerPromise;
  51666. private static _Worker;
  51667. private static _actionId;
  51668. private static _CreateWorkerAsync;
  51669. /**
  51670. * Transcodes a loaded image file to compressed pixel data
  51671. * @param imageData image data to transcode
  51672. * @param config configuration options for the transcoding
  51673. * @returns a promise resulting in the transcoded image
  51674. */
  51675. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51676. /**
  51677. * Loads a texture from the transcode result
  51678. * @param texture texture load to
  51679. * @param transcodeResult the result of transcoding the basis file to load from
  51680. */
  51681. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51682. }
  51683. }
  51684. declare module BABYLON {
  51685. /**
  51686. * Loader for .basis file format
  51687. */
  51688. export class _BasisTextureLoader implements IInternalTextureLoader {
  51689. /**
  51690. * Defines whether the loader supports cascade loading the different faces.
  51691. */
  51692. readonly supportCascades: boolean;
  51693. /**
  51694. * This returns if the loader support the current file information.
  51695. * @param extension defines the file extension of the file being loaded
  51696. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51697. * @param fallback defines the fallback internal texture if any
  51698. * @param isBase64 defines whether the texture is encoded as a base64
  51699. * @param isBuffer defines whether the texture data are stored as a buffer
  51700. * @returns true if the loader can load the specified file
  51701. */
  51702. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51703. /**
  51704. * Transform the url before loading if required.
  51705. * @param rootUrl the url of the texture
  51706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51707. * @returns the transformed texture
  51708. */
  51709. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51710. /**
  51711. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51712. * @param rootUrl the url of the texture
  51713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51714. * @returns the fallback texture
  51715. */
  51716. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51717. /**
  51718. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51719. * @param data contains the texture data
  51720. * @param texture defines the BabylonJS internal texture
  51721. * @param createPolynomials will be true if polynomials have been requested
  51722. * @param onLoad defines the callback to trigger once the texture is ready
  51723. * @param onError defines the callback to trigger in case of error
  51724. */
  51725. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51726. /**
  51727. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51728. * @param data contains the texture data
  51729. * @param texture defines the BabylonJS internal texture
  51730. * @param callback defines the method to call once ready to upload
  51731. */
  51732. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51733. }
  51734. }
  51735. declare module BABYLON {
  51736. /**
  51737. * 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.
  51738. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51739. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51740. */
  51741. export class CustomProceduralTexture extends ProceduralTexture {
  51742. private _animate;
  51743. private _time;
  51744. private _config;
  51745. private _texturePath;
  51746. /**
  51747. * Instantiates a new Custom Procedural Texture.
  51748. * 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.
  51749. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51750. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51751. * @param name Define the name of the texture
  51752. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51753. * @param size Define the size of the texture to create
  51754. * @param scene Define the scene the texture belongs to
  51755. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51756. * @param generateMipMaps Define if the texture should creates mip maps or not
  51757. */
  51758. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51759. private _loadJson;
  51760. /**
  51761. * Is the texture ready to be used ? (rendered at least once)
  51762. * @returns true if ready, otherwise, false.
  51763. */
  51764. isReady(): boolean;
  51765. /**
  51766. * Render the texture to its associated render target.
  51767. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51768. */
  51769. render(useCameraPostProcess?: boolean): void;
  51770. /**
  51771. * Update the list of dependant textures samplers in the shader.
  51772. */
  51773. updateTextures(): void;
  51774. /**
  51775. * Update the uniform values of the procedural texture in the shader.
  51776. */
  51777. updateShaderUniforms(): void;
  51778. /**
  51779. * Define if the texture animates or not.
  51780. */
  51781. animate: boolean;
  51782. }
  51783. }
  51784. declare module BABYLON {
  51785. /** @hidden */
  51786. export var noisePixelShader: {
  51787. name: string;
  51788. shader: string;
  51789. };
  51790. }
  51791. declare module BABYLON {
  51792. /**
  51793. * Class used to generate noise procedural textures
  51794. */
  51795. export class NoiseProceduralTexture extends ProceduralTexture {
  51796. private _time;
  51797. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51798. brightness: number;
  51799. /** Defines the number of octaves to process */
  51800. octaves: number;
  51801. /** Defines the level of persistence (0.8 by default) */
  51802. persistence: number;
  51803. /** Gets or sets animation speed factor (default is 1) */
  51804. animationSpeedFactor: number;
  51805. /**
  51806. * Creates a new NoiseProceduralTexture
  51807. * @param name defines the name fo the texture
  51808. * @param size defines the size of the texture (default is 256)
  51809. * @param scene defines the hosting scene
  51810. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51811. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51812. */
  51813. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51814. private _updateShaderUniforms;
  51815. protected _getDefines(): string;
  51816. /** Generate the current state of the procedural texture */
  51817. render(useCameraPostProcess?: boolean): void;
  51818. /**
  51819. * Serializes this noise procedural texture
  51820. * @returns a serialized noise procedural texture object
  51821. */
  51822. serialize(): any;
  51823. /**
  51824. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51825. * @param parsedTexture defines parsed texture data
  51826. * @param scene defines the current scene
  51827. * @param rootUrl defines the root URL containing noise procedural texture information
  51828. * @returns a parsed NoiseProceduralTexture
  51829. */
  51830. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51831. }
  51832. }
  51833. declare module BABYLON {
  51834. /**
  51835. * Raw cube texture where the raw buffers are passed in
  51836. */
  51837. export class RawCubeTexture extends CubeTexture {
  51838. /**
  51839. * Creates a cube texture where the raw buffers are passed in.
  51840. * @param scene defines the scene the texture is attached to
  51841. * @param data defines the array of data to use to create each face
  51842. * @param size defines the size of the textures
  51843. * @param format defines the format of the data
  51844. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51845. * @param generateMipMaps defines if the engine should generate the mip levels
  51846. * @param invertY defines if data must be stored with Y axis inverted
  51847. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51848. * @param compression defines the compression used (null by default)
  51849. */
  51850. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51851. /**
  51852. * Updates the raw cube texture.
  51853. * @param data defines the data to store
  51854. * @param format defines the data format
  51855. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51856. * @param invertY defines if data must be stored with Y axis inverted
  51857. * @param compression defines the compression used (null by default)
  51858. * @param level defines which level of the texture to update
  51859. */
  51860. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51861. /**
  51862. * Updates a raw cube texture with RGBD encoded data.
  51863. * @param data defines the array of data [mipmap][face] to use to create each face
  51864. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51865. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51866. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51867. * @returns a promsie that resolves when the operation is complete
  51868. */
  51869. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51870. /**
  51871. * Clones the raw cube texture.
  51872. * @return a new cube texture
  51873. */
  51874. clone(): CubeTexture;
  51875. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51876. }
  51877. }
  51878. declare module BABYLON {
  51879. /**
  51880. * Class used to store 3D textures containing user data
  51881. */
  51882. export class RawTexture3D extends Texture {
  51883. /** Gets or sets the texture format to use */
  51884. format: number;
  51885. private _engine;
  51886. /**
  51887. * Create a new RawTexture3D
  51888. * @param data defines the data of the texture
  51889. * @param width defines the width of the texture
  51890. * @param height defines the height of the texture
  51891. * @param depth defines the depth of the texture
  51892. * @param format defines the texture format to use
  51893. * @param scene defines the hosting scene
  51894. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51895. * @param invertY defines if texture must be stored with Y axis inverted
  51896. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51897. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51898. */
  51899. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51900. /** Gets or sets the texture format to use */
  51901. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51902. /**
  51903. * Update the texture with new data
  51904. * @param data defines the data to store in the texture
  51905. */
  51906. update(data: ArrayBufferView): void;
  51907. }
  51908. }
  51909. declare module BABYLON {
  51910. /**
  51911. * Creates a refraction texture used by refraction channel of the standard material.
  51912. * It is like a mirror but to see through a material.
  51913. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51914. */
  51915. export class RefractionTexture extends RenderTargetTexture {
  51916. /**
  51917. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51918. * 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.
  51919. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51920. */
  51921. refractionPlane: Plane;
  51922. /**
  51923. * Define how deep under the surface we should see.
  51924. */
  51925. depth: number;
  51926. /**
  51927. * Creates a refraction texture used by refraction channel of the standard material.
  51928. * It is like a mirror but to see through a material.
  51929. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51930. * @param name Define the texture name
  51931. * @param size Define the size of the underlying texture
  51932. * @param scene Define the scene the refraction belongs to
  51933. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51934. */
  51935. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51936. /**
  51937. * Clone the refraction texture.
  51938. * @returns the cloned texture
  51939. */
  51940. clone(): RefractionTexture;
  51941. /**
  51942. * Serialize the texture to a JSON representation you could use in Parse later on
  51943. * @returns the serialized JSON representation
  51944. */
  51945. serialize(): any;
  51946. }
  51947. }
  51948. declare module BABYLON {
  51949. /**
  51950. * Defines the options related to the creation of an HtmlElementTexture
  51951. */
  51952. export interface IHtmlElementTextureOptions {
  51953. /**
  51954. * Defines wether mip maps should be created or not.
  51955. */
  51956. generateMipMaps?: boolean;
  51957. /**
  51958. * Defines the sampling mode of the texture.
  51959. */
  51960. samplingMode?: number;
  51961. /**
  51962. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51963. */
  51964. engine: Nullable<ThinEngine>;
  51965. /**
  51966. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51967. */
  51968. scene: Nullable<Scene>;
  51969. }
  51970. /**
  51971. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51972. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51973. * is automatically managed.
  51974. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51975. * in your application.
  51976. *
  51977. * As the update is not automatic, you need to call them manually.
  51978. */
  51979. export class HtmlElementTexture extends BaseTexture {
  51980. /**
  51981. * The texture URL.
  51982. */
  51983. element: HTMLVideoElement | HTMLCanvasElement;
  51984. private static readonly DefaultOptions;
  51985. private _textureMatrix;
  51986. private _engine;
  51987. private _isVideo;
  51988. private _generateMipMaps;
  51989. private _samplingMode;
  51990. /**
  51991. * Instantiates a HtmlElementTexture from the following parameters.
  51992. *
  51993. * @param name Defines the name of the texture
  51994. * @param element Defines the video or canvas the texture is filled with
  51995. * @param options Defines the other none mandatory texture creation options
  51996. */
  51997. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51998. private _createInternalTexture;
  51999. /**
  52000. * Returns the texture matrix used in most of the material.
  52001. */
  52002. getTextureMatrix(): Matrix;
  52003. /**
  52004. * Updates the content of the texture.
  52005. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52006. */
  52007. update(invertY?: Nullable<boolean>): void;
  52008. }
  52009. }
  52010. declare module BABYLON {
  52011. /**
  52012. * Enum used to define the target of a block
  52013. */
  52014. export enum NodeMaterialBlockTargets {
  52015. /** Vertex shader */
  52016. Vertex = 1,
  52017. /** Fragment shader */
  52018. Fragment = 2,
  52019. /** Neutral */
  52020. Neutral = 4,
  52021. /** Vertex and Fragment */
  52022. VertexAndFragment = 3
  52023. }
  52024. }
  52025. declare module BABYLON {
  52026. /**
  52027. * Defines the kind of connection point for node based material
  52028. */
  52029. export enum NodeMaterialBlockConnectionPointTypes {
  52030. /** Float */
  52031. Float = 1,
  52032. /** Int */
  52033. Int = 2,
  52034. /** Vector2 */
  52035. Vector2 = 4,
  52036. /** Vector3 */
  52037. Vector3 = 8,
  52038. /** Vector4 */
  52039. Vector4 = 16,
  52040. /** Color3 */
  52041. Color3 = 32,
  52042. /** Color4 */
  52043. Color4 = 64,
  52044. /** Matrix */
  52045. Matrix = 128,
  52046. /** Detect type based on connection */
  52047. AutoDetect = 1024,
  52048. /** Output type that will be defined by input type */
  52049. BasedOnInput = 2048
  52050. }
  52051. }
  52052. declare module BABYLON {
  52053. /**
  52054. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52055. */
  52056. export enum NodeMaterialBlockConnectionPointMode {
  52057. /** Value is an uniform */
  52058. Uniform = 0,
  52059. /** Value is a mesh attribute */
  52060. Attribute = 1,
  52061. /** Value is a varying between vertex and fragment shaders */
  52062. Varying = 2,
  52063. /** Mode is undefined */
  52064. Undefined = 3
  52065. }
  52066. }
  52067. declare module BABYLON {
  52068. /**
  52069. * Enum used to define system values e.g. values automatically provided by the system
  52070. */
  52071. export enum NodeMaterialSystemValues {
  52072. /** World */
  52073. World = 1,
  52074. /** View */
  52075. View = 2,
  52076. /** Projection */
  52077. Projection = 3,
  52078. /** ViewProjection */
  52079. ViewProjection = 4,
  52080. /** WorldView */
  52081. WorldView = 5,
  52082. /** WorldViewProjection */
  52083. WorldViewProjection = 6,
  52084. /** CameraPosition */
  52085. CameraPosition = 7,
  52086. /** Fog Color */
  52087. FogColor = 8,
  52088. /** Delta time */
  52089. DeltaTime = 9
  52090. }
  52091. }
  52092. declare module BABYLON {
  52093. /**
  52094. * Root class for all node material optimizers
  52095. */
  52096. export class NodeMaterialOptimizer {
  52097. /**
  52098. * Function used to optimize a NodeMaterial graph
  52099. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52100. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52101. */
  52102. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52103. }
  52104. }
  52105. declare module BABYLON {
  52106. /**
  52107. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52108. */
  52109. export class TransformBlock extends NodeMaterialBlock {
  52110. /**
  52111. * Defines the value to use to complement W value to transform it to a Vector4
  52112. */
  52113. complementW: number;
  52114. /**
  52115. * Defines the value to use to complement z value to transform it to a Vector4
  52116. */
  52117. complementZ: number;
  52118. /**
  52119. * Creates a new TransformBlock
  52120. * @param name defines the block name
  52121. */
  52122. constructor(name: string);
  52123. /**
  52124. * Gets the current class name
  52125. * @returns the class name
  52126. */
  52127. getClassName(): string;
  52128. /**
  52129. * Gets the vector input
  52130. */
  52131. readonly vector: NodeMaterialConnectionPoint;
  52132. /**
  52133. * Gets the output component
  52134. */
  52135. readonly output: NodeMaterialConnectionPoint;
  52136. /**
  52137. * Gets the matrix transform input
  52138. */
  52139. readonly transform: NodeMaterialConnectionPoint;
  52140. protected _buildBlock(state: NodeMaterialBuildState): this;
  52141. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52142. protected _dumpPropertiesCode(): string;
  52143. }
  52144. }
  52145. declare module BABYLON {
  52146. /**
  52147. * Block used to output the vertex position
  52148. */
  52149. export class VertexOutputBlock extends NodeMaterialBlock {
  52150. /**
  52151. * Creates a new VertexOutputBlock
  52152. * @param name defines the block name
  52153. */
  52154. constructor(name: string);
  52155. /**
  52156. * Gets the current class name
  52157. * @returns the class name
  52158. */
  52159. getClassName(): string;
  52160. /**
  52161. * Gets the vector input component
  52162. */
  52163. readonly vector: NodeMaterialConnectionPoint;
  52164. protected _buildBlock(state: NodeMaterialBuildState): this;
  52165. }
  52166. }
  52167. declare module BABYLON {
  52168. /**
  52169. * Block used to output the final color
  52170. */
  52171. export class FragmentOutputBlock extends NodeMaterialBlock {
  52172. /**
  52173. * Create a new FragmentOutputBlock
  52174. * @param name defines the block name
  52175. */
  52176. constructor(name: string);
  52177. /**
  52178. * Gets the current class name
  52179. * @returns the class name
  52180. */
  52181. getClassName(): string;
  52182. /**
  52183. * Gets the rgba input component
  52184. */
  52185. readonly rgba: NodeMaterialConnectionPoint;
  52186. /**
  52187. * Gets the rgb input component
  52188. */
  52189. readonly rgb: NodeMaterialConnectionPoint;
  52190. /**
  52191. * Gets the a input component
  52192. */
  52193. readonly a: NodeMaterialConnectionPoint;
  52194. protected _buildBlock(state: NodeMaterialBuildState): this;
  52195. }
  52196. }
  52197. declare module BABYLON {
  52198. /**
  52199. * Block used to read a reflection texture from a sampler
  52200. */
  52201. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52202. private _define3DName;
  52203. private _defineCubicName;
  52204. private _defineExplicitName;
  52205. private _defineProjectionName;
  52206. private _defineLocalCubicName;
  52207. private _defineSphericalName;
  52208. private _definePlanarName;
  52209. private _defineEquirectangularName;
  52210. private _defineMirroredEquirectangularFixedName;
  52211. private _defineEquirectangularFixedName;
  52212. private _defineSkyboxName;
  52213. private _cubeSamplerName;
  52214. private _2DSamplerName;
  52215. private _positionUVWName;
  52216. private _directionWName;
  52217. private _reflectionCoordsName;
  52218. private _reflection2DCoordsName;
  52219. private _reflectionColorName;
  52220. private _reflectionMatrixName;
  52221. /**
  52222. * Gets or sets the texture associated with the node
  52223. */
  52224. texture: Nullable<BaseTexture>;
  52225. /**
  52226. * Create a new TextureBlock
  52227. * @param name defines the block name
  52228. */
  52229. constructor(name: string);
  52230. /**
  52231. * Gets the current class name
  52232. * @returns the class name
  52233. */
  52234. getClassName(): string;
  52235. /**
  52236. * Gets the world position input component
  52237. */
  52238. readonly position: NodeMaterialConnectionPoint;
  52239. /**
  52240. * Gets the world position input component
  52241. */
  52242. readonly worldPosition: NodeMaterialConnectionPoint;
  52243. /**
  52244. * Gets the world normal input component
  52245. */
  52246. readonly worldNormal: NodeMaterialConnectionPoint;
  52247. /**
  52248. * Gets the world input component
  52249. */
  52250. readonly world: NodeMaterialConnectionPoint;
  52251. /**
  52252. * Gets the camera (or eye) position component
  52253. */
  52254. readonly cameraPosition: NodeMaterialConnectionPoint;
  52255. /**
  52256. * Gets the view input component
  52257. */
  52258. readonly view: NodeMaterialConnectionPoint;
  52259. /**
  52260. * Gets the rgb output component
  52261. */
  52262. readonly rgb: NodeMaterialConnectionPoint;
  52263. /**
  52264. * Gets the r output component
  52265. */
  52266. readonly r: NodeMaterialConnectionPoint;
  52267. /**
  52268. * Gets the g output component
  52269. */
  52270. readonly g: NodeMaterialConnectionPoint;
  52271. /**
  52272. * Gets the b output component
  52273. */
  52274. readonly b: NodeMaterialConnectionPoint;
  52275. autoConfigure(material: NodeMaterial): void;
  52276. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52277. isReady(): boolean;
  52278. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52279. private _injectVertexCode;
  52280. private _writeOutput;
  52281. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52282. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52283. }
  52284. }
  52285. declare module BABYLON {
  52286. /**
  52287. * Interface used to configure the node material editor
  52288. */
  52289. export interface INodeMaterialEditorOptions {
  52290. /** Define the URl to load node editor script */
  52291. editorURL?: string;
  52292. }
  52293. /** @hidden */
  52294. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52295. /** BONES */
  52296. NUM_BONE_INFLUENCERS: number;
  52297. BonesPerMesh: number;
  52298. BONETEXTURE: boolean;
  52299. /** MORPH TARGETS */
  52300. MORPHTARGETS: boolean;
  52301. MORPHTARGETS_NORMAL: boolean;
  52302. MORPHTARGETS_TANGENT: boolean;
  52303. MORPHTARGETS_UV: boolean;
  52304. NUM_MORPH_INFLUENCERS: number;
  52305. /** IMAGE PROCESSING */
  52306. IMAGEPROCESSING: boolean;
  52307. VIGNETTE: boolean;
  52308. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52309. VIGNETTEBLENDMODEOPAQUE: boolean;
  52310. TONEMAPPING: boolean;
  52311. TONEMAPPING_ACES: boolean;
  52312. CONTRAST: boolean;
  52313. EXPOSURE: boolean;
  52314. COLORCURVES: boolean;
  52315. COLORGRADING: boolean;
  52316. COLORGRADING3D: boolean;
  52317. SAMPLER3DGREENDEPTH: boolean;
  52318. SAMPLER3DBGRMAP: boolean;
  52319. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52320. /** MISC. */
  52321. BUMPDIRECTUV: number;
  52322. constructor();
  52323. setValue(name: string, value: boolean): void;
  52324. }
  52325. /**
  52326. * Class used to configure NodeMaterial
  52327. */
  52328. export interface INodeMaterialOptions {
  52329. /**
  52330. * Defines if blocks should emit comments
  52331. */
  52332. emitComments: boolean;
  52333. }
  52334. /**
  52335. * Class used to create a node based material built by assembling shader blocks
  52336. */
  52337. export class NodeMaterial extends PushMaterial {
  52338. private static _BuildIdGenerator;
  52339. private _options;
  52340. private _vertexCompilationState;
  52341. private _fragmentCompilationState;
  52342. private _sharedData;
  52343. private _buildId;
  52344. private _buildWasSuccessful;
  52345. private _cachedWorldViewMatrix;
  52346. private _cachedWorldViewProjectionMatrix;
  52347. private _optimizers;
  52348. private _animationFrame;
  52349. /** Define the URl to load node editor script */
  52350. static EditorURL: string;
  52351. private BJSNODEMATERIALEDITOR;
  52352. /** Get the inspector from bundle or global */
  52353. private _getGlobalNodeMaterialEditor;
  52354. /**
  52355. * 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)
  52356. */
  52357. ignoreAlpha: boolean;
  52358. /**
  52359. * Defines the maximum number of lights that can be used in the material
  52360. */
  52361. maxSimultaneousLights: number;
  52362. /**
  52363. * Observable raised when the material is built
  52364. */
  52365. onBuildObservable: Observable<NodeMaterial>;
  52366. /**
  52367. * Gets or sets the root nodes of the material vertex shader
  52368. */ private _vertexOutputNodes: NodeMaterialBlock[];
  52369. /**
  52370. * Gets or sets the root nodes of the material fragment (pixel) shader
  52371. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  52372. /** Gets or sets options to control the node material overall behavior */
  52373. options: INodeMaterialOptions;
  52374. /**
  52375. * Default configuration related to image processing available in the standard Material.
  52376. */
  52377. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52378. /**
  52379. * Gets the image processing configuration used either in this material.
  52380. */
  52381. /**
  52382. * Sets the Default image processing configuration used either in the this material.
  52383. *
  52384. * If sets to null, the scene one is in use.
  52385. */
  52386. imageProcessingConfiguration: ImageProcessingConfiguration;
  52387. /**
  52388. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52389. */
  52390. attachedBlocks: NodeMaterialBlock[];
  52391. /**
  52392. * Create a new node based material
  52393. * @param name defines the material name
  52394. * @param scene defines the hosting scene
  52395. * @param options defines creation option
  52396. */
  52397. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52398. /**
  52399. * Gets the current class name of the material e.g. "NodeMaterial"
  52400. * @returns the class name
  52401. */
  52402. getClassName(): string;
  52403. /**
  52404. * Keep track of the image processing observer to allow dispose and replace.
  52405. */
  52406. private _imageProcessingObserver;
  52407. /**
  52408. * Attaches a new image processing configuration to the Standard Material.
  52409. * @param configuration
  52410. */
  52411. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52412. /**
  52413. * Get a block by its name
  52414. * @param name defines the name of the block to retrieve
  52415. * @returns the required block or null if not found
  52416. */
  52417. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52418. /**
  52419. * Get a block by its name
  52420. * @param predicate defines the predicate used to find the good candidate
  52421. * @returns the required block or null if not found
  52422. */
  52423. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52424. /**
  52425. * Get an input block by its name
  52426. * @param predicate defines the predicate used to find the good candidate
  52427. * @returns the required input block or null if not found
  52428. */
  52429. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52430. /**
  52431. * Gets the list of input blocks attached to this material
  52432. * @returns an array of InputBlocks
  52433. */
  52434. getInputBlocks(): InputBlock[];
  52435. /**
  52436. * Adds a new optimizer to the list of optimizers
  52437. * @param optimizer defines the optimizers to add
  52438. * @returns the current material
  52439. */
  52440. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52441. /**
  52442. * Remove an optimizer from the list of optimizers
  52443. * @param optimizer defines the optimizers to remove
  52444. * @returns the current material
  52445. */
  52446. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52447. /**
  52448. * Add a new block to the list of output nodes
  52449. * @param node defines the node to add
  52450. * @returns the current material
  52451. */
  52452. addOutputNode(node: NodeMaterialBlock): this;
  52453. /**
  52454. * Remove a block from the list of root nodes
  52455. * @param node defines the node to remove
  52456. * @returns the current material
  52457. */
  52458. removeOutputNode(node: NodeMaterialBlock): this;
  52459. private _addVertexOutputNode;
  52460. private _removeVertexOutputNode;
  52461. private _addFragmentOutputNode;
  52462. private _removeFragmentOutputNode;
  52463. /**
  52464. * Specifies if the material will require alpha blending
  52465. * @returns a boolean specifying if alpha blending is needed
  52466. */
  52467. needAlphaBlending(): boolean;
  52468. /**
  52469. * Specifies if this material should be rendered in alpha test mode
  52470. * @returns a boolean specifying if an alpha test is needed.
  52471. */
  52472. needAlphaTesting(): boolean;
  52473. private _initializeBlock;
  52474. private _resetDualBlocks;
  52475. /**
  52476. * Build the material and generates the inner effect
  52477. * @param verbose defines if the build should log activity
  52478. */
  52479. build(verbose?: boolean): void;
  52480. /**
  52481. * Runs an otpimization phase to try to improve the shader code
  52482. */
  52483. optimize(): void;
  52484. private _prepareDefinesForAttributes;
  52485. /**
  52486. * Get if the submesh is ready to be used and all its information available.
  52487. * Child classes can use it to update shaders
  52488. * @param mesh defines the mesh to check
  52489. * @param subMesh defines which submesh to check
  52490. * @param useInstances specifies that instances should be used
  52491. * @returns a boolean indicating that the submesh is ready or not
  52492. */
  52493. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52494. /**
  52495. * Get a string representing the shaders built by the current node graph
  52496. */
  52497. readonly compiledShaders: string;
  52498. /**
  52499. * Binds the world matrix to the material
  52500. * @param world defines the world transformation matrix
  52501. */
  52502. bindOnlyWorldMatrix(world: Matrix): void;
  52503. /**
  52504. * Binds the submesh to this material by preparing the effect and shader to draw
  52505. * @param world defines the world transformation matrix
  52506. * @param mesh defines the mesh containing the submesh
  52507. * @param subMesh defines the submesh to bind the material to
  52508. */
  52509. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52510. /**
  52511. * Gets the active textures from the material
  52512. * @returns an array of textures
  52513. */
  52514. getActiveTextures(): BaseTexture[];
  52515. /**
  52516. * Gets the list of texture blocks
  52517. * @returns an array of texture blocks
  52518. */
  52519. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52520. /**
  52521. * Specifies if the material uses a texture
  52522. * @param texture defines the texture to check against the material
  52523. * @returns a boolean specifying if the material uses the texture
  52524. */
  52525. hasTexture(texture: BaseTexture): boolean;
  52526. /**
  52527. * Disposes the material
  52528. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52529. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52530. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52531. */
  52532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52533. /** Creates the node editor window. */
  52534. private _createNodeEditor;
  52535. /**
  52536. * Launch the node material editor
  52537. * @param config Define the configuration of the editor
  52538. * @return a promise fulfilled when the node editor is visible
  52539. */
  52540. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52541. /**
  52542. * Clear the current material
  52543. */
  52544. clear(): void;
  52545. /**
  52546. * Clear the current material and set it to a default state
  52547. */
  52548. setToDefault(): void;
  52549. /**
  52550. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52551. * @param url defines the url to load from
  52552. * @returns a promise that will fullfil when the material is fully loaded
  52553. */
  52554. loadAsync(url: string): Promise<void>;
  52555. private _gatherBlocks;
  52556. /**
  52557. * Generate a string containing the code declaration required to create an equivalent of this material
  52558. * @returns a string
  52559. */
  52560. generateCode(): string;
  52561. /**
  52562. * Serializes this material in a JSON representation
  52563. * @returns the serialized material object
  52564. */
  52565. serialize(): any;
  52566. private _restoreConnections;
  52567. /**
  52568. * Clear the current graph and load a new one from a serialization object
  52569. * @param source defines the JSON representation of the material
  52570. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52571. */
  52572. loadFromSerialization(source: any, rootUrl?: string): void;
  52573. /**
  52574. * Creates a node material from parsed material data
  52575. * @param source defines the JSON representation of the material
  52576. * @param scene defines the hosting scene
  52577. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52578. * @returns a new node material
  52579. */
  52580. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52581. /**
  52582. * Creates a new node material set to default basic configuration
  52583. * @param name defines the name of the material
  52584. * @param scene defines the hosting scene
  52585. * @returns a new NodeMaterial
  52586. */
  52587. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52588. }
  52589. }
  52590. declare module BABYLON {
  52591. /**
  52592. * Block used to read a texture from a sampler
  52593. */
  52594. export class TextureBlock extends NodeMaterialBlock {
  52595. private _defineName;
  52596. private _linearDefineName;
  52597. private _samplerName;
  52598. private _transformedUVName;
  52599. private _textureTransformName;
  52600. private _textureInfoName;
  52601. private _mainUVName;
  52602. private _mainUVDefineName;
  52603. /**
  52604. * Gets or sets the texture associated with the node
  52605. */
  52606. texture: Nullable<Texture>;
  52607. /**
  52608. * Create a new TextureBlock
  52609. * @param name defines the block name
  52610. */
  52611. constructor(name: string);
  52612. /**
  52613. * Gets the current class name
  52614. * @returns the class name
  52615. */
  52616. getClassName(): string;
  52617. /**
  52618. * Gets the uv input component
  52619. */
  52620. readonly uv: NodeMaterialConnectionPoint;
  52621. /**
  52622. * Gets the rgba output component
  52623. */
  52624. readonly rgba: NodeMaterialConnectionPoint;
  52625. /**
  52626. * Gets the rgb output component
  52627. */
  52628. readonly rgb: NodeMaterialConnectionPoint;
  52629. /**
  52630. * Gets the r output component
  52631. */
  52632. readonly r: NodeMaterialConnectionPoint;
  52633. /**
  52634. * Gets the g output component
  52635. */
  52636. readonly g: NodeMaterialConnectionPoint;
  52637. /**
  52638. * Gets the b output component
  52639. */
  52640. readonly b: NodeMaterialConnectionPoint;
  52641. /**
  52642. * Gets the a output component
  52643. */
  52644. readonly a: NodeMaterialConnectionPoint;
  52645. readonly target: NodeMaterialBlockTargets;
  52646. autoConfigure(material: NodeMaterial): void;
  52647. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52649. isReady(): boolean;
  52650. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52651. private readonly _isMixed;
  52652. private _injectVertexCode;
  52653. private _writeOutput;
  52654. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52655. protected _dumpPropertiesCode(): string;
  52656. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52657. }
  52658. }
  52659. declare module BABYLON {
  52660. /**
  52661. * Class used to store shared data between 2 NodeMaterialBuildState
  52662. */
  52663. export class NodeMaterialBuildStateSharedData {
  52664. /**
  52665. * Gets the list of emitted varyings
  52666. */
  52667. temps: string[];
  52668. /**
  52669. * Gets the list of emitted varyings
  52670. */
  52671. varyings: string[];
  52672. /**
  52673. * Gets the varying declaration string
  52674. */
  52675. varyingDeclaration: string;
  52676. /**
  52677. * Input blocks
  52678. */
  52679. inputBlocks: InputBlock[];
  52680. /**
  52681. * Input blocks
  52682. */
  52683. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52684. /**
  52685. * Bindable blocks (Blocks that need to set data to the effect)
  52686. */
  52687. bindableBlocks: NodeMaterialBlock[];
  52688. /**
  52689. * List of blocks that can provide a compilation fallback
  52690. */
  52691. blocksWithFallbacks: NodeMaterialBlock[];
  52692. /**
  52693. * List of blocks that can provide a define update
  52694. */
  52695. blocksWithDefines: NodeMaterialBlock[];
  52696. /**
  52697. * List of blocks that can provide a repeatable content
  52698. */
  52699. repeatableContentBlocks: NodeMaterialBlock[];
  52700. /**
  52701. * List of blocks that can provide a dynamic list of uniforms
  52702. */
  52703. dynamicUniformBlocks: NodeMaterialBlock[];
  52704. /**
  52705. * List of blocks that can block the isReady function for the material
  52706. */
  52707. blockingBlocks: NodeMaterialBlock[];
  52708. /**
  52709. * Gets the list of animated inputs
  52710. */
  52711. animatedInputs: InputBlock[];
  52712. /**
  52713. * Build Id used to avoid multiple recompilations
  52714. */
  52715. buildId: number;
  52716. /** List of emitted variables */
  52717. variableNames: {
  52718. [key: string]: number;
  52719. };
  52720. /** List of emitted defines */
  52721. defineNames: {
  52722. [key: string]: number;
  52723. };
  52724. /** Should emit comments? */
  52725. emitComments: boolean;
  52726. /** Emit build activity */
  52727. verbose: boolean;
  52728. /** Gets or sets the hosting scene */
  52729. scene: Scene;
  52730. /**
  52731. * Gets the compilation hints emitted at compilation time
  52732. */
  52733. hints: {
  52734. needWorldViewMatrix: boolean;
  52735. needWorldViewProjectionMatrix: boolean;
  52736. needAlphaBlending: boolean;
  52737. needAlphaTesting: boolean;
  52738. };
  52739. /**
  52740. * List of compilation checks
  52741. */
  52742. checks: {
  52743. emitVertex: boolean;
  52744. emitFragment: boolean;
  52745. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52746. };
  52747. /** Creates a new shared data */
  52748. constructor();
  52749. /**
  52750. * Emits console errors and exceptions if there is a failing check
  52751. */
  52752. emitErrors(): void;
  52753. }
  52754. }
  52755. declare module BABYLON {
  52756. /**
  52757. * Class used to store node based material build state
  52758. */
  52759. export class NodeMaterialBuildState {
  52760. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52761. supportUniformBuffers: boolean;
  52762. /**
  52763. * Gets the list of emitted attributes
  52764. */
  52765. attributes: string[];
  52766. /**
  52767. * Gets the list of emitted uniforms
  52768. */
  52769. uniforms: string[];
  52770. /**
  52771. * Gets the list of emitted constants
  52772. */
  52773. constants: string[];
  52774. /**
  52775. * Gets the list of emitted samplers
  52776. */
  52777. samplers: string[];
  52778. /**
  52779. * Gets the list of emitted functions
  52780. */
  52781. functions: {
  52782. [key: string]: string;
  52783. };
  52784. /**
  52785. * Gets the list of emitted extensions
  52786. */
  52787. extensions: {
  52788. [key: string]: string;
  52789. };
  52790. /**
  52791. * Gets the target of the compilation state
  52792. */
  52793. target: NodeMaterialBlockTargets;
  52794. /**
  52795. * Gets the list of emitted counters
  52796. */
  52797. counters: {
  52798. [key: string]: number;
  52799. };
  52800. /**
  52801. * Shared data between multiple NodeMaterialBuildState instances
  52802. */
  52803. sharedData: NodeMaterialBuildStateSharedData;
  52804. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  52805. /** @hidden */ private _attributeDeclaration: string;
  52806. /** @hidden */ private _uniformDeclaration: string;
  52807. /** @hidden */ private _constantDeclaration: string;
  52808. /** @hidden */ private _samplerDeclaration: string;
  52809. /** @hidden */ private _varyingTransfer: string;
  52810. private _repeatableContentAnchorIndex;
  52811. /** @hidden */ private _builtCompilationString: string;
  52812. /**
  52813. * Gets the emitted compilation strings
  52814. */
  52815. compilationString: string;
  52816. /**
  52817. * Finalize the compilation strings
  52818. * @param state defines the current compilation state
  52819. */
  52820. finalize(state: NodeMaterialBuildState): void;
  52821. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  52822. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  52823. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  52824. /** @hidden */ private _excludeVariableName(name: string): void;
  52825. /** @hidden */ private _emit2DSampler(name: string): void;
  52826. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52827. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  52828. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  52829. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52830. replaceStrings?: {
  52831. search: RegExp;
  52832. replace: string;
  52833. }[];
  52834. repeatKey?: string;
  52835. }): string;
  52836. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52837. repeatKey?: string;
  52838. removeAttributes?: boolean;
  52839. removeUniforms?: boolean;
  52840. removeVaryings?: boolean;
  52841. removeIfDef?: boolean;
  52842. replaceStrings?: {
  52843. search: RegExp;
  52844. replace: string;
  52845. }[];
  52846. }, storeKey?: string): void;
  52847. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52848. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52849. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52850. /** @hidden */ private _emitFloat(value: number): string;
  52851. }
  52852. }
  52853. declare module BABYLON {
  52854. /**
  52855. * Defines a block that can be used inside a node based material
  52856. */
  52857. export class NodeMaterialBlock {
  52858. private _buildId;
  52859. private _buildTarget;
  52860. private _target;
  52861. private _isFinalMerger;
  52862. private _isInput;
  52863. /** @hidden */ private _codeVariableName: string;
  52864. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52865. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52866. /** @hidden */ private _preparationId: number;
  52867. /**
  52868. * Gets or sets the name of the block
  52869. */
  52870. name: string;
  52871. /**
  52872. * Gets or sets the unique id of the node
  52873. */
  52874. uniqueId: number;
  52875. /**
  52876. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52877. */
  52878. readonly isFinalMerger: boolean;
  52879. /**
  52880. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52881. */
  52882. readonly isInput: boolean;
  52883. /**
  52884. * Gets or sets the build Id
  52885. */
  52886. buildId: number;
  52887. /**
  52888. * Gets or sets the target of the block
  52889. */
  52890. target: NodeMaterialBlockTargets;
  52891. /**
  52892. * Gets the list of input points
  52893. */
  52894. readonly inputs: NodeMaterialConnectionPoint[];
  52895. /** Gets the list of output points */
  52896. readonly outputs: NodeMaterialConnectionPoint[];
  52897. /**
  52898. * Find an input by its name
  52899. * @param name defines the name of the input to look for
  52900. * @returns the input or null if not found
  52901. */
  52902. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52903. /**
  52904. * Find an output by its name
  52905. * @param name defines the name of the outputto look for
  52906. * @returns the output or null if not found
  52907. */
  52908. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52909. /**
  52910. * Creates a new NodeMaterialBlock
  52911. * @param name defines the block name
  52912. * @param target defines the target of that block (Vertex by default)
  52913. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52914. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52915. */
  52916. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52917. /**
  52918. * Initialize the block and prepare the context for build
  52919. * @param state defines the state that will be used for the build
  52920. */
  52921. initialize(state: NodeMaterialBuildState): void;
  52922. /**
  52923. * Bind data to effect. Will only be called for blocks with isBindable === true
  52924. * @param effect defines the effect to bind data to
  52925. * @param nodeMaterial defines the hosting NodeMaterial
  52926. * @param mesh defines the mesh that will be rendered
  52927. */
  52928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52929. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52930. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52931. protected _writeFloat(value: number): string;
  52932. /**
  52933. * Gets the current class name e.g. "NodeMaterialBlock"
  52934. * @returns the class name
  52935. */
  52936. getClassName(): string;
  52937. /**
  52938. * Register a new input. Must be called inside a block constructor
  52939. * @param name defines the connection point name
  52940. * @param type defines the connection point type
  52941. * @param isOptional defines a boolean indicating that this input can be omitted
  52942. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52943. * @returns the current block
  52944. */
  52945. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52946. /**
  52947. * Register a new output. Must be called inside a block constructor
  52948. * @param name defines the connection point name
  52949. * @param type defines the connection point type
  52950. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52951. * @returns the current block
  52952. */
  52953. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52954. /**
  52955. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52956. * @param forOutput defines an optional connection point to check compatibility with
  52957. * @returns the first available input or null
  52958. */
  52959. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52960. /**
  52961. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52962. * @param forBlock defines an optional block to check compatibility with
  52963. * @returns the first available input or null
  52964. */
  52965. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52966. /**
  52967. * Gets the sibling of the given output
  52968. * @param current defines the current output
  52969. * @returns the next output in the list or null
  52970. */
  52971. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52972. /**
  52973. * Connect current block with another block
  52974. * @param other defines the block to connect with
  52975. * @param options define the various options to help pick the right connections
  52976. * @returns the current block
  52977. */
  52978. connectTo(other: NodeMaterialBlock, options?: {
  52979. input?: string;
  52980. output?: string;
  52981. outputSwizzle?: string;
  52982. }): this | undefined;
  52983. protected _buildBlock(state: NodeMaterialBuildState): void;
  52984. /**
  52985. * Add uniforms, samplers and uniform buffers at compilation time
  52986. * @param state defines the state to update
  52987. * @param nodeMaterial defines the node material requesting the update
  52988. * @param defines defines the material defines to update
  52989. * @param uniformBuffers defines the list of uniform buffer names
  52990. */
  52991. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  52992. /**
  52993. * Add potential fallbacks if shader compilation fails
  52994. * @param mesh defines the mesh to be rendered
  52995. * @param fallbacks defines the current prioritized list of fallbacks
  52996. */
  52997. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52998. /**
  52999. * Initialize defines for shader compilation
  53000. * @param mesh defines the mesh to be rendered
  53001. * @param nodeMaterial defines the node material requesting the update
  53002. * @param defines defines the material defines to update
  53003. * @param useInstances specifies that instances should be used
  53004. */
  53005. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53006. /**
  53007. * Update defines for shader compilation
  53008. * @param mesh defines the mesh to be rendered
  53009. * @param nodeMaterial defines the node material requesting the update
  53010. * @param defines defines the material defines to update
  53011. * @param useInstances specifies that instances should be used
  53012. */
  53013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53014. /**
  53015. * Lets the block try to connect some inputs automatically
  53016. * @param material defines the hosting NodeMaterial
  53017. */
  53018. autoConfigure(material: NodeMaterial): void;
  53019. /**
  53020. * Function called when a block is declared as repeatable content generator
  53021. * @param vertexShaderState defines the current compilation state for the vertex shader
  53022. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53023. * @param mesh defines the mesh to be rendered
  53024. * @param defines defines the material defines to update
  53025. */
  53026. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53027. /**
  53028. * Checks if the block is ready
  53029. * @param mesh defines the mesh to be rendered
  53030. * @param nodeMaterial defines the node material requesting the update
  53031. * @param defines defines the material defines to update
  53032. * @param useInstances specifies that instances should be used
  53033. * @returns true if the block is ready
  53034. */
  53035. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53036. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53037. private _processBuild;
  53038. /**
  53039. * Compile the current node and generate the shader code
  53040. * @param state defines the current compilation state (uniforms, samplers, current string)
  53041. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53042. * @returns true if already built
  53043. */
  53044. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53045. protected _inputRename(name: string): string;
  53046. protected _outputRename(name: string): string;
  53047. protected _dumpPropertiesCode(): string;
  53048. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53049. /**
  53050. * Clone the current block to a new identical block
  53051. * @param scene defines the hosting scene
  53052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53053. * @returns a copy of the current block
  53054. */
  53055. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53056. /**
  53057. * Serializes this block in a JSON representation
  53058. * @returns the serialized block object
  53059. */
  53060. serialize(): any;
  53061. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53062. /**
  53063. * Release resources
  53064. */
  53065. dispose(): void;
  53066. }
  53067. }
  53068. declare module BABYLON {
  53069. /**
  53070. * Enum defining the type of animations supported by InputBlock
  53071. */
  53072. export enum AnimatedInputBlockTypes {
  53073. /** No animation */
  53074. None = 0,
  53075. /** Time based animation. Will only work for floats */
  53076. Time = 1
  53077. }
  53078. }
  53079. declare module BABYLON {
  53080. /**
  53081. * Block used to expose an input value
  53082. */
  53083. export class InputBlock extends NodeMaterialBlock {
  53084. private _mode;
  53085. private _associatedVariableName;
  53086. private _storedValue;
  53087. private _valueCallback;
  53088. private _type;
  53089. private _animationType;
  53090. /** Gets or set a value used to limit the range of float values */
  53091. min: number;
  53092. /** Gets or set a value used to limit the range of float values */
  53093. max: number;
  53094. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53095. matrixMode: number;
  53096. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  53097. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53098. visibleInInspector: boolean;
  53099. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53100. isConstant: boolean;
  53101. /**
  53102. * Gets or sets the connection point type (default is float)
  53103. */
  53104. readonly type: NodeMaterialBlockConnectionPointTypes;
  53105. /**
  53106. * Creates a new InputBlock
  53107. * @param name defines the block name
  53108. * @param target defines the target of that block (Vertex by default)
  53109. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53110. */
  53111. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53112. /**
  53113. * Gets the output component
  53114. */
  53115. readonly output: NodeMaterialConnectionPoint;
  53116. /**
  53117. * Set the source of this connection point to a vertex attribute
  53118. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53119. * @returns the current connection point
  53120. */
  53121. setAsAttribute(attributeName?: string): InputBlock;
  53122. /**
  53123. * Set the source of this connection point to a system value
  53124. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53125. * @returns the current connection point
  53126. */
  53127. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53128. /**
  53129. * Gets or sets the value of that point.
  53130. * Please note that this value will be ignored if valueCallback is defined
  53131. */
  53132. value: any;
  53133. /**
  53134. * Gets or sets a callback used to get the value of that point.
  53135. * Please note that setting this value will force the connection point to ignore the value property
  53136. */
  53137. valueCallback: () => any;
  53138. /**
  53139. * Gets or sets the associated variable name in the shader
  53140. */
  53141. associatedVariableName: string;
  53142. /** Gets or sets the type of animation applied to the input */
  53143. animationType: AnimatedInputBlockTypes;
  53144. /**
  53145. * Gets a boolean indicating that this connection point not defined yet
  53146. */
  53147. readonly isUndefined: boolean;
  53148. /**
  53149. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53150. * In this case the connection point name must be the name of the uniform to use.
  53151. * Can only be set on inputs
  53152. */
  53153. isUniform: boolean;
  53154. /**
  53155. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53156. * In this case the connection point name must be the name of the attribute to use
  53157. * Can only be set on inputs
  53158. */
  53159. isAttribute: boolean;
  53160. /**
  53161. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53162. * Can only be set on exit points
  53163. */
  53164. isVarying: boolean;
  53165. /**
  53166. * Gets a boolean indicating that the current connection point is a system value
  53167. */
  53168. readonly isSystemValue: boolean;
  53169. /**
  53170. * Gets or sets the current well known value or null if not defined as a system value
  53171. */
  53172. systemValue: Nullable<NodeMaterialSystemValues>;
  53173. /**
  53174. * Gets the current class name
  53175. * @returns the class name
  53176. */
  53177. getClassName(): string;
  53178. /**
  53179. * Animate the input if animationType !== None
  53180. * @param scene defines the rendering scene
  53181. */
  53182. animate(scene: Scene): void;
  53183. private _emitDefine;
  53184. initialize(state: NodeMaterialBuildState): void;
  53185. /**
  53186. * Set the input block to its default value (based on its type)
  53187. */
  53188. setDefaultValue(): void;
  53189. private _emitConstant;
  53190. private _emit;
  53191. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53192. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  53193. protected _buildBlock(state: NodeMaterialBuildState): void;
  53194. protected _dumpPropertiesCode(): string;
  53195. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53196. }
  53197. }
  53198. declare module BABYLON {
  53199. /**
  53200. * Defines a connection point for a block
  53201. */
  53202. export class NodeMaterialConnectionPoint {
  53203. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  53204. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53205. private _endpoints;
  53206. private _associatedVariableName;
  53207. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53208. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53209. private _type;
  53210. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  53211. /**
  53212. * Gets or sets the additional types supported by this connection point
  53213. */
  53214. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53215. /**
  53216. * Gets or sets the additional types excluded by this connection point
  53217. */
  53218. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53219. /**
  53220. * Observable triggered when this point is connected
  53221. */
  53222. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  53223. /**
  53224. * Gets or sets the associated variable name in the shader
  53225. */
  53226. associatedVariableName: string;
  53227. /**
  53228. * Gets or sets the connection point type (default is float)
  53229. */
  53230. type: NodeMaterialBlockConnectionPointTypes;
  53231. /**
  53232. * Gets or sets the connection point name
  53233. */
  53234. name: string;
  53235. /**
  53236. * Gets or sets a boolean indicating that this connection point can be omitted
  53237. */
  53238. isOptional: boolean;
  53239. /**
  53240. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53241. */
  53242. define: string;
  53243. /** @hidden */ private _prioritizeVertex: boolean;
  53244. private _target;
  53245. /** Gets or sets the target of that connection point */
  53246. target: NodeMaterialBlockTargets;
  53247. /**
  53248. * Gets a boolean indicating that the current point is connected
  53249. */
  53250. readonly isConnected: boolean;
  53251. /**
  53252. * Gets a boolean indicating that the current point is connected to an input block
  53253. */
  53254. readonly isConnectedToInputBlock: boolean;
  53255. /**
  53256. * Gets a the connected input block (if any)
  53257. */
  53258. readonly connectInputBlock: Nullable<InputBlock>;
  53259. /** Get the other side of the connection (if any) */
  53260. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53261. /** Get the block that owns this connection point */
  53262. readonly ownerBlock: NodeMaterialBlock;
  53263. /** Get the block connected on the other side of this connection (if any) */
  53264. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53265. /** Get the block connected on the endpoints of this connection (if any) */
  53266. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53267. /** Gets the list of connected endpoints */
  53268. readonly endpoints: NodeMaterialConnectionPoint[];
  53269. /** Gets a boolean indicating if that output point is connected to at least one input */
  53270. readonly hasEndpoints: boolean;
  53271. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  53272. readonly isConnectedInVertexShader: boolean;
  53273. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  53274. readonly isConnectedInFragmentShader: boolean;
  53275. /**
  53276. * Creates a new connection point
  53277. * @param name defines the connection point name
  53278. * @param ownerBlock defines the block hosting this connection point
  53279. */
  53280. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53281. /**
  53282. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53283. * @returns the class name
  53284. */
  53285. getClassName(): string;
  53286. /**
  53287. * Gets an boolean indicating if the current point can be connected to another point
  53288. * @param connectionPoint defines the other connection point
  53289. * @returns true if the connection is possible
  53290. */
  53291. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53292. /**
  53293. * Connect this point to another connection point
  53294. * @param connectionPoint defines the other connection point
  53295. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53296. * @returns the current connection point
  53297. */
  53298. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53299. /**
  53300. * Disconnect this point from one of his endpoint
  53301. * @param endpoint defines the other connection point
  53302. * @returns the current connection point
  53303. */
  53304. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53305. /**
  53306. * Serializes this point in a JSON representation
  53307. * @returns the serialized point object
  53308. */
  53309. serialize(): any;
  53310. /**
  53311. * Release resources
  53312. */
  53313. dispose(): void;
  53314. }
  53315. }
  53316. declare module BABYLON {
  53317. /**
  53318. * Block used to add support for vertex skinning (bones)
  53319. */
  53320. export class BonesBlock extends NodeMaterialBlock {
  53321. /**
  53322. * Creates a new BonesBlock
  53323. * @param name defines the block name
  53324. */
  53325. constructor(name: string);
  53326. /**
  53327. * Initialize the block and prepare the context for build
  53328. * @param state defines the state that will be used for the build
  53329. */
  53330. initialize(state: NodeMaterialBuildState): void;
  53331. /**
  53332. * Gets the current class name
  53333. * @returns the class name
  53334. */
  53335. getClassName(): string;
  53336. /**
  53337. * Gets the matrix indices input component
  53338. */
  53339. readonly matricesIndices: NodeMaterialConnectionPoint;
  53340. /**
  53341. * Gets the matrix weights input component
  53342. */
  53343. readonly matricesWeights: NodeMaterialConnectionPoint;
  53344. /**
  53345. * Gets the extra matrix indices input component
  53346. */
  53347. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53348. /**
  53349. * Gets the extra matrix weights input component
  53350. */
  53351. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53352. /**
  53353. * Gets the world input component
  53354. */
  53355. readonly world: NodeMaterialConnectionPoint;
  53356. /**
  53357. * Gets the output component
  53358. */
  53359. readonly output: NodeMaterialConnectionPoint;
  53360. autoConfigure(material: NodeMaterial): void;
  53361. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53364. protected _buildBlock(state: NodeMaterialBuildState): this;
  53365. }
  53366. }
  53367. declare module BABYLON {
  53368. /**
  53369. * Block used to add support for instances
  53370. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53371. */
  53372. export class InstancesBlock extends NodeMaterialBlock {
  53373. /**
  53374. * Creates a new InstancesBlock
  53375. * @param name defines the block name
  53376. */
  53377. constructor(name: string);
  53378. /**
  53379. * Gets the current class name
  53380. * @returns the class name
  53381. */
  53382. getClassName(): string;
  53383. /**
  53384. * Gets the first world row input component
  53385. */
  53386. readonly world0: NodeMaterialConnectionPoint;
  53387. /**
  53388. * Gets the second world row input component
  53389. */
  53390. readonly world1: NodeMaterialConnectionPoint;
  53391. /**
  53392. * Gets the third world row input component
  53393. */
  53394. readonly world2: NodeMaterialConnectionPoint;
  53395. /**
  53396. * Gets the forth world row input component
  53397. */
  53398. readonly world3: NodeMaterialConnectionPoint;
  53399. /**
  53400. * Gets the world input component
  53401. */
  53402. readonly world: NodeMaterialConnectionPoint;
  53403. /**
  53404. * Gets the output component
  53405. */
  53406. readonly output: NodeMaterialConnectionPoint;
  53407. autoConfigure(material: NodeMaterial): void;
  53408. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53409. protected _buildBlock(state: NodeMaterialBuildState): this;
  53410. }
  53411. }
  53412. declare module BABYLON {
  53413. /**
  53414. * Block used to add morph targets support to vertex shader
  53415. */
  53416. export class MorphTargetsBlock extends NodeMaterialBlock {
  53417. private _repeatableContentAnchor;
  53418. private _repeatebleContentGenerated;
  53419. /**
  53420. * Create a new MorphTargetsBlock
  53421. * @param name defines the block name
  53422. */
  53423. constructor(name: string);
  53424. /**
  53425. * Gets the current class name
  53426. * @returns the class name
  53427. */
  53428. getClassName(): string;
  53429. /**
  53430. * Gets the position input component
  53431. */
  53432. readonly position: NodeMaterialConnectionPoint;
  53433. /**
  53434. * Gets the normal input component
  53435. */
  53436. readonly normal: NodeMaterialConnectionPoint;
  53437. /**
  53438. * Gets the tangent input component
  53439. */
  53440. readonly tangent: NodeMaterialConnectionPoint;
  53441. /**
  53442. * Gets the tangent input component
  53443. */
  53444. readonly uv: NodeMaterialConnectionPoint;
  53445. /**
  53446. * Gets the position output component
  53447. */
  53448. readonly positionOutput: NodeMaterialConnectionPoint;
  53449. /**
  53450. * Gets the normal output component
  53451. */
  53452. readonly normalOutput: NodeMaterialConnectionPoint;
  53453. /**
  53454. * Gets the tangent output component
  53455. */
  53456. readonly tangentOutput: NodeMaterialConnectionPoint;
  53457. /**
  53458. * Gets the tangent output component
  53459. */
  53460. readonly uvOutput: NodeMaterialConnectionPoint;
  53461. initialize(state: NodeMaterialBuildState): void;
  53462. autoConfigure(material: NodeMaterial): void;
  53463. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53465. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53466. protected _buildBlock(state: NodeMaterialBuildState): this;
  53467. }
  53468. }
  53469. declare module BABYLON {
  53470. /**
  53471. * Block used to get data information from a light
  53472. */
  53473. export class LightInformationBlock extends NodeMaterialBlock {
  53474. private _lightDataUniformName;
  53475. private _lightColorUniformName;
  53476. private _lightTypeDefineName;
  53477. /**
  53478. * Gets or sets the light associated with this block
  53479. */
  53480. light: Nullable<Light>;
  53481. /**
  53482. * Creates a new LightInformationBlock
  53483. * @param name defines the block name
  53484. */
  53485. constructor(name: string);
  53486. /**
  53487. * Gets the current class name
  53488. * @returns the class name
  53489. */
  53490. getClassName(): string;
  53491. /**
  53492. * Gets the world position input component
  53493. */
  53494. readonly worldPosition: NodeMaterialConnectionPoint;
  53495. /**
  53496. * Gets the direction output component
  53497. */
  53498. readonly direction: NodeMaterialConnectionPoint;
  53499. /**
  53500. * Gets the direction output component
  53501. */
  53502. readonly color: NodeMaterialConnectionPoint;
  53503. /**
  53504. * Gets the direction output component
  53505. */
  53506. readonly intensity: NodeMaterialConnectionPoint;
  53507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53509. protected _buildBlock(state: NodeMaterialBuildState): this;
  53510. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53511. }
  53512. }
  53513. declare module BABYLON {
  53514. /**
  53515. * Block used to add image processing support to fragment shader
  53516. */
  53517. export class ImageProcessingBlock extends NodeMaterialBlock {
  53518. /**
  53519. * Create a new ImageProcessingBlock
  53520. * @param name defines the block name
  53521. */
  53522. constructor(name: string);
  53523. /**
  53524. * Gets the current class name
  53525. * @returns the class name
  53526. */
  53527. getClassName(): string;
  53528. /**
  53529. * Gets the color input component
  53530. */
  53531. readonly color: NodeMaterialConnectionPoint;
  53532. /**
  53533. * Gets the output component
  53534. */
  53535. readonly output: NodeMaterialConnectionPoint;
  53536. /**
  53537. * Initialize the block and prepare the context for build
  53538. * @param state defines the state that will be used for the build
  53539. */
  53540. initialize(state: NodeMaterialBuildState): void;
  53541. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53543. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53544. protected _buildBlock(state: NodeMaterialBuildState): this;
  53545. }
  53546. }
  53547. declare module BABYLON {
  53548. /**
  53549. * Block used to pertub normals based on a normal map
  53550. */
  53551. export class PerturbNormalBlock extends NodeMaterialBlock {
  53552. private _tangentSpaceParameterName;
  53553. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53554. invertX: boolean;
  53555. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53556. invertY: boolean;
  53557. /**
  53558. * Create a new PerturbNormalBlock
  53559. * @param name defines the block name
  53560. */
  53561. constructor(name: string);
  53562. /**
  53563. * Gets the current class name
  53564. * @returns the class name
  53565. */
  53566. getClassName(): string;
  53567. /**
  53568. * Gets the world position input component
  53569. */
  53570. readonly worldPosition: NodeMaterialConnectionPoint;
  53571. /**
  53572. * Gets the world normal input component
  53573. */
  53574. readonly worldNormal: NodeMaterialConnectionPoint;
  53575. /**
  53576. * Gets the uv input component
  53577. */
  53578. readonly uv: NodeMaterialConnectionPoint;
  53579. /**
  53580. * Gets the normal map color input component
  53581. */
  53582. readonly normalMapColor: NodeMaterialConnectionPoint;
  53583. /**
  53584. * Gets the strength input component
  53585. */
  53586. readonly strength: NodeMaterialConnectionPoint;
  53587. /**
  53588. * Gets the output component
  53589. */
  53590. readonly output: NodeMaterialConnectionPoint;
  53591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53593. autoConfigure(material: NodeMaterial): void;
  53594. protected _buildBlock(state: NodeMaterialBuildState): this;
  53595. protected _dumpPropertiesCode(): string;
  53596. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53597. }
  53598. }
  53599. declare module BABYLON {
  53600. /**
  53601. * Block used to discard a pixel if a value is smaller than a cutoff
  53602. */
  53603. export class DiscardBlock extends NodeMaterialBlock {
  53604. /**
  53605. * Create a new DiscardBlock
  53606. * @param name defines the block name
  53607. */
  53608. constructor(name: string);
  53609. /**
  53610. * Gets the current class name
  53611. * @returns the class name
  53612. */
  53613. getClassName(): string;
  53614. /**
  53615. * Gets the color input component
  53616. */
  53617. readonly value: NodeMaterialConnectionPoint;
  53618. /**
  53619. * Gets the cutoff input component
  53620. */
  53621. readonly cutoff: NodeMaterialConnectionPoint;
  53622. protected _buildBlock(state: NodeMaterialBuildState): this;
  53623. }
  53624. }
  53625. declare module BABYLON {
  53626. /**
  53627. * Block used to add support for scene fog
  53628. */
  53629. export class FogBlock extends NodeMaterialBlock {
  53630. private _fogDistanceName;
  53631. private _fogParameters;
  53632. /**
  53633. * Create a new FogBlock
  53634. * @param name defines the block name
  53635. */
  53636. constructor(name: string);
  53637. /**
  53638. * Gets the current class name
  53639. * @returns the class name
  53640. */
  53641. getClassName(): string;
  53642. /**
  53643. * Gets the world position input component
  53644. */
  53645. readonly worldPosition: NodeMaterialConnectionPoint;
  53646. /**
  53647. * Gets the view input component
  53648. */
  53649. readonly view: NodeMaterialConnectionPoint;
  53650. /**
  53651. * Gets the color input component
  53652. */
  53653. readonly input: NodeMaterialConnectionPoint;
  53654. /**
  53655. * Gets the fog color input component
  53656. */
  53657. readonly fogColor: NodeMaterialConnectionPoint;
  53658. /**
  53659. * Gets the output component
  53660. */
  53661. readonly output: NodeMaterialConnectionPoint;
  53662. autoConfigure(material: NodeMaterial): void;
  53663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53665. protected _buildBlock(state: NodeMaterialBuildState): this;
  53666. }
  53667. }
  53668. declare module BABYLON {
  53669. /**
  53670. * Block used to add light in the fragment shader
  53671. */
  53672. export class LightBlock extends NodeMaterialBlock {
  53673. private _lightId;
  53674. /**
  53675. * Gets or sets the light associated with this block
  53676. */
  53677. light: Nullable<Light>;
  53678. /**
  53679. * Create a new LightBlock
  53680. * @param name defines the block name
  53681. */
  53682. constructor(name: string);
  53683. /**
  53684. * Gets the current class name
  53685. * @returns the class name
  53686. */
  53687. getClassName(): string;
  53688. /**
  53689. * Gets the world position input component
  53690. */
  53691. readonly worldPosition: NodeMaterialConnectionPoint;
  53692. /**
  53693. * Gets the world normal input component
  53694. */
  53695. readonly worldNormal: NodeMaterialConnectionPoint;
  53696. /**
  53697. * Gets the camera (or eye) position component
  53698. */
  53699. readonly cameraPosition: NodeMaterialConnectionPoint;
  53700. /**
  53701. * Gets the glossiness component
  53702. */
  53703. readonly glossiness: NodeMaterialConnectionPoint;
  53704. /**
  53705. * Gets the glossinness power component
  53706. */
  53707. readonly glossPower: NodeMaterialConnectionPoint;
  53708. /**
  53709. * Gets the diffuse color component
  53710. */
  53711. readonly diffuseColor: NodeMaterialConnectionPoint;
  53712. /**
  53713. * Gets the specular color component
  53714. */
  53715. readonly specularColor: NodeMaterialConnectionPoint;
  53716. /**
  53717. * Gets the diffuse output component
  53718. */
  53719. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53720. /**
  53721. * Gets the specular output component
  53722. */
  53723. readonly specularOutput: NodeMaterialConnectionPoint;
  53724. autoConfigure(material: NodeMaterial): void;
  53725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53726. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53728. private _injectVertexCode;
  53729. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53730. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53731. }
  53732. }
  53733. declare module BABYLON {
  53734. /**
  53735. * Block used to multiply 2 values
  53736. */
  53737. export class MultiplyBlock extends NodeMaterialBlock {
  53738. /**
  53739. * Creates a new MultiplyBlock
  53740. * @param name defines the block name
  53741. */
  53742. constructor(name: string);
  53743. /**
  53744. * Gets the current class name
  53745. * @returns the class name
  53746. */
  53747. getClassName(): string;
  53748. /**
  53749. * Gets the left operand input component
  53750. */
  53751. readonly left: NodeMaterialConnectionPoint;
  53752. /**
  53753. * Gets the right operand input component
  53754. */
  53755. readonly right: NodeMaterialConnectionPoint;
  53756. /**
  53757. * Gets the output component
  53758. */
  53759. readonly output: NodeMaterialConnectionPoint;
  53760. protected _buildBlock(state: NodeMaterialBuildState): this;
  53761. }
  53762. }
  53763. declare module BABYLON {
  53764. /**
  53765. * Block used to add 2 vectors
  53766. */
  53767. export class AddBlock extends NodeMaterialBlock {
  53768. /**
  53769. * Creates a new AddBlock
  53770. * @param name defines the block name
  53771. */
  53772. constructor(name: string);
  53773. /**
  53774. * Gets the current class name
  53775. * @returns the class name
  53776. */
  53777. getClassName(): string;
  53778. /**
  53779. * Gets the left operand input component
  53780. */
  53781. readonly left: NodeMaterialConnectionPoint;
  53782. /**
  53783. * Gets the right operand input component
  53784. */
  53785. readonly right: NodeMaterialConnectionPoint;
  53786. /**
  53787. * Gets the output component
  53788. */
  53789. readonly output: NodeMaterialConnectionPoint;
  53790. protected _buildBlock(state: NodeMaterialBuildState): this;
  53791. }
  53792. }
  53793. declare module BABYLON {
  53794. /**
  53795. * Block used to scale a vector by a float
  53796. */
  53797. export class ScaleBlock extends NodeMaterialBlock {
  53798. /**
  53799. * Creates a new ScaleBlock
  53800. * @param name defines the block name
  53801. */
  53802. constructor(name: string);
  53803. /**
  53804. * Gets the current class name
  53805. * @returns the class name
  53806. */
  53807. getClassName(): string;
  53808. /**
  53809. * Gets the input component
  53810. */
  53811. readonly input: NodeMaterialConnectionPoint;
  53812. /**
  53813. * Gets the factor input component
  53814. */
  53815. readonly factor: NodeMaterialConnectionPoint;
  53816. /**
  53817. * Gets the output component
  53818. */
  53819. readonly output: NodeMaterialConnectionPoint;
  53820. protected _buildBlock(state: NodeMaterialBuildState): this;
  53821. }
  53822. }
  53823. declare module BABYLON {
  53824. /**
  53825. * Block used to clamp a float
  53826. */
  53827. export class ClampBlock extends NodeMaterialBlock {
  53828. /** Gets or sets the minimum range */
  53829. minimum: number;
  53830. /** Gets or sets the maximum range */
  53831. maximum: number;
  53832. /**
  53833. * Creates a new ClampBlock
  53834. * @param name defines the block name
  53835. */
  53836. constructor(name: string);
  53837. /**
  53838. * Gets the current class name
  53839. * @returns the class name
  53840. */
  53841. getClassName(): string;
  53842. /**
  53843. * Gets the value input component
  53844. */
  53845. readonly value: NodeMaterialConnectionPoint;
  53846. /**
  53847. * Gets the output component
  53848. */
  53849. readonly output: NodeMaterialConnectionPoint;
  53850. protected _buildBlock(state: NodeMaterialBuildState): this;
  53851. protected _dumpPropertiesCode(): string;
  53852. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53853. }
  53854. }
  53855. declare module BABYLON {
  53856. /**
  53857. * Block used to apply a cross product between 2 vectors
  53858. */
  53859. export class CrossBlock extends NodeMaterialBlock {
  53860. /**
  53861. * Creates a new CrossBlock
  53862. * @param name defines the block name
  53863. */
  53864. constructor(name: string);
  53865. /**
  53866. * Gets the current class name
  53867. * @returns the class name
  53868. */
  53869. getClassName(): string;
  53870. /**
  53871. * Gets the left operand input component
  53872. */
  53873. readonly left: NodeMaterialConnectionPoint;
  53874. /**
  53875. * Gets the right operand input component
  53876. */
  53877. readonly right: NodeMaterialConnectionPoint;
  53878. /**
  53879. * Gets the output component
  53880. */
  53881. readonly output: NodeMaterialConnectionPoint;
  53882. protected _buildBlock(state: NodeMaterialBuildState): this;
  53883. }
  53884. }
  53885. declare module BABYLON {
  53886. /**
  53887. * Block used to apply a dot product between 2 vectors
  53888. */
  53889. export class DotBlock extends NodeMaterialBlock {
  53890. /**
  53891. * Creates a new DotBlock
  53892. * @param name defines the block name
  53893. */
  53894. constructor(name: string);
  53895. /**
  53896. * Gets the current class name
  53897. * @returns the class name
  53898. */
  53899. getClassName(): string;
  53900. /**
  53901. * Gets the left operand input component
  53902. */
  53903. readonly left: NodeMaterialConnectionPoint;
  53904. /**
  53905. * Gets the right operand input component
  53906. */
  53907. readonly right: NodeMaterialConnectionPoint;
  53908. /**
  53909. * Gets the output component
  53910. */
  53911. readonly output: NodeMaterialConnectionPoint;
  53912. protected _buildBlock(state: NodeMaterialBuildState): this;
  53913. }
  53914. }
  53915. declare module BABYLON {
  53916. /**
  53917. * Block used to remap a float from a range to a new one
  53918. */
  53919. export class RemapBlock extends NodeMaterialBlock {
  53920. /**
  53921. * Gets or sets the source range
  53922. */
  53923. sourceRange: Vector2;
  53924. /**
  53925. * Gets or sets the target range
  53926. */
  53927. targetRange: Vector2;
  53928. /**
  53929. * Creates a new RemapBlock
  53930. * @param name defines the block name
  53931. */
  53932. constructor(name: string);
  53933. /**
  53934. * Gets the current class name
  53935. * @returns the class name
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Gets the input component
  53940. */
  53941. readonly input: NodeMaterialConnectionPoint;
  53942. /**
  53943. * Gets the source min input component
  53944. */
  53945. readonly sourceMin: NodeMaterialConnectionPoint;
  53946. /**
  53947. * Gets the source max input component
  53948. */
  53949. readonly sourceMax: NodeMaterialConnectionPoint;
  53950. /**
  53951. * Gets the target min input component
  53952. */
  53953. readonly targetMin: NodeMaterialConnectionPoint;
  53954. /**
  53955. * Gets the target max input component
  53956. */
  53957. readonly targetMax: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the output component
  53960. */
  53961. readonly output: NodeMaterialConnectionPoint;
  53962. protected _buildBlock(state: NodeMaterialBuildState): this;
  53963. protected _dumpPropertiesCode(): string;
  53964. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53965. }
  53966. }
  53967. declare module BABYLON {
  53968. /**
  53969. * Block used to normalize a vector
  53970. */
  53971. export class NormalizeBlock extends NodeMaterialBlock {
  53972. /**
  53973. * Creates a new NormalizeBlock
  53974. * @param name defines the block name
  53975. */
  53976. constructor(name: string);
  53977. /**
  53978. * Gets the current class name
  53979. * @returns the class name
  53980. */
  53981. getClassName(): string;
  53982. /**
  53983. * Gets the input component
  53984. */
  53985. readonly input: NodeMaterialConnectionPoint;
  53986. /**
  53987. * Gets the output component
  53988. */
  53989. readonly output: NodeMaterialConnectionPoint;
  53990. protected _buildBlock(state: NodeMaterialBuildState): this;
  53991. }
  53992. }
  53993. declare module BABYLON {
  53994. /**
  53995. * Operations supported by the Trigonometry block
  53996. */
  53997. export enum TrigonometryBlockOperations {
  53998. /** Cos */
  53999. Cos = 0,
  54000. /** Sin */
  54001. Sin = 1,
  54002. /** Abs */
  54003. Abs = 2,
  54004. /** Exp */
  54005. Exp = 3,
  54006. /** Exp2 */
  54007. Exp2 = 4,
  54008. /** Round */
  54009. Round = 5,
  54010. /** Floor */
  54011. Floor = 6,
  54012. /** Ceiling */
  54013. Ceiling = 7,
  54014. /** Square root */
  54015. Sqrt = 8,
  54016. /** Log */
  54017. Log = 9,
  54018. /** Tangent */
  54019. Tan = 10,
  54020. /** Arc tangent */
  54021. ArcTan = 11,
  54022. /** Arc cosinus */
  54023. ArcCos = 12,
  54024. /** Arc sinus */
  54025. ArcSin = 13,
  54026. /** Fraction */
  54027. Fract = 14,
  54028. /** Sign */
  54029. Sign = 15,
  54030. /** To radians (from degrees) */
  54031. Radians = 16,
  54032. /** To degrees (from radians) */
  54033. Degrees = 17
  54034. }
  54035. /**
  54036. * Block used to apply trigonometry operation to floats
  54037. */
  54038. export class TrigonometryBlock extends NodeMaterialBlock {
  54039. /**
  54040. * Gets or sets the operation applied by the block
  54041. */
  54042. operation: TrigonometryBlockOperations;
  54043. /**
  54044. * Creates a new TrigonometryBlock
  54045. * @param name defines the block name
  54046. */
  54047. constructor(name: string);
  54048. /**
  54049. * Gets the current class name
  54050. * @returns the class name
  54051. */
  54052. getClassName(): string;
  54053. /**
  54054. * Gets the input component
  54055. */
  54056. readonly input: NodeMaterialConnectionPoint;
  54057. /**
  54058. * Gets the output component
  54059. */
  54060. readonly output: NodeMaterialConnectionPoint;
  54061. protected _buildBlock(state: NodeMaterialBuildState): this;
  54062. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54063. }
  54064. }
  54065. declare module BABYLON {
  54066. /**
  54067. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54068. */
  54069. export class ColorMergerBlock extends NodeMaterialBlock {
  54070. /**
  54071. * Create a new ColorMergerBlock
  54072. * @param name defines the block name
  54073. */
  54074. constructor(name: string);
  54075. /**
  54076. * Gets the current class name
  54077. * @returns the class name
  54078. */
  54079. getClassName(): string;
  54080. /**
  54081. * Gets the r component (input)
  54082. */
  54083. readonly r: NodeMaterialConnectionPoint;
  54084. /**
  54085. * Gets the g component (input)
  54086. */
  54087. readonly g: NodeMaterialConnectionPoint;
  54088. /**
  54089. * Gets the b component (input)
  54090. */
  54091. readonly b: NodeMaterialConnectionPoint;
  54092. /**
  54093. * Gets the a component (input)
  54094. */
  54095. readonly a: NodeMaterialConnectionPoint;
  54096. /**
  54097. * Gets the rgba component (output)
  54098. */
  54099. readonly rgba: NodeMaterialConnectionPoint;
  54100. /**
  54101. * Gets the rgb component (output)
  54102. */
  54103. readonly rgb: NodeMaterialConnectionPoint;
  54104. protected _buildBlock(state: NodeMaterialBuildState): this;
  54105. }
  54106. }
  54107. declare module BABYLON {
  54108. /**
  54109. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54110. */
  54111. export class VectorMergerBlock extends NodeMaterialBlock {
  54112. /**
  54113. * Create a new VectorMergerBlock
  54114. * @param name defines the block name
  54115. */
  54116. constructor(name: string);
  54117. /**
  54118. * Gets the current class name
  54119. * @returns the class name
  54120. */
  54121. getClassName(): string;
  54122. /**
  54123. * Gets the x component (input)
  54124. */
  54125. readonly x: NodeMaterialConnectionPoint;
  54126. /**
  54127. * Gets the y component (input)
  54128. */
  54129. readonly y: NodeMaterialConnectionPoint;
  54130. /**
  54131. * Gets the z component (input)
  54132. */
  54133. readonly z: NodeMaterialConnectionPoint;
  54134. /**
  54135. * Gets the w component (input)
  54136. */
  54137. readonly w: NodeMaterialConnectionPoint;
  54138. /**
  54139. * Gets the xyzw component (output)
  54140. */
  54141. readonly xyzw: NodeMaterialConnectionPoint;
  54142. /**
  54143. * Gets the xyz component (output)
  54144. */
  54145. readonly xyz: NodeMaterialConnectionPoint;
  54146. /**
  54147. * Gets the xy component (output)
  54148. */
  54149. readonly xy: NodeMaterialConnectionPoint;
  54150. protected _buildBlock(state: NodeMaterialBuildState): this;
  54151. }
  54152. }
  54153. declare module BABYLON {
  54154. /**
  54155. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54156. */
  54157. export class ColorSplitterBlock extends NodeMaterialBlock {
  54158. /**
  54159. * Create a new ColorSplitterBlock
  54160. * @param name defines the block name
  54161. */
  54162. constructor(name: string);
  54163. /**
  54164. * Gets the current class name
  54165. * @returns the class name
  54166. */
  54167. getClassName(): string;
  54168. /**
  54169. * Gets the rgba component (input)
  54170. */
  54171. readonly rgba: NodeMaterialConnectionPoint;
  54172. /**
  54173. * Gets the rgb component (input)
  54174. */
  54175. readonly rgbIn: NodeMaterialConnectionPoint;
  54176. /**
  54177. * Gets the rgb component (output)
  54178. */
  54179. readonly rgbOut: NodeMaterialConnectionPoint;
  54180. /**
  54181. * Gets the r component (output)
  54182. */
  54183. readonly r: NodeMaterialConnectionPoint;
  54184. /**
  54185. * Gets the g component (output)
  54186. */
  54187. readonly g: NodeMaterialConnectionPoint;
  54188. /**
  54189. * Gets the b component (output)
  54190. */
  54191. readonly b: NodeMaterialConnectionPoint;
  54192. /**
  54193. * Gets the a component (output)
  54194. */
  54195. readonly a: NodeMaterialConnectionPoint;
  54196. protected _inputRename(name: string): string;
  54197. protected _outputRename(name: string): string;
  54198. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54199. }
  54200. }
  54201. declare module BABYLON {
  54202. /**
  54203. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54204. */
  54205. export class VectorSplitterBlock extends NodeMaterialBlock {
  54206. /**
  54207. * Create a new VectorSplitterBlock
  54208. * @param name defines the block name
  54209. */
  54210. constructor(name: string);
  54211. /**
  54212. * Gets the current class name
  54213. * @returns the class name
  54214. */
  54215. getClassName(): string;
  54216. /**
  54217. * Gets the xyzw component (input)
  54218. */
  54219. readonly xyzw: NodeMaterialConnectionPoint;
  54220. /**
  54221. * Gets the xyz component (input)
  54222. */
  54223. readonly xyzIn: NodeMaterialConnectionPoint;
  54224. /**
  54225. * Gets the xy component (input)
  54226. */
  54227. readonly xyIn: NodeMaterialConnectionPoint;
  54228. /**
  54229. * Gets the xyz component (output)
  54230. */
  54231. readonly xyzOut: NodeMaterialConnectionPoint;
  54232. /**
  54233. * Gets the xy component (output)
  54234. */
  54235. readonly xyOut: NodeMaterialConnectionPoint;
  54236. /**
  54237. * Gets the x component (output)
  54238. */
  54239. readonly x: NodeMaterialConnectionPoint;
  54240. /**
  54241. * Gets the y component (output)
  54242. */
  54243. readonly y: NodeMaterialConnectionPoint;
  54244. /**
  54245. * Gets the z component (output)
  54246. */
  54247. readonly z: NodeMaterialConnectionPoint;
  54248. /**
  54249. * Gets the w component (output)
  54250. */
  54251. readonly w: NodeMaterialConnectionPoint;
  54252. protected _inputRename(name: string): string;
  54253. protected _outputRename(name: string): string;
  54254. protected _buildBlock(state: NodeMaterialBuildState): this;
  54255. }
  54256. }
  54257. declare module BABYLON {
  54258. /**
  54259. * Block used to lerp between 2 values
  54260. */
  54261. export class LerpBlock extends NodeMaterialBlock {
  54262. /**
  54263. * Creates a new LerpBlock
  54264. * @param name defines the block name
  54265. */
  54266. constructor(name: string);
  54267. /**
  54268. * Gets the current class name
  54269. * @returns the class name
  54270. */
  54271. getClassName(): string;
  54272. /**
  54273. * Gets the left operand input component
  54274. */
  54275. readonly left: NodeMaterialConnectionPoint;
  54276. /**
  54277. * Gets the right operand input component
  54278. */
  54279. readonly right: NodeMaterialConnectionPoint;
  54280. /**
  54281. * Gets the gradient operand input component
  54282. */
  54283. readonly gradient: NodeMaterialConnectionPoint;
  54284. /**
  54285. * Gets the output component
  54286. */
  54287. readonly output: NodeMaterialConnectionPoint;
  54288. protected _buildBlock(state: NodeMaterialBuildState): this;
  54289. }
  54290. }
  54291. declare module BABYLON {
  54292. /**
  54293. * Block used to divide 2 vectors
  54294. */
  54295. export class DivideBlock extends NodeMaterialBlock {
  54296. /**
  54297. * Creates a new DivideBlock
  54298. * @param name defines the block name
  54299. */
  54300. constructor(name: string);
  54301. /**
  54302. * Gets the current class name
  54303. * @returns the class name
  54304. */
  54305. getClassName(): string;
  54306. /**
  54307. * Gets the left operand input component
  54308. */
  54309. readonly left: NodeMaterialConnectionPoint;
  54310. /**
  54311. * Gets the right operand input component
  54312. */
  54313. readonly right: NodeMaterialConnectionPoint;
  54314. /**
  54315. * Gets the output component
  54316. */
  54317. readonly output: NodeMaterialConnectionPoint;
  54318. protected _buildBlock(state: NodeMaterialBuildState): this;
  54319. }
  54320. }
  54321. declare module BABYLON {
  54322. /**
  54323. * Block used to subtract 2 vectors
  54324. */
  54325. export class SubtractBlock extends NodeMaterialBlock {
  54326. /**
  54327. * Creates a new SubtractBlock
  54328. * @param name defines the block name
  54329. */
  54330. constructor(name: string);
  54331. /**
  54332. * Gets the current class name
  54333. * @returns the class name
  54334. */
  54335. getClassName(): string;
  54336. /**
  54337. * Gets the left operand input component
  54338. */
  54339. readonly left: NodeMaterialConnectionPoint;
  54340. /**
  54341. * Gets the right operand input component
  54342. */
  54343. readonly right: NodeMaterialConnectionPoint;
  54344. /**
  54345. * Gets the output component
  54346. */
  54347. readonly output: NodeMaterialConnectionPoint;
  54348. protected _buildBlock(state: NodeMaterialBuildState): this;
  54349. }
  54350. }
  54351. declare module BABYLON {
  54352. /**
  54353. * Block used to step a value
  54354. */
  54355. export class StepBlock extends NodeMaterialBlock {
  54356. /**
  54357. * Creates a new StepBlock
  54358. * @param name defines the block name
  54359. */
  54360. constructor(name: string);
  54361. /**
  54362. * Gets the current class name
  54363. * @returns the class name
  54364. */
  54365. getClassName(): string;
  54366. /**
  54367. * Gets the value operand input component
  54368. */
  54369. readonly value: NodeMaterialConnectionPoint;
  54370. /**
  54371. * Gets the edge operand input component
  54372. */
  54373. readonly edge: NodeMaterialConnectionPoint;
  54374. /**
  54375. * Gets the output component
  54376. */
  54377. readonly output: NodeMaterialConnectionPoint;
  54378. protected _buildBlock(state: NodeMaterialBuildState): this;
  54379. }
  54380. }
  54381. declare module BABYLON {
  54382. /**
  54383. * Block used to get the opposite (1 - x) of a value
  54384. */
  54385. export class OneMinusBlock extends NodeMaterialBlock {
  54386. /**
  54387. * Creates a new OneMinusBlock
  54388. * @param name defines the block name
  54389. */
  54390. constructor(name: string);
  54391. /**
  54392. * Gets the current class name
  54393. * @returns the class name
  54394. */
  54395. getClassName(): string;
  54396. /**
  54397. * Gets the input component
  54398. */
  54399. readonly input: NodeMaterialConnectionPoint;
  54400. /**
  54401. * Gets the output component
  54402. */
  54403. readonly output: NodeMaterialConnectionPoint;
  54404. protected _buildBlock(state: NodeMaterialBuildState): this;
  54405. }
  54406. }
  54407. declare module BABYLON {
  54408. /**
  54409. * Block used to get the view direction
  54410. */
  54411. export class ViewDirectionBlock extends NodeMaterialBlock {
  54412. /**
  54413. * Creates a new ViewDirectionBlock
  54414. * @param name defines the block name
  54415. */
  54416. constructor(name: string);
  54417. /**
  54418. * Gets the current class name
  54419. * @returns the class name
  54420. */
  54421. getClassName(): string;
  54422. /**
  54423. * Gets the world position component
  54424. */
  54425. readonly worldPosition: NodeMaterialConnectionPoint;
  54426. /**
  54427. * Gets the camera position component
  54428. */
  54429. readonly cameraPosition: NodeMaterialConnectionPoint;
  54430. /**
  54431. * Gets the output component
  54432. */
  54433. readonly output: NodeMaterialConnectionPoint;
  54434. autoConfigure(material: NodeMaterial): void;
  54435. protected _buildBlock(state: NodeMaterialBuildState): this;
  54436. }
  54437. }
  54438. declare module BABYLON {
  54439. /**
  54440. * Block used to compute fresnel value
  54441. */
  54442. export class FresnelBlock extends NodeMaterialBlock {
  54443. /**
  54444. * Create a new FresnelBlock
  54445. * @param name defines the block name
  54446. */
  54447. constructor(name: string);
  54448. /**
  54449. * Gets the current class name
  54450. * @returns the class name
  54451. */
  54452. getClassName(): string;
  54453. /**
  54454. * Gets the world normal input component
  54455. */
  54456. readonly worldNormal: NodeMaterialConnectionPoint;
  54457. /**
  54458. * Gets the view direction input component
  54459. */
  54460. readonly viewDirection: NodeMaterialConnectionPoint;
  54461. /**
  54462. * Gets the bias input component
  54463. */
  54464. readonly bias: NodeMaterialConnectionPoint;
  54465. /**
  54466. * Gets the camera (or eye) position component
  54467. */
  54468. readonly power: NodeMaterialConnectionPoint;
  54469. /**
  54470. * Gets the fresnel output component
  54471. */
  54472. readonly fresnel: NodeMaterialConnectionPoint;
  54473. autoConfigure(material: NodeMaterial): void;
  54474. protected _buildBlock(state: NodeMaterialBuildState): this;
  54475. }
  54476. }
  54477. declare module BABYLON {
  54478. /**
  54479. * Block used to get the max of 2 values
  54480. */
  54481. export class MaxBlock extends NodeMaterialBlock {
  54482. /**
  54483. * Creates a new MaxBlock
  54484. * @param name defines the block name
  54485. */
  54486. constructor(name: string);
  54487. /**
  54488. * Gets the current class name
  54489. * @returns the class name
  54490. */
  54491. getClassName(): string;
  54492. /**
  54493. * Gets the left operand input component
  54494. */
  54495. readonly left: NodeMaterialConnectionPoint;
  54496. /**
  54497. * Gets the right operand input component
  54498. */
  54499. readonly right: NodeMaterialConnectionPoint;
  54500. /**
  54501. * Gets the output component
  54502. */
  54503. readonly output: NodeMaterialConnectionPoint;
  54504. protected _buildBlock(state: NodeMaterialBuildState): this;
  54505. }
  54506. }
  54507. declare module BABYLON {
  54508. /**
  54509. * Block used to get the min of 2 values
  54510. */
  54511. export class MinBlock extends NodeMaterialBlock {
  54512. /**
  54513. * Creates a new MinBlock
  54514. * @param name defines the block name
  54515. */
  54516. constructor(name: string);
  54517. /**
  54518. * Gets the current class name
  54519. * @returns the class name
  54520. */
  54521. getClassName(): string;
  54522. /**
  54523. * Gets the left operand input component
  54524. */
  54525. readonly left: NodeMaterialConnectionPoint;
  54526. /**
  54527. * Gets the right operand input component
  54528. */
  54529. readonly right: NodeMaterialConnectionPoint;
  54530. /**
  54531. * Gets the output component
  54532. */
  54533. readonly output: NodeMaterialConnectionPoint;
  54534. protected _buildBlock(state: NodeMaterialBuildState): this;
  54535. }
  54536. }
  54537. declare module BABYLON {
  54538. /**
  54539. * Block used to get the distance between 2 values
  54540. */
  54541. export class DistanceBlock extends NodeMaterialBlock {
  54542. /**
  54543. * Creates a new DistanceBlock
  54544. * @param name defines the block name
  54545. */
  54546. constructor(name: string);
  54547. /**
  54548. * Gets the current class name
  54549. * @returns the class name
  54550. */
  54551. getClassName(): string;
  54552. /**
  54553. * Gets the left operand input component
  54554. */
  54555. readonly left: NodeMaterialConnectionPoint;
  54556. /**
  54557. * Gets the right operand input component
  54558. */
  54559. readonly right: NodeMaterialConnectionPoint;
  54560. /**
  54561. * Gets the output component
  54562. */
  54563. readonly output: NodeMaterialConnectionPoint;
  54564. protected _buildBlock(state: NodeMaterialBuildState): this;
  54565. }
  54566. }
  54567. declare module BABYLON {
  54568. /**
  54569. * Block used to get the length of a vector
  54570. */
  54571. export class LengthBlock extends NodeMaterialBlock {
  54572. /**
  54573. * Creates a new LengthBlock
  54574. * @param name defines the block name
  54575. */
  54576. constructor(name: string);
  54577. /**
  54578. * Gets the current class name
  54579. * @returns the class name
  54580. */
  54581. getClassName(): string;
  54582. /**
  54583. * Gets the value input component
  54584. */
  54585. readonly value: NodeMaterialConnectionPoint;
  54586. /**
  54587. * Gets the output component
  54588. */
  54589. readonly output: NodeMaterialConnectionPoint;
  54590. protected _buildBlock(state: NodeMaterialBuildState): this;
  54591. }
  54592. }
  54593. declare module BABYLON {
  54594. /**
  54595. * Block used to get negative version of a value (i.e. x * -1)
  54596. */
  54597. export class NegateBlock extends NodeMaterialBlock {
  54598. /**
  54599. * Creates a new NegateBlock
  54600. * @param name defines the block name
  54601. */
  54602. constructor(name: string);
  54603. /**
  54604. * Gets the current class name
  54605. * @returns the class name
  54606. */
  54607. getClassName(): string;
  54608. /**
  54609. * Gets the value input component
  54610. */
  54611. readonly value: NodeMaterialConnectionPoint;
  54612. /**
  54613. * Gets the output component
  54614. */
  54615. readonly output: NodeMaterialConnectionPoint;
  54616. protected _buildBlock(state: NodeMaterialBuildState): this;
  54617. }
  54618. }
  54619. declare module BABYLON {
  54620. /**
  54621. * Block used to get the value of the first parameter raised to the power of the second
  54622. */
  54623. export class PowBlock extends NodeMaterialBlock {
  54624. /**
  54625. * Creates a new PowBlock
  54626. * @param name defines the block name
  54627. */
  54628. constructor(name: string);
  54629. /**
  54630. * Gets the current class name
  54631. * @returns the class name
  54632. */
  54633. getClassName(): string;
  54634. /**
  54635. * Gets the value operand input component
  54636. */
  54637. readonly value: NodeMaterialConnectionPoint;
  54638. /**
  54639. * Gets the power operand input component
  54640. */
  54641. readonly power: NodeMaterialConnectionPoint;
  54642. /**
  54643. * Gets the output component
  54644. */
  54645. readonly output: NodeMaterialConnectionPoint;
  54646. protected _buildBlock(state: NodeMaterialBuildState): this;
  54647. }
  54648. }
  54649. declare module BABYLON {
  54650. /**
  54651. * Block used to get a random number
  54652. */
  54653. export class RandomNumberBlock extends NodeMaterialBlock {
  54654. /**
  54655. * Creates a new RandomNumberBlock
  54656. * @param name defines the block name
  54657. */
  54658. constructor(name: string);
  54659. /**
  54660. * Gets the current class name
  54661. * @returns the class name
  54662. */
  54663. getClassName(): string;
  54664. /**
  54665. * Gets the seed input component
  54666. */
  54667. readonly seed: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the output component
  54670. */
  54671. readonly output: NodeMaterialConnectionPoint;
  54672. protected _buildBlock(state: NodeMaterialBuildState): this;
  54673. }
  54674. }
  54675. declare module BABYLON {
  54676. /**
  54677. * Block used to compute arc tangent of 2 values
  54678. */
  54679. export class ArcTan2Block extends NodeMaterialBlock {
  54680. /**
  54681. * Creates a new ArcTan2Block
  54682. * @param name defines the block name
  54683. */
  54684. constructor(name: string);
  54685. /**
  54686. * Gets the current class name
  54687. * @returns the class name
  54688. */
  54689. getClassName(): string;
  54690. /**
  54691. * Gets the x operand input component
  54692. */
  54693. readonly x: NodeMaterialConnectionPoint;
  54694. /**
  54695. * Gets the y operand input component
  54696. */
  54697. readonly y: NodeMaterialConnectionPoint;
  54698. /**
  54699. * Gets the output component
  54700. */
  54701. readonly output: NodeMaterialConnectionPoint;
  54702. protected _buildBlock(state: NodeMaterialBuildState): this;
  54703. }
  54704. }
  54705. declare module BABYLON {
  54706. /**
  54707. * Block used to smooth step a value
  54708. */
  54709. export class SmoothStepBlock extends NodeMaterialBlock {
  54710. /**
  54711. * Creates a new SmoothStepBlock
  54712. * @param name defines the block name
  54713. */
  54714. constructor(name: string);
  54715. /**
  54716. * Gets the current class name
  54717. * @returns the class name
  54718. */
  54719. getClassName(): string;
  54720. /**
  54721. * Gets the value operand input component
  54722. */
  54723. readonly value: NodeMaterialConnectionPoint;
  54724. /**
  54725. * Gets the first edge operand input component
  54726. */
  54727. readonly edge0: NodeMaterialConnectionPoint;
  54728. /**
  54729. * Gets the second edge operand input component
  54730. */
  54731. readonly edge1: NodeMaterialConnectionPoint;
  54732. /**
  54733. * Gets the output component
  54734. */
  54735. readonly output: NodeMaterialConnectionPoint;
  54736. protected _buildBlock(state: NodeMaterialBuildState): this;
  54737. }
  54738. }
  54739. declare module BABYLON {
  54740. /**
  54741. * Block used to get the reciprocal (1 / x) of a value
  54742. */
  54743. export class ReciprocalBlock extends NodeMaterialBlock {
  54744. /**
  54745. * Creates a new ReciprocalBlock
  54746. * @param name defines the block name
  54747. */
  54748. constructor(name: string);
  54749. /**
  54750. * Gets the current class name
  54751. * @returns the class name
  54752. */
  54753. getClassName(): string;
  54754. /**
  54755. * Gets the input component
  54756. */
  54757. readonly input: NodeMaterialConnectionPoint;
  54758. /**
  54759. * Gets the output component
  54760. */
  54761. readonly output: NodeMaterialConnectionPoint;
  54762. protected _buildBlock(state: NodeMaterialBuildState): this;
  54763. }
  54764. }
  54765. declare module BABYLON {
  54766. /**
  54767. * Block used to replace a color by another one
  54768. */
  54769. export class ReplaceColorBlock extends NodeMaterialBlock {
  54770. /**
  54771. * Creates a new ReplaceColorBlock
  54772. * @param name defines the block name
  54773. */
  54774. constructor(name: string);
  54775. /**
  54776. * Gets the current class name
  54777. * @returns the class name
  54778. */
  54779. getClassName(): string;
  54780. /**
  54781. * Gets the value input component
  54782. */
  54783. readonly value: NodeMaterialConnectionPoint;
  54784. /**
  54785. * Gets the reference input component
  54786. */
  54787. readonly reference: NodeMaterialConnectionPoint;
  54788. /**
  54789. * Gets the distance input component
  54790. */
  54791. readonly distance: NodeMaterialConnectionPoint;
  54792. /**
  54793. * Gets the replacement input component
  54794. */
  54795. readonly replacement: NodeMaterialConnectionPoint;
  54796. /**
  54797. * Gets the output component
  54798. */
  54799. readonly output: NodeMaterialConnectionPoint;
  54800. protected _buildBlock(state: NodeMaterialBuildState): this;
  54801. }
  54802. }
  54803. declare module BABYLON {
  54804. /**
  54805. * Block used to posterize a value
  54806. * @see https://en.wikipedia.org/wiki/Posterization
  54807. */
  54808. export class PosterizeBlock extends NodeMaterialBlock {
  54809. /**
  54810. * Creates a new PosterizeBlock
  54811. * @param name defines the block name
  54812. */
  54813. constructor(name: string);
  54814. /**
  54815. * Gets the current class name
  54816. * @returns the class name
  54817. */
  54818. getClassName(): string;
  54819. /**
  54820. * Gets the value input component
  54821. */
  54822. readonly value: NodeMaterialConnectionPoint;
  54823. /**
  54824. * Gets the steps input component
  54825. */
  54826. readonly steps: NodeMaterialConnectionPoint;
  54827. /**
  54828. * Gets the output component
  54829. */
  54830. readonly output: NodeMaterialConnectionPoint;
  54831. protected _buildBlock(state: NodeMaterialBuildState): this;
  54832. }
  54833. }
  54834. declare module BABYLON {
  54835. /**
  54836. * Operations supported by the Wave block
  54837. */
  54838. export enum WaveBlockKind {
  54839. /** SawTooth */
  54840. SawTooth = 0,
  54841. /** Square */
  54842. Square = 1,
  54843. /** Triangle */
  54844. Triangle = 2
  54845. }
  54846. /**
  54847. * Block used to apply wave operation to floats
  54848. */
  54849. export class WaveBlock extends NodeMaterialBlock {
  54850. /**
  54851. * Gets or sets the kibnd of wave to be applied by the block
  54852. */
  54853. kind: WaveBlockKind;
  54854. /**
  54855. * Creates a new WaveBlock
  54856. * @param name defines the block name
  54857. */
  54858. constructor(name: string);
  54859. /**
  54860. * Gets the current class name
  54861. * @returns the class name
  54862. */
  54863. getClassName(): string;
  54864. /**
  54865. * Gets the input component
  54866. */
  54867. readonly input: NodeMaterialConnectionPoint;
  54868. /**
  54869. * Gets the output component
  54870. */
  54871. readonly output: NodeMaterialConnectionPoint;
  54872. protected _buildBlock(state: NodeMaterialBuildState): this;
  54873. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54874. }
  54875. }
  54876. declare module BABYLON {
  54877. /**
  54878. * Class used to store a color step for the GradientBlock
  54879. */
  54880. export class GradientBlockColorStep {
  54881. /**
  54882. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54883. */
  54884. step: number;
  54885. /**
  54886. * Gets or sets the color associated with this step
  54887. */
  54888. color: Color3;
  54889. /**
  54890. * Creates a new GradientBlockColorStep
  54891. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  54892. * @param color defines the color associated with this step
  54893. */
  54894. constructor(
  54895. /**
  54896. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54897. */
  54898. step: number,
  54899. /**
  54900. * Gets or sets the color associated with this step
  54901. */
  54902. color: Color3);
  54903. }
  54904. /**
  54905. * Block used to return a color from a gradient based on an input value between 0 and 1
  54906. */
  54907. export class GradientBlock extends NodeMaterialBlock {
  54908. /**
  54909. * Gets or sets the list of color steps
  54910. */
  54911. colorSteps: GradientBlockColorStep[];
  54912. /**
  54913. * Creates a new GradientBlock
  54914. * @param name defines the block name
  54915. */
  54916. constructor(name: string);
  54917. /**
  54918. * Gets the current class name
  54919. * @returns the class name
  54920. */
  54921. getClassName(): string;
  54922. /**
  54923. * Gets the gradient input component
  54924. */
  54925. readonly gradient: NodeMaterialConnectionPoint;
  54926. /**
  54927. * Gets the output component
  54928. */
  54929. readonly output: NodeMaterialConnectionPoint;
  54930. private _writeColorConstant;
  54931. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54932. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54933. protected _dumpPropertiesCode(): string;
  54934. }
  54935. }
  54936. declare module BABYLON {
  54937. /**
  54938. * Block used to normalize lerp between 2 values
  54939. */
  54940. export class NLerpBlock extends NodeMaterialBlock {
  54941. /**
  54942. * Creates a new NLerpBlock
  54943. * @param name defines the block name
  54944. */
  54945. constructor(name: string);
  54946. /**
  54947. * Gets the current class name
  54948. * @returns the class name
  54949. */
  54950. getClassName(): string;
  54951. /**
  54952. * Gets the left operand input component
  54953. */
  54954. readonly left: NodeMaterialConnectionPoint;
  54955. /**
  54956. * Gets the right operand input component
  54957. */
  54958. readonly right: NodeMaterialConnectionPoint;
  54959. /**
  54960. * Gets the gradient operand input component
  54961. */
  54962. readonly gradient: NodeMaterialConnectionPoint;
  54963. /**
  54964. * Gets the output component
  54965. */
  54966. readonly output: NodeMaterialConnectionPoint;
  54967. protected _buildBlock(state: NodeMaterialBuildState): this;
  54968. }
  54969. }
  54970. declare module BABYLON {
  54971. /**
  54972. * Block used to test if the fragment shader is front facing
  54973. */
  54974. export class FrontFacingBlock extends NodeMaterialBlock {
  54975. /**
  54976. * Creates a new FrontFacingBlock
  54977. * @param name defines the block name
  54978. */
  54979. constructor(name: string);
  54980. /**
  54981. * Gets the current class name
  54982. * @returns the class name
  54983. */
  54984. getClassName(): string;
  54985. /**
  54986. * Gets the world normal component
  54987. */
  54988. readonly worldNormal: NodeMaterialConnectionPoint;
  54989. /**
  54990. * Gets the view direction input component
  54991. */
  54992. readonly viewDirection: NodeMaterialConnectionPoint;
  54993. /**
  54994. * Gets the output component
  54995. */
  54996. readonly output: NodeMaterialConnectionPoint;
  54997. autoConfigure(material: NodeMaterial): void;
  54998. protected _buildBlock(state: NodeMaterialBuildState): this;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Effect Render Options
  55004. */
  55005. export interface IEffectRendererOptions {
  55006. /**
  55007. * Defines the vertices positions.
  55008. */
  55009. positions?: number[];
  55010. /**
  55011. * Defines the indices.
  55012. */
  55013. indices?: number[];
  55014. }
  55015. /**
  55016. * Helper class to render one or more effects
  55017. */
  55018. export class EffectRenderer {
  55019. private engine;
  55020. private static _DefaultOptions;
  55021. private _vertexBuffers;
  55022. private _indexBuffer;
  55023. private _ringBufferIndex;
  55024. private _ringScreenBuffer;
  55025. private _fullscreenViewport;
  55026. private _getNextFrameBuffer;
  55027. /**
  55028. * Creates an effect renderer
  55029. * @param engine the engine to use for rendering
  55030. * @param options defines the options of the effect renderer
  55031. */
  55032. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55033. /**
  55034. * Sets the current viewport in normalized coordinates 0-1
  55035. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55036. */
  55037. setViewport(viewport?: Viewport): void;
  55038. /**
  55039. * Binds the embedded attributes buffer to the effect.
  55040. * @param effect Defines the effect to bind the attributes for
  55041. */
  55042. bindBuffers(effect: Effect): void;
  55043. /**
  55044. * Sets the current effect wrapper to use during draw.
  55045. * The effect needs to be ready before calling this api.
  55046. * This also sets the default full screen position attribute.
  55047. * @param effectWrapper Defines the effect to draw with
  55048. */
  55049. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55050. /**
  55051. * Draws a full screen quad.
  55052. */
  55053. draw(): void;
  55054. /**
  55055. * renders one or more effects to a specified texture
  55056. * @param effectWrappers list of effects to renderer
  55057. * @param outputTexture texture to draw to, if null it will render to the screen
  55058. */
  55059. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55060. /**
  55061. * Disposes of the effect renderer
  55062. */
  55063. dispose(): void;
  55064. }
  55065. /**
  55066. * Options to create an EffectWrapper
  55067. */
  55068. interface EffectWrapperCreationOptions {
  55069. /**
  55070. * Engine to use to create the effect
  55071. */
  55072. engine: ThinEngine;
  55073. /**
  55074. * Fragment shader for the effect
  55075. */
  55076. fragmentShader: string;
  55077. /**
  55078. * Vertex shader for the effect
  55079. */
  55080. vertexShader?: string;
  55081. /**
  55082. * Attributes to use in the shader
  55083. */
  55084. attributeNames?: Array<string>;
  55085. /**
  55086. * Uniforms to use in the shader
  55087. */
  55088. uniformNames?: Array<string>;
  55089. /**
  55090. * Texture sampler names to use in the shader
  55091. */
  55092. samplerNames?: Array<string>;
  55093. /**
  55094. * The friendly name of the effect displayed in Spector.
  55095. */
  55096. name?: string;
  55097. }
  55098. /**
  55099. * Wraps an effect to be used for rendering
  55100. */
  55101. export class EffectWrapper {
  55102. /**
  55103. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55104. */
  55105. onApplyObservable: Observable<{}>;
  55106. /**
  55107. * The underlying effect
  55108. */
  55109. effect: Effect;
  55110. /**
  55111. * Creates an effect to be renderer
  55112. * @param creationOptions options to create the effect
  55113. */
  55114. constructor(creationOptions: EffectWrapperCreationOptions);
  55115. /**
  55116. * Disposes of the effect wrapper
  55117. */
  55118. dispose(): void;
  55119. }
  55120. }
  55121. declare module BABYLON {
  55122. /**
  55123. * Helper class to push actions to a pool of workers.
  55124. */
  55125. export class WorkerPool implements IDisposable {
  55126. private _workerInfos;
  55127. private _pendingActions;
  55128. /**
  55129. * Constructor
  55130. * @param workers Array of workers to use for actions
  55131. */
  55132. constructor(workers: Array<Worker>);
  55133. /**
  55134. * Terminates all workers and clears any pending actions.
  55135. */
  55136. dispose(): void;
  55137. /**
  55138. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55139. * pended until a worker has completed its action.
  55140. * @param action The action to perform. Call onComplete when the action is complete.
  55141. */
  55142. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55143. private _execute;
  55144. }
  55145. }
  55146. declare module BABYLON {
  55147. /**
  55148. * Configuration for Draco compression
  55149. */
  55150. export interface IDracoCompressionConfiguration {
  55151. /**
  55152. * Configuration for the decoder.
  55153. */
  55154. decoder: {
  55155. /**
  55156. * The url to the WebAssembly module.
  55157. */
  55158. wasmUrl?: string;
  55159. /**
  55160. * The url to the WebAssembly binary.
  55161. */
  55162. wasmBinaryUrl?: string;
  55163. /**
  55164. * The url to the fallback JavaScript module.
  55165. */
  55166. fallbackUrl?: string;
  55167. };
  55168. }
  55169. /**
  55170. * Draco compression (https://google.github.io/draco/)
  55171. *
  55172. * This class wraps the Draco module.
  55173. *
  55174. * **Encoder**
  55175. *
  55176. * The encoder is not currently implemented.
  55177. *
  55178. * **Decoder**
  55179. *
  55180. * 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.
  55181. *
  55182. * To update the configuration, use the following code:
  55183. * ```javascript
  55184. * DracoCompression.Configuration = {
  55185. * decoder: {
  55186. * wasmUrl: "<url to the WebAssembly library>",
  55187. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55188. * fallbackUrl: "<url to the fallback JavaScript library>",
  55189. * }
  55190. * };
  55191. * ```
  55192. *
  55193. * 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.
  55194. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55195. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55196. *
  55197. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55198. * ```javascript
  55199. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55200. * ```
  55201. *
  55202. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55203. */
  55204. export class DracoCompression implements IDisposable {
  55205. private _workerPoolPromise?;
  55206. private _decoderModulePromise?;
  55207. /**
  55208. * The configuration. Defaults to the following urls:
  55209. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55210. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55211. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55212. */
  55213. static Configuration: IDracoCompressionConfiguration;
  55214. /**
  55215. * Returns true if the decoder configuration is available.
  55216. */
  55217. static readonly DecoderAvailable: boolean;
  55218. /**
  55219. * Default number of workers to create when creating the draco compression object.
  55220. */
  55221. static DefaultNumWorkers: number;
  55222. private static GetDefaultNumWorkers;
  55223. private static _Default;
  55224. /**
  55225. * Default instance for the draco compression object.
  55226. */
  55227. static readonly Default: DracoCompression;
  55228. /**
  55229. * Constructor
  55230. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55231. */
  55232. constructor(numWorkers?: number);
  55233. /**
  55234. * Stop all async operations and release resources.
  55235. */
  55236. dispose(): void;
  55237. /**
  55238. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55239. * @returns a promise that resolves when ready
  55240. */
  55241. whenReadyAsync(): Promise<void>;
  55242. /**
  55243. * Decode Draco compressed mesh data to vertex data.
  55244. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55245. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55246. * @returns A promise that resolves with the decoded vertex data
  55247. */
  55248. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55249. [kind: string]: number;
  55250. }): Promise<VertexData>;
  55251. }
  55252. }
  55253. declare module BABYLON {
  55254. /**
  55255. * Class for building Constructive Solid Geometry
  55256. */
  55257. export class CSG {
  55258. private polygons;
  55259. /**
  55260. * The world matrix
  55261. */
  55262. matrix: Matrix;
  55263. /**
  55264. * Stores the position
  55265. */
  55266. position: Vector3;
  55267. /**
  55268. * Stores the rotation
  55269. */
  55270. rotation: Vector3;
  55271. /**
  55272. * Stores the rotation quaternion
  55273. */
  55274. rotationQuaternion: Nullable<Quaternion>;
  55275. /**
  55276. * Stores the scaling vector
  55277. */
  55278. scaling: Vector3;
  55279. /**
  55280. * Convert the Mesh to CSG
  55281. * @param mesh The Mesh to convert to CSG
  55282. * @returns A new CSG from the Mesh
  55283. */
  55284. static FromMesh(mesh: Mesh): CSG;
  55285. /**
  55286. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55287. * @param polygons Polygons used to construct a CSG solid
  55288. */
  55289. private static FromPolygons;
  55290. /**
  55291. * Clones, or makes a deep copy, of the CSG
  55292. * @returns A new CSG
  55293. */
  55294. clone(): CSG;
  55295. /**
  55296. * Unions this CSG with another CSG
  55297. * @param csg The CSG to union against this CSG
  55298. * @returns The unioned CSG
  55299. */
  55300. union(csg: CSG): CSG;
  55301. /**
  55302. * Unions this CSG with another CSG in place
  55303. * @param csg The CSG to union against this CSG
  55304. */
  55305. unionInPlace(csg: CSG): void;
  55306. /**
  55307. * Subtracts this CSG with another CSG
  55308. * @param csg The CSG to subtract against this CSG
  55309. * @returns A new CSG
  55310. */
  55311. subtract(csg: CSG): CSG;
  55312. /**
  55313. * Subtracts this CSG with another CSG in place
  55314. * @param csg The CSG to subtact against this CSG
  55315. */
  55316. subtractInPlace(csg: CSG): void;
  55317. /**
  55318. * Intersect this CSG with another CSG
  55319. * @param csg The CSG to intersect against this CSG
  55320. * @returns A new CSG
  55321. */
  55322. intersect(csg: CSG): CSG;
  55323. /**
  55324. * Intersects this CSG with another CSG in place
  55325. * @param csg The CSG to intersect against this CSG
  55326. */
  55327. intersectInPlace(csg: CSG): void;
  55328. /**
  55329. * Return a new CSG solid with solid and empty space switched. This solid is
  55330. * not modified.
  55331. * @returns A new CSG solid with solid and empty space switched
  55332. */
  55333. inverse(): CSG;
  55334. /**
  55335. * Inverses the CSG in place
  55336. */
  55337. inverseInPlace(): void;
  55338. /**
  55339. * This is used to keep meshes transformations so they can be restored
  55340. * when we build back a Babylon Mesh
  55341. * NB : All CSG operations are performed in world coordinates
  55342. * @param csg The CSG to copy the transform attributes from
  55343. * @returns This CSG
  55344. */
  55345. copyTransformAttributes(csg: CSG): CSG;
  55346. /**
  55347. * Build Raw mesh from CSG
  55348. * Coordinates here are in world space
  55349. * @param name The name of the mesh geometry
  55350. * @param scene The Scene
  55351. * @param keepSubMeshes Specifies if the submeshes should be kept
  55352. * @returns A new Mesh
  55353. */
  55354. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55355. /**
  55356. * Build Mesh from CSG taking material and transforms into account
  55357. * @param name The name of the Mesh
  55358. * @param material The material of the Mesh
  55359. * @param scene The Scene
  55360. * @param keepSubMeshes Specifies if submeshes should be kept
  55361. * @returns The new Mesh
  55362. */
  55363. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55364. }
  55365. }
  55366. declare module BABYLON {
  55367. /**
  55368. * Class used to create a trail following a mesh
  55369. */
  55370. export class TrailMesh extends Mesh {
  55371. private _generator;
  55372. private _autoStart;
  55373. private _running;
  55374. private _diameter;
  55375. private _length;
  55376. private _sectionPolygonPointsCount;
  55377. private _sectionVectors;
  55378. private _sectionNormalVectors;
  55379. private _beforeRenderObserver;
  55380. /**
  55381. * @constructor
  55382. * @param name The value used by scene.getMeshByName() to do a lookup.
  55383. * @param generator The mesh to generate a trail.
  55384. * @param scene The scene to add this mesh to.
  55385. * @param diameter Diameter of trailing mesh. Default is 1.
  55386. * @param length Length of trailing mesh. Default is 60.
  55387. * @param autoStart Automatically start trailing mesh. Default true.
  55388. */
  55389. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55390. /**
  55391. * "TrailMesh"
  55392. * @returns "TrailMesh"
  55393. */
  55394. getClassName(): string;
  55395. private _createMesh;
  55396. /**
  55397. * Start trailing mesh.
  55398. */
  55399. start(): void;
  55400. /**
  55401. * Stop trailing mesh.
  55402. */
  55403. stop(): void;
  55404. /**
  55405. * Update trailing mesh geometry.
  55406. */
  55407. update(): void;
  55408. /**
  55409. * Returns a new TrailMesh object.
  55410. * @param name is a string, the name given to the new mesh
  55411. * @param newGenerator use new generator object for cloned trail mesh
  55412. * @returns a new mesh
  55413. */
  55414. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55415. /**
  55416. * Serializes this trail mesh
  55417. * @param serializationObject object to write serialization to
  55418. */
  55419. serialize(serializationObject: any): void;
  55420. /**
  55421. * Parses a serialized trail mesh
  55422. * @param parsedMesh the serialized mesh
  55423. * @param scene the scene to create the trail mesh in
  55424. * @returns the created trail mesh
  55425. */
  55426. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55427. }
  55428. }
  55429. declare module BABYLON {
  55430. /**
  55431. * Class containing static functions to help procedurally build meshes
  55432. */
  55433. export class TiledBoxBuilder {
  55434. /**
  55435. * Creates a box mesh
  55436. * 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)
  55437. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55439. * * 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
  55440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55441. * @param name defines the name of the mesh
  55442. * @param options defines the options used to create the mesh
  55443. * @param scene defines the hosting scene
  55444. * @returns the box mesh
  55445. */
  55446. static CreateTiledBox(name: string, options: {
  55447. pattern?: number;
  55448. width?: number;
  55449. height?: number;
  55450. depth?: number;
  55451. tileSize?: number;
  55452. tileWidth?: number;
  55453. tileHeight?: number;
  55454. alignHorizontal?: number;
  55455. alignVertical?: number;
  55456. faceUV?: Vector4[];
  55457. faceColors?: Color4[];
  55458. sideOrientation?: number;
  55459. updatable?: boolean;
  55460. }, scene?: Nullable<Scene>): Mesh;
  55461. }
  55462. }
  55463. declare module BABYLON {
  55464. /**
  55465. * Class containing static functions to help procedurally build meshes
  55466. */
  55467. export class TorusKnotBuilder {
  55468. /**
  55469. * Creates a torus knot mesh
  55470. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55471. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55472. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55473. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55475. * * 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
  55476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55477. * @param name defines the name of the mesh
  55478. * @param options defines the options used to create the mesh
  55479. * @param scene defines the hosting scene
  55480. * @returns the torus knot mesh
  55481. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55482. */
  55483. static CreateTorusKnot(name: string, options: {
  55484. radius?: number;
  55485. tube?: number;
  55486. radialSegments?: number;
  55487. tubularSegments?: number;
  55488. p?: number;
  55489. q?: number;
  55490. updatable?: boolean;
  55491. sideOrientation?: number;
  55492. frontUVs?: Vector4;
  55493. backUVs?: Vector4;
  55494. }, scene: any): Mesh;
  55495. }
  55496. }
  55497. declare module BABYLON {
  55498. /**
  55499. * Polygon
  55500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55501. */
  55502. export class Polygon {
  55503. /**
  55504. * Creates a rectangle
  55505. * @param xmin bottom X coord
  55506. * @param ymin bottom Y coord
  55507. * @param xmax top X coord
  55508. * @param ymax top Y coord
  55509. * @returns points that make the resulting rectation
  55510. */
  55511. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55512. /**
  55513. * Creates a circle
  55514. * @param radius radius of circle
  55515. * @param cx scale in x
  55516. * @param cy scale in y
  55517. * @param numberOfSides number of sides that make up the circle
  55518. * @returns points that make the resulting circle
  55519. */
  55520. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55521. /**
  55522. * Creates a polygon from input string
  55523. * @param input Input polygon data
  55524. * @returns the parsed points
  55525. */
  55526. static Parse(input: string): Vector2[];
  55527. /**
  55528. * Starts building a polygon from x and y coordinates
  55529. * @param x x coordinate
  55530. * @param y y coordinate
  55531. * @returns the started path2
  55532. */
  55533. static StartingAt(x: number, y: number): Path2;
  55534. }
  55535. /**
  55536. * Builds a polygon
  55537. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55538. */
  55539. export class PolygonMeshBuilder {
  55540. private _points;
  55541. private _outlinepoints;
  55542. private _holes;
  55543. private _name;
  55544. private _scene;
  55545. private _epoints;
  55546. private _eholes;
  55547. private _addToepoint;
  55548. /**
  55549. * Babylon reference to the earcut plugin.
  55550. */
  55551. bjsEarcut: any;
  55552. /**
  55553. * Creates a PolygonMeshBuilder
  55554. * @param name name of the builder
  55555. * @param contours Path of the polygon
  55556. * @param scene scene to add to when creating the mesh
  55557. * @param earcutInjection can be used to inject your own earcut reference
  55558. */
  55559. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55560. /**
  55561. * Adds a whole within the polygon
  55562. * @param hole Array of points defining the hole
  55563. * @returns this
  55564. */
  55565. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55566. /**
  55567. * Creates the polygon
  55568. * @param updatable If the mesh should be updatable
  55569. * @param depth The depth of the mesh created
  55570. * @returns the created mesh
  55571. */
  55572. build(updatable?: boolean, depth?: number): Mesh;
  55573. /**
  55574. * Creates the polygon
  55575. * @param depth The depth of the mesh created
  55576. * @returns the created VertexData
  55577. */
  55578. buildVertexData(depth?: number): VertexData;
  55579. /**
  55580. * Adds a side to the polygon
  55581. * @param positions points that make the polygon
  55582. * @param normals normals of the polygon
  55583. * @param uvs uvs of the polygon
  55584. * @param indices indices of the polygon
  55585. * @param bounds bounds of the polygon
  55586. * @param points points of the polygon
  55587. * @param depth depth of the polygon
  55588. * @param flip flip of the polygon
  55589. */
  55590. private addSide;
  55591. }
  55592. }
  55593. declare module BABYLON {
  55594. /**
  55595. * Class containing static functions to help procedurally build meshes
  55596. */
  55597. export class PolygonBuilder {
  55598. /**
  55599. * Creates a polygon mesh
  55600. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55601. * * 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
  55602. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55604. * * 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)
  55605. * * Remember you can only change the shape positions, not their number when updating a polygon
  55606. * @param name defines the name of the mesh
  55607. * @param options defines the options used to create the mesh
  55608. * @param scene defines the hosting scene
  55609. * @param earcutInjection can be used to inject your own earcut reference
  55610. * @returns the polygon mesh
  55611. */
  55612. static CreatePolygon(name: string, options: {
  55613. shape: Vector3[];
  55614. holes?: Vector3[][];
  55615. depth?: number;
  55616. faceUV?: Vector4[];
  55617. faceColors?: Color4[];
  55618. updatable?: boolean;
  55619. sideOrientation?: number;
  55620. frontUVs?: Vector4;
  55621. backUVs?: Vector4;
  55622. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55623. /**
  55624. * Creates an extruded polygon mesh, with depth in the Y direction.
  55625. * * 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)
  55626. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55627. * @param name defines the name of the mesh
  55628. * @param options defines the options used to create the mesh
  55629. * @param scene defines the hosting scene
  55630. * @param earcutInjection can be used to inject your own earcut reference
  55631. * @returns the polygon mesh
  55632. */
  55633. static ExtrudePolygon(name: string, options: {
  55634. shape: Vector3[];
  55635. holes?: Vector3[][];
  55636. depth?: number;
  55637. faceUV?: Vector4[];
  55638. faceColors?: Color4[];
  55639. updatable?: boolean;
  55640. sideOrientation?: number;
  55641. frontUVs?: Vector4;
  55642. backUVs?: Vector4;
  55643. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55644. }
  55645. }
  55646. declare module BABYLON {
  55647. /**
  55648. * Class containing static functions to help procedurally build meshes
  55649. */
  55650. export class LatheBuilder {
  55651. /**
  55652. * Creates lathe mesh.
  55653. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55654. * * 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
  55655. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55656. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55657. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55658. * * 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
  55659. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55660. * * 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
  55661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55662. * * 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
  55663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55665. * @param name defines the name of the mesh
  55666. * @param options defines the options used to create the mesh
  55667. * @param scene defines the hosting scene
  55668. * @returns the lathe mesh
  55669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55670. */
  55671. static CreateLathe(name: string, options: {
  55672. shape: Vector3[];
  55673. radius?: number;
  55674. tessellation?: number;
  55675. clip?: number;
  55676. arc?: number;
  55677. closed?: boolean;
  55678. updatable?: boolean;
  55679. sideOrientation?: number;
  55680. frontUVs?: Vector4;
  55681. backUVs?: Vector4;
  55682. cap?: number;
  55683. invertUV?: boolean;
  55684. }, scene?: Nullable<Scene>): Mesh;
  55685. }
  55686. }
  55687. declare module BABYLON {
  55688. /**
  55689. * Class containing static functions to help procedurally build meshes
  55690. */
  55691. export class TiledPlaneBuilder {
  55692. /**
  55693. * Creates a tiled plane mesh
  55694. * * The parameter `pattern` will, depending on value, do nothing or
  55695. * * * flip (reflect about central vertical) alternate tiles across and up
  55696. * * * flip every tile on alternate rows
  55697. * * * rotate (180 degs) alternate tiles across and up
  55698. * * * rotate every tile on alternate rows
  55699. * * * flip and rotate alternate tiles across and up
  55700. * * * flip and rotate every tile on alternate rows
  55701. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55702. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55703. * * 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
  55704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55705. * * 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)
  55706. * * 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)
  55707. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55708. * @param name defines the name of the mesh
  55709. * @param options defines the options used to create the mesh
  55710. * @param scene defines the hosting scene
  55711. * @returns the box mesh
  55712. */
  55713. static CreateTiledPlane(name: string, options: {
  55714. pattern?: number;
  55715. tileSize?: number;
  55716. tileWidth?: number;
  55717. tileHeight?: number;
  55718. size?: number;
  55719. width?: number;
  55720. height?: number;
  55721. alignHorizontal?: number;
  55722. alignVertical?: number;
  55723. sideOrientation?: number;
  55724. frontUVs?: Vector4;
  55725. backUVs?: Vector4;
  55726. updatable?: boolean;
  55727. }, scene?: Nullable<Scene>): Mesh;
  55728. }
  55729. }
  55730. declare module BABYLON {
  55731. /**
  55732. * Class containing static functions to help procedurally build meshes
  55733. */
  55734. export class TubeBuilder {
  55735. /**
  55736. * Creates a tube mesh.
  55737. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55738. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55739. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55740. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55741. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55742. * * 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)
  55743. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55744. * * 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
  55745. * * 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
  55746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55747. * * 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
  55748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55750. * @param name defines the name of the mesh
  55751. * @param options defines the options used to create the mesh
  55752. * @param scene defines the hosting scene
  55753. * @returns the tube mesh
  55754. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55755. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55756. */
  55757. static CreateTube(name: string, options: {
  55758. path: Vector3[];
  55759. radius?: number;
  55760. tessellation?: number;
  55761. radiusFunction?: {
  55762. (i: number, distance: number): number;
  55763. };
  55764. cap?: number;
  55765. arc?: number;
  55766. updatable?: boolean;
  55767. sideOrientation?: number;
  55768. frontUVs?: Vector4;
  55769. backUVs?: Vector4;
  55770. instance?: Mesh;
  55771. invertUV?: boolean;
  55772. }, scene?: Nullable<Scene>): Mesh;
  55773. }
  55774. }
  55775. declare module BABYLON {
  55776. /**
  55777. * Class containing static functions to help procedurally build meshes
  55778. */
  55779. export class IcoSphereBuilder {
  55780. /**
  55781. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55782. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55783. * * 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`)
  55784. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55785. * * 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
  55786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55787. * * 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
  55788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55789. * @param name defines the name of the mesh
  55790. * @param options defines the options used to create the mesh
  55791. * @param scene defines the hosting scene
  55792. * @returns the icosahedron mesh
  55793. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55794. */
  55795. static CreateIcoSphere(name: string, options: {
  55796. radius?: number;
  55797. radiusX?: number;
  55798. radiusY?: number;
  55799. radiusZ?: number;
  55800. flat?: boolean;
  55801. subdivisions?: number;
  55802. sideOrientation?: number;
  55803. frontUVs?: Vector4;
  55804. backUVs?: Vector4;
  55805. updatable?: boolean;
  55806. }, scene?: Nullable<Scene>): Mesh;
  55807. }
  55808. }
  55809. declare module BABYLON {
  55810. /**
  55811. * Class containing static functions to help procedurally build meshes
  55812. */
  55813. export class DecalBuilder {
  55814. /**
  55815. * Creates a decal mesh.
  55816. * 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
  55817. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55818. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55819. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55820. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55821. * @param name defines the name of the mesh
  55822. * @param sourceMesh defines the mesh where the decal must be applied
  55823. * @param options defines the options used to create the mesh
  55824. * @param scene defines the hosting scene
  55825. * @returns the decal mesh
  55826. * @see https://doc.babylonjs.com/how_to/decals
  55827. */
  55828. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55829. position?: Vector3;
  55830. normal?: Vector3;
  55831. size?: Vector3;
  55832. angle?: number;
  55833. }): Mesh;
  55834. }
  55835. }
  55836. declare module BABYLON {
  55837. /**
  55838. * Class containing static functions to help procedurally build meshes
  55839. */
  55840. export class MeshBuilder {
  55841. /**
  55842. * Creates a box mesh
  55843. * * The parameter `size` sets the size (float) of each box side (default 1)
  55844. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55845. * * 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)
  55846. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55848. * * 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
  55849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55850. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55851. * @param name defines the name of the mesh
  55852. * @param options defines the options used to create the mesh
  55853. * @param scene defines the hosting scene
  55854. * @returns the box mesh
  55855. */
  55856. static CreateBox(name: string, options: {
  55857. size?: number;
  55858. width?: number;
  55859. height?: number;
  55860. depth?: number;
  55861. faceUV?: Vector4[];
  55862. faceColors?: Color4[];
  55863. sideOrientation?: number;
  55864. frontUVs?: Vector4;
  55865. backUVs?: Vector4;
  55866. updatable?: boolean;
  55867. }, scene?: Nullable<Scene>): Mesh;
  55868. /**
  55869. * Creates a tiled box mesh
  55870. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55872. * @param name defines the name of the mesh
  55873. * @param options defines the options used to create the mesh
  55874. * @param scene defines the hosting scene
  55875. * @returns the tiled box mesh
  55876. */
  55877. static CreateTiledBox(name: string, options: {
  55878. pattern?: number;
  55879. size?: number;
  55880. width?: number;
  55881. height?: number;
  55882. depth: number;
  55883. tileSize?: number;
  55884. tileWidth?: number;
  55885. tileHeight?: number;
  55886. faceUV?: Vector4[];
  55887. faceColors?: Color4[];
  55888. alignHorizontal?: number;
  55889. alignVertical?: number;
  55890. sideOrientation?: number;
  55891. updatable?: boolean;
  55892. }, scene?: Nullable<Scene>): Mesh;
  55893. /**
  55894. * Creates a sphere mesh
  55895. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55896. * * 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`)
  55897. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55898. * * 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
  55899. * * 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)
  55900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55901. * * 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
  55902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55903. * @param name defines the name of the mesh
  55904. * @param options defines the options used to create the mesh
  55905. * @param scene defines the hosting scene
  55906. * @returns the sphere mesh
  55907. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55908. */
  55909. static CreateSphere(name: string, options: {
  55910. segments?: number;
  55911. diameter?: number;
  55912. diameterX?: number;
  55913. diameterY?: number;
  55914. diameterZ?: number;
  55915. arc?: number;
  55916. slice?: number;
  55917. sideOrientation?: number;
  55918. frontUVs?: Vector4;
  55919. backUVs?: Vector4;
  55920. updatable?: boolean;
  55921. }, scene?: Nullable<Scene>): Mesh;
  55922. /**
  55923. * Creates a plane polygonal mesh. By default, this is a disc
  55924. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55925. * * 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
  55926. * * 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
  55927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55928. * * 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
  55929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55930. * @param name defines the name of the mesh
  55931. * @param options defines the options used to create the mesh
  55932. * @param scene defines the hosting scene
  55933. * @returns the plane polygonal mesh
  55934. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55935. */
  55936. static CreateDisc(name: string, options: {
  55937. radius?: number;
  55938. tessellation?: number;
  55939. arc?: number;
  55940. updatable?: boolean;
  55941. sideOrientation?: number;
  55942. frontUVs?: Vector4;
  55943. backUVs?: Vector4;
  55944. }, scene?: Nullable<Scene>): Mesh;
  55945. /**
  55946. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55947. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55948. * * 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`)
  55949. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55950. * * 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
  55951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55952. * * 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
  55953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55954. * @param name defines the name of the mesh
  55955. * @param options defines the options used to create the mesh
  55956. * @param scene defines the hosting scene
  55957. * @returns the icosahedron mesh
  55958. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55959. */
  55960. static CreateIcoSphere(name: string, options: {
  55961. radius?: number;
  55962. radiusX?: number;
  55963. radiusY?: number;
  55964. radiusZ?: number;
  55965. flat?: boolean;
  55966. subdivisions?: number;
  55967. sideOrientation?: number;
  55968. frontUVs?: Vector4;
  55969. backUVs?: Vector4;
  55970. updatable?: boolean;
  55971. }, scene?: Nullable<Scene>): Mesh;
  55972. /**
  55973. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55974. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55975. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55976. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55977. * * 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
  55978. * * 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
  55979. * * 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
  55980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55981. * * 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
  55982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55983. * * 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
  55984. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55985. * * 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
  55986. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55988. * @param name defines the name of the mesh
  55989. * @param options defines the options used to create the mesh
  55990. * @param scene defines the hosting scene
  55991. * @returns the ribbon mesh
  55992. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55994. */
  55995. static CreateRibbon(name: string, options: {
  55996. pathArray: Vector3[][];
  55997. closeArray?: boolean;
  55998. closePath?: boolean;
  55999. offset?: number;
  56000. updatable?: boolean;
  56001. sideOrientation?: number;
  56002. frontUVs?: Vector4;
  56003. backUVs?: Vector4;
  56004. instance?: Mesh;
  56005. invertUV?: boolean;
  56006. uvs?: Vector2[];
  56007. colors?: Color4[];
  56008. }, scene?: Nullable<Scene>): Mesh;
  56009. /**
  56010. * Creates a cylinder or a cone mesh
  56011. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56012. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56013. * * 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.
  56014. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56015. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56016. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56017. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56018. * * 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).
  56019. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56020. * * 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).
  56021. * * 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
  56022. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56023. * * 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
  56024. * * 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.
  56025. * * If `enclose` is false, a ring surface is one element.
  56026. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56027. * * 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
  56028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56029. * * 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
  56030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56031. * @param name defines the name of the mesh
  56032. * @param options defines the options used to create the mesh
  56033. * @param scene defines the hosting scene
  56034. * @returns the cylinder mesh
  56035. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56036. */
  56037. static CreateCylinder(name: string, options: {
  56038. height?: number;
  56039. diameterTop?: number;
  56040. diameterBottom?: number;
  56041. diameter?: number;
  56042. tessellation?: number;
  56043. subdivisions?: number;
  56044. arc?: number;
  56045. faceColors?: Color4[];
  56046. faceUV?: Vector4[];
  56047. updatable?: boolean;
  56048. hasRings?: boolean;
  56049. enclose?: boolean;
  56050. cap?: number;
  56051. sideOrientation?: number;
  56052. frontUVs?: Vector4;
  56053. backUVs?: Vector4;
  56054. }, scene?: Nullable<Scene>): Mesh;
  56055. /**
  56056. * Creates a torus mesh
  56057. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56058. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56059. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56061. * * 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
  56062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56063. * @param name defines the name of the mesh
  56064. * @param options defines the options used to create the mesh
  56065. * @param scene defines the hosting scene
  56066. * @returns the torus mesh
  56067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56068. */
  56069. static CreateTorus(name: string, options: {
  56070. diameter?: number;
  56071. thickness?: number;
  56072. tessellation?: number;
  56073. updatable?: boolean;
  56074. sideOrientation?: number;
  56075. frontUVs?: Vector4;
  56076. backUVs?: Vector4;
  56077. }, scene?: Nullable<Scene>): Mesh;
  56078. /**
  56079. * Creates a torus knot mesh
  56080. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56081. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56082. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56083. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56085. * * 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
  56086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56087. * @param name defines the name of the mesh
  56088. * @param options defines the options used to create the mesh
  56089. * @param scene defines the hosting scene
  56090. * @returns the torus knot mesh
  56091. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56092. */
  56093. static CreateTorusKnot(name: string, options: {
  56094. radius?: number;
  56095. tube?: number;
  56096. radialSegments?: number;
  56097. tubularSegments?: number;
  56098. p?: number;
  56099. q?: number;
  56100. updatable?: boolean;
  56101. sideOrientation?: number;
  56102. frontUVs?: Vector4;
  56103. backUVs?: Vector4;
  56104. }, scene?: Nullable<Scene>): Mesh;
  56105. /**
  56106. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56107. * * 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
  56108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56109. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56110. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56111. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56112. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56113. * * 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
  56114. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56117. * @param name defines the name of the new line system
  56118. * @param options defines the options used to create the line system
  56119. * @param scene defines the hosting scene
  56120. * @returns a new line system mesh
  56121. */
  56122. static CreateLineSystem(name: string, options: {
  56123. lines: Vector3[][];
  56124. updatable?: boolean;
  56125. instance?: Nullable<LinesMesh>;
  56126. colors?: Nullable<Color4[][]>;
  56127. useVertexAlpha?: boolean;
  56128. }, scene: Nullable<Scene>): LinesMesh;
  56129. /**
  56130. * Creates a line mesh
  56131. * 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
  56132. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56133. * * The parameter `points` is an array successive Vector3
  56134. * * 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
  56135. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56136. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56137. * * When updating an instance, remember that only point positions can change, not the number of points
  56138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56140. * @param name defines the name of the new line system
  56141. * @param options defines the options used to create the line system
  56142. * @param scene defines the hosting scene
  56143. * @returns a new line mesh
  56144. */
  56145. static CreateLines(name: string, options: {
  56146. points: Vector3[];
  56147. updatable?: boolean;
  56148. instance?: Nullable<LinesMesh>;
  56149. colors?: Color4[];
  56150. useVertexAlpha?: boolean;
  56151. }, scene?: Nullable<Scene>): LinesMesh;
  56152. /**
  56153. * Creates a dashed line mesh
  56154. * * 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
  56155. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56156. * * The parameter `points` is an array successive Vector3
  56157. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56158. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56159. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56160. * * 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
  56161. * * When updating an instance, remember that only point positions can change, not the number of points
  56162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56163. * @param name defines the name of the mesh
  56164. * @param options defines the options used to create the mesh
  56165. * @param scene defines the hosting scene
  56166. * @returns the dashed line mesh
  56167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56168. */
  56169. static CreateDashedLines(name: string, options: {
  56170. points: Vector3[];
  56171. dashSize?: number;
  56172. gapSize?: number;
  56173. dashNb?: number;
  56174. updatable?: boolean;
  56175. instance?: LinesMesh;
  56176. }, scene?: Nullable<Scene>): LinesMesh;
  56177. /**
  56178. * 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.
  56179. * * 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.
  56180. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56181. * * 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.
  56182. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56183. * * 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
  56184. * * 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
  56185. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56187. * * 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
  56188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56190. * @param name defines the name of the mesh
  56191. * @param options defines the options used to create the mesh
  56192. * @param scene defines the hosting scene
  56193. * @returns the extruded shape mesh
  56194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56196. */
  56197. static ExtrudeShape(name: string, options: {
  56198. shape: Vector3[];
  56199. path: Vector3[];
  56200. scale?: number;
  56201. rotation?: number;
  56202. cap?: number;
  56203. updatable?: boolean;
  56204. sideOrientation?: number;
  56205. frontUVs?: Vector4;
  56206. backUVs?: Vector4;
  56207. instance?: Mesh;
  56208. invertUV?: boolean;
  56209. }, scene?: Nullable<Scene>): Mesh;
  56210. /**
  56211. * Creates an custom extruded shape mesh.
  56212. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56213. * * 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.
  56214. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56215. * * 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
  56216. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56217. * * 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
  56218. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56219. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56220. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56221. * * 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
  56222. * * 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
  56223. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56225. * * 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
  56226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56228. * @param name defines the name of the mesh
  56229. * @param options defines the options used to create the mesh
  56230. * @param scene defines the hosting scene
  56231. * @returns the custom extruded shape mesh
  56232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56235. */
  56236. static ExtrudeShapeCustom(name: string, options: {
  56237. shape: Vector3[];
  56238. path: Vector3[];
  56239. scaleFunction?: any;
  56240. rotationFunction?: any;
  56241. ribbonCloseArray?: boolean;
  56242. ribbonClosePath?: boolean;
  56243. cap?: number;
  56244. updatable?: boolean;
  56245. sideOrientation?: number;
  56246. frontUVs?: Vector4;
  56247. backUVs?: Vector4;
  56248. instance?: Mesh;
  56249. invertUV?: boolean;
  56250. }, scene?: Nullable<Scene>): Mesh;
  56251. /**
  56252. * Creates lathe mesh.
  56253. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56254. * * 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
  56255. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56256. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56257. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56258. * * 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
  56259. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56260. * * 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
  56261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56262. * * 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
  56263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56265. * @param name defines the name of the mesh
  56266. * @param options defines the options used to create the mesh
  56267. * @param scene defines the hosting scene
  56268. * @returns the lathe mesh
  56269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56270. */
  56271. static CreateLathe(name: string, options: {
  56272. shape: Vector3[];
  56273. radius?: number;
  56274. tessellation?: number;
  56275. clip?: number;
  56276. arc?: number;
  56277. closed?: boolean;
  56278. updatable?: boolean;
  56279. sideOrientation?: number;
  56280. frontUVs?: Vector4;
  56281. backUVs?: Vector4;
  56282. cap?: number;
  56283. invertUV?: boolean;
  56284. }, scene?: Nullable<Scene>): Mesh;
  56285. /**
  56286. * Creates a tiled plane mesh
  56287. * * You can set a limited pattern arrangement with the tiles
  56288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56289. * * 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
  56290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56291. * @param name defines the name of the mesh
  56292. * @param options defines the options used to create the mesh
  56293. * @param scene defines the hosting scene
  56294. * @returns the plane mesh
  56295. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56296. */
  56297. static CreateTiledPlane(name: string, options: {
  56298. pattern?: number;
  56299. tileSize?: number;
  56300. tileWidth?: number;
  56301. tileHeight?: number;
  56302. size?: number;
  56303. width?: number;
  56304. height?: number;
  56305. alignHorizontal?: number;
  56306. alignVertical?: number;
  56307. sideOrientation?: number;
  56308. frontUVs?: Vector4;
  56309. backUVs?: Vector4;
  56310. updatable?: boolean;
  56311. }, scene?: Nullable<Scene>): Mesh;
  56312. /**
  56313. * Creates a plane mesh
  56314. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56315. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56316. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56318. * * 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
  56319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56320. * @param name defines the name of the mesh
  56321. * @param options defines the options used to create the mesh
  56322. * @param scene defines the hosting scene
  56323. * @returns the plane mesh
  56324. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56325. */
  56326. static CreatePlane(name: string, options: {
  56327. size?: number;
  56328. width?: number;
  56329. height?: number;
  56330. sideOrientation?: number;
  56331. frontUVs?: Vector4;
  56332. backUVs?: Vector4;
  56333. updatable?: boolean;
  56334. sourcePlane?: Plane;
  56335. }, scene?: Nullable<Scene>): Mesh;
  56336. /**
  56337. * Creates a ground mesh
  56338. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56339. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56341. * @param name defines the name of the mesh
  56342. * @param options defines the options used to create the mesh
  56343. * @param scene defines the hosting scene
  56344. * @returns the ground mesh
  56345. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56346. */
  56347. static CreateGround(name: string, options: {
  56348. width?: number;
  56349. height?: number;
  56350. subdivisions?: number;
  56351. subdivisionsX?: number;
  56352. subdivisionsY?: number;
  56353. updatable?: boolean;
  56354. }, scene?: Nullable<Scene>): Mesh;
  56355. /**
  56356. * Creates a tiled ground mesh
  56357. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56358. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56359. * * 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
  56360. * * 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
  56361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56362. * @param name defines the name of the mesh
  56363. * @param options defines the options used to create the mesh
  56364. * @param scene defines the hosting scene
  56365. * @returns the tiled ground mesh
  56366. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56367. */
  56368. static CreateTiledGround(name: string, options: {
  56369. xmin: number;
  56370. zmin: number;
  56371. xmax: number;
  56372. zmax: number;
  56373. subdivisions?: {
  56374. w: number;
  56375. h: number;
  56376. };
  56377. precision?: {
  56378. w: number;
  56379. h: number;
  56380. };
  56381. updatable?: boolean;
  56382. }, scene?: Nullable<Scene>): Mesh;
  56383. /**
  56384. * Creates a ground mesh from a height map
  56385. * * The parameter `url` sets the URL of the height map image resource.
  56386. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56387. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56388. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56389. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56390. * * 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.
  56391. * * 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).
  56392. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56394. * @param name defines the name of the mesh
  56395. * @param url defines the url to the height map
  56396. * @param options defines the options used to create the mesh
  56397. * @param scene defines the hosting scene
  56398. * @returns the ground mesh
  56399. * @see https://doc.babylonjs.com/babylon101/height_map
  56400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56401. */
  56402. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56403. width?: number;
  56404. height?: number;
  56405. subdivisions?: number;
  56406. minHeight?: number;
  56407. maxHeight?: number;
  56408. colorFilter?: Color3;
  56409. alphaFilter?: number;
  56410. updatable?: boolean;
  56411. onReady?: (mesh: GroundMesh) => void;
  56412. }, scene?: Nullable<Scene>): GroundMesh;
  56413. /**
  56414. * Creates a polygon mesh
  56415. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56416. * * 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
  56417. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56419. * * 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)
  56420. * * Remember you can only change the shape positions, not their number when updating a polygon
  56421. * @param name defines the name of the mesh
  56422. * @param options defines the options used to create the mesh
  56423. * @param scene defines the hosting scene
  56424. * @param earcutInjection can be used to inject your own earcut reference
  56425. * @returns the polygon mesh
  56426. */
  56427. static CreatePolygon(name: string, options: {
  56428. shape: Vector3[];
  56429. holes?: Vector3[][];
  56430. depth?: number;
  56431. faceUV?: Vector4[];
  56432. faceColors?: Color4[];
  56433. updatable?: boolean;
  56434. sideOrientation?: number;
  56435. frontUVs?: Vector4;
  56436. backUVs?: Vector4;
  56437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56438. /**
  56439. * Creates an extruded polygon mesh, with depth in the Y direction.
  56440. * * 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)
  56441. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56442. * @param name defines the name of the mesh
  56443. * @param options defines the options used to create the mesh
  56444. * @param scene defines the hosting scene
  56445. * @param earcutInjection can be used to inject your own earcut reference
  56446. * @returns the polygon mesh
  56447. */
  56448. static ExtrudePolygon(name: string, options: {
  56449. shape: Vector3[];
  56450. holes?: Vector3[][];
  56451. depth?: number;
  56452. faceUV?: Vector4[];
  56453. faceColors?: Color4[];
  56454. updatable?: boolean;
  56455. sideOrientation?: number;
  56456. frontUVs?: Vector4;
  56457. backUVs?: Vector4;
  56458. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56459. /**
  56460. * Creates a tube mesh.
  56461. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56462. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56463. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56464. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56465. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56466. * * 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)
  56467. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56468. * * 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
  56469. * * 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
  56470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56471. * * 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
  56472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56474. * @param name defines the name of the mesh
  56475. * @param options defines the options used to create the mesh
  56476. * @param scene defines the hosting scene
  56477. * @returns the tube mesh
  56478. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56479. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56480. */
  56481. static CreateTube(name: string, options: {
  56482. path: Vector3[];
  56483. radius?: number;
  56484. tessellation?: number;
  56485. radiusFunction?: {
  56486. (i: number, distance: number): number;
  56487. };
  56488. cap?: number;
  56489. arc?: number;
  56490. updatable?: boolean;
  56491. sideOrientation?: number;
  56492. frontUVs?: Vector4;
  56493. backUVs?: Vector4;
  56494. instance?: Mesh;
  56495. invertUV?: boolean;
  56496. }, scene?: Nullable<Scene>): Mesh;
  56497. /**
  56498. * Creates a polyhedron mesh
  56499. * * 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
  56500. * * The parameter `size` (positive float, default 1) sets the polygon size
  56501. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56502. * * 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`
  56503. * * 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
  56504. * * 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)`)
  56505. * * 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
  56506. * * 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
  56507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56508. * * 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
  56509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56510. * @param name defines the name of the mesh
  56511. * @param options defines the options used to create the mesh
  56512. * @param scene defines the hosting scene
  56513. * @returns the polyhedron mesh
  56514. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56515. */
  56516. static CreatePolyhedron(name: string, options: {
  56517. type?: number;
  56518. size?: number;
  56519. sizeX?: number;
  56520. sizeY?: number;
  56521. sizeZ?: number;
  56522. custom?: any;
  56523. faceUV?: Vector4[];
  56524. faceColors?: Color4[];
  56525. flat?: boolean;
  56526. updatable?: boolean;
  56527. sideOrientation?: number;
  56528. frontUVs?: Vector4;
  56529. backUVs?: Vector4;
  56530. }, scene?: Nullable<Scene>): Mesh;
  56531. /**
  56532. * Creates a decal mesh.
  56533. * 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
  56534. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56535. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56536. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56537. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56538. * @param name defines the name of the mesh
  56539. * @param sourceMesh defines the mesh where the decal must be applied
  56540. * @param options defines the options used to create the mesh
  56541. * @param scene defines the hosting scene
  56542. * @returns the decal mesh
  56543. * @see https://doc.babylonjs.com/how_to/decals
  56544. */
  56545. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56546. position?: Vector3;
  56547. normal?: Vector3;
  56548. size?: Vector3;
  56549. angle?: number;
  56550. }): Mesh;
  56551. }
  56552. }
  56553. declare module BABYLON {
  56554. /**
  56555. * A simplifier interface for future simplification implementations
  56556. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56557. */
  56558. export interface ISimplifier {
  56559. /**
  56560. * Simplification of a given mesh according to the given settings.
  56561. * Since this requires computation, it is assumed that the function runs async.
  56562. * @param settings The settings of the simplification, including quality and distance
  56563. * @param successCallback A callback that will be called after the mesh was simplified.
  56564. * @param errorCallback in case of an error, this callback will be called. optional.
  56565. */
  56566. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56567. }
  56568. /**
  56569. * Expected simplification settings.
  56570. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56571. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56572. */
  56573. export interface ISimplificationSettings {
  56574. /**
  56575. * Gets or sets the expected quality
  56576. */
  56577. quality: number;
  56578. /**
  56579. * Gets or sets the distance when this optimized version should be used
  56580. */
  56581. distance: number;
  56582. /**
  56583. * Gets an already optimized mesh
  56584. */
  56585. optimizeMesh?: boolean;
  56586. }
  56587. /**
  56588. * Class used to specify simplification options
  56589. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56590. */
  56591. export class SimplificationSettings implements ISimplificationSettings {
  56592. /** expected quality */
  56593. quality: number;
  56594. /** distance when this optimized version should be used */
  56595. distance: number;
  56596. /** already optimized mesh */
  56597. optimizeMesh?: boolean | undefined;
  56598. /**
  56599. * Creates a SimplificationSettings
  56600. * @param quality expected quality
  56601. * @param distance distance when this optimized version should be used
  56602. * @param optimizeMesh already optimized mesh
  56603. */
  56604. constructor(
  56605. /** expected quality */
  56606. quality: number,
  56607. /** distance when this optimized version should be used */
  56608. distance: number,
  56609. /** already optimized mesh */
  56610. optimizeMesh?: boolean | undefined);
  56611. }
  56612. /**
  56613. * Interface used to define a simplification task
  56614. */
  56615. export interface ISimplificationTask {
  56616. /**
  56617. * Array of settings
  56618. */
  56619. settings: Array<ISimplificationSettings>;
  56620. /**
  56621. * Simplification type
  56622. */
  56623. simplificationType: SimplificationType;
  56624. /**
  56625. * Mesh to simplify
  56626. */
  56627. mesh: Mesh;
  56628. /**
  56629. * Callback called on success
  56630. */
  56631. successCallback?: () => void;
  56632. /**
  56633. * Defines if parallel processing can be used
  56634. */
  56635. parallelProcessing: boolean;
  56636. }
  56637. /**
  56638. * Queue used to order the simplification tasks
  56639. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56640. */
  56641. export class SimplificationQueue {
  56642. private _simplificationArray;
  56643. /**
  56644. * Gets a boolean indicating that the process is still running
  56645. */
  56646. running: boolean;
  56647. /**
  56648. * Creates a new queue
  56649. */
  56650. constructor();
  56651. /**
  56652. * Adds a new simplification task
  56653. * @param task defines a task to add
  56654. */
  56655. addTask(task: ISimplificationTask): void;
  56656. /**
  56657. * Execute next task
  56658. */
  56659. executeNext(): void;
  56660. /**
  56661. * Execute a simplification task
  56662. * @param task defines the task to run
  56663. */
  56664. runSimplification(task: ISimplificationTask): void;
  56665. private getSimplifier;
  56666. }
  56667. /**
  56668. * The implemented types of simplification
  56669. * At the moment only Quadratic Error Decimation is implemented
  56670. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56671. */
  56672. export enum SimplificationType {
  56673. /** Quadratic error decimation */
  56674. QUADRATIC = 0
  56675. }
  56676. }
  56677. declare module BABYLON {
  56678. interface Scene {
  56679. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  56680. /**
  56681. * Gets or sets the simplification queue attached to the scene
  56682. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56683. */
  56684. simplificationQueue: SimplificationQueue;
  56685. }
  56686. interface Mesh {
  56687. /**
  56688. * Simplify the mesh according to the given array of settings.
  56689. * Function will return immediately and will simplify async
  56690. * @param settings a collection of simplification settings
  56691. * @param parallelProcessing should all levels calculate parallel or one after the other
  56692. * @param simplificationType the type of simplification to run
  56693. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56694. * @returns the current mesh
  56695. */
  56696. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56697. }
  56698. /**
  56699. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56700. * created in a scene
  56701. */
  56702. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56703. /**
  56704. * The component name helpfull to identify the component in the list of scene components.
  56705. */
  56706. readonly name: string;
  56707. /**
  56708. * The scene the component belongs to.
  56709. */
  56710. scene: Scene;
  56711. /**
  56712. * Creates a new instance of the component for the given scene
  56713. * @param scene Defines the scene to register the component in
  56714. */
  56715. constructor(scene: Scene);
  56716. /**
  56717. * Registers the component in a given scene
  56718. */
  56719. register(): void;
  56720. /**
  56721. * Rebuilds the elements related to this component in case of
  56722. * context lost for instance.
  56723. */
  56724. rebuild(): void;
  56725. /**
  56726. * Disposes the component and the associated ressources
  56727. */
  56728. dispose(): void;
  56729. private _beforeCameraUpdate;
  56730. }
  56731. }
  56732. declare module BABYLON {
  56733. /**
  56734. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56735. */
  56736. export interface INavigationEnginePlugin {
  56737. /**
  56738. * plugin name
  56739. */
  56740. name: string;
  56741. /**
  56742. * Creates a navigation mesh
  56743. * @param meshes array of all the geometry used to compute the navigatio mesh
  56744. * @param parameters bunch of parameters used to filter geometry
  56745. */
  56746. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56747. /**
  56748. * Create a navigation mesh debug mesh
  56749. * @param scene is where the mesh will be added
  56750. * @returns debug display mesh
  56751. */
  56752. createDebugNavMesh(scene: Scene): Mesh;
  56753. /**
  56754. * Get a navigation mesh constrained position, closest to the parameter position
  56755. * @param position world position
  56756. * @returns the closest point to position constrained by the navigation mesh
  56757. */
  56758. getClosestPoint(position: Vector3): Vector3;
  56759. /**
  56760. * Get a navigation mesh constrained position, within a particular radius
  56761. * @param position world position
  56762. * @param maxRadius the maximum distance to the constrained world position
  56763. * @returns the closest point to position constrained by the navigation mesh
  56764. */
  56765. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56766. /**
  56767. * Compute the final position from a segment made of destination-position
  56768. * @param position world position
  56769. * @param destination world position
  56770. * @returns the resulting point along the navmesh
  56771. */
  56772. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56773. /**
  56774. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56775. * @param start world position
  56776. * @param end world position
  56777. * @returns array containing world position composing the path
  56778. */
  56779. computePath(start: Vector3, end: Vector3): Vector3[];
  56780. /**
  56781. * If this plugin is supported
  56782. * @returns true if plugin is supported
  56783. */
  56784. isSupported(): boolean;
  56785. /**
  56786. * Create a new Crowd so you can add agents
  56787. * @param maxAgents the maximum agent count in the crowd
  56788. * @param maxAgentRadius the maximum radius an agent can have
  56789. * @param scene to attach the crowd to
  56790. * @returns the crowd you can add agents to
  56791. */
  56792. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56793. /**
  56794. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56795. * The queries will try to find a solution within those bounds
  56796. * default is (1,1,1)
  56797. * @param extent x,y,z value that define the extent around the queries point of reference
  56798. */
  56799. setDefaultQueryExtent(extent: Vector3): void;
  56800. /**
  56801. * Get the Bounding box extent specified by setDefaultQueryExtent
  56802. * @returns the box extent values
  56803. */
  56804. getDefaultQueryExtent(): Vector3;
  56805. /**
  56806. * Release all resources
  56807. */
  56808. dispose(): void;
  56809. }
  56810. /**
  56811. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56812. */
  56813. export interface ICrowd {
  56814. /**
  56815. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56816. * You can attach anything to that node. The node position is updated in the scene update tick.
  56817. * @param pos world position that will be constrained by the navigation mesh
  56818. * @param parameters agent parameters
  56819. * @param transform hooked to the agent that will be update by the scene
  56820. * @returns agent index
  56821. */
  56822. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56823. /**
  56824. * Returns the agent position in world space
  56825. * @param index agent index returned by addAgent
  56826. * @returns world space position
  56827. */
  56828. getAgentPosition(index: number): Vector3;
  56829. /**
  56830. * Gets the agent velocity in world space
  56831. * @param index agent index returned by addAgent
  56832. * @returns world space velocity
  56833. */
  56834. getAgentVelocity(index: number): Vector3;
  56835. /**
  56836. * remove a particular agent previously created
  56837. * @param index agent index returned by addAgent
  56838. */
  56839. removeAgent(index: number): void;
  56840. /**
  56841. * get the list of all agents attached to this crowd
  56842. * @returns list of agent indices
  56843. */
  56844. getAgents(): number[];
  56845. /**
  56846. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56847. * @param deltaTime in seconds
  56848. */
  56849. update(deltaTime: number): void;
  56850. /**
  56851. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56852. * @param index agent index returned by addAgent
  56853. * @param destination targeted world position
  56854. */
  56855. agentGoto(index: number, destination: Vector3): void;
  56856. /**
  56857. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56858. * The queries will try to find a solution within those bounds
  56859. * default is (1,1,1)
  56860. * @param extent x,y,z value that define the extent around the queries point of reference
  56861. */
  56862. setDefaultQueryExtent(extent: Vector3): void;
  56863. /**
  56864. * Get the Bounding box extent specified by setDefaultQueryExtent
  56865. * @returns the box extent values
  56866. */
  56867. getDefaultQueryExtent(): Vector3;
  56868. /**
  56869. * Release all resources
  56870. */
  56871. dispose(): void;
  56872. }
  56873. /**
  56874. * Configures an agent
  56875. */
  56876. export interface IAgentParameters {
  56877. /**
  56878. * Agent radius. [Limit: >= 0]
  56879. */
  56880. radius: number;
  56881. /**
  56882. * Agent height. [Limit: > 0]
  56883. */
  56884. height: number;
  56885. /**
  56886. * Maximum allowed acceleration. [Limit: >= 0]
  56887. */
  56888. maxAcceleration: number;
  56889. /**
  56890. * Maximum allowed speed. [Limit: >= 0]
  56891. */
  56892. maxSpeed: number;
  56893. /**
  56894. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56895. */
  56896. collisionQueryRange: number;
  56897. /**
  56898. * The path visibility optimization range. [Limit: > 0]
  56899. */
  56900. pathOptimizationRange: number;
  56901. /**
  56902. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56903. */
  56904. separationWeight: number;
  56905. }
  56906. /**
  56907. * Configures the navigation mesh creation
  56908. */
  56909. export interface INavMeshParameters {
  56910. /**
  56911. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56912. */
  56913. cs: number;
  56914. /**
  56915. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56916. */
  56917. ch: number;
  56918. /**
  56919. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56920. */
  56921. walkableSlopeAngle: number;
  56922. /**
  56923. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56924. * be considered walkable. [Limit: >= 3] [Units: vx]
  56925. */
  56926. walkableHeight: number;
  56927. /**
  56928. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56929. */
  56930. walkableClimb: number;
  56931. /**
  56932. * The distance to erode/shrink the walkable area of the heightfield away from
  56933. * obstructions. [Limit: >=0] [Units: vx]
  56934. */
  56935. walkableRadius: number;
  56936. /**
  56937. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56938. */
  56939. maxEdgeLen: number;
  56940. /**
  56941. * The maximum distance a simplfied contour's border edges should deviate
  56942. * the original raw contour. [Limit: >=0] [Units: vx]
  56943. */
  56944. maxSimplificationError: number;
  56945. /**
  56946. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56947. */
  56948. minRegionArea: number;
  56949. /**
  56950. * Any regions with a span count smaller than this value will, if possible,
  56951. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56952. */
  56953. mergeRegionArea: number;
  56954. /**
  56955. * The maximum number of vertices allowed for polygons generated during the
  56956. * contour to polygon conversion process. [Limit: >= 3]
  56957. */
  56958. maxVertsPerPoly: number;
  56959. /**
  56960. * Sets the sampling distance to use when generating the detail mesh.
  56961. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56962. */
  56963. detailSampleDist: number;
  56964. /**
  56965. * The maximum distance the detail mesh surface should deviate from heightfield
  56966. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56967. */
  56968. detailSampleMaxError: number;
  56969. }
  56970. }
  56971. declare module BABYLON {
  56972. /**
  56973. * RecastJS navigation plugin
  56974. */
  56975. export class RecastJSPlugin implements INavigationEnginePlugin {
  56976. /**
  56977. * Reference to the Recast library
  56978. */
  56979. bjsRECAST: any;
  56980. /**
  56981. * plugin name
  56982. */
  56983. name: string;
  56984. /**
  56985. * the first navmesh created. We might extend this to support multiple navmeshes
  56986. */
  56987. navMesh: any;
  56988. /**
  56989. * Initializes the recastJS plugin
  56990. * @param recastInjection can be used to inject your own recast reference
  56991. */
  56992. constructor(recastInjection?: any);
  56993. /**
  56994. * Creates a navigation mesh
  56995. * @param meshes array of all the geometry used to compute the navigatio mesh
  56996. * @param parameters bunch of parameters used to filter geometry
  56997. */
  56998. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56999. /**
  57000. * Create a navigation mesh debug mesh
  57001. * @param scene is where the mesh will be added
  57002. * @returns debug display mesh
  57003. */
  57004. createDebugNavMesh(scene: Scene): Mesh;
  57005. /**
  57006. * Get a navigation mesh constrained position, closest to the parameter position
  57007. * @param position world position
  57008. * @returns the closest point to position constrained by the navigation mesh
  57009. */
  57010. getClosestPoint(position: Vector3): Vector3;
  57011. /**
  57012. * Get a navigation mesh constrained position, within a particular radius
  57013. * @param position world position
  57014. * @param maxRadius the maximum distance to the constrained world position
  57015. * @returns the closest point to position constrained by the navigation mesh
  57016. */
  57017. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57018. /**
  57019. * Compute the final position from a segment made of destination-position
  57020. * @param position world position
  57021. * @param destination world position
  57022. * @returns the resulting point along the navmesh
  57023. */
  57024. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57025. /**
  57026. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57027. * @param start world position
  57028. * @param end world position
  57029. * @returns array containing world position composing the path
  57030. */
  57031. computePath(start: Vector3, end: Vector3): Vector3[];
  57032. /**
  57033. * Create a new Crowd so you can add agents
  57034. * @param maxAgents the maximum agent count in the crowd
  57035. * @param maxAgentRadius the maximum radius an agent can have
  57036. * @param scene to attach the crowd to
  57037. * @returns the crowd you can add agents to
  57038. */
  57039. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57040. /**
  57041. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57042. * The queries will try to find a solution within those bounds
  57043. * default is (1,1,1)
  57044. * @param extent x,y,z value that define the extent around the queries point of reference
  57045. */
  57046. setDefaultQueryExtent(extent: Vector3): void;
  57047. /**
  57048. * Get the Bounding box extent specified by setDefaultQueryExtent
  57049. * @returns the box extent values
  57050. */
  57051. getDefaultQueryExtent(): Vector3;
  57052. /**
  57053. * Disposes
  57054. */
  57055. dispose(): void;
  57056. /**
  57057. * If this plugin is supported
  57058. * @returns true if plugin is supported
  57059. */
  57060. isSupported(): boolean;
  57061. }
  57062. /**
  57063. * Recast detour crowd implementation
  57064. */
  57065. export class RecastJSCrowd implements ICrowd {
  57066. /**
  57067. * Recast/detour plugin
  57068. */
  57069. bjsRECASTPlugin: RecastJSPlugin;
  57070. /**
  57071. * Link to the detour crowd
  57072. */
  57073. recastCrowd: any;
  57074. /**
  57075. * One transform per agent
  57076. */
  57077. transforms: TransformNode[];
  57078. /**
  57079. * All agents created
  57080. */
  57081. agents: number[];
  57082. /**
  57083. * Link to the scene is kept to unregister the crowd from the scene
  57084. */
  57085. private _scene;
  57086. /**
  57087. * Observer for crowd updates
  57088. */
  57089. private _onBeforeAnimationsObserver;
  57090. /**
  57091. * Constructor
  57092. * @param plugin recastJS plugin
  57093. * @param maxAgents the maximum agent count in the crowd
  57094. * @param maxAgentRadius the maximum radius an agent can have
  57095. * @param scene to attach the crowd to
  57096. * @returns the crowd you can add agents to
  57097. */
  57098. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57099. /**
  57100. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57101. * You can attach anything to that node. The node position is updated in the scene update tick.
  57102. * @param pos world position that will be constrained by the navigation mesh
  57103. * @param parameters agent parameters
  57104. * @param transform hooked to the agent that will be update by the scene
  57105. * @returns agent index
  57106. */
  57107. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57108. /**
  57109. * Returns the agent position in world space
  57110. * @param index agent index returned by addAgent
  57111. * @returns world space position
  57112. */
  57113. getAgentPosition(index: number): Vector3;
  57114. /**
  57115. * Returns the agent velocity in world space
  57116. * @param index agent index returned by addAgent
  57117. * @returns world space velocity
  57118. */
  57119. getAgentVelocity(index: number): Vector3;
  57120. /**
  57121. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57122. * @param index agent index returned by addAgent
  57123. * @param destination targeted world position
  57124. */
  57125. agentGoto(index: number, destination: Vector3): void;
  57126. /**
  57127. * remove a particular agent previously created
  57128. * @param index agent index returned by addAgent
  57129. */
  57130. removeAgent(index: number): void;
  57131. /**
  57132. * get the list of all agents attached to this crowd
  57133. * @returns list of agent indices
  57134. */
  57135. getAgents(): number[];
  57136. /**
  57137. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57138. * @param deltaTime in seconds
  57139. */
  57140. update(deltaTime: number): void;
  57141. /**
  57142. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57143. * The queries will try to find a solution within those bounds
  57144. * default is (1,1,1)
  57145. * @param extent x,y,z value that define the extent around the queries point of reference
  57146. */
  57147. setDefaultQueryExtent(extent: Vector3): void;
  57148. /**
  57149. * Get the Bounding box extent specified by setDefaultQueryExtent
  57150. * @returns the box extent values
  57151. */
  57152. getDefaultQueryExtent(): Vector3;
  57153. /**
  57154. * Release all resources
  57155. */
  57156. dispose(): void;
  57157. }
  57158. }
  57159. declare module BABYLON {
  57160. /**
  57161. * Class used to enable access to IndexedDB
  57162. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57163. */
  57164. export class Database implements IOfflineProvider {
  57165. private _callbackManifestChecked;
  57166. private _currentSceneUrl;
  57167. private _db;
  57168. private _enableSceneOffline;
  57169. private _enableTexturesOffline;
  57170. private _manifestVersionFound;
  57171. private _mustUpdateRessources;
  57172. private _hasReachedQuota;
  57173. private _isSupported;
  57174. private _idbFactory;
  57175. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57176. private static IsUASupportingBlobStorage;
  57177. /**
  57178. * Gets a boolean indicating if Database storate is enabled (off by default)
  57179. */
  57180. static IDBStorageEnabled: boolean;
  57181. /**
  57182. * Gets a boolean indicating if scene must be saved in the database
  57183. */
  57184. readonly enableSceneOffline: boolean;
  57185. /**
  57186. * Gets a boolean indicating if textures must be saved in the database
  57187. */
  57188. readonly enableTexturesOffline: boolean;
  57189. /**
  57190. * Creates a new Database
  57191. * @param urlToScene defines the url to load the scene
  57192. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57193. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57194. */
  57195. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57196. private static _ParseURL;
  57197. private static _ReturnFullUrlLocation;
  57198. private _checkManifestFile;
  57199. /**
  57200. * Open the database and make it available
  57201. * @param successCallback defines the callback to call on success
  57202. * @param errorCallback defines the callback to call on error
  57203. */
  57204. open(successCallback: () => void, errorCallback: () => void): void;
  57205. /**
  57206. * Loads an image from the database
  57207. * @param url defines the url to load from
  57208. * @param image defines the target DOM image
  57209. */
  57210. loadImage(url: string, image: HTMLImageElement): void;
  57211. private _loadImageFromDBAsync;
  57212. private _saveImageIntoDBAsync;
  57213. private _checkVersionFromDB;
  57214. private _loadVersionFromDBAsync;
  57215. private _saveVersionIntoDBAsync;
  57216. /**
  57217. * Loads a file from database
  57218. * @param url defines the URL to load from
  57219. * @param sceneLoaded defines a callback to call on success
  57220. * @param progressCallBack defines a callback to call when progress changed
  57221. * @param errorCallback defines a callback to call on error
  57222. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57223. */
  57224. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57225. private _loadFileAsync;
  57226. private _saveFileAsync;
  57227. /**
  57228. * Validates if xhr data is correct
  57229. * @param xhr defines the request to validate
  57230. * @param dataType defines the expected data type
  57231. * @returns true if data is correct
  57232. */
  57233. private static _ValidateXHRData;
  57234. }
  57235. }
  57236. declare module BABYLON {
  57237. /** @hidden */
  57238. export var gpuUpdateParticlesPixelShader: {
  57239. name: string;
  57240. shader: string;
  57241. };
  57242. }
  57243. declare module BABYLON {
  57244. /** @hidden */
  57245. export var gpuUpdateParticlesVertexShader: {
  57246. name: string;
  57247. shader: string;
  57248. };
  57249. }
  57250. declare module BABYLON {
  57251. /** @hidden */
  57252. export var clipPlaneFragmentDeclaration2: {
  57253. name: string;
  57254. shader: string;
  57255. };
  57256. }
  57257. declare module BABYLON {
  57258. /** @hidden */
  57259. export var gpuRenderParticlesPixelShader: {
  57260. name: string;
  57261. shader: string;
  57262. };
  57263. }
  57264. declare module BABYLON {
  57265. /** @hidden */
  57266. export var clipPlaneVertexDeclaration2: {
  57267. name: string;
  57268. shader: string;
  57269. };
  57270. }
  57271. declare module BABYLON {
  57272. /** @hidden */
  57273. export var gpuRenderParticlesVertexShader: {
  57274. name: string;
  57275. shader: string;
  57276. };
  57277. }
  57278. declare module BABYLON {
  57279. /**
  57280. * This represents a GPU particle system in Babylon
  57281. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57282. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57283. */
  57284. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57285. /**
  57286. * The layer mask we are rendering the particles through.
  57287. */
  57288. layerMask: number;
  57289. private _capacity;
  57290. private _activeCount;
  57291. private _currentActiveCount;
  57292. private _accumulatedCount;
  57293. private _renderEffect;
  57294. private _updateEffect;
  57295. private _buffer0;
  57296. private _buffer1;
  57297. private _spriteBuffer;
  57298. private _updateVAO;
  57299. private _renderVAO;
  57300. private _targetIndex;
  57301. private _sourceBuffer;
  57302. private _targetBuffer;
  57303. private _engine;
  57304. private _currentRenderId;
  57305. private _started;
  57306. private _stopped;
  57307. private _timeDelta;
  57308. private _randomTexture;
  57309. private _randomTexture2;
  57310. private _attributesStrideSize;
  57311. private _updateEffectOptions;
  57312. private _randomTextureSize;
  57313. private _actualFrame;
  57314. private readonly _rawTextureWidth;
  57315. /**
  57316. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57317. */
  57318. static readonly IsSupported: boolean;
  57319. /**
  57320. * An event triggered when the system is disposed.
  57321. */
  57322. onDisposeObservable: Observable<GPUParticleSystem>;
  57323. /**
  57324. * Gets the maximum number of particles active at the same time.
  57325. * @returns The max number of active particles.
  57326. */
  57327. getCapacity(): number;
  57328. /**
  57329. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57330. * to override the particles.
  57331. */
  57332. forceDepthWrite: boolean;
  57333. /**
  57334. * Gets or set the number of active particles
  57335. */
  57336. activeParticleCount: number;
  57337. private _preWarmDone;
  57338. /**
  57339. * Is this system ready to be used/rendered
  57340. * @return true if the system is ready
  57341. */
  57342. isReady(): boolean;
  57343. /**
  57344. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57345. * @returns True if it has been started, otherwise false.
  57346. */
  57347. isStarted(): boolean;
  57348. /**
  57349. * Starts the particle system and begins to emit
  57350. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57351. */
  57352. start(delay?: number): void;
  57353. /**
  57354. * Stops the particle system.
  57355. */
  57356. stop(): void;
  57357. /**
  57358. * Remove all active particles
  57359. */
  57360. reset(): void;
  57361. /**
  57362. * Returns the string "GPUParticleSystem"
  57363. * @returns a string containing the class name
  57364. */
  57365. getClassName(): string;
  57366. private _colorGradientsTexture;
  57367. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57368. /**
  57369. * Adds a new color gradient
  57370. * @param gradient defines the gradient to use (between 0 and 1)
  57371. * @param color1 defines the color to affect to the specified gradient
  57372. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57373. * @returns the current particle system
  57374. */
  57375. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57376. /**
  57377. * Remove a specific color gradient
  57378. * @param gradient defines the gradient to remove
  57379. * @returns the current particle system
  57380. */
  57381. removeColorGradient(gradient: number): GPUParticleSystem;
  57382. private _angularSpeedGradientsTexture;
  57383. private _sizeGradientsTexture;
  57384. private _velocityGradientsTexture;
  57385. private _limitVelocityGradientsTexture;
  57386. private _dragGradientsTexture;
  57387. private _addFactorGradient;
  57388. /**
  57389. * Adds a new size gradient
  57390. * @param gradient defines the gradient to use (between 0 and 1)
  57391. * @param factor defines the size factor to affect to the specified gradient
  57392. * @returns the current particle system
  57393. */
  57394. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57395. /**
  57396. * Remove a specific size gradient
  57397. * @param gradient defines the gradient to remove
  57398. * @returns the current particle system
  57399. */
  57400. removeSizeGradient(gradient: number): GPUParticleSystem;
  57401. /**
  57402. * Adds a new angular speed gradient
  57403. * @param gradient defines the gradient to use (between 0 and 1)
  57404. * @param factor defines the angular speed to affect to the specified gradient
  57405. * @returns the current particle system
  57406. */
  57407. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57408. /**
  57409. * Remove a specific angular speed gradient
  57410. * @param gradient defines the gradient to remove
  57411. * @returns the current particle system
  57412. */
  57413. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57414. /**
  57415. * Adds a new velocity gradient
  57416. * @param gradient defines the gradient to use (between 0 and 1)
  57417. * @param factor defines the velocity to affect to the specified gradient
  57418. * @returns the current particle system
  57419. */
  57420. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57421. /**
  57422. * Remove a specific velocity gradient
  57423. * @param gradient defines the gradient to remove
  57424. * @returns the current particle system
  57425. */
  57426. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57427. /**
  57428. * Adds a new limit velocity gradient
  57429. * @param gradient defines the gradient to use (between 0 and 1)
  57430. * @param factor defines the limit velocity value to affect to the specified gradient
  57431. * @returns the current particle system
  57432. */
  57433. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57434. /**
  57435. * Remove a specific limit velocity gradient
  57436. * @param gradient defines the gradient to remove
  57437. * @returns the current particle system
  57438. */
  57439. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57440. /**
  57441. * Adds a new drag gradient
  57442. * @param gradient defines the gradient to use (between 0 and 1)
  57443. * @param factor defines the drag value to affect to the specified gradient
  57444. * @returns the current particle system
  57445. */
  57446. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57447. /**
  57448. * Remove a specific drag gradient
  57449. * @param gradient defines the gradient to remove
  57450. * @returns the current particle system
  57451. */
  57452. removeDragGradient(gradient: number): GPUParticleSystem;
  57453. /**
  57454. * Not supported by GPUParticleSystem
  57455. * @param gradient defines the gradient to use (between 0 and 1)
  57456. * @param factor defines the emit rate value to affect to the specified gradient
  57457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57458. * @returns the current particle system
  57459. */
  57460. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57461. /**
  57462. * Not supported by GPUParticleSystem
  57463. * @param gradient defines the gradient to remove
  57464. * @returns the current particle system
  57465. */
  57466. removeEmitRateGradient(gradient: number): IParticleSystem;
  57467. /**
  57468. * Not supported by GPUParticleSystem
  57469. * @param gradient defines the gradient to use (between 0 and 1)
  57470. * @param factor defines the start size value to affect to the specified gradient
  57471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57472. * @returns the current particle system
  57473. */
  57474. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57475. /**
  57476. * Not supported by GPUParticleSystem
  57477. * @param gradient defines the gradient to remove
  57478. * @returns the current particle system
  57479. */
  57480. removeStartSizeGradient(gradient: number): IParticleSystem;
  57481. /**
  57482. * Not supported by GPUParticleSystem
  57483. * @param gradient defines the gradient to use (between 0 and 1)
  57484. * @param min defines the color remap minimal range
  57485. * @param max defines the color remap maximal range
  57486. * @returns the current particle system
  57487. */
  57488. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57489. /**
  57490. * Not supported by GPUParticleSystem
  57491. * @param gradient defines the gradient to remove
  57492. * @returns the current particle system
  57493. */
  57494. removeColorRemapGradient(): IParticleSystem;
  57495. /**
  57496. * Not supported by GPUParticleSystem
  57497. * @param gradient defines the gradient to use (between 0 and 1)
  57498. * @param min defines the alpha remap minimal range
  57499. * @param max defines the alpha remap maximal range
  57500. * @returns the current particle system
  57501. */
  57502. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57503. /**
  57504. * Not supported by GPUParticleSystem
  57505. * @param gradient defines the gradient to remove
  57506. * @returns the current particle system
  57507. */
  57508. removeAlphaRemapGradient(): IParticleSystem;
  57509. /**
  57510. * Not supported by GPUParticleSystem
  57511. * @param gradient defines the gradient to use (between 0 and 1)
  57512. * @param color defines the color to affect to the specified gradient
  57513. * @returns the current particle system
  57514. */
  57515. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57516. /**
  57517. * Not supported by GPUParticleSystem
  57518. * @param gradient defines the gradient to remove
  57519. * @returns the current particle system
  57520. */
  57521. removeRampGradient(): IParticleSystem;
  57522. /**
  57523. * Not supported by GPUParticleSystem
  57524. * @returns the list of ramp gradients
  57525. */
  57526. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57527. /**
  57528. * Not supported by GPUParticleSystem
  57529. * Gets or sets a boolean indicating that ramp gradients must be used
  57530. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57531. */
  57532. useRampGradients: boolean;
  57533. /**
  57534. * Not supported by GPUParticleSystem
  57535. * @param gradient defines the gradient to use (between 0 and 1)
  57536. * @param factor defines the life time factor to affect to the specified gradient
  57537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57538. * @returns the current particle system
  57539. */
  57540. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57541. /**
  57542. * Not supported by GPUParticleSystem
  57543. * @param gradient defines the gradient to remove
  57544. * @returns the current particle system
  57545. */
  57546. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57547. /**
  57548. * Instantiates a GPU particle system.
  57549. * 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.
  57550. * @param name The name of the particle system
  57551. * @param options The options used to create the system
  57552. * @param scene The scene the particle system belongs to
  57553. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57554. */
  57555. constructor(name: string, options: Partial<{
  57556. capacity: number;
  57557. randomTextureSize: number;
  57558. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57559. protected _reset(): void;
  57560. private _createUpdateVAO;
  57561. private _createRenderVAO;
  57562. private _initialize;
  57563. /** @hidden */ private _recreateUpdateEffect(): void;
  57564. /** @hidden */ private _recreateRenderEffect(): void;
  57565. /**
  57566. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57567. * @param preWarm defines if we are in the pre-warmimg phase
  57568. */
  57569. animate(preWarm?: boolean): void;
  57570. private _createFactorGradientTexture;
  57571. private _createSizeGradientTexture;
  57572. private _createAngularSpeedGradientTexture;
  57573. private _createVelocityGradientTexture;
  57574. private _createLimitVelocityGradientTexture;
  57575. private _createDragGradientTexture;
  57576. private _createColorGradientTexture;
  57577. /**
  57578. * Renders the particle system in its current state
  57579. * @param preWarm defines if the system should only update the particles but not render them
  57580. * @returns the current number of particles
  57581. */
  57582. render(preWarm?: boolean): number;
  57583. /**
  57584. * Rebuilds the particle system
  57585. */
  57586. rebuild(): void;
  57587. private _releaseBuffers;
  57588. private _releaseVAOs;
  57589. /**
  57590. * Disposes the particle system and free the associated resources
  57591. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57592. */
  57593. dispose(disposeTexture?: boolean): void;
  57594. /**
  57595. * Clones the particle system.
  57596. * @param name The name of the cloned object
  57597. * @param newEmitter The new emitter to use
  57598. * @returns the cloned particle system
  57599. */
  57600. clone(name: string, newEmitter: any): GPUParticleSystem;
  57601. /**
  57602. * Serializes the particle system to a JSON object.
  57603. * @returns the JSON object
  57604. */
  57605. serialize(): any;
  57606. /**
  57607. * Parses a JSON object to create a GPU particle system.
  57608. * @param parsedParticleSystem The JSON object to parse
  57609. * @param scene The scene to create the particle system in
  57610. * @param rootUrl The root url to use to load external dependencies like texture
  57611. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57612. * @returns the parsed GPU particle system
  57613. */
  57614. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57615. }
  57616. }
  57617. declare module BABYLON {
  57618. /**
  57619. * Represents a set of particle systems working together to create a specific effect
  57620. */
  57621. export class ParticleSystemSet implements IDisposable {
  57622. /**
  57623. * Gets or sets base Assets URL
  57624. */
  57625. static BaseAssetsUrl: string;
  57626. private _emitterCreationOptions;
  57627. private _emitterNode;
  57628. /**
  57629. * Gets the particle system list
  57630. */
  57631. systems: IParticleSystem[];
  57632. /**
  57633. * Gets the emitter node used with this set
  57634. */
  57635. readonly emitterNode: Nullable<TransformNode>;
  57636. /**
  57637. * Creates a new emitter mesh as a sphere
  57638. * @param options defines the options used to create the sphere
  57639. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57640. * @param scene defines the hosting scene
  57641. */
  57642. setEmitterAsSphere(options: {
  57643. diameter: number;
  57644. segments: number;
  57645. color: Color3;
  57646. }, renderingGroupId: number, scene: Scene): void;
  57647. /**
  57648. * Starts all particle systems of the set
  57649. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57650. */
  57651. start(emitter?: AbstractMesh): void;
  57652. /**
  57653. * Release all associated resources
  57654. */
  57655. dispose(): void;
  57656. /**
  57657. * Serialize the set into a JSON compatible object
  57658. * @returns a JSON compatible representation of the set
  57659. */
  57660. serialize(): any;
  57661. /**
  57662. * Parse a new ParticleSystemSet from a serialized source
  57663. * @param data defines a JSON compatible representation of the set
  57664. * @param scene defines the hosting scene
  57665. * @param gpu defines if we want GPU particles or CPU particles
  57666. * @returns a new ParticleSystemSet
  57667. */
  57668. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57669. }
  57670. }
  57671. declare module BABYLON {
  57672. /**
  57673. * This class is made for on one-liner static method to help creating particle system set.
  57674. */
  57675. export class ParticleHelper {
  57676. /**
  57677. * Gets or sets base Assets URL
  57678. */
  57679. static BaseAssetsUrl: string;
  57680. /**
  57681. * Create a default particle system that you can tweak
  57682. * @param emitter defines the emitter to use
  57683. * @param capacity defines the system capacity (default is 500 particles)
  57684. * @param scene defines the hosting scene
  57685. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57686. * @returns the new Particle system
  57687. */
  57688. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57689. /**
  57690. * This is the main static method (one-liner) of this helper to create different particle systems
  57691. * @param type This string represents the type to the particle system to create
  57692. * @param scene The scene where the particle system should live
  57693. * @param gpu If the system will use gpu
  57694. * @returns the ParticleSystemSet created
  57695. */
  57696. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57697. /**
  57698. * Static function used to export a particle system to a ParticleSystemSet variable.
  57699. * Please note that the emitter shape is not exported
  57700. * @param systems defines the particle systems to export
  57701. * @returns the created particle system set
  57702. */
  57703. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. interface Engine {
  57708. /**
  57709. * Create an effect to use with particle systems.
  57710. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57711. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57712. * @param uniformsNames defines a list of attribute names
  57713. * @param samplers defines an array of string used to represent textures
  57714. * @param defines defines the string containing the defines to use to compile the shaders
  57715. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57716. * @param onCompiled defines a function to call when the effect creation is successful
  57717. * @param onError defines a function to call when the effect creation has failed
  57718. * @returns the new Effect
  57719. */
  57720. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57721. }
  57722. interface Mesh {
  57723. /**
  57724. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57725. * @returns an array of IParticleSystem
  57726. */
  57727. getEmittedParticleSystems(): IParticleSystem[];
  57728. /**
  57729. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57730. * @returns an array of IParticleSystem
  57731. */
  57732. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57733. }
  57734. /**
  57735. * @hidden
  57736. */
  57737. export var _IDoNeedToBeInTheBuild: number;
  57738. }
  57739. declare module BABYLON {
  57740. /** Defines the 4 color options */
  57741. export enum PointColor {
  57742. /** color value */
  57743. Color = 2,
  57744. /** uv value */
  57745. UV = 1,
  57746. /** random value */
  57747. Random = 0,
  57748. /** stated value */
  57749. Stated = 3
  57750. }
  57751. /**
  57752. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  57753. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  57754. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  57755. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  57756. *
  57757. * Full documentation here : TO BE ENTERED
  57758. */
  57759. export class PointsCloudSystem implements IDisposable {
  57760. /**
  57761. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  57762. * Example : var p = SPS.particles[i];
  57763. */
  57764. particles: CloudPoint[];
  57765. /**
  57766. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  57767. */
  57768. nbParticles: number;
  57769. /**
  57770. * This a counter for your own usage. It's not set by any SPS functions.
  57771. */
  57772. counter: number;
  57773. /**
  57774. * The PCS name. This name is also given to the underlying mesh.
  57775. */
  57776. name: string;
  57777. /**
  57778. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  57779. */
  57780. mesh: Mesh;
  57781. /**
  57782. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  57783. * Please read :
  57784. */
  57785. vars: any;
  57786. /**
  57787. * @hidden
  57788. */ private _size: number;
  57789. private _scene;
  57790. private _promises;
  57791. private _positions;
  57792. private _indices;
  57793. private _normals;
  57794. private _colors;
  57795. private _uvs;
  57796. private _indices32;
  57797. private _positions32;
  57798. private _colors32;
  57799. private _uvs32;
  57800. private _updatable;
  57801. private _isVisibilityBoxLocked;
  57802. private _alwaysVisible;
  57803. private _groups;
  57804. private _groupCounter;
  57805. private _computeParticleColor;
  57806. private _computeParticleTexture;
  57807. private _computeParticleRotation;
  57808. private _computeBoundingBox;
  57809. private _isReady;
  57810. /**
  57811. * Creates a PCS (Points Cloud System) object
  57812. * @param name (String) is the PCS name, this will be the underlying mesh name
  57813. * @param pointSize (number) is the size for each point
  57814. * @param scene (Scene) is the scene in which the PCS is added
  57815. * @param options defines the options of the PCS e.g.
  57816. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  57817. */
  57818. constructor(name: string, pointSize: number, scene: Scene, options?: {
  57819. updatable?: boolean;
  57820. });
  57821. /**
  57822. * Builds the PCS underlying mesh. Returns a standard Mesh.
  57823. * If no points were added to the PCS, the returned mesh is just a single point.
  57824. * @returns a promise for the created mesh
  57825. */
  57826. buildMeshAsync(): Promise<Mesh>;
  57827. /**
  57828. * @hidden
  57829. */
  57830. private _buildMesh;
  57831. private _addParticle;
  57832. private _randomUnitVector;
  57833. private _getColorIndicesForCoord;
  57834. private _setPointsColorOrUV;
  57835. private _colorFromTexture;
  57836. private _calculateDensity;
  57837. /**
  57838. * Adds points to the PCS in random positions within a unit sphere
  57839. * @param nb (positive integer) the number of particles to be created from this model
  57840. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  57841. * @returns the number of groups in the system
  57842. */
  57843. addPoints(nb: number, pointFunction?: any): number;
  57844. /**
  57845. * Adds points to the PCS from the surface of the model shape
  57846. * @param mesh is any Mesh object that will be used as a surface model for the points
  57847. * @param nb (positive integer) the number of particles to be created from this model
  57848. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  57849. * @param color (color3) to be used when colorWith is stated
  57850. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  57851. * @returns the number of groups in the system
  57852. */
  57853. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  57854. /**
  57855. * Adds points to the PCS inside the model shape
  57856. * @param mesh is any Mesh object that will be used as a surface model for the points
  57857. * @param nb (positive integer) the number of particles to be created from this model
  57858. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  57859. * @param color (color4) to be used when colorWith is stated
  57860. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  57861. * @returns the number of groups in the system
  57862. */
  57863. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  57864. /**
  57865. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  57866. * This method calls `updateParticle()` for each particle of the SPS.
  57867. * For an animated SPS, it is usually called within the render loop.
  57868. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  57869. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  57870. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  57871. * @returns the PCS.
  57872. */
  57873. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  57874. /**
  57875. * Disposes the PCS.
  57876. */
  57877. dispose(): void;
  57878. /**
  57879. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  57880. * doc :
  57881. * @returns the PCS.
  57882. */
  57883. refreshVisibleSize(): PointsCloudSystem;
  57884. /**
  57885. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  57886. * @param size the size (float) of the visibility box
  57887. * note : this doesn't lock the PCS mesh bounding box.
  57888. * doc :
  57889. */
  57890. setVisibilityBox(size: number): void;
  57891. /**
  57892. * Gets whether the PCS is always visible or not
  57893. * doc :
  57894. */
  57895. /**
  57896. * Sets the PCS as always visible or not
  57897. * doc :
  57898. */
  57899. isAlwaysVisible: boolean;
  57900. /**
  57901. * Tells to `setParticles()` to compute the particle rotations or not
  57902. * Default value : false. The PCS is faster when it's set to false
  57903. * Note : particle rotations are only applied to parent particles
  57904. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  57905. */
  57906. computeParticleRotation: boolean;
  57907. /**
  57908. * Tells to `setParticles()` to compute the particle colors or not.
  57909. * Default value : true. The PCS is faster when it's set to false.
  57910. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  57911. */
  57912. /**
  57913. * Gets if `setParticles()` computes the particle colors or not.
  57914. * Default value : false. The PCS is faster when it's set to false.
  57915. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  57916. */
  57917. computeParticleColor: boolean;
  57918. /**
  57919. * Gets if `setParticles()` computes the particle textures or not.
  57920. * Default value : false. The PCS is faster when it's set to false.
  57921. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  57922. */
  57923. computeParticleTexture: boolean;
  57924. /**
  57925. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  57926. */
  57927. /**
  57928. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  57929. */
  57930. computeBoundingBox: boolean;
  57931. /**
  57932. * This function does nothing. It may be overwritten to set all the particle first values.
  57933. * The PCS doesn't call this function, you may have to call it by your own.
  57934. * doc :
  57935. */
  57936. initParticles(): void;
  57937. /**
  57938. * This function does nothing. It may be overwritten to recycle a particle
  57939. * The PCS doesn't call this function, you can to call it
  57940. * doc :
  57941. * @param particle The particle to recycle
  57942. * @returns the recycled particle
  57943. */
  57944. recycleParticle(particle: CloudPoint): CloudPoint;
  57945. /**
  57946. * Updates a particle : this function should be overwritten by the user.
  57947. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  57948. * doc :
  57949. * @example : just set a particle position or velocity and recycle conditions
  57950. * @param particle The particle to update
  57951. * @returns the updated particle
  57952. */
  57953. updateParticle(particle: CloudPoint): CloudPoint;
  57954. /**
  57955. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  57956. * This does nothing and may be overwritten by the user.
  57957. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  57958. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  57959. * @param update the boolean update value actually passed to setParticles()
  57960. */
  57961. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  57962. /**
  57963. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  57964. * This will be passed three parameters.
  57965. * This does nothing and may be overwritten by the user.
  57966. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  57967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  57968. * @param update the boolean update value actually passed to setParticles()
  57969. */
  57970. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  57971. }
  57972. }
  57973. declare module BABYLON {
  57974. /**
  57975. * Represents one particle of a points cloud system.
  57976. */
  57977. export class CloudPoint {
  57978. /**
  57979. * particle global index
  57980. */
  57981. idx: number;
  57982. /**
  57983. * The color of the particle
  57984. */
  57985. color: Nullable<Color4>;
  57986. /**
  57987. * The world space position of the particle.
  57988. */
  57989. position: Vector3;
  57990. /**
  57991. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  57992. */
  57993. rotation: Vector3;
  57994. /**
  57995. * The world space rotation quaternion of the particle.
  57996. */
  57997. rotationQuaternion: Nullable<Quaternion>;
  57998. /**
  57999. * The uv of the particle.
  58000. */
  58001. uv: Nullable<Vector2>;
  58002. /**
  58003. * The current speed of the particle.
  58004. */
  58005. velocity: Vector3;
  58006. /**
  58007. * The pivot point in the particle local space.
  58008. */
  58009. pivot: Vector3;
  58010. /**
  58011. * Must the particle be translated from its pivot point in its local space ?
  58012. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58013. * Default : false
  58014. */
  58015. translateFromPivot: boolean;
  58016. /**
  58017. * Index of this particle in the global "positions" array (Internal use)
  58018. * @hidden
  58019. */ private _pos: number;
  58020. /**
  58021. * @hidden Index of this particle in the global "indices" array (Internal use)
  58022. */ private _ind: number;
  58023. /**
  58024. * Group this particle belongs to
  58025. */ private _group: PointsGroup;
  58026. /**
  58027. * Group id of this particle
  58028. */
  58029. groupId: number;
  58030. /**
  58031. * Index of the particle in its group id (Internal use)
  58032. */
  58033. idxInGroup: number;
  58034. /**
  58035. * @hidden Particle BoundingInfo object (Internal use)
  58036. */ private _boundingInfo: BoundingInfo;
  58037. /**
  58038. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58039. */ private _pcs: PointsCloudSystem;
  58040. /**
  58041. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  58042. */ private _stillInvisible: boolean;
  58043. /**
  58044. * @hidden Last computed particle rotation matrix
  58045. */ private _rotationMatrix: number[];
  58046. /**
  58047. * Parent particle Id, if any.
  58048. * Default null.
  58049. */
  58050. parentId: Nullable<number>;
  58051. /**
  58052. * @hidden Internal global position in the PCS.
  58053. */ private _globalPosition: Vector3;
  58054. /**
  58055. * Creates a Point Cloud object.
  58056. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  58057. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  58058. * @param group (PointsGroup) is the group the particle belongs to
  58059. * @param groupId (integer) is the group identifier in the PCS.
  58060. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  58061. * @param pcs defines the PCS it is associated to
  58062. */
  58063. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  58064. /**
  58065. * get point size
  58066. */
  58067. /**
  58068. * Set point size
  58069. */
  58070. size: Vector3;
  58071. /**
  58072. * Legacy support, changed quaternion to rotationQuaternion
  58073. */
  58074. /**
  58075. * Legacy support, changed quaternion to rotationQuaternion
  58076. */
  58077. quaternion: Nullable<Quaternion>;
  58078. /**
  58079. * Returns a boolean. True if the particle intersects a mesh, else false
  58080. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  58081. * @param target is the object (point or mesh) what the intersection is computed against
  58082. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  58083. * @returns true if it intersects
  58084. */
  58085. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  58086. /**
  58087. * get the rotation matrix of the particle
  58088. * @hidden
  58089. */
  58090. getRotationMatrix(m: Matrix): void;
  58091. }
  58092. /**
  58093. * Represents a group of points in a points cloud system
  58094. * * PCS internal tool, don't use it manually.
  58095. */
  58096. export class PointsGroup {
  58097. /**
  58098. * The group id
  58099. * @hidden
  58100. */
  58101. groupID: number;
  58102. /**
  58103. * image data for group (internal use)
  58104. * @hidden
  58105. */ private _groupImageData: Nullable<ArrayBufferView>;
  58106. /**
  58107. * Image Width (internal use)
  58108. * @hidden
  58109. */ private _groupImgWidth: number;
  58110. /**
  58111. * Image Height (internal use)
  58112. * @hidden
  58113. */ private _groupImgHeight: number;
  58114. /**
  58115. * Custom position function (internal use)
  58116. * @hidden
  58117. */ private _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  58118. /**
  58119. * density per facet for surface points
  58120. * @hidden
  58121. */ private _groupDensity: number[];
  58122. /**
  58123. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  58124. * PCS internal tool, don't use it manually.
  58125. * @hidden
  58126. */
  58127. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  58128. }
  58129. }
  58130. declare module BABYLON {
  58131. interface Scene {
  58132. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  58133. /**
  58134. * Gets the current physics engine
  58135. * @returns a IPhysicsEngine or null if none attached
  58136. */
  58137. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58138. /**
  58139. * Enables physics to the current scene
  58140. * @param gravity defines the scene's gravity for the physics engine
  58141. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58142. * @return a boolean indicating if the physics engine was initialized
  58143. */
  58144. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58145. /**
  58146. * Disables and disposes the physics engine associated with the scene
  58147. */
  58148. disablePhysicsEngine(): void;
  58149. /**
  58150. * Gets a boolean indicating if there is an active physics engine
  58151. * @returns a boolean indicating if there is an active physics engine
  58152. */
  58153. isPhysicsEnabled(): boolean;
  58154. /**
  58155. * Deletes a physics compound impostor
  58156. * @param compound defines the compound to delete
  58157. */
  58158. deleteCompoundImpostor(compound: any): void;
  58159. /**
  58160. * An event triggered when physic simulation is about to be run
  58161. */
  58162. onBeforePhysicsObservable: Observable<Scene>;
  58163. /**
  58164. * An event triggered when physic simulation has been done
  58165. */
  58166. onAfterPhysicsObservable: Observable<Scene>;
  58167. }
  58168. interface AbstractMesh {
  58169. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  58170. /**
  58171. * Gets or sets impostor used for physic simulation
  58172. * @see http://doc.babylonjs.com/features/physics_engine
  58173. */
  58174. physicsImpostor: Nullable<PhysicsImpostor>;
  58175. /**
  58176. * Gets the current physics impostor
  58177. * @see http://doc.babylonjs.com/features/physics_engine
  58178. * @returns a physics impostor or null
  58179. */
  58180. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58181. /** Apply a physic impulse to the mesh
  58182. * @param force defines the force to apply
  58183. * @param contactPoint defines where to apply the force
  58184. * @returns the current mesh
  58185. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58186. */
  58187. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58188. /**
  58189. * Creates a physic joint between two meshes
  58190. * @param otherMesh defines the other mesh to use
  58191. * @param pivot1 defines the pivot to use on this mesh
  58192. * @param pivot2 defines the pivot to use on the other mesh
  58193. * @param options defines additional options (can be plugin dependent)
  58194. * @returns the current mesh
  58195. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58196. */
  58197. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58198. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  58199. }
  58200. /**
  58201. * Defines the physics engine scene component responsible to manage a physics engine
  58202. */
  58203. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58204. /**
  58205. * The component name helpful to identify the component in the list of scene components.
  58206. */
  58207. readonly name: string;
  58208. /**
  58209. * The scene the component belongs to.
  58210. */
  58211. scene: Scene;
  58212. /**
  58213. * Creates a new instance of the component for the given scene
  58214. * @param scene Defines the scene to register the component in
  58215. */
  58216. constructor(scene: Scene);
  58217. /**
  58218. * Registers the component in a given scene
  58219. */
  58220. register(): void;
  58221. /**
  58222. * Rebuilds the elements related to this component in case of
  58223. * context lost for instance.
  58224. */
  58225. rebuild(): void;
  58226. /**
  58227. * Disposes the component and the associated ressources
  58228. */
  58229. dispose(): void;
  58230. }
  58231. }
  58232. declare module BABYLON {
  58233. /**
  58234. * A helper for physics simulations
  58235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58236. */
  58237. export class PhysicsHelper {
  58238. private _scene;
  58239. private _physicsEngine;
  58240. /**
  58241. * Initializes the Physics helper
  58242. * @param scene Babylon.js scene
  58243. */
  58244. constructor(scene: Scene);
  58245. /**
  58246. * Applies a radial explosion impulse
  58247. * @param origin the origin of the explosion
  58248. * @param radiusOrEventOptions the radius or the options of radial explosion
  58249. * @param strength the explosion strength
  58250. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58251. * @returns A physics radial explosion event, or null
  58252. */
  58253. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58254. /**
  58255. * Applies a radial explosion force
  58256. * @param origin the origin of the explosion
  58257. * @param radiusOrEventOptions the radius or the options of radial explosion
  58258. * @param strength the explosion strength
  58259. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58260. * @returns A physics radial explosion event, or null
  58261. */
  58262. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58263. /**
  58264. * Creates a gravitational field
  58265. * @param origin the origin of the explosion
  58266. * @param radiusOrEventOptions the radius or the options of radial explosion
  58267. * @param strength the explosion strength
  58268. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58269. * @returns A physics gravitational field event, or null
  58270. */
  58271. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58272. /**
  58273. * Creates a physics updraft event
  58274. * @param origin the origin of the updraft
  58275. * @param radiusOrEventOptions the radius or the options of the updraft
  58276. * @param strength the strength of the updraft
  58277. * @param height the height of the updraft
  58278. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58279. * @returns A physics updraft event, or null
  58280. */
  58281. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58282. /**
  58283. * Creates a physics vortex event
  58284. * @param origin the of the vortex
  58285. * @param radiusOrEventOptions the radius or the options of the vortex
  58286. * @param strength the strength of the vortex
  58287. * @param height the height of the vortex
  58288. * @returns a Physics vortex event, or null
  58289. * A physics vortex event or null
  58290. */
  58291. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58292. }
  58293. /**
  58294. * Represents a physics radial explosion event
  58295. */
  58296. class PhysicsRadialExplosionEvent {
  58297. private _scene;
  58298. private _options;
  58299. private _sphere;
  58300. private _dataFetched;
  58301. /**
  58302. * Initializes a radial explosioin event
  58303. * @param _scene BabylonJS scene
  58304. * @param _options The options for the vortex event
  58305. */
  58306. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58307. /**
  58308. * Returns the data related to the radial explosion event (sphere).
  58309. * @returns The radial explosion event data
  58310. */
  58311. getData(): PhysicsRadialExplosionEventData;
  58312. /**
  58313. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58314. * @param impostor A physics imposter
  58315. * @param origin the origin of the explosion
  58316. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58317. */
  58318. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58319. /**
  58320. * Triggers affecterd impostors callbacks
  58321. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58322. */
  58323. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58324. /**
  58325. * Disposes the sphere.
  58326. * @param force Specifies if the sphere should be disposed by force
  58327. */
  58328. dispose(force?: boolean): void;
  58329. /*** Helpers ***/
  58330. private _prepareSphere;
  58331. private _intersectsWithSphere;
  58332. }
  58333. /**
  58334. * Represents a gravitational field event
  58335. */
  58336. class PhysicsGravitationalFieldEvent {
  58337. private _physicsHelper;
  58338. private _scene;
  58339. private _origin;
  58340. private _options;
  58341. private _tickCallback;
  58342. private _sphere;
  58343. private _dataFetched;
  58344. /**
  58345. * Initializes the physics gravitational field event
  58346. * @param _physicsHelper A physics helper
  58347. * @param _scene BabylonJS scene
  58348. * @param _origin The origin position of the gravitational field event
  58349. * @param _options The options for the vortex event
  58350. */
  58351. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58352. /**
  58353. * Returns the data related to the gravitational field event (sphere).
  58354. * @returns A gravitational field event
  58355. */
  58356. getData(): PhysicsGravitationalFieldEventData;
  58357. /**
  58358. * Enables the gravitational field.
  58359. */
  58360. enable(): void;
  58361. /**
  58362. * Disables the gravitational field.
  58363. */
  58364. disable(): void;
  58365. /**
  58366. * Disposes the sphere.
  58367. * @param force The force to dispose from the gravitational field event
  58368. */
  58369. dispose(force?: boolean): void;
  58370. private _tick;
  58371. }
  58372. /**
  58373. * Represents a physics updraft event
  58374. */
  58375. class PhysicsUpdraftEvent {
  58376. private _scene;
  58377. private _origin;
  58378. private _options;
  58379. private _physicsEngine;
  58380. private _originTop;
  58381. private _originDirection;
  58382. private _tickCallback;
  58383. private _cylinder;
  58384. private _cylinderPosition;
  58385. private _dataFetched;
  58386. /**
  58387. * Initializes the physics updraft event
  58388. * @param _scene BabylonJS scene
  58389. * @param _origin The origin position of the updraft
  58390. * @param _options The options for the updraft event
  58391. */
  58392. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58393. /**
  58394. * Returns the data related to the updraft event (cylinder).
  58395. * @returns A physics updraft event
  58396. */
  58397. getData(): PhysicsUpdraftEventData;
  58398. /**
  58399. * Enables the updraft.
  58400. */
  58401. enable(): void;
  58402. /**
  58403. * Disables the updraft.
  58404. */
  58405. disable(): void;
  58406. /**
  58407. * Disposes the cylinder.
  58408. * @param force Specifies if the updraft should be disposed by force
  58409. */
  58410. dispose(force?: boolean): void;
  58411. private getImpostorHitData;
  58412. private _tick;
  58413. /*** Helpers ***/
  58414. private _prepareCylinder;
  58415. private _intersectsWithCylinder;
  58416. }
  58417. /**
  58418. * Represents a physics vortex event
  58419. */
  58420. class PhysicsVortexEvent {
  58421. private _scene;
  58422. private _origin;
  58423. private _options;
  58424. private _physicsEngine;
  58425. private _originTop;
  58426. private _tickCallback;
  58427. private _cylinder;
  58428. private _cylinderPosition;
  58429. private _dataFetched;
  58430. /**
  58431. * Initializes the physics vortex event
  58432. * @param _scene The BabylonJS scene
  58433. * @param _origin The origin position of the vortex
  58434. * @param _options The options for the vortex event
  58435. */
  58436. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58437. /**
  58438. * Returns the data related to the vortex event (cylinder).
  58439. * @returns The physics vortex event data
  58440. */
  58441. getData(): PhysicsVortexEventData;
  58442. /**
  58443. * Enables the vortex.
  58444. */
  58445. enable(): void;
  58446. /**
  58447. * Disables the cortex.
  58448. */
  58449. disable(): void;
  58450. /**
  58451. * Disposes the sphere.
  58452. * @param force
  58453. */
  58454. dispose(force?: boolean): void;
  58455. private getImpostorHitData;
  58456. private _tick;
  58457. /*** Helpers ***/
  58458. private _prepareCylinder;
  58459. private _intersectsWithCylinder;
  58460. }
  58461. /**
  58462. * Options fot the radial explosion event
  58463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58464. */
  58465. export class PhysicsRadialExplosionEventOptions {
  58466. /**
  58467. * The radius of the sphere for the radial explosion.
  58468. */
  58469. radius: number;
  58470. /**
  58471. * The strenth of the explosion.
  58472. */
  58473. strength: number;
  58474. /**
  58475. * The strenght of the force in correspondence to the distance of the affected object
  58476. */
  58477. falloff: PhysicsRadialImpulseFalloff;
  58478. /**
  58479. * Sphere options for the radial explosion.
  58480. */
  58481. sphere: {
  58482. segments: number;
  58483. diameter: number;
  58484. };
  58485. /**
  58486. * Sphere options for the radial explosion.
  58487. */
  58488. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58489. }
  58490. /**
  58491. * Options fot the updraft event
  58492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58493. */
  58494. export class PhysicsUpdraftEventOptions {
  58495. /**
  58496. * The radius of the cylinder for the vortex
  58497. */
  58498. radius: number;
  58499. /**
  58500. * The strenth of the updraft.
  58501. */
  58502. strength: number;
  58503. /**
  58504. * The height of the cylinder for the updraft.
  58505. */
  58506. height: number;
  58507. /**
  58508. * The mode for the the updraft.
  58509. */
  58510. updraftMode: PhysicsUpdraftMode;
  58511. }
  58512. /**
  58513. * Options fot the vortex event
  58514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58515. */
  58516. export class PhysicsVortexEventOptions {
  58517. /**
  58518. * The radius of the cylinder for the vortex
  58519. */
  58520. radius: number;
  58521. /**
  58522. * The strenth of the vortex.
  58523. */
  58524. strength: number;
  58525. /**
  58526. * The height of the cylinder for the vortex.
  58527. */
  58528. height: number;
  58529. /**
  58530. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58531. */
  58532. centripetalForceThreshold: number;
  58533. /**
  58534. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58535. */
  58536. centripetalForceMultiplier: number;
  58537. /**
  58538. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58539. */
  58540. centrifugalForceMultiplier: number;
  58541. /**
  58542. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58543. */
  58544. updraftForceMultiplier: number;
  58545. }
  58546. /**
  58547. * The strenght of the force in correspondence to the distance of the affected object
  58548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58549. */
  58550. export enum PhysicsRadialImpulseFalloff {
  58551. /** Defines that impulse is constant in strength across it's whole radius */
  58552. Constant = 0,
  58553. /** Defines that impulse gets weaker if it's further from the origin */
  58554. Linear = 1
  58555. }
  58556. /**
  58557. * The strength of the force in correspondence to the distance of the affected object
  58558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58559. */
  58560. export enum PhysicsUpdraftMode {
  58561. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58562. Center = 0,
  58563. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58564. Perpendicular = 1
  58565. }
  58566. /**
  58567. * Interface for a physics hit data
  58568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58569. */
  58570. export interface PhysicsHitData {
  58571. /**
  58572. * The force applied at the contact point
  58573. */
  58574. force: Vector3;
  58575. /**
  58576. * The contact point
  58577. */
  58578. contactPoint: Vector3;
  58579. /**
  58580. * The distance from the origin to the contact point
  58581. */
  58582. distanceFromOrigin: number;
  58583. }
  58584. /**
  58585. * Interface for radial explosion event data
  58586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58587. */
  58588. export interface PhysicsRadialExplosionEventData {
  58589. /**
  58590. * A sphere used for the radial explosion event
  58591. */
  58592. sphere: Mesh;
  58593. }
  58594. /**
  58595. * Interface for gravitational field event data
  58596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58597. */
  58598. export interface PhysicsGravitationalFieldEventData {
  58599. /**
  58600. * A sphere mesh used for the gravitational field event
  58601. */
  58602. sphere: Mesh;
  58603. }
  58604. /**
  58605. * Interface for updraft event data
  58606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58607. */
  58608. export interface PhysicsUpdraftEventData {
  58609. /**
  58610. * A cylinder used for the updraft event
  58611. */
  58612. cylinder: Mesh;
  58613. }
  58614. /**
  58615. * Interface for vortex event data
  58616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58617. */
  58618. export interface PhysicsVortexEventData {
  58619. /**
  58620. * A cylinder used for the vortex event
  58621. */
  58622. cylinder: Mesh;
  58623. }
  58624. /**
  58625. * Interface for an affected physics impostor
  58626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58627. */
  58628. export interface PhysicsAffectedImpostorWithData {
  58629. /**
  58630. * The impostor affected by the effect
  58631. */
  58632. impostor: PhysicsImpostor;
  58633. /**
  58634. * The data about the hit/horce from the explosion
  58635. */
  58636. hitData: PhysicsHitData;
  58637. }
  58638. }
  58639. declare module BABYLON {
  58640. /** @hidden */
  58641. export var blackAndWhitePixelShader: {
  58642. name: string;
  58643. shader: string;
  58644. };
  58645. }
  58646. declare module BABYLON {
  58647. /**
  58648. * Post process used to render in black and white
  58649. */
  58650. export class BlackAndWhitePostProcess extends PostProcess {
  58651. /**
  58652. * Linear about to convert he result to black and white (default: 1)
  58653. */
  58654. degree: number;
  58655. /**
  58656. * Creates a black and white post process
  58657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58658. * @param name The name of the effect.
  58659. * @param options The required width/height ratio to downsize to before computing the render pass.
  58660. * @param camera The camera to apply the render pass to.
  58661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58662. * @param engine The engine which the post process will be applied. (default: current engine)
  58663. * @param reusable If the post process can be reused on the same frame. (default: false)
  58664. */
  58665. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58666. }
  58667. }
  58668. declare module BABYLON {
  58669. /**
  58670. * This represents a set of one or more post processes in Babylon.
  58671. * A post process can be used to apply a shader to a texture after it is rendered.
  58672. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58673. */
  58674. export class PostProcessRenderEffect {
  58675. private _postProcesses;
  58676. private _getPostProcesses;
  58677. private _singleInstance;
  58678. private _cameras;
  58679. private _indicesForCamera;
  58680. /**
  58681. * Name of the effect
  58682. * @hidden
  58683. */ private _name: string;
  58684. /**
  58685. * Instantiates a post process render effect.
  58686. * A post process can be used to apply a shader to a texture after it is rendered.
  58687. * @param engine The engine the effect is tied to
  58688. * @param name The name of the effect
  58689. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58690. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58691. */
  58692. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58693. /**
  58694. * Checks if all the post processes in the effect are supported.
  58695. */
  58696. readonly isSupported: boolean;
  58697. /**
  58698. * Updates the current state of the effect
  58699. * @hidden
  58700. */ private _update(): void;
  58701. /**
  58702. * Attaches the effect on cameras
  58703. * @param cameras The camera to attach to.
  58704. * @hidden
  58705. */ private _attachCameras(cameras: Camera): void;
  58706. /**
  58707. * Attaches the effect on cameras
  58708. * @param cameras The camera to attach to.
  58709. * @hidden
  58710. */ private _attachCameras(cameras: Camera[]): void;
  58711. /**
  58712. * Detaches the effect on cameras
  58713. * @param cameras The camera to detatch from.
  58714. * @hidden
  58715. */ private _detachCameras(cameras: Camera): void;
  58716. /**
  58717. * Detatches the effect on cameras
  58718. * @param cameras The camera to detatch from.
  58719. * @hidden
  58720. */ private _detachCameras(cameras: Camera[]): void;
  58721. /**
  58722. * Enables the effect on given cameras
  58723. * @param cameras The camera to enable.
  58724. * @hidden
  58725. */ private _enable(cameras: Camera): void;
  58726. /**
  58727. * Enables the effect on given cameras
  58728. * @param cameras The camera to enable.
  58729. * @hidden
  58730. */ private _enable(cameras: Nullable<Camera[]>): void;
  58731. /**
  58732. * Disables the effect on the given cameras
  58733. * @param cameras The camera to disable.
  58734. * @hidden
  58735. */ private _disable(cameras: Camera): void;
  58736. /**
  58737. * Disables the effect on the given cameras
  58738. * @param cameras The camera to disable.
  58739. * @hidden
  58740. */ private _disable(cameras: Nullable<Camera[]>): void;
  58741. /**
  58742. * Gets a list of the post processes contained in the effect.
  58743. * @param camera The camera to get the post processes on.
  58744. * @returns The list of the post processes in the effect.
  58745. */
  58746. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58747. }
  58748. }
  58749. declare module BABYLON {
  58750. /** @hidden */
  58751. export var extractHighlightsPixelShader: {
  58752. name: string;
  58753. shader: string;
  58754. };
  58755. }
  58756. declare module BABYLON {
  58757. /**
  58758. * 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.
  58759. */
  58760. export class ExtractHighlightsPostProcess extends PostProcess {
  58761. /**
  58762. * The luminance threshold, pixels below this value will be set to black.
  58763. */
  58764. threshold: number;
  58765. /** @hidden */ private _exposure: number;
  58766. /**
  58767. * Post process which has the input texture to be used when performing highlight extraction
  58768. * @hidden
  58769. */ private _inputPostProcess: Nullable<PostProcess>;
  58770. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58771. }
  58772. }
  58773. declare module BABYLON {
  58774. /** @hidden */
  58775. export var bloomMergePixelShader: {
  58776. name: string;
  58777. shader: string;
  58778. };
  58779. }
  58780. declare module BABYLON {
  58781. /**
  58782. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58783. */
  58784. export class BloomMergePostProcess extends PostProcess {
  58785. /** Weight of the bloom to be added to the original input. */
  58786. weight: number;
  58787. /**
  58788. * Creates a new instance of @see BloomMergePostProcess
  58789. * @param name The name of the effect.
  58790. * @param originalFromInput Post process which's input will be used for the merge.
  58791. * @param blurred Blurred highlights post process which's output will be used.
  58792. * @param weight Weight of the bloom to be added to the original input.
  58793. * @param options The required width/height ratio to downsize to before computing the render pass.
  58794. * @param camera The camera to apply the render pass to.
  58795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58796. * @param engine The engine which the post process will be applied. (default: current engine)
  58797. * @param reusable If the post process can be reused on the same frame. (default: false)
  58798. * @param textureType Type of textures used when performing the post process. (default: 0)
  58799. * @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)
  58800. */
  58801. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58802. /** Weight of the bloom to be added to the original input. */
  58803. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58804. }
  58805. }
  58806. declare module BABYLON {
  58807. /**
  58808. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58809. */
  58810. export class BloomEffect extends PostProcessRenderEffect {
  58811. private bloomScale;
  58812. /**
  58813. * @hidden Internal
  58814. */ private _effects: Array<PostProcess>;
  58815. /**
  58816. * @hidden Internal
  58817. */ private _downscale: ExtractHighlightsPostProcess;
  58818. private _blurX;
  58819. private _blurY;
  58820. private _merge;
  58821. /**
  58822. * The luminance threshold to find bright areas of the image to bloom.
  58823. */
  58824. threshold: number;
  58825. /**
  58826. * The strength of the bloom.
  58827. */
  58828. weight: number;
  58829. /**
  58830. * Specifies the size of the bloom blur kernel, relative to the final output size
  58831. */
  58832. kernel: number;
  58833. /**
  58834. * Creates a new instance of @see BloomEffect
  58835. * @param scene The scene the effect belongs to.
  58836. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58837. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58838. * @param bloomWeight The the strength of bloom.
  58839. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58840. * @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)
  58841. */
  58842. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58843. /**
  58844. * Disposes each of the internal effects for a given camera.
  58845. * @param camera The camera to dispose the effect on.
  58846. */
  58847. disposeEffects(camera: Camera): void;
  58848. /**
  58849. * @hidden Internal
  58850. */ private _updateEffects(): void;
  58851. /**
  58852. * Internal
  58853. * @returns if all the contained post processes are ready.
  58854. * @hidden
  58855. */ private _isReady(): boolean;
  58856. }
  58857. }
  58858. declare module BABYLON {
  58859. /** @hidden */
  58860. export var chromaticAberrationPixelShader: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module BABYLON {
  58866. /**
  58867. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58868. */
  58869. export class ChromaticAberrationPostProcess extends PostProcess {
  58870. /**
  58871. * The amount of seperation of rgb channels (default: 30)
  58872. */
  58873. aberrationAmount: number;
  58874. /**
  58875. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58876. */
  58877. radialIntensity: number;
  58878. /**
  58879. * 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))
  58880. */
  58881. direction: Vector2;
  58882. /**
  58883. * 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))
  58884. */
  58885. centerPosition: Vector2;
  58886. /**
  58887. * Creates a new instance ChromaticAberrationPostProcess
  58888. * @param name The name of the effect.
  58889. * @param screenWidth The width of the screen to apply the effect on.
  58890. * @param screenHeight The height of the screen to apply the effect on.
  58891. * @param options The required width/height ratio to downsize to before computing the render pass.
  58892. * @param camera The camera to apply the render pass to.
  58893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58894. * @param engine The engine which the post process will be applied. (default: current engine)
  58895. * @param reusable If the post process can be reused on the same frame. (default: false)
  58896. * @param textureType Type of textures used when performing the post process. (default: 0)
  58897. * @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)
  58898. */
  58899. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58900. }
  58901. }
  58902. declare module BABYLON {
  58903. /** @hidden */
  58904. export var circleOfConfusionPixelShader: {
  58905. name: string;
  58906. shader: string;
  58907. };
  58908. }
  58909. declare module BABYLON {
  58910. /**
  58911. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58912. */
  58913. export class CircleOfConfusionPostProcess extends PostProcess {
  58914. /**
  58915. * 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.
  58916. */
  58917. lensSize: number;
  58918. /**
  58919. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58920. */
  58921. fStop: number;
  58922. /**
  58923. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58924. */
  58925. focusDistance: number;
  58926. /**
  58927. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58928. */
  58929. focalLength: number;
  58930. private _depthTexture;
  58931. /**
  58932. * Creates a new instance CircleOfConfusionPostProcess
  58933. * @param name The name of the effect.
  58934. * @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.
  58935. * @param options The required width/height ratio to downsize to before computing the render pass.
  58936. * @param camera The camera to apply the render pass to.
  58937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58938. * @param engine The engine which the post process will be applied. (default: current engine)
  58939. * @param reusable If the post process can be reused on the same frame. (default: false)
  58940. * @param textureType Type of textures used when performing the post process. (default: 0)
  58941. * @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)
  58942. */
  58943. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58944. /**
  58945. * 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.
  58946. */
  58947. depthTexture: RenderTargetTexture;
  58948. }
  58949. }
  58950. declare module BABYLON {
  58951. /** @hidden */
  58952. export var colorCorrectionPixelShader: {
  58953. name: string;
  58954. shader: string;
  58955. };
  58956. }
  58957. declare module BABYLON {
  58958. /**
  58959. *
  58960. * This post-process allows the modification of rendered colors by using
  58961. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58962. *
  58963. * The object needs to be provided an url to a texture containing the color
  58964. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58965. * Use an image editing software to tweak the LUT to match your needs.
  58966. *
  58967. * For an example of a color LUT, see here:
  58968. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58969. * For explanations on color grading, see here:
  58970. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58971. *
  58972. */
  58973. export class ColorCorrectionPostProcess extends PostProcess {
  58974. private _colorTableTexture;
  58975. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58976. }
  58977. }
  58978. declare module BABYLON {
  58979. /** @hidden */
  58980. export var convolutionPixelShader: {
  58981. name: string;
  58982. shader: string;
  58983. };
  58984. }
  58985. declare module BABYLON {
  58986. /**
  58987. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58988. * input texture to perform effects such as edge detection or sharpening
  58989. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58990. */
  58991. export class ConvolutionPostProcess extends PostProcess {
  58992. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58993. kernel: number[];
  58994. /**
  58995. * Creates a new instance ConvolutionPostProcess
  58996. * @param name The name of the effect.
  58997. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58998. * @param options The required width/height ratio to downsize to before computing the render pass.
  58999. * @param camera The camera to apply the render pass to.
  59000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59001. * @param engine The engine which the post process will be applied. (default: current engine)
  59002. * @param reusable If the post process can be reused on the same frame. (default: false)
  59003. * @param textureType Type of textures used when performing the post process. (default: 0)
  59004. */
  59005. constructor(name: string,
  59006. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59007. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59008. /**
  59009. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59010. */
  59011. static EdgeDetect0Kernel: number[];
  59012. /**
  59013. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59014. */
  59015. static EdgeDetect1Kernel: number[];
  59016. /**
  59017. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59018. */
  59019. static EdgeDetect2Kernel: number[];
  59020. /**
  59021. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59022. */
  59023. static SharpenKernel: number[];
  59024. /**
  59025. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59026. */
  59027. static EmbossKernel: number[];
  59028. /**
  59029. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59030. */
  59031. static GaussianKernel: number[];
  59032. }
  59033. }
  59034. declare module BABYLON {
  59035. /**
  59036. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59037. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59038. * based on samples that have a large difference in distance than the center pixel.
  59039. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59040. */
  59041. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59042. direction: Vector2;
  59043. /**
  59044. * Creates a new instance CircleOfConfusionPostProcess
  59045. * @param name The name of the effect.
  59046. * @param scene The scene the effect belongs to.
  59047. * @param direction The direction the blur should be applied.
  59048. * @param kernel The size of the kernel used to blur.
  59049. * @param options The required width/height ratio to downsize to before computing the render pass.
  59050. * @param camera The camera to apply the render pass to.
  59051. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59052. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59054. * @param engine The engine which the post process will be applied. (default: current engine)
  59055. * @param reusable If the post process can be reused on the same frame. (default: false)
  59056. * @param textureType Type of textures used when performing the post process. (default: 0)
  59057. * @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)
  59058. */
  59059. 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);
  59060. }
  59061. }
  59062. declare module BABYLON {
  59063. /** @hidden */
  59064. export var depthOfFieldMergePixelShader: {
  59065. name: string;
  59066. shader: string;
  59067. };
  59068. }
  59069. declare module BABYLON {
  59070. /**
  59071. * Options to be set when merging outputs from the default pipeline.
  59072. */
  59073. export class DepthOfFieldMergePostProcessOptions {
  59074. /**
  59075. * The original image to merge on top of
  59076. */
  59077. originalFromInput: PostProcess;
  59078. /**
  59079. * Parameters to perform the merge of the depth of field effect
  59080. */
  59081. depthOfField?: {
  59082. circleOfConfusion: PostProcess;
  59083. blurSteps: Array<PostProcess>;
  59084. };
  59085. /**
  59086. * Parameters to perform the merge of bloom effect
  59087. */
  59088. bloom?: {
  59089. blurred: PostProcess;
  59090. weight: number;
  59091. };
  59092. }
  59093. /**
  59094. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59095. */
  59096. export class DepthOfFieldMergePostProcess extends PostProcess {
  59097. private blurSteps;
  59098. /**
  59099. * Creates a new instance of DepthOfFieldMergePostProcess
  59100. * @param name The name of the effect.
  59101. * @param originalFromInput Post process which's input will be used for the merge.
  59102. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59103. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59104. * @param options The required width/height ratio to downsize to before computing the render pass.
  59105. * @param camera The camera to apply the render pass to.
  59106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59107. * @param engine The engine which the post process will be applied. (default: current engine)
  59108. * @param reusable If the post process can be reused on the same frame. (default: false)
  59109. * @param textureType Type of textures used when performing the post process. (default: 0)
  59110. * @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)
  59111. */
  59112. 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);
  59113. /**
  59114. * Updates the effect with the current post process compile time values and recompiles the shader.
  59115. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59116. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59117. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59118. * @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
  59119. * @param onCompiled Called when the shader has been compiled.
  59120. * @param onError Called if there is an error when compiling a shader.
  59121. */
  59122. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59123. }
  59124. }
  59125. declare module BABYLON {
  59126. /**
  59127. * Specifies the level of max blur that should be applied when using the depth of field effect
  59128. */
  59129. export enum DepthOfFieldEffectBlurLevel {
  59130. /**
  59131. * Subtle blur
  59132. */
  59133. Low = 0,
  59134. /**
  59135. * Medium blur
  59136. */
  59137. Medium = 1,
  59138. /**
  59139. * Large blur
  59140. */
  59141. High = 2
  59142. }
  59143. /**
  59144. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59145. */
  59146. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59147. private _circleOfConfusion;
  59148. /**
  59149. * @hidden Internal, blurs from high to low
  59150. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59151. private _depthOfFieldBlurY;
  59152. private _dofMerge;
  59153. /**
  59154. * @hidden Internal post processes in depth of field effect
  59155. */ private _effects: Array<PostProcess>;
  59156. /**
  59157. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59158. */
  59159. focalLength: number;
  59160. /**
  59161. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59162. */
  59163. fStop: number;
  59164. /**
  59165. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59166. */
  59167. focusDistance: number;
  59168. /**
  59169. * 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.
  59170. */
  59171. lensSize: number;
  59172. /**
  59173. * Creates a new instance DepthOfFieldEffect
  59174. * @param scene The scene the effect belongs to.
  59175. * @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.
  59176. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59177. * @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)
  59178. */
  59179. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59180. /**
  59181. * Get the current class name of the current effet
  59182. * @returns "DepthOfFieldEffect"
  59183. */
  59184. getClassName(): string;
  59185. /**
  59186. * 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.
  59187. */
  59188. depthTexture: RenderTargetTexture;
  59189. /**
  59190. * Disposes each of the internal effects for a given camera.
  59191. * @param camera The camera to dispose the effect on.
  59192. */
  59193. disposeEffects(camera: Camera): void;
  59194. /**
  59195. * @hidden Internal
  59196. */ private _updateEffects(): void;
  59197. /**
  59198. * Internal
  59199. * @returns if all the contained post processes are ready.
  59200. * @hidden
  59201. */ private _isReady(): boolean;
  59202. }
  59203. }
  59204. declare module BABYLON {
  59205. /** @hidden */
  59206. export var displayPassPixelShader: {
  59207. name: string;
  59208. shader: string;
  59209. };
  59210. }
  59211. declare module BABYLON {
  59212. /**
  59213. * DisplayPassPostProcess which produces an output the same as it's input
  59214. */
  59215. export class DisplayPassPostProcess extends PostProcess {
  59216. /**
  59217. * Creates the DisplayPassPostProcess
  59218. * @param name The name of the effect.
  59219. * @param options The required width/height ratio to downsize to before computing the render pass.
  59220. * @param camera The camera to apply the render pass to.
  59221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59222. * @param engine The engine which the post process will be applied. (default: current engine)
  59223. * @param reusable If the post process can be reused on the same frame. (default: false)
  59224. */
  59225. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59226. }
  59227. }
  59228. declare module BABYLON {
  59229. /** @hidden */
  59230. export var filterPixelShader: {
  59231. name: string;
  59232. shader: string;
  59233. };
  59234. }
  59235. declare module BABYLON {
  59236. /**
  59237. * Applies a kernel filter to the image
  59238. */
  59239. export class FilterPostProcess extends PostProcess {
  59240. /** The matrix to be applied to the image */
  59241. kernelMatrix: Matrix;
  59242. /**
  59243. *
  59244. * @param name The name of the effect.
  59245. * @param kernelMatrix The matrix to be applied to the image
  59246. * @param options The required width/height ratio to downsize to before computing the render pass.
  59247. * @param camera The camera to apply the render pass to.
  59248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59249. * @param engine The engine which the post process will be applied. (default: current engine)
  59250. * @param reusable If the post process can be reused on the same frame. (default: false)
  59251. */
  59252. constructor(name: string,
  59253. /** The matrix to be applied to the image */
  59254. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59255. }
  59256. }
  59257. declare module BABYLON {
  59258. /** @hidden */
  59259. export var fxaaPixelShader: {
  59260. name: string;
  59261. shader: string;
  59262. };
  59263. }
  59264. declare module BABYLON {
  59265. /** @hidden */
  59266. export var fxaaVertexShader: {
  59267. name: string;
  59268. shader: string;
  59269. };
  59270. }
  59271. declare module BABYLON {
  59272. /**
  59273. * Fxaa post process
  59274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59275. */
  59276. export class FxaaPostProcess extends PostProcess {
  59277. /** @hidden */
  59278. texelWidth: number;
  59279. /** @hidden */
  59280. texelHeight: number;
  59281. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59282. private _getDefines;
  59283. }
  59284. }
  59285. declare module BABYLON {
  59286. /** @hidden */
  59287. export var grainPixelShader: {
  59288. name: string;
  59289. shader: string;
  59290. };
  59291. }
  59292. declare module BABYLON {
  59293. /**
  59294. * The GrainPostProcess adds noise to the image at mid luminance levels
  59295. */
  59296. export class GrainPostProcess extends PostProcess {
  59297. /**
  59298. * The intensity of the grain added (default: 30)
  59299. */
  59300. intensity: number;
  59301. /**
  59302. * If the grain should be randomized on every frame
  59303. */
  59304. animated: boolean;
  59305. /**
  59306. * Creates a new instance of @see GrainPostProcess
  59307. * @param name The name of the effect.
  59308. * @param options The required width/height ratio to downsize to before computing the render pass.
  59309. * @param camera The camera to apply the render pass to.
  59310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59311. * @param engine The engine which the post process will be applied. (default: current engine)
  59312. * @param reusable If the post process can be reused on the same frame. (default: false)
  59313. * @param textureType Type of textures used when performing the post process. (default: 0)
  59314. * @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)
  59315. */
  59316. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59317. }
  59318. }
  59319. declare module BABYLON {
  59320. /** @hidden */
  59321. export var highlightsPixelShader: {
  59322. name: string;
  59323. shader: string;
  59324. };
  59325. }
  59326. declare module BABYLON {
  59327. /**
  59328. * Extracts highlights from the image
  59329. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59330. */
  59331. export class HighlightsPostProcess extends PostProcess {
  59332. /**
  59333. * Extracts highlights from the image
  59334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59335. * @param name The name of the effect.
  59336. * @param options The required width/height ratio to downsize to before computing the render pass.
  59337. * @param camera The camera to apply the render pass to.
  59338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59339. * @param engine The engine which the post process will be applied. (default: current engine)
  59340. * @param reusable If the post process can be reused on the same frame. (default: false)
  59341. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59342. */
  59343. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59344. }
  59345. }
  59346. declare module BABYLON {
  59347. /** @hidden */
  59348. export var mrtFragmentDeclaration: {
  59349. name: string;
  59350. shader: string;
  59351. };
  59352. }
  59353. declare module BABYLON {
  59354. /** @hidden */
  59355. export var geometryPixelShader: {
  59356. name: string;
  59357. shader: string;
  59358. };
  59359. }
  59360. declare module BABYLON {
  59361. /** @hidden */
  59362. export var geometryVertexShader: {
  59363. name: string;
  59364. shader: string;
  59365. };
  59366. }
  59367. declare module BABYLON {
  59368. /** @hidden */
  59369. interface ISavedTransformationMatrix {
  59370. world: Matrix;
  59371. viewProjection: Matrix;
  59372. }
  59373. /**
  59374. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59375. */
  59376. export class GeometryBufferRenderer {
  59377. /**
  59378. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59379. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59380. */
  59381. static readonly POSITION_TEXTURE_TYPE: number;
  59382. /**
  59383. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59384. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59385. */
  59386. static readonly VELOCITY_TEXTURE_TYPE: number;
  59387. /**
  59388. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59389. * in order to compute objects velocities when enableVelocity is set to "true"
  59390. * @hidden
  59391. */ private _previousTransformationMatrices: {
  59392. [index: number]: ISavedTransformationMatrix;
  59393. };
  59394. /**
  59395. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59396. * in order to compute objects velocities when enableVelocity is set to "true"
  59397. * @hidden
  59398. */ private _previousBonesTransformationMatrices: {
  59399. [index: number]: Float32Array;
  59400. };
  59401. /**
  59402. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59403. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59404. */
  59405. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59406. private _scene;
  59407. private _multiRenderTarget;
  59408. private _ratio;
  59409. private _enablePosition;
  59410. private _enableVelocity;
  59411. private _positionIndex;
  59412. private _velocityIndex;
  59413. protected _effect: Effect;
  59414. protected _cachedDefines: string;
  59415. /**
  59416. * Set the render list (meshes to be rendered) used in the G buffer.
  59417. */
  59418. renderList: Mesh[];
  59419. /**
  59420. * Gets wether or not G buffer are supported by the running hardware.
  59421. * This requires draw buffer supports
  59422. */
  59423. readonly isSupported: boolean;
  59424. /**
  59425. * Returns the index of the given texture type in the G-Buffer textures array
  59426. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59427. * @returns the index of the given texture type in the G-Buffer textures array
  59428. */
  59429. getTextureIndex(textureType: number): number;
  59430. /**
  59431. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59432. */
  59433. /**
  59434. * Sets whether or not objects positions are enabled for the G buffer.
  59435. */
  59436. enablePosition: boolean;
  59437. /**
  59438. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59439. */
  59440. /**
  59441. * Sets wether or not objects velocities are enabled for the G buffer.
  59442. */
  59443. enableVelocity: boolean;
  59444. /**
  59445. * Gets the scene associated with the buffer.
  59446. */
  59447. readonly scene: Scene;
  59448. /**
  59449. * Gets the ratio used by the buffer during its creation.
  59450. * How big is the buffer related to the main canvas.
  59451. */
  59452. readonly ratio: number;
  59453. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  59454. /**
  59455. * Creates a new G Buffer for the scene
  59456. * @param scene The scene the buffer belongs to
  59457. * @param ratio How big is the buffer related to the main canvas.
  59458. */
  59459. constructor(scene: Scene, ratio?: number);
  59460. /**
  59461. * Checks wether everything is ready to render a submesh to the G buffer.
  59462. * @param subMesh the submesh to check readiness for
  59463. * @param useInstances is the mesh drawn using instance or not
  59464. * @returns true if ready otherwise false
  59465. */
  59466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59467. /**
  59468. * Gets the current underlying G Buffer.
  59469. * @returns the buffer
  59470. */
  59471. getGBuffer(): MultiRenderTarget;
  59472. /**
  59473. * Gets the number of samples used to render the buffer (anti aliasing).
  59474. */
  59475. /**
  59476. * Sets the number of samples used to render the buffer (anti aliasing).
  59477. */
  59478. samples: number;
  59479. /**
  59480. * Disposes the renderer and frees up associated resources.
  59481. */
  59482. dispose(): void;
  59483. protected _createRenderTargets(): void;
  59484. private _copyBonesTransformationMatrices;
  59485. }
  59486. }
  59487. declare module BABYLON {
  59488. interface Scene {
  59489. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59490. /**
  59491. * Gets or Sets the current geometry buffer associated to the scene.
  59492. */
  59493. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59494. /**
  59495. * Enables a GeometryBufferRender and associates it with the scene
  59496. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59497. * @returns the GeometryBufferRenderer
  59498. */
  59499. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59500. /**
  59501. * Disables the GeometryBufferRender associated with the scene
  59502. */
  59503. disableGeometryBufferRenderer(): void;
  59504. }
  59505. /**
  59506. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59507. * in several rendering techniques.
  59508. */
  59509. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59510. /**
  59511. * The component name helpful to identify the component in the list of scene components.
  59512. */
  59513. readonly name: string;
  59514. /**
  59515. * The scene the component belongs to.
  59516. */
  59517. scene: Scene;
  59518. /**
  59519. * Creates a new instance of the component for the given scene
  59520. * @param scene Defines the scene to register the component in
  59521. */
  59522. constructor(scene: Scene);
  59523. /**
  59524. * Registers the component in a given scene
  59525. */
  59526. register(): void;
  59527. /**
  59528. * Rebuilds the elements related to this component in case of
  59529. * context lost for instance.
  59530. */
  59531. rebuild(): void;
  59532. /**
  59533. * Disposes the component and the associated ressources
  59534. */
  59535. dispose(): void;
  59536. private _gatherRenderTargets;
  59537. }
  59538. }
  59539. declare module BABYLON {
  59540. /** @hidden */
  59541. export var motionBlurPixelShader: {
  59542. name: string;
  59543. shader: string;
  59544. };
  59545. }
  59546. declare module BABYLON {
  59547. /**
  59548. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59549. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59550. * As an example, all you have to do is to create the post-process:
  59551. * var mb = new BABYLON.MotionBlurPostProcess(
  59552. * 'mb', // The name of the effect.
  59553. * scene, // The scene containing the objects to blur according to their velocity.
  59554. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59555. * camera // The camera to apply the render pass to.
  59556. * );
  59557. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59558. */
  59559. export class MotionBlurPostProcess extends PostProcess {
  59560. /**
  59561. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59562. */
  59563. motionStrength: number;
  59564. /**
  59565. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59566. */
  59567. /**
  59568. * Sets the number of iterations to be used for motion blur quality
  59569. */
  59570. motionBlurSamples: number;
  59571. private _motionBlurSamples;
  59572. private _geometryBufferRenderer;
  59573. /**
  59574. * Creates a new instance MotionBlurPostProcess
  59575. * @param name The name of the effect.
  59576. * @param scene The scene containing the objects to blur according to their velocity.
  59577. * @param options The required width/height ratio to downsize to before computing the render pass.
  59578. * @param camera The camera to apply the render pass to.
  59579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59580. * @param engine The engine which the post process will be applied. (default: current engine)
  59581. * @param reusable If the post process can be reused on the same frame. (default: false)
  59582. * @param textureType Type of textures used when performing the post process. (default: 0)
  59583. * @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)
  59584. */
  59585. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59586. /**
  59587. * Excludes the given skinned mesh from computing bones velocities.
  59588. * 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.
  59589. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59590. */
  59591. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59592. /**
  59593. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59594. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59595. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59596. */
  59597. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59598. /**
  59599. * Disposes the post process.
  59600. * @param camera The camera to dispose the post process on.
  59601. */
  59602. dispose(camera?: Camera): void;
  59603. }
  59604. }
  59605. declare module BABYLON {
  59606. /** @hidden */
  59607. export var refractionPixelShader: {
  59608. name: string;
  59609. shader: string;
  59610. };
  59611. }
  59612. declare module BABYLON {
  59613. /**
  59614. * Post process which applies a refractin texture
  59615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59616. */
  59617. export class RefractionPostProcess extends PostProcess {
  59618. /** the base color of the refraction (used to taint the rendering) */
  59619. color: Color3;
  59620. /** simulated refraction depth */
  59621. depth: number;
  59622. /** the coefficient of the base color (0 to remove base color tainting) */
  59623. colorLevel: number;
  59624. private _refTexture;
  59625. private _ownRefractionTexture;
  59626. /**
  59627. * Gets or sets the refraction texture
  59628. * Please note that you are responsible for disposing the texture if you set it manually
  59629. */
  59630. refractionTexture: Texture;
  59631. /**
  59632. * Initializes the RefractionPostProcess
  59633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59634. * @param name The name of the effect.
  59635. * @param refractionTextureUrl Url of the refraction texture to use
  59636. * @param color the base color of the refraction (used to taint the rendering)
  59637. * @param depth simulated refraction depth
  59638. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59639. * @param camera The camera to apply the render pass to.
  59640. * @param options The required width/height ratio to downsize to before computing the render pass.
  59641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59642. * @param engine The engine which the post process will be applied. (default: current engine)
  59643. * @param reusable If the post process can be reused on the same frame. (default: false)
  59644. */
  59645. constructor(name: string, refractionTextureUrl: string,
  59646. /** the base color of the refraction (used to taint the rendering) */
  59647. color: Color3,
  59648. /** simulated refraction depth */
  59649. depth: number,
  59650. /** the coefficient of the base color (0 to remove base color tainting) */
  59651. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59652. /**
  59653. * Disposes of the post process
  59654. * @param camera Camera to dispose post process on
  59655. */
  59656. dispose(camera: Camera): void;
  59657. }
  59658. }
  59659. declare module BABYLON {
  59660. /** @hidden */
  59661. export var sharpenPixelShader: {
  59662. name: string;
  59663. shader: string;
  59664. };
  59665. }
  59666. declare module BABYLON {
  59667. /**
  59668. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59669. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59670. */
  59671. export class SharpenPostProcess extends PostProcess {
  59672. /**
  59673. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59674. */
  59675. colorAmount: number;
  59676. /**
  59677. * How much sharpness should be applied (default: 0.3)
  59678. */
  59679. edgeAmount: number;
  59680. /**
  59681. * Creates a new instance ConvolutionPostProcess
  59682. * @param name The name of the effect.
  59683. * @param options The required width/height ratio to downsize to before computing the render pass.
  59684. * @param camera The camera to apply the render pass to.
  59685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59686. * @param engine The engine which the post process will be applied. (default: current engine)
  59687. * @param reusable If the post process can be reused on the same frame. (default: false)
  59688. * @param textureType Type of textures used when performing the post process. (default: 0)
  59689. * @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)
  59690. */
  59691. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59692. }
  59693. }
  59694. declare module BABYLON {
  59695. /**
  59696. * PostProcessRenderPipeline
  59697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59698. */
  59699. export class PostProcessRenderPipeline {
  59700. private engine;
  59701. private _renderEffects;
  59702. private _renderEffectsForIsolatedPass;
  59703. /**
  59704. * List of inspectable custom properties (used by the Inspector)
  59705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59706. */
  59707. inspectableCustomProperties: IInspectable[];
  59708. /**
  59709. * @hidden
  59710. */
  59711. protected _cameras: Camera[];
  59712. /** @hidden */ private _name: string;
  59713. /**
  59714. * Gets pipeline name
  59715. */
  59716. readonly name: string;
  59717. /**
  59718. * Initializes a PostProcessRenderPipeline
  59719. * @param engine engine to add the pipeline to
  59720. * @param name name of the pipeline
  59721. */
  59722. constructor(engine: Engine, name: string);
  59723. /**
  59724. * Gets the class name
  59725. * @returns "PostProcessRenderPipeline"
  59726. */
  59727. getClassName(): string;
  59728. /**
  59729. * If all the render effects in the pipeline are supported
  59730. */
  59731. readonly isSupported: boolean;
  59732. /**
  59733. * Adds an effect to the pipeline
  59734. * @param renderEffect the effect to add
  59735. */
  59736. addEffect(renderEffect: PostProcessRenderEffect): void;
  59737. /** @hidden */ private _rebuild(): void;
  59738. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  59739. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59740. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59741. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59742. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  59743. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  59744. /** @hidden */ private _detachCameras(cameras: Camera): void;
  59745. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  59746. /** @hidden */ private _update(): void;
  59747. /** @hidden */ private _reset(): void;
  59748. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59749. /**
  59750. * Disposes of the pipeline
  59751. */
  59752. dispose(): void;
  59753. }
  59754. }
  59755. declare module BABYLON {
  59756. /**
  59757. * PostProcessRenderPipelineManager class
  59758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59759. */
  59760. export class PostProcessRenderPipelineManager {
  59761. private _renderPipelines;
  59762. /**
  59763. * Initializes a PostProcessRenderPipelineManager
  59764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59765. */
  59766. constructor();
  59767. /**
  59768. * Gets the list of supported render pipelines
  59769. */
  59770. readonly supportedPipelines: PostProcessRenderPipeline[];
  59771. /**
  59772. * Adds a pipeline to the manager
  59773. * @param renderPipeline The pipeline to add
  59774. */
  59775. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59776. /**
  59777. * Attaches a camera to the pipeline
  59778. * @param renderPipelineName The name of the pipeline to attach to
  59779. * @param cameras the camera to attach
  59780. * @param unique if the camera can be attached multiple times to the pipeline
  59781. */
  59782. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59783. /**
  59784. * Detaches a camera from the pipeline
  59785. * @param renderPipelineName The name of the pipeline to detach from
  59786. * @param cameras the camera to detach
  59787. */
  59788. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59789. /**
  59790. * Enables an effect by name on a pipeline
  59791. * @param renderPipelineName the name of the pipeline to enable the effect in
  59792. * @param renderEffectName the name of the effect to enable
  59793. * @param cameras the cameras that the effect should be enabled on
  59794. */
  59795. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59796. /**
  59797. * Disables an effect by name on a pipeline
  59798. * @param renderPipelineName the name of the pipeline to disable the effect in
  59799. * @param renderEffectName the name of the effect to disable
  59800. * @param cameras the cameras that the effect should be disabled on
  59801. */
  59802. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59803. /**
  59804. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59805. */
  59806. update(): void;
  59807. /** @hidden */ private _rebuild(): void;
  59808. /**
  59809. * Disposes of the manager and pipelines
  59810. */
  59811. dispose(): void;
  59812. }
  59813. }
  59814. declare module BABYLON {
  59815. interface Scene {
  59816. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59817. /**
  59818. * Gets the postprocess render pipeline manager
  59819. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59820. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59821. */
  59822. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59823. }
  59824. /**
  59825. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59826. */
  59827. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59828. /**
  59829. * The component name helpfull to identify the component in the list of scene components.
  59830. */
  59831. readonly name: string;
  59832. /**
  59833. * The scene the component belongs to.
  59834. */
  59835. scene: Scene;
  59836. /**
  59837. * Creates a new instance of the component for the given scene
  59838. * @param scene Defines the scene to register the component in
  59839. */
  59840. constructor(scene: Scene);
  59841. /**
  59842. * Registers the component in a given scene
  59843. */
  59844. register(): void;
  59845. /**
  59846. * Rebuilds the elements related to this component in case of
  59847. * context lost for instance.
  59848. */
  59849. rebuild(): void;
  59850. /**
  59851. * Disposes the component and the associated ressources
  59852. */
  59853. dispose(): void;
  59854. private _gatherRenderTargets;
  59855. }
  59856. }
  59857. declare module BABYLON {
  59858. /**
  59859. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59860. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59861. */
  59862. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59863. private _scene;
  59864. private _camerasToBeAttached;
  59865. /**
  59866. * ID of the sharpen post process,
  59867. */
  59868. private readonly SharpenPostProcessId;
  59869. /**
  59870. * @ignore
  59871. * ID of the image processing post process;
  59872. */
  59873. readonly ImageProcessingPostProcessId: string;
  59874. /**
  59875. * @ignore
  59876. * ID of the Fast Approximate Anti-Aliasing post process;
  59877. */
  59878. readonly FxaaPostProcessId: string;
  59879. /**
  59880. * ID of the chromatic aberration post process,
  59881. */
  59882. private readonly ChromaticAberrationPostProcessId;
  59883. /**
  59884. * ID of the grain post process
  59885. */
  59886. private readonly GrainPostProcessId;
  59887. /**
  59888. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59889. */
  59890. sharpen: SharpenPostProcess;
  59891. private _sharpenEffect;
  59892. private bloom;
  59893. /**
  59894. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59895. */
  59896. depthOfField: DepthOfFieldEffect;
  59897. /**
  59898. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59899. */
  59900. fxaa: FxaaPostProcess;
  59901. /**
  59902. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59903. */
  59904. imageProcessing: ImageProcessingPostProcess;
  59905. /**
  59906. * Chromatic aberration post process which will shift rgb colors in the image
  59907. */
  59908. chromaticAberration: ChromaticAberrationPostProcess;
  59909. private _chromaticAberrationEffect;
  59910. /**
  59911. * Grain post process which add noise to the image
  59912. */
  59913. grain: GrainPostProcess;
  59914. private _grainEffect;
  59915. /**
  59916. * Glow post process which adds a glow to emissive areas of the image
  59917. */
  59918. private _glowLayer;
  59919. /**
  59920. * Animations which can be used to tweak settings over a period of time
  59921. */
  59922. animations: Animation[];
  59923. private _imageProcessingConfigurationObserver;
  59924. private _sharpenEnabled;
  59925. private _bloomEnabled;
  59926. private _depthOfFieldEnabled;
  59927. private _depthOfFieldBlurLevel;
  59928. private _fxaaEnabled;
  59929. private _imageProcessingEnabled;
  59930. private _defaultPipelineTextureType;
  59931. private _bloomScale;
  59932. private _chromaticAberrationEnabled;
  59933. private _grainEnabled;
  59934. private _buildAllowed;
  59935. /**
  59936. * Gets active scene
  59937. */
  59938. readonly scene: Scene;
  59939. /**
  59940. * Enable or disable the sharpen process from the pipeline
  59941. */
  59942. sharpenEnabled: boolean;
  59943. private _resizeObserver;
  59944. private _hardwareScaleLevel;
  59945. private _bloomKernel;
  59946. /**
  59947. * Specifies the size of the bloom blur kernel, relative to the final output size
  59948. */
  59949. bloomKernel: number;
  59950. /**
  59951. * Specifies the weight of the bloom in the final rendering
  59952. */
  59953. private _bloomWeight;
  59954. /**
  59955. * Specifies the luma threshold for the area that will be blurred by the bloom
  59956. */
  59957. private _bloomThreshold;
  59958. private _hdr;
  59959. /**
  59960. * The strength of the bloom.
  59961. */
  59962. bloomWeight: number;
  59963. /**
  59964. * The strength of the bloom.
  59965. */
  59966. bloomThreshold: number;
  59967. /**
  59968. * The scale of the bloom, lower value will provide better performance.
  59969. */
  59970. bloomScale: number;
  59971. /**
  59972. * Enable or disable the bloom from the pipeline
  59973. */
  59974. bloomEnabled: boolean;
  59975. private _rebuildBloom;
  59976. /**
  59977. * If the depth of field is enabled.
  59978. */
  59979. depthOfFieldEnabled: boolean;
  59980. /**
  59981. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59982. */
  59983. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59984. /**
  59985. * If the anti aliasing is enabled.
  59986. */
  59987. fxaaEnabled: boolean;
  59988. private _samples;
  59989. /**
  59990. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59991. */
  59992. samples: number;
  59993. /**
  59994. * If image processing is enabled.
  59995. */
  59996. imageProcessingEnabled: boolean;
  59997. /**
  59998. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59999. */
  60000. glowLayerEnabled: boolean;
  60001. /**
  60002. * Gets the glow layer (or null if not defined)
  60003. */
  60004. readonly glowLayer: Nullable<GlowLayer>;
  60005. /**
  60006. * Enable or disable the chromaticAberration process from the pipeline
  60007. */
  60008. chromaticAberrationEnabled: boolean;
  60009. /**
  60010. * Enable or disable the grain process from the pipeline
  60011. */
  60012. grainEnabled: boolean;
  60013. /**
  60014. * @constructor
  60015. * @param name - The rendering pipeline name (default: "")
  60016. * @param hdr - If high dynamic range textures should be used (default: true)
  60017. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60018. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60019. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60020. */
  60021. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60022. /**
  60023. * Get the class name
  60024. * @returns "DefaultRenderingPipeline"
  60025. */
  60026. getClassName(): string;
  60027. /**
  60028. * Force the compilation of the entire pipeline.
  60029. */
  60030. prepare(): void;
  60031. private _hasCleared;
  60032. private _prevPostProcess;
  60033. private _prevPrevPostProcess;
  60034. private _setAutoClearAndTextureSharing;
  60035. private _depthOfFieldSceneObserver;
  60036. private _buildPipeline;
  60037. private _disposePostProcesses;
  60038. /**
  60039. * Adds a camera to the pipeline
  60040. * @param camera the camera to be added
  60041. */
  60042. addCamera(camera: Camera): void;
  60043. /**
  60044. * Removes a camera from the pipeline
  60045. * @param camera the camera to remove
  60046. */
  60047. removeCamera(camera: Camera): void;
  60048. /**
  60049. * Dispose of the pipeline and stop all post processes
  60050. */
  60051. dispose(): void;
  60052. /**
  60053. * Serialize the rendering pipeline (Used when exporting)
  60054. * @returns the serialized object
  60055. */
  60056. serialize(): any;
  60057. /**
  60058. * Parse the serialized pipeline
  60059. * @param source Source pipeline.
  60060. * @param scene The scene to load the pipeline to.
  60061. * @param rootUrl The URL of the serialized pipeline.
  60062. * @returns An instantiated pipeline from the serialized object.
  60063. */
  60064. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60065. }
  60066. }
  60067. declare module BABYLON {
  60068. /** @hidden */
  60069. export var lensHighlightsPixelShader: {
  60070. name: string;
  60071. shader: string;
  60072. };
  60073. }
  60074. declare module BABYLON {
  60075. /** @hidden */
  60076. export var depthOfFieldPixelShader: {
  60077. name: string;
  60078. shader: string;
  60079. };
  60080. }
  60081. declare module BABYLON {
  60082. /**
  60083. * BABYLON.JS Chromatic Aberration GLSL Shader
  60084. * Author: Olivier Guyot
  60085. * Separates very slightly R, G and B colors on the edges of the screen
  60086. * Inspired by Francois Tarlier & Martins Upitis
  60087. */
  60088. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60089. /**
  60090. * @ignore
  60091. * The chromatic aberration PostProcess id in the pipeline
  60092. */
  60093. LensChromaticAberrationEffect: string;
  60094. /**
  60095. * @ignore
  60096. * The highlights enhancing PostProcess id in the pipeline
  60097. */
  60098. HighlightsEnhancingEffect: string;
  60099. /**
  60100. * @ignore
  60101. * The depth-of-field PostProcess id in the pipeline
  60102. */
  60103. LensDepthOfFieldEffect: string;
  60104. private _scene;
  60105. private _depthTexture;
  60106. private _grainTexture;
  60107. private _chromaticAberrationPostProcess;
  60108. private _highlightsPostProcess;
  60109. private _depthOfFieldPostProcess;
  60110. private _edgeBlur;
  60111. private _grainAmount;
  60112. private _chromaticAberration;
  60113. private _distortion;
  60114. private _highlightsGain;
  60115. private _highlightsThreshold;
  60116. private _dofDistance;
  60117. private _dofAperture;
  60118. private _dofDarken;
  60119. private _dofPentagon;
  60120. private _blurNoise;
  60121. /**
  60122. * @constructor
  60123. *
  60124. * Effect parameters are as follow:
  60125. * {
  60126. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60127. * edge_blur: number; // from 0 to x (1 for realism)
  60128. * distortion: number; // from 0 to x (1 for realism)
  60129. * grain_amount: number; // from 0 to 1
  60130. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60131. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60132. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60133. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60134. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60135. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60136. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60137. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60138. * }
  60139. * Note: if an effect parameter is unset, effect is disabled
  60140. *
  60141. * @param name The rendering pipeline name
  60142. * @param parameters - An object containing all parameters (see above)
  60143. * @param scene The scene linked to this pipeline
  60144. * @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)
  60145. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60146. */
  60147. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60148. /**
  60149. * Get the class name
  60150. * @returns "LensRenderingPipeline"
  60151. */
  60152. getClassName(): string;
  60153. /**
  60154. * Gets associated scene
  60155. */
  60156. readonly scene: Scene;
  60157. /**
  60158. * Gets or sets the edge blur
  60159. */
  60160. edgeBlur: number;
  60161. /**
  60162. * Gets or sets the grain amount
  60163. */
  60164. grainAmount: number;
  60165. /**
  60166. * Gets or sets the chromatic aberration amount
  60167. */
  60168. chromaticAberration: number;
  60169. /**
  60170. * Gets or sets the depth of field aperture
  60171. */
  60172. dofAperture: number;
  60173. /**
  60174. * Gets or sets the edge distortion
  60175. */
  60176. edgeDistortion: number;
  60177. /**
  60178. * Gets or sets the depth of field distortion
  60179. */
  60180. dofDistortion: number;
  60181. /**
  60182. * Gets or sets the darken out of focus amount
  60183. */
  60184. darkenOutOfFocus: number;
  60185. /**
  60186. * Gets or sets a boolean indicating if blur noise is enabled
  60187. */
  60188. blurNoise: boolean;
  60189. /**
  60190. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60191. */
  60192. pentagonBokeh: boolean;
  60193. /**
  60194. * Gets or sets the highlight grain amount
  60195. */
  60196. highlightsGain: number;
  60197. /**
  60198. * Gets or sets the highlight threshold
  60199. */
  60200. highlightsThreshold: number;
  60201. /**
  60202. * Sets the amount of blur at the edges
  60203. * @param amount blur amount
  60204. */
  60205. setEdgeBlur(amount: number): void;
  60206. /**
  60207. * Sets edge blur to 0
  60208. */
  60209. disableEdgeBlur(): void;
  60210. /**
  60211. * Sets the amout of grain
  60212. * @param amount Amount of grain
  60213. */
  60214. setGrainAmount(amount: number): void;
  60215. /**
  60216. * Set grain amount to 0
  60217. */
  60218. disableGrain(): void;
  60219. /**
  60220. * Sets the chromatic aberration amount
  60221. * @param amount amount of chromatic aberration
  60222. */
  60223. setChromaticAberration(amount: number): void;
  60224. /**
  60225. * Sets chromatic aberration amount to 0
  60226. */
  60227. disableChromaticAberration(): void;
  60228. /**
  60229. * Sets the EdgeDistortion amount
  60230. * @param amount amount of EdgeDistortion
  60231. */
  60232. setEdgeDistortion(amount: number): void;
  60233. /**
  60234. * Sets edge distortion to 0
  60235. */
  60236. disableEdgeDistortion(): void;
  60237. /**
  60238. * Sets the FocusDistance amount
  60239. * @param amount amount of FocusDistance
  60240. */
  60241. setFocusDistance(amount: number): void;
  60242. /**
  60243. * Disables depth of field
  60244. */
  60245. disableDepthOfField(): void;
  60246. /**
  60247. * Sets the Aperture amount
  60248. * @param amount amount of Aperture
  60249. */
  60250. setAperture(amount: number): void;
  60251. /**
  60252. * Sets the DarkenOutOfFocus amount
  60253. * @param amount amount of DarkenOutOfFocus
  60254. */
  60255. setDarkenOutOfFocus(amount: number): void;
  60256. private _pentagonBokehIsEnabled;
  60257. /**
  60258. * Creates a pentagon bokeh effect
  60259. */
  60260. enablePentagonBokeh(): void;
  60261. /**
  60262. * Disables the pentagon bokeh effect
  60263. */
  60264. disablePentagonBokeh(): void;
  60265. /**
  60266. * Enables noise blur
  60267. */
  60268. enableNoiseBlur(): void;
  60269. /**
  60270. * Disables noise blur
  60271. */
  60272. disableNoiseBlur(): void;
  60273. /**
  60274. * Sets the HighlightsGain amount
  60275. * @param amount amount of HighlightsGain
  60276. */
  60277. setHighlightsGain(amount: number): void;
  60278. /**
  60279. * Sets the HighlightsThreshold amount
  60280. * @param amount amount of HighlightsThreshold
  60281. */
  60282. setHighlightsThreshold(amount: number): void;
  60283. /**
  60284. * Disables highlights
  60285. */
  60286. disableHighlights(): void;
  60287. /**
  60288. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60289. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60290. */
  60291. dispose(disableDepthRender?: boolean): void;
  60292. private _createChromaticAberrationPostProcess;
  60293. private _createHighlightsPostProcess;
  60294. private _createDepthOfFieldPostProcess;
  60295. private _createGrainTexture;
  60296. }
  60297. }
  60298. declare module BABYLON {
  60299. /** @hidden */
  60300. export var ssao2PixelShader: {
  60301. name: string;
  60302. shader: string;
  60303. };
  60304. }
  60305. declare module BABYLON {
  60306. /** @hidden */
  60307. export var ssaoCombinePixelShader: {
  60308. name: string;
  60309. shader: string;
  60310. };
  60311. }
  60312. declare module BABYLON {
  60313. /**
  60314. * Render pipeline to produce ssao effect
  60315. */
  60316. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60317. /**
  60318. * @ignore
  60319. * The PassPostProcess id in the pipeline that contains the original scene color
  60320. */
  60321. SSAOOriginalSceneColorEffect: string;
  60322. /**
  60323. * @ignore
  60324. * The SSAO PostProcess id in the pipeline
  60325. */
  60326. SSAORenderEffect: string;
  60327. /**
  60328. * @ignore
  60329. * The horizontal blur PostProcess id in the pipeline
  60330. */
  60331. SSAOBlurHRenderEffect: string;
  60332. /**
  60333. * @ignore
  60334. * The vertical blur PostProcess id in the pipeline
  60335. */
  60336. SSAOBlurVRenderEffect: string;
  60337. /**
  60338. * @ignore
  60339. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60340. */
  60341. SSAOCombineRenderEffect: string;
  60342. /**
  60343. * The output strength of the SSAO post-process. Default value is 1.0.
  60344. */
  60345. totalStrength: number;
  60346. /**
  60347. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60348. */
  60349. maxZ: number;
  60350. /**
  60351. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60352. */
  60353. minZAspect: number;
  60354. private _samples;
  60355. /**
  60356. * Number of samples used for the SSAO calculations. Default value is 8
  60357. */
  60358. samples: number;
  60359. private _textureSamples;
  60360. /**
  60361. * Number of samples to use for antialiasing
  60362. */
  60363. textureSamples: number;
  60364. /**
  60365. * Ratio object used for SSAO ratio and blur ratio
  60366. */
  60367. private _ratio;
  60368. /**
  60369. * Dynamically generated sphere sampler.
  60370. */
  60371. private _sampleSphere;
  60372. /**
  60373. * Blur filter offsets
  60374. */
  60375. private _samplerOffsets;
  60376. private _expensiveBlur;
  60377. /**
  60378. * If bilateral blur should be used
  60379. */
  60380. expensiveBlur: boolean;
  60381. /**
  60382. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60383. */
  60384. radius: number;
  60385. /**
  60386. * The base color of the SSAO post-process
  60387. * The final result is "base + ssao" between [0, 1]
  60388. */
  60389. base: number;
  60390. /**
  60391. * Support test.
  60392. */
  60393. static readonly IsSupported: boolean;
  60394. private _scene;
  60395. private _depthTexture;
  60396. private _normalTexture;
  60397. private _randomTexture;
  60398. private _originalColorPostProcess;
  60399. private _ssaoPostProcess;
  60400. private _blurHPostProcess;
  60401. private _blurVPostProcess;
  60402. private _ssaoCombinePostProcess;
  60403. private _firstUpdate;
  60404. /**
  60405. * Gets active scene
  60406. */
  60407. readonly scene: Scene;
  60408. /**
  60409. * @constructor
  60410. * @param name The rendering pipeline name
  60411. * @param scene The scene linked to this pipeline
  60412. * @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 }
  60413. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60414. */
  60415. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60416. /**
  60417. * Get the class name
  60418. * @returns "SSAO2RenderingPipeline"
  60419. */
  60420. getClassName(): string;
  60421. /**
  60422. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60423. */
  60424. dispose(disableGeometryBufferRenderer?: boolean): void;
  60425. private _createBlurPostProcess;
  60426. /** @hidden */ private _rebuild(): void;
  60427. private _bits;
  60428. private _radicalInverse_VdC;
  60429. private _hammersley;
  60430. private _hemisphereSample_uniform;
  60431. private _generateHemisphere;
  60432. private _createSSAOPostProcess;
  60433. private _createSSAOCombinePostProcess;
  60434. private _createRandomTexture;
  60435. /**
  60436. * Serialize the rendering pipeline (Used when exporting)
  60437. * @returns the serialized object
  60438. */
  60439. serialize(): any;
  60440. /**
  60441. * Parse the serialized pipeline
  60442. * @param source Source pipeline.
  60443. * @param scene The scene to load the pipeline to.
  60444. * @param rootUrl The URL of the serialized pipeline.
  60445. * @returns An instantiated pipeline from the serialized object.
  60446. */
  60447. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60448. }
  60449. }
  60450. declare module BABYLON {
  60451. /** @hidden */
  60452. export var ssaoPixelShader: {
  60453. name: string;
  60454. shader: string;
  60455. };
  60456. }
  60457. declare module BABYLON {
  60458. /**
  60459. * Render pipeline to produce ssao effect
  60460. */
  60461. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60462. /**
  60463. * @ignore
  60464. * The PassPostProcess id in the pipeline that contains the original scene color
  60465. */
  60466. SSAOOriginalSceneColorEffect: string;
  60467. /**
  60468. * @ignore
  60469. * The SSAO PostProcess id in the pipeline
  60470. */
  60471. SSAORenderEffect: string;
  60472. /**
  60473. * @ignore
  60474. * The horizontal blur PostProcess id in the pipeline
  60475. */
  60476. SSAOBlurHRenderEffect: string;
  60477. /**
  60478. * @ignore
  60479. * The vertical blur PostProcess id in the pipeline
  60480. */
  60481. SSAOBlurVRenderEffect: string;
  60482. /**
  60483. * @ignore
  60484. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60485. */
  60486. SSAOCombineRenderEffect: string;
  60487. /**
  60488. * The output strength of the SSAO post-process. Default value is 1.0.
  60489. */
  60490. totalStrength: number;
  60491. /**
  60492. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60493. */
  60494. radius: number;
  60495. /**
  60496. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60497. * Must not be equal to fallOff and superior to fallOff.
  60498. * Default value is 0.0075
  60499. */
  60500. area: number;
  60501. /**
  60502. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60503. * Must not be equal to area and inferior to area.
  60504. * Default value is 0.000001
  60505. */
  60506. fallOff: number;
  60507. /**
  60508. * The base color of the SSAO post-process
  60509. * The final result is "base + ssao" between [0, 1]
  60510. */
  60511. base: number;
  60512. private _scene;
  60513. private _depthTexture;
  60514. private _randomTexture;
  60515. private _originalColorPostProcess;
  60516. private _ssaoPostProcess;
  60517. private _blurHPostProcess;
  60518. private _blurVPostProcess;
  60519. private _ssaoCombinePostProcess;
  60520. private _firstUpdate;
  60521. /**
  60522. * Gets active scene
  60523. */
  60524. readonly scene: Scene;
  60525. /**
  60526. * @constructor
  60527. * @param name - The rendering pipeline name
  60528. * @param scene - The scene linked to this pipeline
  60529. * @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 }
  60530. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60531. */
  60532. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60533. /**
  60534. * Get the class name
  60535. * @returns "SSAORenderingPipeline"
  60536. */
  60537. getClassName(): string;
  60538. /**
  60539. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60540. */
  60541. dispose(disableDepthRender?: boolean): void;
  60542. private _createBlurPostProcess;
  60543. /** @hidden */ private _rebuild(): void;
  60544. private _createSSAOPostProcess;
  60545. private _createSSAOCombinePostProcess;
  60546. private _createRandomTexture;
  60547. }
  60548. }
  60549. declare module BABYLON {
  60550. /** @hidden */
  60551. export var standardPixelShader: {
  60552. name: string;
  60553. shader: string;
  60554. };
  60555. }
  60556. declare module BABYLON {
  60557. /**
  60558. * Standard rendering pipeline
  60559. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60560. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60561. */
  60562. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60563. /**
  60564. * Public members
  60565. */
  60566. /**
  60567. * Post-process which contains the original scene color before the pipeline applies all the effects
  60568. */
  60569. originalPostProcess: Nullable<PostProcess>;
  60570. /**
  60571. * Post-process used to down scale an image x4
  60572. */
  60573. downSampleX4PostProcess: Nullable<PostProcess>;
  60574. /**
  60575. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60576. */
  60577. brightPassPostProcess: Nullable<PostProcess>;
  60578. /**
  60579. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60580. */
  60581. blurHPostProcesses: PostProcess[];
  60582. /**
  60583. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60584. */
  60585. blurVPostProcesses: PostProcess[];
  60586. /**
  60587. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60588. */
  60589. textureAdderPostProcess: Nullable<PostProcess>;
  60590. /**
  60591. * Post-process used to create volumetric lighting effect
  60592. */
  60593. volumetricLightPostProcess: Nullable<PostProcess>;
  60594. /**
  60595. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60596. */
  60597. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60598. /**
  60599. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60600. */
  60601. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60602. /**
  60603. * Post-process used to merge the volumetric light effect and the real scene color
  60604. */
  60605. volumetricLightMergePostProces: Nullable<PostProcess>;
  60606. /**
  60607. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60608. */
  60609. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60610. /**
  60611. * Base post-process used to calculate the average luminance of the final image for HDR
  60612. */
  60613. luminancePostProcess: Nullable<PostProcess>;
  60614. /**
  60615. * Post-processes used to create down sample post-processes in order to get
  60616. * the average luminance of the final image for HDR
  60617. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60618. */
  60619. luminanceDownSamplePostProcesses: PostProcess[];
  60620. /**
  60621. * Post-process used to create a HDR effect (light adaptation)
  60622. */
  60623. hdrPostProcess: Nullable<PostProcess>;
  60624. /**
  60625. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60626. */
  60627. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60628. /**
  60629. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60630. */
  60631. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60632. /**
  60633. * Post-process used to merge the final HDR post-process and the real scene color
  60634. */
  60635. hdrFinalPostProcess: Nullable<PostProcess>;
  60636. /**
  60637. * Post-process used to create a lens flare effect
  60638. */
  60639. lensFlarePostProcess: Nullable<PostProcess>;
  60640. /**
  60641. * Post-process that merges the result of the lens flare post-process and the real scene color
  60642. */
  60643. lensFlareComposePostProcess: Nullable<PostProcess>;
  60644. /**
  60645. * Post-process used to create a motion blur effect
  60646. */
  60647. motionBlurPostProcess: Nullable<PostProcess>;
  60648. /**
  60649. * Post-process used to create a depth of field effect
  60650. */
  60651. depthOfFieldPostProcess: Nullable<PostProcess>;
  60652. /**
  60653. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60654. */
  60655. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60656. /**
  60657. * Represents the brightness threshold in order to configure the illuminated surfaces
  60658. */
  60659. brightThreshold: number;
  60660. /**
  60661. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60662. */
  60663. blurWidth: number;
  60664. /**
  60665. * Sets if the blur for highlighted surfaces must be only horizontal
  60666. */
  60667. horizontalBlur: boolean;
  60668. /**
  60669. * Gets the overall exposure used by the pipeline
  60670. */
  60671. /**
  60672. * Sets the overall exposure used by the pipeline
  60673. */
  60674. exposure: number;
  60675. /**
  60676. * Texture used typically to simulate "dirty" on camera lens
  60677. */
  60678. lensTexture: Nullable<Texture>;
  60679. /**
  60680. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60681. */
  60682. volumetricLightCoefficient: number;
  60683. /**
  60684. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60685. */
  60686. volumetricLightPower: number;
  60687. /**
  60688. * Used the set the blur intensity to smooth the volumetric lights
  60689. */
  60690. volumetricLightBlurScale: number;
  60691. /**
  60692. * Light (spot or directional) used to generate the volumetric lights rays
  60693. * The source light must have a shadow generate so the pipeline can get its
  60694. * depth map
  60695. */
  60696. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60697. /**
  60698. * For eye adaptation, represents the minimum luminance the eye can see
  60699. */
  60700. hdrMinimumLuminance: number;
  60701. /**
  60702. * For eye adaptation, represents the decrease luminance speed
  60703. */
  60704. hdrDecreaseRate: number;
  60705. /**
  60706. * For eye adaptation, represents the increase luminance speed
  60707. */
  60708. hdrIncreaseRate: number;
  60709. /**
  60710. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60711. */
  60712. /**
  60713. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60714. */
  60715. hdrAutoExposure: boolean;
  60716. /**
  60717. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60718. */
  60719. lensColorTexture: Nullable<Texture>;
  60720. /**
  60721. * The overall strengh for the lens flare effect
  60722. */
  60723. lensFlareStrength: number;
  60724. /**
  60725. * Dispersion coefficient for lens flare ghosts
  60726. */
  60727. lensFlareGhostDispersal: number;
  60728. /**
  60729. * Main lens flare halo width
  60730. */
  60731. lensFlareHaloWidth: number;
  60732. /**
  60733. * Based on the lens distortion effect, defines how much the lens flare result
  60734. * is distorted
  60735. */
  60736. lensFlareDistortionStrength: number;
  60737. /**
  60738. * Configures the blur intensity used for for lens flare (halo)
  60739. */
  60740. lensFlareBlurWidth: number;
  60741. /**
  60742. * Lens star texture must be used to simulate rays on the flares and is available
  60743. * in the documentation
  60744. */
  60745. lensStarTexture: Nullable<Texture>;
  60746. /**
  60747. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60748. * flare effect by taking account of the dirt texture
  60749. */
  60750. lensFlareDirtTexture: Nullable<Texture>;
  60751. /**
  60752. * Represents the focal length for the depth of field effect
  60753. */
  60754. depthOfFieldDistance: number;
  60755. /**
  60756. * Represents the blur intensity for the blurred part of the depth of field effect
  60757. */
  60758. depthOfFieldBlurWidth: number;
  60759. /**
  60760. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60761. */
  60762. /**
  60763. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60764. */
  60765. motionStrength: number;
  60766. /**
  60767. * Gets wether or not the motion blur post-process is object based or screen based.
  60768. */
  60769. /**
  60770. * Sets wether or not the motion blur post-process should be object based or screen based
  60771. */
  60772. objectBasedMotionBlur: boolean;
  60773. /**
  60774. * List of animations for the pipeline (IAnimatable implementation)
  60775. */
  60776. animations: Animation[];
  60777. /**
  60778. * Private members
  60779. */
  60780. private _scene;
  60781. private _currentDepthOfFieldSource;
  60782. private _basePostProcess;
  60783. private _fixedExposure;
  60784. private _currentExposure;
  60785. private _hdrAutoExposure;
  60786. private _hdrCurrentLuminance;
  60787. private _motionStrength;
  60788. private _isObjectBasedMotionBlur;
  60789. private _floatTextureType;
  60790. private _camerasToBeAttached;
  60791. private _ratio;
  60792. private _bloomEnabled;
  60793. private _depthOfFieldEnabled;
  60794. private _vlsEnabled;
  60795. private _lensFlareEnabled;
  60796. private _hdrEnabled;
  60797. private _motionBlurEnabled;
  60798. private _fxaaEnabled;
  60799. private _motionBlurSamples;
  60800. private _volumetricLightStepsCount;
  60801. private _samples;
  60802. /**
  60803. * @ignore
  60804. * Specifies if the bloom pipeline is enabled
  60805. */
  60806. BloomEnabled: boolean;
  60807. /**
  60808. * @ignore
  60809. * Specifies if the depth of field pipeline is enabed
  60810. */
  60811. DepthOfFieldEnabled: boolean;
  60812. /**
  60813. * @ignore
  60814. * Specifies if the lens flare pipeline is enabed
  60815. */
  60816. LensFlareEnabled: boolean;
  60817. /**
  60818. * @ignore
  60819. * Specifies if the HDR pipeline is enabled
  60820. */
  60821. HDREnabled: boolean;
  60822. /**
  60823. * @ignore
  60824. * Specifies if the volumetric lights scattering effect is enabled
  60825. */
  60826. VLSEnabled: boolean;
  60827. /**
  60828. * @ignore
  60829. * Specifies if the motion blur effect is enabled
  60830. */
  60831. MotionBlurEnabled: boolean;
  60832. /**
  60833. * Specifies if anti-aliasing is enabled
  60834. */
  60835. fxaaEnabled: boolean;
  60836. /**
  60837. * Specifies the number of steps used to calculate the volumetric lights
  60838. * Typically in interval [50, 200]
  60839. */
  60840. volumetricLightStepsCount: number;
  60841. /**
  60842. * Specifies the number of samples used for the motion blur effect
  60843. * Typically in interval [16, 64]
  60844. */
  60845. motionBlurSamples: number;
  60846. /**
  60847. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60848. */
  60849. samples: number;
  60850. /**
  60851. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60852. * @constructor
  60853. * @param name The rendering pipeline name
  60854. * @param scene The scene linked to this pipeline
  60855. * @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)
  60856. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60857. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60858. */
  60859. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60860. private _buildPipeline;
  60861. private _createDownSampleX4PostProcess;
  60862. private _createBrightPassPostProcess;
  60863. private _createBlurPostProcesses;
  60864. private _createTextureAdderPostProcess;
  60865. private _createVolumetricLightPostProcess;
  60866. private _createLuminancePostProcesses;
  60867. private _createHdrPostProcess;
  60868. private _createLensFlarePostProcess;
  60869. private _createDepthOfFieldPostProcess;
  60870. private _createMotionBlurPostProcess;
  60871. private _getDepthTexture;
  60872. private _disposePostProcesses;
  60873. /**
  60874. * Dispose of the pipeline and stop all post processes
  60875. */
  60876. dispose(): void;
  60877. /**
  60878. * Serialize the rendering pipeline (Used when exporting)
  60879. * @returns the serialized object
  60880. */
  60881. serialize(): any;
  60882. /**
  60883. * Parse the serialized pipeline
  60884. * @param source Source pipeline.
  60885. * @param scene The scene to load the pipeline to.
  60886. * @param rootUrl The URL of the serialized pipeline.
  60887. * @returns An instantiated pipeline from the serialized object.
  60888. */
  60889. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60890. /**
  60891. * Luminance steps
  60892. */
  60893. static LuminanceSteps: number;
  60894. }
  60895. }
  60896. declare module BABYLON {
  60897. /** @hidden */
  60898. export var tonemapPixelShader: {
  60899. name: string;
  60900. shader: string;
  60901. };
  60902. }
  60903. declare module BABYLON {
  60904. /** Defines operator used for tonemapping */
  60905. export enum TonemappingOperator {
  60906. /** Hable */
  60907. Hable = 0,
  60908. /** Reinhard */
  60909. Reinhard = 1,
  60910. /** HejiDawson */
  60911. HejiDawson = 2,
  60912. /** Photographic */
  60913. Photographic = 3
  60914. }
  60915. /**
  60916. * Defines a post process to apply tone mapping
  60917. */
  60918. export class TonemapPostProcess extends PostProcess {
  60919. private _operator;
  60920. /** Defines the required exposure adjustement */
  60921. exposureAdjustment: number;
  60922. /**
  60923. * Creates a new TonemapPostProcess
  60924. * @param name defines the name of the postprocess
  60925. * @param _operator defines the operator to use
  60926. * @param exposureAdjustment defines the required exposure adjustement
  60927. * @param camera defines the camera to use (can be null)
  60928. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60929. * @param engine defines the hosting engine (can be ignore if camera is set)
  60930. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60931. */
  60932. constructor(name: string, _operator: TonemappingOperator,
  60933. /** Defines the required exposure adjustement */
  60934. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60935. }
  60936. }
  60937. declare module BABYLON {
  60938. /** @hidden */
  60939. export var depthVertexShader: {
  60940. name: string;
  60941. shader: string;
  60942. };
  60943. }
  60944. declare module BABYLON {
  60945. /** @hidden */
  60946. export var volumetricLightScatteringPixelShader: {
  60947. name: string;
  60948. shader: string;
  60949. };
  60950. }
  60951. declare module BABYLON {
  60952. /** @hidden */
  60953. export var volumetricLightScatteringPassVertexShader: {
  60954. name: string;
  60955. shader: string;
  60956. };
  60957. }
  60958. declare module BABYLON {
  60959. /** @hidden */
  60960. export var volumetricLightScatteringPassPixelShader: {
  60961. name: string;
  60962. shader: string;
  60963. };
  60964. }
  60965. declare module BABYLON {
  60966. /**
  60967. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60968. */
  60969. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60970. private _volumetricLightScatteringPass;
  60971. private _volumetricLightScatteringRTT;
  60972. private _viewPort;
  60973. private _screenCoordinates;
  60974. private _cachedDefines;
  60975. /**
  60976. * If not undefined, the mesh position is computed from the attached node position
  60977. */
  60978. attachedNode: {
  60979. position: Vector3;
  60980. };
  60981. /**
  60982. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60983. */
  60984. customMeshPosition: Vector3;
  60985. /**
  60986. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60987. */
  60988. useCustomMeshPosition: boolean;
  60989. /**
  60990. * If the post-process should inverse the light scattering direction
  60991. */
  60992. invert: boolean;
  60993. /**
  60994. * The internal mesh used by the post-process
  60995. */
  60996. mesh: Mesh;
  60997. /**
  60998. * @hidden
  60999. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61000. */
  61001. useDiffuseColor: boolean;
  61002. /**
  61003. * Array containing the excluded meshes not rendered in the internal pass
  61004. */
  61005. excludedMeshes: AbstractMesh[];
  61006. /**
  61007. * Controls the overall intensity of the post-process
  61008. */
  61009. exposure: number;
  61010. /**
  61011. * Dissipates each sample's contribution in range [0, 1]
  61012. */
  61013. decay: number;
  61014. /**
  61015. * Controls the overall intensity of each sample
  61016. */
  61017. weight: number;
  61018. /**
  61019. * Controls the density of each sample
  61020. */
  61021. density: number;
  61022. /**
  61023. * @constructor
  61024. * @param name The post-process name
  61025. * @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)
  61026. * @param camera The camera that the post-process will be attached to
  61027. * @param mesh The mesh used to create the light scattering
  61028. * @param samples The post-process quality, default 100
  61029. * @param samplingModeThe post-process filtering mode
  61030. * @param engine The babylon engine
  61031. * @param reusable If the post-process is reusable
  61032. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61033. */
  61034. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61035. /**
  61036. * Returns the string "VolumetricLightScatteringPostProcess"
  61037. * @returns "VolumetricLightScatteringPostProcess"
  61038. */
  61039. getClassName(): string;
  61040. private _isReady;
  61041. /**
  61042. * Sets the new light position for light scattering effect
  61043. * @param position The new custom light position
  61044. */
  61045. setCustomMeshPosition(position: Vector3): void;
  61046. /**
  61047. * Returns the light position for light scattering effect
  61048. * @return Vector3 The custom light position
  61049. */
  61050. getCustomMeshPosition(): Vector3;
  61051. /**
  61052. * Disposes the internal assets and detaches the post-process from the camera
  61053. */
  61054. dispose(camera: Camera): void;
  61055. /**
  61056. * Returns the render target texture used by the post-process
  61057. * @return the render target texture used by the post-process
  61058. */
  61059. getPass(): RenderTargetTexture;
  61060. private _meshExcluded;
  61061. private _createPass;
  61062. private _updateMeshScreenCoordinates;
  61063. /**
  61064. * Creates a default mesh for the Volumeric Light Scattering post-process
  61065. * @param name The mesh name
  61066. * @param scene The scene where to create the mesh
  61067. * @return the default mesh
  61068. */
  61069. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61070. }
  61071. }
  61072. declare module BABYLON {
  61073. interface Scene {
  61074. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  61075. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  61076. /**
  61077. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61078. */
  61079. forceShowBoundingBoxes: boolean;
  61080. /**
  61081. * Gets the bounding box renderer associated with the scene
  61082. * @returns a BoundingBoxRenderer
  61083. */
  61084. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61085. }
  61086. interface AbstractMesh {
  61087. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  61088. /**
  61089. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61090. */
  61091. showBoundingBox: boolean;
  61092. }
  61093. /**
  61094. * Component responsible of rendering the bounding box of the meshes in a scene.
  61095. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61096. */
  61097. export class BoundingBoxRenderer implements ISceneComponent {
  61098. /**
  61099. * The component name helpfull to identify the component in the list of scene components.
  61100. */
  61101. readonly name: string;
  61102. /**
  61103. * The scene the component belongs to.
  61104. */
  61105. scene: Scene;
  61106. /**
  61107. * Color of the bounding box lines placed in front of an object
  61108. */
  61109. frontColor: Color3;
  61110. /**
  61111. * Color of the bounding box lines placed behind an object
  61112. */
  61113. backColor: Color3;
  61114. /**
  61115. * Defines if the renderer should show the back lines or not
  61116. */
  61117. showBackLines: boolean;
  61118. /**
  61119. * @hidden
  61120. */
  61121. renderList: SmartArray<BoundingBox>;
  61122. private _colorShader;
  61123. private _vertexBuffers;
  61124. private _indexBuffer;
  61125. private _fillIndexBuffer;
  61126. private _fillIndexData;
  61127. /**
  61128. * Instantiates a new bounding box renderer in a scene.
  61129. * @param scene the scene the renderer renders in
  61130. */
  61131. constructor(scene: Scene);
  61132. /**
  61133. * Registers the component in a given scene
  61134. */
  61135. register(): void;
  61136. private _evaluateSubMesh;
  61137. private _activeMesh;
  61138. private _prepareRessources;
  61139. private _createIndexBuffer;
  61140. /**
  61141. * Rebuilds the elements related to this component in case of
  61142. * context lost for instance.
  61143. */
  61144. rebuild(): void;
  61145. /**
  61146. * @hidden
  61147. */
  61148. reset(): void;
  61149. /**
  61150. * Render the bounding boxes of a specific rendering group
  61151. * @param renderingGroupId defines the rendering group to render
  61152. */
  61153. render(renderingGroupId: number): void;
  61154. /**
  61155. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61156. * @param mesh Define the mesh to render the occlusion bounding box for
  61157. */
  61158. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61159. /**
  61160. * Dispose and release the resources attached to this renderer.
  61161. */
  61162. dispose(): void;
  61163. }
  61164. }
  61165. declare module BABYLON {
  61166. /** @hidden */
  61167. export var depthPixelShader: {
  61168. name: string;
  61169. shader: string;
  61170. };
  61171. }
  61172. declare module BABYLON {
  61173. /**
  61174. * This represents a depth renderer in Babylon.
  61175. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61176. */
  61177. export class DepthRenderer {
  61178. private _scene;
  61179. private _depthMap;
  61180. private _effect;
  61181. private readonly _storeNonLinearDepth;
  61182. private readonly _clearColor;
  61183. /** Get if the depth renderer is using packed depth or not */
  61184. readonly isPacked: boolean;
  61185. private _cachedDefines;
  61186. private _camera;
  61187. /**
  61188. * Specifiess that the depth renderer will only be used within
  61189. * the camera it is created for.
  61190. * This can help forcing its rendering during the camera processing.
  61191. */
  61192. useOnlyInActiveCamera: boolean;
  61193. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  61194. /**
  61195. * Instantiates a depth renderer
  61196. * @param scene The scene the renderer belongs to
  61197. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61198. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61199. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61200. */
  61201. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61202. /**
  61203. * Creates the depth rendering effect and checks if the effect is ready.
  61204. * @param subMesh The submesh to be used to render the depth map of
  61205. * @param useInstances If multiple world instances should be used
  61206. * @returns if the depth renderer is ready to render the depth map
  61207. */
  61208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61209. /**
  61210. * Gets the texture which the depth map will be written to.
  61211. * @returns The depth map texture
  61212. */
  61213. getDepthMap(): RenderTargetTexture;
  61214. /**
  61215. * Disposes of the depth renderer.
  61216. */
  61217. dispose(): void;
  61218. }
  61219. }
  61220. declare module BABYLON {
  61221. interface Scene {
  61222. /** @hidden (Backing field) */ private _depthRenderer: {
  61223. [id: string]: DepthRenderer;
  61224. };
  61225. /**
  61226. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61227. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61228. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61229. * @returns the created depth renderer
  61230. */
  61231. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61232. /**
  61233. * Disables a depth renderer for a given camera
  61234. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61235. */
  61236. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61237. }
  61238. /**
  61239. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61240. * in several rendering techniques.
  61241. */
  61242. export class DepthRendererSceneComponent implements ISceneComponent {
  61243. /**
  61244. * The component name helpfull to identify the component in the list of scene components.
  61245. */
  61246. readonly name: string;
  61247. /**
  61248. * The scene the component belongs to.
  61249. */
  61250. scene: Scene;
  61251. /**
  61252. * Creates a new instance of the component for the given scene
  61253. * @param scene Defines the scene to register the component in
  61254. */
  61255. constructor(scene: Scene);
  61256. /**
  61257. * Registers the component in a given scene
  61258. */
  61259. register(): void;
  61260. /**
  61261. * Rebuilds the elements related to this component in case of
  61262. * context lost for instance.
  61263. */
  61264. rebuild(): void;
  61265. /**
  61266. * Disposes the component and the associated ressources
  61267. */
  61268. dispose(): void;
  61269. private _gatherRenderTargets;
  61270. private _gatherActiveCameraRenderTargets;
  61271. }
  61272. }
  61273. declare module BABYLON {
  61274. /** @hidden */
  61275. export var outlinePixelShader: {
  61276. name: string;
  61277. shader: string;
  61278. };
  61279. }
  61280. declare module BABYLON {
  61281. /** @hidden */
  61282. export var outlineVertexShader: {
  61283. name: string;
  61284. shader: string;
  61285. };
  61286. }
  61287. declare module BABYLON {
  61288. interface Scene {
  61289. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  61290. /**
  61291. * Gets the outline renderer associated with the scene
  61292. * @returns a OutlineRenderer
  61293. */
  61294. getOutlineRenderer(): OutlineRenderer;
  61295. }
  61296. interface AbstractMesh {
  61297. /** @hidden (Backing field) */ private _renderOutline: boolean;
  61298. /**
  61299. * Gets or sets a boolean indicating if the outline must be rendered as well
  61300. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61301. */
  61302. renderOutline: boolean;
  61303. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  61304. /**
  61305. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61306. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61307. */
  61308. renderOverlay: boolean;
  61309. }
  61310. /**
  61311. * This class is responsible to draw bothe outline/overlay of meshes.
  61312. * It should not be used directly but through the available method on mesh.
  61313. */
  61314. export class OutlineRenderer implements ISceneComponent {
  61315. /**
  61316. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61317. */
  61318. private static _StencilReference;
  61319. /**
  61320. * The name of the component. Each component must have a unique name.
  61321. */
  61322. name: string;
  61323. /**
  61324. * The scene the component belongs to.
  61325. */
  61326. scene: Scene;
  61327. /**
  61328. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61329. */
  61330. zOffset: number;
  61331. private _engine;
  61332. private _effect;
  61333. private _cachedDefines;
  61334. private _savedDepthWrite;
  61335. /**
  61336. * Instantiates a new outline renderer. (There could be only one per scene).
  61337. * @param scene Defines the scene it belongs to
  61338. */
  61339. constructor(scene: Scene);
  61340. /**
  61341. * Register the component to one instance of a scene.
  61342. */
  61343. register(): void;
  61344. /**
  61345. * Rebuilds the elements related to this component in case of
  61346. * context lost for instance.
  61347. */
  61348. rebuild(): void;
  61349. /**
  61350. * Disposes the component and the associated ressources.
  61351. */
  61352. dispose(): void;
  61353. /**
  61354. * Renders the outline in the canvas.
  61355. * @param subMesh Defines the sumesh to render
  61356. * @param batch Defines the batch of meshes in case of instances
  61357. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61358. */
  61359. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61360. /**
  61361. * Returns whether or not the outline renderer is ready for a given submesh.
  61362. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61363. * @param subMesh Defines the submesh to check readyness for
  61364. * @param useInstances Defines wheter wee are trying to render instances or not
  61365. * @returns true if ready otherwise false
  61366. */
  61367. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61368. private _beforeRenderingMesh;
  61369. private _afterRenderingMesh;
  61370. }
  61371. }
  61372. declare module BABYLON {
  61373. /**
  61374. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61375. * @see http://doc.babylonjs.com/babylon101/sprites
  61376. */
  61377. export class SpritePackedManager extends SpriteManager {
  61378. /** defines the packed manager's name */
  61379. name: string;
  61380. /**
  61381. * Creates a new sprite manager from a packed sprite sheet
  61382. * @param name defines the manager's name
  61383. * @param imgUrl defines the sprite sheet url
  61384. * @param capacity defines the maximum allowed number of sprites
  61385. * @param scene defines the hosting scene
  61386. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61387. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61388. * @param samplingMode defines the smapling mode to use with spritesheet
  61389. * @param fromPacked set to true; do not alter
  61390. */
  61391. constructor(
  61392. /** defines the packed manager's name */
  61393. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61394. }
  61395. }
  61396. declare module BABYLON {
  61397. /**
  61398. * Defines the list of states available for a task inside a AssetsManager
  61399. */
  61400. export enum AssetTaskState {
  61401. /**
  61402. * Initialization
  61403. */
  61404. INIT = 0,
  61405. /**
  61406. * Running
  61407. */
  61408. RUNNING = 1,
  61409. /**
  61410. * Done
  61411. */
  61412. DONE = 2,
  61413. /**
  61414. * Error
  61415. */
  61416. ERROR = 3
  61417. }
  61418. /**
  61419. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61420. */
  61421. export abstract class AbstractAssetTask {
  61422. /**
  61423. * Task name
  61424. */ name: string;
  61425. /**
  61426. * Callback called when the task is successful
  61427. */
  61428. onSuccess: (task: any) => void;
  61429. /**
  61430. * Callback called when the task is not successful
  61431. */
  61432. onError: (task: any, message?: string, exception?: any) => void;
  61433. /**
  61434. * Creates a new AssetsManager
  61435. * @param name defines the name of the task
  61436. */
  61437. constructor(
  61438. /**
  61439. * Task name
  61440. */ name: string);
  61441. private _isCompleted;
  61442. private _taskState;
  61443. private _errorObject;
  61444. /**
  61445. * Get if the task is completed
  61446. */
  61447. readonly isCompleted: boolean;
  61448. /**
  61449. * Gets the current state of the task
  61450. */
  61451. readonly taskState: AssetTaskState;
  61452. /**
  61453. * Gets the current error object (if task is in error)
  61454. */
  61455. readonly errorObject: {
  61456. message?: string;
  61457. exception?: any;
  61458. };
  61459. /**
  61460. * Internal only
  61461. * @hidden
  61462. */ private _setErrorObject(message?: string, exception?: any): void;
  61463. /**
  61464. * Execute the current task
  61465. * @param scene defines the scene where you want your assets to be loaded
  61466. * @param onSuccess is a callback called when the task is successfully executed
  61467. * @param onError is a callback called if an error occurs
  61468. */
  61469. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61470. /**
  61471. * Execute the current task
  61472. * @param scene defines the scene where you want your assets to be loaded
  61473. * @param onSuccess is a callback called when the task is successfully executed
  61474. * @param onError is a callback called if an error occurs
  61475. */
  61476. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61477. /**
  61478. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61479. * This can be used with failed tasks that have the reason for failure fixed.
  61480. */
  61481. reset(): void;
  61482. private onErrorCallback;
  61483. private onDoneCallback;
  61484. }
  61485. /**
  61486. * Define the interface used by progress events raised during assets loading
  61487. */
  61488. export interface IAssetsProgressEvent {
  61489. /**
  61490. * Defines the number of remaining tasks to process
  61491. */
  61492. remainingCount: number;
  61493. /**
  61494. * Defines the total number of tasks
  61495. */
  61496. totalCount: number;
  61497. /**
  61498. * Defines the task that was just processed
  61499. */
  61500. task: AbstractAssetTask;
  61501. }
  61502. /**
  61503. * Class used to share progress information about assets loading
  61504. */
  61505. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61506. /**
  61507. * Defines the number of remaining tasks to process
  61508. */
  61509. remainingCount: number;
  61510. /**
  61511. * Defines the total number of tasks
  61512. */
  61513. totalCount: number;
  61514. /**
  61515. * Defines the task that was just processed
  61516. */
  61517. task: AbstractAssetTask;
  61518. /**
  61519. * Creates a AssetsProgressEvent
  61520. * @param remainingCount defines the number of remaining tasks to process
  61521. * @param totalCount defines the total number of tasks
  61522. * @param task defines the task that was just processed
  61523. */
  61524. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61525. }
  61526. /**
  61527. * Define a task used by AssetsManager to load meshes
  61528. */
  61529. export class MeshAssetTask extends AbstractAssetTask {
  61530. /**
  61531. * Defines the name of the task
  61532. */
  61533. name: string;
  61534. /**
  61535. * Defines the list of mesh's names you want to load
  61536. */
  61537. meshesNames: any;
  61538. /**
  61539. * Defines the root url to use as a base to load your meshes and associated resources
  61540. */
  61541. rootUrl: string;
  61542. /**
  61543. * Defines the filename of the scene to load from
  61544. */
  61545. sceneFilename: string;
  61546. /**
  61547. * Gets the list of loaded meshes
  61548. */
  61549. loadedMeshes: Array<AbstractMesh>;
  61550. /**
  61551. * Gets the list of loaded particle systems
  61552. */
  61553. loadedParticleSystems: Array<IParticleSystem>;
  61554. /**
  61555. * Gets the list of loaded skeletons
  61556. */
  61557. loadedSkeletons: Array<Skeleton>;
  61558. /**
  61559. * Gets the list of loaded animation groups
  61560. */
  61561. loadedAnimationGroups: Array<AnimationGroup>;
  61562. /**
  61563. * Callback called when the task is successful
  61564. */
  61565. onSuccess: (task: MeshAssetTask) => void;
  61566. /**
  61567. * Callback called when the task is successful
  61568. */
  61569. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61570. /**
  61571. * Creates a new MeshAssetTask
  61572. * @param name defines the name of the task
  61573. * @param meshesNames defines the list of mesh's names you want to load
  61574. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61575. * @param sceneFilename defines the filename of the scene to load from
  61576. */
  61577. constructor(
  61578. /**
  61579. * Defines the name of the task
  61580. */
  61581. name: string,
  61582. /**
  61583. * Defines the list of mesh's names you want to load
  61584. */
  61585. meshesNames: any,
  61586. /**
  61587. * Defines the root url to use as a base to load your meshes and associated resources
  61588. */
  61589. rootUrl: string,
  61590. /**
  61591. * Defines the filename of the scene to load from
  61592. */
  61593. sceneFilename: string);
  61594. /**
  61595. * Execute the current task
  61596. * @param scene defines the scene where you want your assets to be loaded
  61597. * @param onSuccess is a callback called when the task is successfully executed
  61598. * @param onError is a callback called if an error occurs
  61599. */
  61600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61601. }
  61602. /**
  61603. * Define a task used by AssetsManager to load text content
  61604. */
  61605. export class TextFileAssetTask extends AbstractAssetTask {
  61606. /**
  61607. * Defines the name of the task
  61608. */
  61609. name: string;
  61610. /**
  61611. * Defines the location of the file to load
  61612. */
  61613. url: string;
  61614. /**
  61615. * Gets the loaded text string
  61616. */
  61617. text: string;
  61618. /**
  61619. * Callback called when the task is successful
  61620. */
  61621. onSuccess: (task: TextFileAssetTask) => void;
  61622. /**
  61623. * Callback called when the task is successful
  61624. */
  61625. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61626. /**
  61627. * Creates a new TextFileAssetTask object
  61628. * @param name defines the name of the task
  61629. * @param url defines the location of the file to load
  61630. */
  61631. constructor(
  61632. /**
  61633. * Defines the name of the task
  61634. */
  61635. name: string,
  61636. /**
  61637. * Defines the location of the file to load
  61638. */
  61639. url: string);
  61640. /**
  61641. * Execute the current task
  61642. * @param scene defines the scene where you want your assets to be loaded
  61643. * @param onSuccess is a callback called when the task is successfully executed
  61644. * @param onError is a callback called if an error occurs
  61645. */
  61646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61647. }
  61648. /**
  61649. * Define a task used by AssetsManager to load binary data
  61650. */
  61651. export class BinaryFileAssetTask extends AbstractAssetTask {
  61652. /**
  61653. * Defines the name of the task
  61654. */
  61655. name: string;
  61656. /**
  61657. * Defines the location of the file to load
  61658. */
  61659. url: string;
  61660. /**
  61661. * Gets the lodaded data (as an array buffer)
  61662. */
  61663. data: ArrayBuffer;
  61664. /**
  61665. * Callback called when the task is successful
  61666. */
  61667. onSuccess: (task: BinaryFileAssetTask) => void;
  61668. /**
  61669. * Callback called when the task is successful
  61670. */
  61671. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61672. /**
  61673. * Creates a new BinaryFileAssetTask object
  61674. * @param name defines the name of the new task
  61675. * @param url defines the location of the file to load
  61676. */
  61677. constructor(
  61678. /**
  61679. * Defines the name of the task
  61680. */
  61681. name: string,
  61682. /**
  61683. * Defines the location of the file to load
  61684. */
  61685. url: string);
  61686. /**
  61687. * Execute the current task
  61688. * @param scene defines the scene where you want your assets to be loaded
  61689. * @param onSuccess is a callback called when the task is successfully executed
  61690. * @param onError is a callback called if an error occurs
  61691. */
  61692. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61693. }
  61694. /**
  61695. * Define a task used by AssetsManager to load images
  61696. */
  61697. export class ImageAssetTask extends AbstractAssetTask {
  61698. /**
  61699. * Defines the name of the task
  61700. */
  61701. name: string;
  61702. /**
  61703. * Defines the location of the image to load
  61704. */
  61705. url: string;
  61706. /**
  61707. * Gets the loaded images
  61708. */
  61709. image: HTMLImageElement;
  61710. /**
  61711. * Callback called when the task is successful
  61712. */
  61713. onSuccess: (task: ImageAssetTask) => void;
  61714. /**
  61715. * Callback called when the task is successful
  61716. */
  61717. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61718. /**
  61719. * Creates a new ImageAssetTask
  61720. * @param name defines the name of the task
  61721. * @param url defines the location of the image to load
  61722. */
  61723. constructor(
  61724. /**
  61725. * Defines the name of the task
  61726. */
  61727. name: string,
  61728. /**
  61729. * Defines the location of the image to load
  61730. */
  61731. url: string);
  61732. /**
  61733. * Execute the current task
  61734. * @param scene defines the scene where you want your assets to be loaded
  61735. * @param onSuccess is a callback called when the task is successfully executed
  61736. * @param onError is a callback called if an error occurs
  61737. */
  61738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61739. }
  61740. /**
  61741. * Defines the interface used by texture loading tasks
  61742. */
  61743. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61744. /**
  61745. * Gets the loaded texture
  61746. */
  61747. texture: TEX;
  61748. }
  61749. /**
  61750. * Define a task used by AssetsManager to load 2D textures
  61751. */
  61752. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61753. /**
  61754. * Defines the name of the task
  61755. */
  61756. name: string;
  61757. /**
  61758. * Defines the location of the file to load
  61759. */
  61760. url: string;
  61761. /**
  61762. * Defines if mipmap should not be generated (default is false)
  61763. */
  61764. noMipmap?: boolean | undefined;
  61765. /**
  61766. * Defines if texture must be inverted on Y axis (default is false)
  61767. */
  61768. invertY?: boolean | undefined;
  61769. /**
  61770. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61771. */
  61772. samplingMode: number;
  61773. /**
  61774. * Gets the loaded texture
  61775. */
  61776. texture: Texture;
  61777. /**
  61778. * Callback called when the task is successful
  61779. */
  61780. onSuccess: (task: TextureAssetTask) => void;
  61781. /**
  61782. * Callback called when the task is successful
  61783. */
  61784. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61785. /**
  61786. * Creates a new TextureAssetTask object
  61787. * @param name defines the name of the task
  61788. * @param url defines the location of the file to load
  61789. * @param noMipmap defines if mipmap should not be generated (default is false)
  61790. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61791. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61792. */
  61793. constructor(
  61794. /**
  61795. * Defines the name of the task
  61796. */
  61797. name: string,
  61798. /**
  61799. * Defines the location of the file to load
  61800. */
  61801. url: string,
  61802. /**
  61803. * Defines if mipmap should not be generated (default is false)
  61804. */
  61805. noMipmap?: boolean | undefined,
  61806. /**
  61807. * Defines if texture must be inverted on Y axis (default is false)
  61808. */
  61809. invertY?: boolean | undefined,
  61810. /**
  61811. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61812. */
  61813. samplingMode?: number);
  61814. /**
  61815. * Execute the current task
  61816. * @param scene defines the scene where you want your assets to be loaded
  61817. * @param onSuccess is a callback called when the task is successfully executed
  61818. * @param onError is a callback called if an error occurs
  61819. */
  61820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61821. }
  61822. /**
  61823. * Define a task used by AssetsManager to load cube textures
  61824. */
  61825. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61826. /**
  61827. * Defines the name of the task
  61828. */
  61829. name: string;
  61830. /**
  61831. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61832. */
  61833. url: string;
  61834. /**
  61835. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61836. */
  61837. extensions?: string[] | undefined;
  61838. /**
  61839. * Defines if mipmaps should not be generated (default is false)
  61840. */
  61841. noMipmap?: boolean | undefined;
  61842. /**
  61843. * Defines the explicit list of files (undefined by default)
  61844. */
  61845. files?: string[] | undefined;
  61846. /**
  61847. * Gets the loaded texture
  61848. */
  61849. texture: CubeTexture;
  61850. /**
  61851. * Callback called when the task is successful
  61852. */
  61853. onSuccess: (task: CubeTextureAssetTask) => void;
  61854. /**
  61855. * Callback called when the task is successful
  61856. */
  61857. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61858. /**
  61859. * Creates a new CubeTextureAssetTask
  61860. * @param name defines the name of the task
  61861. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61862. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61863. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61864. * @param files defines the explicit list of files (undefined by default)
  61865. */
  61866. constructor(
  61867. /**
  61868. * Defines the name of the task
  61869. */
  61870. name: string,
  61871. /**
  61872. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61873. */
  61874. url: string,
  61875. /**
  61876. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61877. */
  61878. extensions?: string[] | undefined,
  61879. /**
  61880. * Defines if mipmaps should not be generated (default is false)
  61881. */
  61882. noMipmap?: boolean | undefined,
  61883. /**
  61884. * Defines the explicit list of files (undefined by default)
  61885. */
  61886. files?: string[] | undefined);
  61887. /**
  61888. * Execute the current task
  61889. * @param scene defines the scene where you want your assets to be loaded
  61890. * @param onSuccess is a callback called when the task is successfully executed
  61891. * @param onError is a callback called if an error occurs
  61892. */
  61893. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61894. }
  61895. /**
  61896. * Define a task used by AssetsManager to load HDR cube textures
  61897. */
  61898. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61899. /**
  61900. * Defines the name of the task
  61901. */
  61902. name: string;
  61903. /**
  61904. * Defines the location of the file to load
  61905. */
  61906. url: string;
  61907. /**
  61908. * Defines the desired size (the more it increases the longer the generation will be)
  61909. */
  61910. size: number;
  61911. /**
  61912. * Defines if mipmaps should not be generated (default is false)
  61913. */
  61914. noMipmap: boolean;
  61915. /**
  61916. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61917. */
  61918. generateHarmonics: boolean;
  61919. /**
  61920. * 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)
  61921. */
  61922. gammaSpace: boolean;
  61923. /**
  61924. * Internal Use Only
  61925. */
  61926. reserved: boolean;
  61927. /**
  61928. * Gets the loaded texture
  61929. */
  61930. texture: HDRCubeTexture;
  61931. /**
  61932. * Callback called when the task is successful
  61933. */
  61934. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61935. /**
  61936. * Callback called when the task is successful
  61937. */
  61938. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61939. /**
  61940. * Creates a new HDRCubeTextureAssetTask object
  61941. * @param name defines the name of the task
  61942. * @param url defines the location of the file to load
  61943. * @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.
  61944. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61945. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61946. * @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)
  61947. * @param reserved Internal use only
  61948. */
  61949. constructor(
  61950. /**
  61951. * Defines the name of the task
  61952. */
  61953. name: string,
  61954. /**
  61955. * Defines the location of the file to load
  61956. */
  61957. url: string,
  61958. /**
  61959. * Defines the desired size (the more it increases the longer the generation will be)
  61960. */
  61961. size: number,
  61962. /**
  61963. * Defines if mipmaps should not be generated (default is false)
  61964. */
  61965. noMipmap?: boolean,
  61966. /**
  61967. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61968. */
  61969. generateHarmonics?: boolean,
  61970. /**
  61971. * 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)
  61972. */
  61973. gammaSpace?: boolean,
  61974. /**
  61975. * Internal Use Only
  61976. */
  61977. reserved?: boolean);
  61978. /**
  61979. * Execute the current task
  61980. * @param scene defines the scene where you want your assets to be loaded
  61981. * @param onSuccess is a callback called when the task is successfully executed
  61982. * @param onError is a callback called if an error occurs
  61983. */
  61984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61985. }
  61986. /**
  61987. * Define a task used by AssetsManager to load Equirectangular cube textures
  61988. */
  61989. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61990. /**
  61991. * Defines the name of the task
  61992. */
  61993. name: string;
  61994. /**
  61995. * Defines the location of the file to load
  61996. */
  61997. url: string;
  61998. /**
  61999. * Defines the desired size (the more it increases the longer the generation will be)
  62000. */
  62001. size: number;
  62002. /**
  62003. * Defines if mipmaps should not be generated (default is false)
  62004. */
  62005. noMipmap: boolean;
  62006. /**
  62007. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62008. * but the standard material would require them in Gamma space) (default is true)
  62009. */
  62010. gammaSpace: boolean;
  62011. /**
  62012. * Gets the loaded texture
  62013. */
  62014. texture: EquiRectangularCubeTexture;
  62015. /**
  62016. * Callback called when the task is successful
  62017. */
  62018. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62019. /**
  62020. * Callback called when the task is successful
  62021. */
  62022. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62023. /**
  62024. * Creates a new EquiRectangularCubeTextureAssetTask object
  62025. * @param name defines the name of the task
  62026. * @param url defines the location of the file to load
  62027. * @param size defines the desired size (the more it increases the longer the generation will be)
  62028. * If the size is omitted this implies you are using a preprocessed cubemap.
  62029. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62030. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62031. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62032. * (default is true)
  62033. */
  62034. constructor(
  62035. /**
  62036. * Defines the name of the task
  62037. */
  62038. name: string,
  62039. /**
  62040. * Defines the location of the file to load
  62041. */
  62042. url: string,
  62043. /**
  62044. * Defines the desired size (the more it increases the longer the generation will be)
  62045. */
  62046. size: number,
  62047. /**
  62048. * Defines if mipmaps should not be generated (default is false)
  62049. */
  62050. noMipmap?: boolean,
  62051. /**
  62052. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62053. * but the standard material would require them in Gamma space) (default is true)
  62054. */
  62055. gammaSpace?: boolean);
  62056. /**
  62057. * Execute the current task
  62058. * @param scene defines the scene where you want your assets to be loaded
  62059. * @param onSuccess is a callback called when the task is successfully executed
  62060. * @param onError is a callback called if an error occurs
  62061. */
  62062. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62063. }
  62064. /**
  62065. * This class can be used to easily import assets into a scene
  62066. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62067. */
  62068. export class AssetsManager {
  62069. private _scene;
  62070. private _isLoading;
  62071. protected _tasks: AbstractAssetTask[];
  62072. protected _waitingTasksCount: number;
  62073. protected _totalTasksCount: number;
  62074. /**
  62075. * Callback called when all tasks are processed
  62076. */
  62077. onFinish: (tasks: AbstractAssetTask[]) => void;
  62078. /**
  62079. * Callback called when a task is successful
  62080. */
  62081. onTaskSuccess: (task: AbstractAssetTask) => void;
  62082. /**
  62083. * Callback called when a task had an error
  62084. */
  62085. onTaskError: (task: AbstractAssetTask) => void;
  62086. /**
  62087. * Callback called when a task is done (whatever the result is)
  62088. */
  62089. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62090. /**
  62091. * Observable called when all tasks are processed
  62092. */
  62093. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62094. /**
  62095. * Observable called when a task had an error
  62096. */
  62097. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62098. /**
  62099. * Observable called when all tasks were executed
  62100. */
  62101. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62102. /**
  62103. * Observable called when a task is done (whatever the result is)
  62104. */
  62105. onProgressObservable: Observable<IAssetsProgressEvent>;
  62106. /**
  62107. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62109. */
  62110. useDefaultLoadingScreen: boolean;
  62111. /**
  62112. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62113. * when all assets have been downloaded.
  62114. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62115. */
  62116. autoHideLoadingUI: boolean;
  62117. /**
  62118. * Creates a new AssetsManager
  62119. * @param scene defines the scene to work on
  62120. */
  62121. constructor(scene: Scene);
  62122. /**
  62123. * Add a MeshAssetTask to the list of active tasks
  62124. * @param taskName defines the name of the new task
  62125. * @param meshesNames defines the name of meshes to load
  62126. * @param rootUrl defines the root url to use to locate files
  62127. * @param sceneFilename defines the filename of the scene file
  62128. * @returns a new MeshAssetTask object
  62129. */
  62130. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62131. /**
  62132. * Add a TextFileAssetTask to the list of active tasks
  62133. * @param taskName defines the name of the new task
  62134. * @param url defines the url of the file to load
  62135. * @returns a new TextFileAssetTask object
  62136. */
  62137. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62138. /**
  62139. * Add a BinaryFileAssetTask to the list of active tasks
  62140. * @param taskName defines the name of the new task
  62141. * @param url defines the url of the file to load
  62142. * @returns a new BinaryFileAssetTask object
  62143. */
  62144. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62145. /**
  62146. * Add a ImageAssetTask to the list of active tasks
  62147. * @param taskName defines the name of the new task
  62148. * @param url defines the url of the file to load
  62149. * @returns a new ImageAssetTask object
  62150. */
  62151. addImageTask(taskName: string, url: string): ImageAssetTask;
  62152. /**
  62153. * Add a TextureAssetTask to the list of active tasks
  62154. * @param taskName defines the name of the new task
  62155. * @param url defines the url of the file to load
  62156. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62157. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62158. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62159. * @returns a new TextureAssetTask object
  62160. */
  62161. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62162. /**
  62163. * Add a CubeTextureAssetTask to the list of active tasks
  62164. * @param taskName defines the name of the new task
  62165. * @param url defines the url of the file to load
  62166. * @param extensions defines the extension to use to load the cube map (can be null)
  62167. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62168. * @param files defines the list of files to load (can be null)
  62169. * @returns a new CubeTextureAssetTask object
  62170. */
  62171. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62172. /**
  62173. *
  62174. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62175. * @param taskName defines the name of the new task
  62176. * @param url defines the url of the file to load
  62177. * @param size defines the size you want for the cubemap (can be null)
  62178. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62179. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62180. * @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)
  62181. * @param reserved Internal use only
  62182. * @returns a new HDRCubeTextureAssetTask object
  62183. */
  62184. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62185. /**
  62186. *
  62187. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62188. * @param taskName defines the name of the new task
  62189. * @param url defines the url of the file to load
  62190. * @param size defines the size you want for the cubemap (can be null)
  62191. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62192. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62193. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62194. * @returns a new EquiRectangularCubeTextureAssetTask object
  62195. */
  62196. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62197. /**
  62198. * Remove a task from the assets manager.
  62199. * @param task the task to remove
  62200. */
  62201. removeTask(task: AbstractAssetTask): void;
  62202. private _decreaseWaitingTasksCount;
  62203. private _runTask;
  62204. /**
  62205. * Reset the AssetsManager and remove all tasks
  62206. * @return the current instance of the AssetsManager
  62207. */
  62208. reset(): AssetsManager;
  62209. /**
  62210. * Start the loading process
  62211. * @return the current instance of the AssetsManager
  62212. */
  62213. load(): AssetsManager;
  62214. /**
  62215. * Start the loading process as an async operation
  62216. * @return a promise returning the list of failed tasks
  62217. */
  62218. loadAsync(): Promise<void>;
  62219. }
  62220. }
  62221. declare module BABYLON {
  62222. /**
  62223. * Wrapper class for promise with external resolve and reject.
  62224. */
  62225. export class Deferred<T> {
  62226. /**
  62227. * The promise associated with this deferred object.
  62228. */
  62229. readonly promise: Promise<T>;
  62230. private _resolve;
  62231. private _reject;
  62232. /**
  62233. * The resolve method of the promise associated with this deferred object.
  62234. */
  62235. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62236. /**
  62237. * The reject method of the promise associated with this deferred object.
  62238. */
  62239. readonly reject: (reason?: any) => void;
  62240. /**
  62241. * Constructor for this deferred object.
  62242. */
  62243. constructor();
  62244. }
  62245. }
  62246. declare module BABYLON {
  62247. /**
  62248. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62249. */
  62250. export class MeshExploder {
  62251. private _centerMesh;
  62252. private _meshes;
  62253. private _meshesOrigins;
  62254. private _toCenterVectors;
  62255. private _scaledDirection;
  62256. private _newPosition;
  62257. private _centerPosition;
  62258. /**
  62259. * Explodes meshes from a center mesh.
  62260. * @param meshes The meshes to explode.
  62261. * @param centerMesh The mesh to be center of explosion.
  62262. */
  62263. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62264. private _setCenterMesh;
  62265. /**
  62266. * Get class name
  62267. * @returns "MeshExploder"
  62268. */
  62269. getClassName(): string;
  62270. /**
  62271. * "Exploded meshes"
  62272. * @returns Array of meshes with the centerMesh at index 0.
  62273. */
  62274. getMeshes(): Array<Mesh>;
  62275. /**
  62276. * Explodes meshes giving a specific direction
  62277. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62278. */
  62279. explode(direction?: number): void;
  62280. }
  62281. }
  62282. declare module BABYLON {
  62283. /**
  62284. * Class used to help managing file picking and drag'n'drop
  62285. */
  62286. export class FilesInput {
  62287. /**
  62288. * List of files ready to be loaded
  62289. */
  62290. static readonly FilesToLoad: {
  62291. [key: string]: File;
  62292. };
  62293. /**
  62294. * Callback called when a file is processed
  62295. */
  62296. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62297. private _engine;
  62298. private _currentScene;
  62299. private _sceneLoadedCallback;
  62300. private _progressCallback;
  62301. private _additionalRenderLoopLogicCallback;
  62302. private _textureLoadingCallback;
  62303. private _startingProcessingFilesCallback;
  62304. private _onReloadCallback;
  62305. private _errorCallback;
  62306. private _elementToMonitor;
  62307. private _sceneFileToLoad;
  62308. private _filesToLoad;
  62309. /**
  62310. * Creates a new FilesInput
  62311. * @param engine defines the rendering engine
  62312. * @param scene defines the hosting scene
  62313. * @param sceneLoadedCallback callback called when scene is loaded
  62314. * @param progressCallback callback called to track progress
  62315. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62316. * @param textureLoadingCallback callback called when a texture is loading
  62317. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62318. * @param onReloadCallback callback called when a reload is requested
  62319. * @param errorCallback callback call if an error occurs
  62320. */
  62321. 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);
  62322. private _dragEnterHandler;
  62323. private _dragOverHandler;
  62324. private _dropHandler;
  62325. /**
  62326. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62327. * @param elementToMonitor defines the DOM element to track
  62328. */
  62329. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62330. /**
  62331. * Release all associated resources
  62332. */
  62333. dispose(): void;
  62334. private renderFunction;
  62335. private drag;
  62336. private drop;
  62337. private _traverseFolder;
  62338. private _processFiles;
  62339. /**
  62340. * Load files from a drop event
  62341. * @param event defines the drop event to use as source
  62342. */
  62343. loadFiles(event: any): void;
  62344. private _processReload;
  62345. /**
  62346. * Reload the current scene from the loaded files
  62347. */
  62348. reload(): void;
  62349. }
  62350. }
  62351. declare module BABYLON {
  62352. /**
  62353. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62355. */
  62356. export class SceneOptimization {
  62357. /**
  62358. * Defines the priority of this optimization (0 by default which means first in the list)
  62359. */
  62360. priority: number;
  62361. /**
  62362. * Gets a string describing the action executed by the current optimization
  62363. * @returns description string
  62364. */
  62365. getDescription(): string;
  62366. /**
  62367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62368. * @param scene defines the current scene where to apply this optimization
  62369. * @param optimizer defines the current optimizer
  62370. * @returns true if everything that can be done was applied
  62371. */
  62372. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62373. /**
  62374. * Creates the SceneOptimization object
  62375. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62376. * @param desc defines the description associated with the optimization
  62377. */
  62378. constructor(
  62379. /**
  62380. * Defines the priority of this optimization (0 by default which means first in the list)
  62381. */
  62382. priority?: number);
  62383. }
  62384. /**
  62385. * Defines an optimization used to reduce the size of render target textures
  62386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62387. */
  62388. export class TextureOptimization extends SceneOptimization {
  62389. /**
  62390. * Defines the priority of this optimization (0 by default which means first in the list)
  62391. */
  62392. priority: number;
  62393. /**
  62394. * 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
  62395. */
  62396. maximumSize: number;
  62397. /**
  62398. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62399. */
  62400. step: number;
  62401. /**
  62402. * Gets a string describing the action executed by the current optimization
  62403. * @returns description string
  62404. */
  62405. getDescription(): string;
  62406. /**
  62407. * Creates the TextureOptimization object
  62408. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62409. * @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
  62410. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62411. */
  62412. constructor(
  62413. /**
  62414. * Defines the priority of this optimization (0 by default which means first in the list)
  62415. */
  62416. priority?: number,
  62417. /**
  62418. * 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
  62419. */
  62420. maximumSize?: number,
  62421. /**
  62422. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62423. */
  62424. step?: number);
  62425. /**
  62426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62427. * @param scene defines the current scene where to apply this optimization
  62428. * @param optimizer defines the current optimizer
  62429. * @returns true if everything that can be done was applied
  62430. */
  62431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62432. }
  62433. /**
  62434. * Defines an optimization used to increase or decrease the rendering resolution
  62435. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62436. */
  62437. export class HardwareScalingOptimization extends SceneOptimization {
  62438. /**
  62439. * Defines the priority of this optimization (0 by default which means first in the list)
  62440. */
  62441. priority: number;
  62442. /**
  62443. * Defines the maximum scale to use (2 by default)
  62444. */
  62445. maximumScale: number;
  62446. /**
  62447. * Defines the step to use between two passes (0.5 by default)
  62448. */
  62449. step: number;
  62450. private _currentScale;
  62451. private _directionOffset;
  62452. /**
  62453. * Gets a string describing the action executed by the current optimization
  62454. * @return description string
  62455. */
  62456. getDescription(): string;
  62457. /**
  62458. * Creates the HardwareScalingOptimization object
  62459. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62460. * @param maximumScale defines the maximum scale to use (2 by default)
  62461. * @param step defines the step to use between two passes (0.5 by default)
  62462. */
  62463. constructor(
  62464. /**
  62465. * Defines the priority of this optimization (0 by default which means first in the list)
  62466. */
  62467. priority?: number,
  62468. /**
  62469. * Defines the maximum scale to use (2 by default)
  62470. */
  62471. maximumScale?: number,
  62472. /**
  62473. * Defines the step to use between two passes (0.5 by default)
  62474. */
  62475. step?: number);
  62476. /**
  62477. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62478. * @param scene defines the current scene where to apply this optimization
  62479. * @param optimizer defines the current optimizer
  62480. * @returns true if everything that can be done was applied
  62481. */
  62482. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62483. }
  62484. /**
  62485. * Defines an optimization used to remove shadows
  62486. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62487. */
  62488. export class ShadowsOptimization extends SceneOptimization {
  62489. /**
  62490. * Gets a string describing the action executed by the current optimization
  62491. * @return description string
  62492. */
  62493. getDescription(): string;
  62494. /**
  62495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62496. * @param scene defines the current scene where to apply this optimization
  62497. * @param optimizer defines the current optimizer
  62498. * @returns true if everything that can be done was applied
  62499. */
  62500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62501. }
  62502. /**
  62503. * Defines an optimization used to turn post-processes off
  62504. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62505. */
  62506. export class PostProcessesOptimization extends SceneOptimization {
  62507. /**
  62508. * Gets a string describing the action executed by the current optimization
  62509. * @return description string
  62510. */
  62511. getDescription(): string;
  62512. /**
  62513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62514. * @param scene defines the current scene where to apply this optimization
  62515. * @param optimizer defines the current optimizer
  62516. * @returns true if everything that can be done was applied
  62517. */
  62518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62519. }
  62520. /**
  62521. * Defines an optimization used to turn lens flares off
  62522. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62523. */
  62524. export class LensFlaresOptimization extends SceneOptimization {
  62525. /**
  62526. * Gets a string describing the action executed by the current optimization
  62527. * @return description string
  62528. */
  62529. getDescription(): string;
  62530. /**
  62531. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62532. * @param scene defines the current scene where to apply this optimization
  62533. * @param optimizer defines the current optimizer
  62534. * @returns true if everything that can be done was applied
  62535. */
  62536. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62537. }
  62538. /**
  62539. * Defines an optimization based on user defined callback.
  62540. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62541. */
  62542. export class CustomOptimization extends SceneOptimization {
  62543. /**
  62544. * Callback called to apply the custom optimization.
  62545. */
  62546. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62547. /**
  62548. * Callback called to get custom description
  62549. */
  62550. onGetDescription: () => string;
  62551. /**
  62552. * Gets a string describing the action executed by the current optimization
  62553. * @returns description string
  62554. */
  62555. getDescription(): string;
  62556. /**
  62557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62558. * @param scene defines the current scene where to apply this optimization
  62559. * @param optimizer defines the current optimizer
  62560. * @returns true if everything that can be done was applied
  62561. */
  62562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62563. }
  62564. /**
  62565. * Defines an optimization used to turn particles off
  62566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62567. */
  62568. export class ParticlesOptimization extends SceneOptimization {
  62569. /**
  62570. * Gets a string describing the action executed by the current optimization
  62571. * @return description string
  62572. */
  62573. getDescription(): string;
  62574. /**
  62575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62576. * @param scene defines the current scene where to apply this optimization
  62577. * @param optimizer defines the current optimizer
  62578. * @returns true if everything that can be done was applied
  62579. */
  62580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62581. }
  62582. /**
  62583. * Defines an optimization used to turn render targets off
  62584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62585. */
  62586. export class RenderTargetsOptimization extends SceneOptimization {
  62587. /**
  62588. * Gets a string describing the action executed by the current optimization
  62589. * @return description string
  62590. */
  62591. getDescription(): string;
  62592. /**
  62593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62594. * @param scene defines the current scene where to apply this optimization
  62595. * @param optimizer defines the current optimizer
  62596. * @returns true if everything that can be done was applied
  62597. */
  62598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62599. }
  62600. /**
  62601. * Defines an optimization used to merge meshes with compatible materials
  62602. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62603. */
  62604. export class MergeMeshesOptimization extends SceneOptimization {
  62605. private static _UpdateSelectionTree;
  62606. /**
  62607. * Gets or sets a boolean which defines if optimization octree has to be updated
  62608. */
  62609. /**
  62610. * Gets or sets a boolean which defines if optimization octree has to be updated
  62611. */
  62612. static UpdateSelectionTree: boolean;
  62613. /**
  62614. * Gets a string describing the action executed by the current optimization
  62615. * @return description string
  62616. */
  62617. getDescription(): string;
  62618. private _canBeMerged;
  62619. /**
  62620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62621. * @param scene defines the current scene where to apply this optimization
  62622. * @param optimizer defines the current optimizer
  62623. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62624. * @returns true if everything that can be done was applied
  62625. */
  62626. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62627. }
  62628. /**
  62629. * Defines a list of options used by SceneOptimizer
  62630. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62631. */
  62632. export class SceneOptimizerOptions {
  62633. /**
  62634. * Defines the target frame rate to reach (60 by default)
  62635. */
  62636. targetFrameRate: number;
  62637. /**
  62638. * Defines the interval between two checkes (2000ms by default)
  62639. */
  62640. trackerDuration: number;
  62641. /**
  62642. * Gets the list of optimizations to apply
  62643. */
  62644. optimizations: SceneOptimization[];
  62645. /**
  62646. * Creates a new list of options used by SceneOptimizer
  62647. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62648. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62649. */
  62650. constructor(
  62651. /**
  62652. * Defines the target frame rate to reach (60 by default)
  62653. */
  62654. targetFrameRate?: number,
  62655. /**
  62656. * Defines the interval between two checkes (2000ms by default)
  62657. */
  62658. trackerDuration?: number);
  62659. /**
  62660. * Add a new optimization
  62661. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62662. * @returns the current SceneOptimizerOptions
  62663. */
  62664. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62665. /**
  62666. * Add a new custom optimization
  62667. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62668. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62669. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62670. * @returns the current SceneOptimizerOptions
  62671. */
  62672. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62673. /**
  62674. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62675. * @param targetFrameRate defines the target frame rate (60 by default)
  62676. * @returns a SceneOptimizerOptions object
  62677. */
  62678. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62679. /**
  62680. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62681. * @param targetFrameRate defines the target frame rate (60 by default)
  62682. * @returns a SceneOptimizerOptions object
  62683. */
  62684. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62685. /**
  62686. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62687. * @param targetFrameRate defines the target frame rate (60 by default)
  62688. * @returns a SceneOptimizerOptions object
  62689. */
  62690. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62691. }
  62692. /**
  62693. * Class used to run optimizations in order to reach a target frame rate
  62694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62695. */
  62696. export class SceneOptimizer implements IDisposable {
  62697. private _isRunning;
  62698. private _options;
  62699. private _scene;
  62700. private _currentPriorityLevel;
  62701. private _targetFrameRate;
  62702. private _trackerDuration;
  62703. private _currentFrameRate;
  62704. private _sceneDisposeObserver;
  62705. private _improvementMode;
  62706. /**
  62707. * Defines an observable called when the optimizer reaches the target frame rate
  62708. */
  62709. onSuccessObservable: Observable<SceneOptimizer>;
  62710. /**
  62711. * Defines an observable called when the optimizer enables an optimization
  62712. */
  62713. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62714. /**
  62715. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62716. */
  62717. onFailureObservable: Observable<SceneOptimizer>;
  62718. /**
  62719. * Gets a boolean indicating if the optimizer is in improvement mode
  62720. */
  62721. readonly isInImprovementMode: boolean;
  62722. /**
  62723. * Gets the current priority level (0 at start)
  62724. */
  62725. readonly currentPriorityLevel: number;
  62726. /**
  62727. * Gets the current frame rate checked by the SceneOptimizer
  62728. */
  62729. readonly currentFrameRate: number;
  62730. /**
  62731. * Gets or sets the current target frame rate (60 by default)
  62732. */
  62733. /**
  62734. * Gets or sets the current target frame rate (60 by default)
  62735. */
  62736. targetFrameRate: number;
  62737. /**
  62738. * Gets or sets the current interval between two checks (every 2000ms by default)
  62739. */
  62740. /**
  62741. * Gets or sets the current interval between two checks (every 2000ms by default)
  62742. */
  62743. trackerDuration: number;
  62744. /**
  62745. * Gets the list of active optimizations
  62746. */
  62747. readonly optimizations: SceneOptimization[];
  62748. /**
  62749. * Creates a new SceneOptimizer
  62750. * @param scene defines the scene to work on
  62751. * @param options defines the options to use with the SceneOptimizer
  62752. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62753. * @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)
  62754. */
  62755. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62756. /**
  62757. * Stops the current optimizer
  62758. */
  62759. stop(): void;
  62760. /**
  62761. * Reset the optimizer to initial step (current priority level = 0)
  62762. */
  62763. reset(): void;
  62764. /**
  62765. * Start the optimizer. By default it will try to reach a specific framerate
  62766. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62767. */
  62768. start(): void;
  62769. private _checkCurrentState;
  62770. /**
  62771. * Release all resources
  62772. */
  62773. dispose(): void;
  62774. /**
  62775. * Helper function to create a SceneOptimizer with one single line of code
  62776. * @param scene defines the scene to work on
  62777. * @param options defines the options to use with the SceneOptimizer
  62778. * @param onSuccess defines a callback to call on success
  62779. * @param onFailure defines a callback to call on failure
  62780. * @returns the new SceneOptimizer object
  62781. */
  62782. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62783. }
  62784. }
  62785. declare module BABYLON {
  62786. /**
  62787. * Class used to serialize a scene into a string
  62788. */
  62789. export class SceneSerializer {
  62790. /**
  62791. * Clear cache used by a previous serialization
  62792. */
  62793. static ClearCache(): void;
  62794. /**
  62795. * Serialize a scene into a JSON compatible object
  62796. * @param scene defines the scene to serialize
  62797. * @returns a JSON compatible object
  62798. */
  62799. static Serialize(scene: Scene): any;
  62800. /**
  62801. * Serialize a mesh into a JSON compatible object
  62802. * @param toSerialize defines the mesh to serialize
  62803. * @param withParents defines if parents must be serialized as well
  62804. * @param withChildren defines if children must be serialized as well
  62805. * @returns a JSON compatible object
  62806. */
  62807. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62808. }
  62809. }
  62810. declare module BABYLON {
  62811. /**
  62812. * Class used to host texture specific utilities
  62813. */
  62814. export class TextureTools {
  62815. /**
  62816. * Uses the GPU to create a copy texture rescaled at a given size
  62817. * @param texture Texture to copy from
  62818. * @param width defines the desired width
  62819. * @param height defines the desired height
  62820. * @param useBilinearMode defines if bilinear mode has to be used
  62821. * @return the generated texture
  62822. */
  62823. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62824. }
  62825. }
  62826. declare module BABYLON {
  62827. /**
  62828. * This represents the different options available for the video capture.
  62829. */
  62830. export interface VideoRecorderOptions {
  62831. /** Defines the mime type of the video. */
  62832. mimeType: string;
  62833. /** Defines the FPS the video should be recorded at. */
  62834. fps: number;
  62835. /** Defines the chunk size for the recording data. */
  62836. recordChunckSize: number;
  62837. /** The audio tracks to attach to the recording. */
  62838. audioTracks?: MediaStreamTrack[];
  62839. }
  62840. /**
  62841. * This can help with recording videos from BabylonJS.
  62842. * This is based on the available WebRTC functionalities of the browser.
  62843. *
  62844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62845. */
  62846. export class VideoRecorder {
  62847. private static readonly _defaultOptions;
  62848. /**
  62849. * Returns whether or not the VideoRecorder is available in your browser.
  62850. * @param engine Defines the Babylon Engine.
  62851. * @returns true if supported otherwise false.
  62852. */
  62853. static IsSupported(engine: Engine): boolean;
  62854. private readonly _options;
  62855. private _canvas;
  62856. private _mediaRecorder;
  62857. private _recordedChunks;
  62858. private _fileName;
  62859. private _resolve;
  62860. private _reject;
  62861. /**
  62862. * True when a recording is already in progress.
  62863. */
  62864. readonly isRecording: boolean;
  62865. /**
  62866. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62867. * @param engine Defines the BabylonJS Engine you wish to record.
  62868. * @param options Defines options that can be used to customize the capture.
  62869. */
  62870. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62871. /**
  62872. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62873. */
  62874. stopRecording(): void;
  62875. /**
  62876. * Starts recording the canvas for a max duration specified in parameters.
  62877. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62878. * If null no automatic download will start and you can rely on the promise to get the data back.
  62879. * @param maxDuration Defines the maximum recording time in seconds.
  62880. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62881. * @return A promise callback at the end of the recording with the video data in Blob.
  62882. */
  62883. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62884. /**
  62885. * Releases internal resources used during the recording.
  62886. */
  62887. dispose(): void;
  62888. private _handleDataAvailable;
  62889. private _handleError;
  62890. private _handleStop;
  62891. }
  62892. }
  62893. declare module BABYLON {
  62894. /**
  62895. * Class containing a set of static utilities functions for screenshots
  62896. */
  62897. export class ScreenshotTools {
  62898. /**
  62899. * Captures a screenshot of the current rendering
  62900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62901. * @param engine defines the rendering engine
  62902. * @param camera defines the source camera
  62903. * @param size This parameter can be set to a single number or to an object with the
  62904. * following (optional) properties: precision, width, height. If a single number is passed,
  62905. * it will be used for both width and height. If an object is passed, the screenshot size
  62906. * will be derived from the parameters. The precision property is a multiplier allowing
  62907. * rendering at a higher or lower resolution
  62908. * @param successCallback defines the callback receives a single parameter which contains the
  62909. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62910. * src parameter of an <img> to display it
  62911. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62912. * Check your browser for supported MIME types
  62913. */
  62914. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62915. /**
  62916. * Captures a screenshot of the current rendering
  62917. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62918. * @param engine defines the rendering engine
  62919. * @param camera defines the source camera
  62920. * @param size This parameter can be set to a single number or to an object with the
  62921. * following (optional) properties: precision, width, height. If a single number is passed,
  62922. * it will be used for both width and height. If an object is passed, the screenshot size
  62923. * will be derived from the parameters. The precision property is a multiplier allowing
  62924. * rendering at a higher or lower resolution
  62925. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62926. * Check your browser for supported MIME types
  62927. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62928. * to the src parameter of an <img> to display it
  62929. */
  62930. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62931. /**
  62932. * Generates an image screenshot from the specified camera.
  62933. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62934. * @param engine The engine to use for rendering
  62935. * @param camera The camera to use for rendering
  62936. * @param size This parameter can be set to a single number or to an object with the
  62937. * following (optional) properties: precision, width, height. If a single number is passed,
  62938. * it will be used for both width and height. If an object is passed, the screenshot size
  62939. * will be derived from the parameters. The precision property is a multiplier allowing
  62940. * rendering at a higher or lower resolution
  62941. * @param successCallback The callback receives a single parameter which contains the
  62942. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62943. * src parameter of an <img> to display it
  62944. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62945. * Check your browser for supported MIME types
  62946. * @param samples Texture samples (default: 1)
  62947. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62948. * @param fileName A name for for the downloaded file.
  62949. */
  62950. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62951. /**
  62952. * Generates an image screenshot from the specified camera.
  62953. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62954. * @param engine The engine to use for rendering
  62955. * @param camera The camera to use for rendering
  62956. * @param size This parameter can be set to a single number or to an object with the
  62957. * following (optional) properties: precision, width, height. If a single number is passed,
  62958. * it will be used for both width and height. If an object is passed, the screenshot size
  62959. * will be derived from the parameters. The precision property is a multiplier allowing
  62960. * rendering at a higher or lower resolution
  62961. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62962. * Check your browser for supported MIME types
  62963. * @param samples Texture samples (default: 1)
  62964. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62965. * @param fileName A name for for the downloaded file.
  62966. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62967. * to the src parameter of an <img> to display it
  62968. */
  62969. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62970. /**
  62971. * Gets height and width for screenshot size
  62972. * @private
  62973. */
  62974. private static _getScreenshotSize;
  62975. }
  62976. }
  62977. declare module BABYLON {
  62978. /**
  62979. * Interface for a data buffer
  62980. */
  62981. export interface IDataBuffer {
  62982. /**
  62983. * Reads bytes from the data buffer.
  62984. * @param byteOffset The byte offset to read
  62985. * @param byteLength The byte length to read
  62986. * @returns A promise that resolves when the bytes are read
  62987. */
  62988. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  62989. /**
  62990. * The byte length of the buffer.
  62991. */
  62992. readonly byteLength: number;
  62993. }
  62994. /**
  62995. * Utility class for reading from a data buffer
  62996. */
  62997. export class DataReader {
  62998. /**
  62999. * The data buffer associated with this data reader.
  63000. */
  63001. readonly buffer: IDataBuffer;
  63002. /**
  63003. * The current byte offset from the beginning of the data buffer.
  63004. */
  63005. byteOffset: number;
  63006. private _dataView;
  63007. private _dataByteOffset;
  63008. /**
  63009. * Constructor
  63010. * @param buffer The buffer to read
  63011. */
  63012. constructor(buffer: IDataBuffer);
  63013. /**
  63014. * Loads the given byte length.
  63015. * @param byteLength The byte length to load
  63016. * @returns A promise that resolves when the load is complete
  63017. */
  63018. loadAsync(byteLength: number): Promise<void>;
  63019. /**
  63020. * Read a unsigned 32-bit integer from the currently loaded data range.
  63021. * @returns The 32-bit integer read
  63022. */
  63023. readUint32(): number;
  63024. /**
  63025. * Read a byte array from the currently loaded data range.
  63026. * @param byteLength The byte length to read
  63027. * @returns The byte array read
  63028. */
  63029. readUint8Array(byteLength: number): Uint8Array;
  63030. /**
  63031. * Read a string from the currently loaded data range.
  63032. * @param byteLength The byte length to read
  63033. * @returns The string read
  63034. */
  63035. readString(byteLength: number): string;
  63036. /**
  63037. * Skips the given byte length the currently loaded data range.
  63038. * @param byteLength The byte length to skip
  63039. */
  63040. skipBytes(byteLength: number): void;
  63041. }
  63042. }
  63043. declare module BABYLON {
  63044. /**
  63045. * A cursor which tracks a point on a path
  63046. */
  63047. export class PathCursor {
  63048. private path;
  63049. /**
  63050. * Stores path cursor callbacks for when an onchange event is triggered
  63051. */
  63052. private _onchange;
  63053. /**
  63054. * The value of the path cursor
  63055. */
  63056. value: number;
  63057. /**
  63058. * The animation array of the path cursor
  63059. */
  63060. animations: Animation[];
  63061. /**
  63062. * Initializes the path cursor
  63063. * @param path The path to track
  63064. */
  63065. constructor(path: Path2);
  63066. /**
  63067. * Gets the cursor point on the path
  63068. * @returns A point on the path cursor at the cursor location
  63069. */
  63070. getPoint(): Vector3;
  63071. /**
  63072. * Moves the cursor ahead by the step amount
  63073. * @param step The amount to move the cursor forward
  63074. * @returns This path cursor
  63075. */
  63076. moveAhead(step?: number): PathCursor;
  63077. /**
  63078. * Moves the cursor behind by the step amount
  63079. * @param step The amount to move the cursor back
  63080. * @returns This path cursor
  63081. */
  63082. moveBack(step?: number): PathCursor;
  63083. /**
  63084. * Moves the cursor by the step amount
  63085. * If the step amount is greater than one, an exception is thrown
  63086. * @param step The amount to move the cursor
  63087. * @returns This path cursor
  63088. */
  63089. move(step: number): PathCursor;
  63090. /**
  63091. * Ensures that the value is limited between zero and one
  63092. * @returns This path cursor
  63093. */
  63094. private ensureLimits;
  63095. /**
  63096. * Runs onchange callbacks on change (used by the animation engine)
  63097. * @returns This path cursor
  63098. */
  63099. private raiseOnChange;
  63100. /**
  63101. * Executes a function on change
  63102. * @param f A path cursor onchange callback
  63103. * @returns This path cursor
  63104. */
  63105. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63106. }
  63107. }
  63108. declare module BABYLON {
  63109. /** @hidden */
  63110. export var blurPixelShader: {
  63111. name: string;
  63112. shader: string;
  63113. };
  63114. }
  63115. declare module BABYLON {
  63116. /** @hidden */
  63117. export var pointCloudVertexDeclaration: {
  63118. name: string;
  63119. shader: string;
  63120. };
  63121. }
  63122. // Mixins
  63123. interface Window {
  63124. mozIndexedDB: IDBFactory;
  63125. webkitIndexedDB: IDBFactory;
  63126. msIndexedDB: IDBFactory;
  63127. webkitURL: typeof URL;
  63128. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63129. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63130. WebGLRenderingContext: WebGLRenderingContext;
  63131. MSGesture: MSGesture;
  63132. CANNON: any;
  63133. AudioContext: AudioContext;
  63134. webkitAudioContext: AudioContext;
  63135. PointerEvent: any;
  63136. Math: Math;
  63137. Uint8Array: Uint8ArrayConstructor;
  63138. Float32Array: Float32ArrayConstructor;
  63139. mozURL: typeof URL;
  63140. msURL: typeof URL;
  63141. VRFrameData: any; // WebVR, from specs 1.1
  63142. DracoDecoderModule: any;
  63143. setImmediate(handler: (...args: any[]) => void): number;
  63144. }
  63145. interface HTMLCanvasElement {
  63146. requestPointerLock(): void;
  63147. msRequestPointerLock?(): void;
  63148. mozRequestPointerLock?(): void;
  63149. webkitRequestPointerLock?(): void;
  63150. /** Track wether a record is in progress */
  63151. isRecording: boolean;
  63152. /** Capture Stream method defined by some browsers */
  63153. captureStream(fps?: number): MediaStream;
  63154. }
  63155. interface CanvasRenderingContext2D {
  63156. msImageSmoothingEnabled: boolean;
  63157. }
  63158. interface MouseEvent {
  63159. mozMovementX: number;
  63160. mozMovementY: number;
  63161. webkitMovementX: number;
  63162. webkitMovementY: number;
  63163. msMovementX: number;
  63164. msMovementY: number;
  63165. }
  63166. interface Navigator {
  63167. mozGetVRDevices: (any: any) => any;
  63168. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63169. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63170. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63171. webkitGetGamepads(): Gamepad[];
  63172. msGetGamepads(): Gamepad[];
  63173. webkitGamepads(): Gamepad[];
  63174. }
  63175. interface HTMLVideoElement {
  63176. mozSrcObject: any;
  63177. }
  63178. interface Math {
  63179. fround(x: number): number;
  63180. imul(a: number, b: number): number;
  63181. }
  63182. interface WebGLRenderingContext {
  63183. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63184. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63185. vertexAttribDivisor(index: number, divisor: number): void;
  63186. createVertexArray(): any;
  63187. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63188. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63189. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63190. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63191. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63192. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63193. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63194. // Queries
  63195. createQuery(): WebGLQuery;
  63196. deleteQuery(query: WebGLQuery): void;
  63197. beginQuery(target: number, query: WebGLQuery): void;
  63198. endQuery(target: number): void;
  63199. getQueryParameter(query: WebGLQuery, pname: number): any;
  63200. getQuery(target: number, pname: number): any;
  63201. MAX_SAMPLES: number;
  63202. RGBA8: number;
  63203. READ_FRAMEBUFFER: number;
  63204. DRAW_FRAMEBUFFER: number;
  63205. UNIFORM_BUFFER: number;
  63206. HALF_FLOAT_OES: number;
  63207. RGBA16F: number;
  63208. RGBA32F: number;
  63209. R32F: number;
  63210. RG32F: number;
  63211. RGB32F: number;
  63212. R16F: number;
  63213. RG16F: number;
  63214. RGB16F: number;
  63215. RED: number;
  63216. RG: number;
  63217. R8: number;
  63218. RG8: number;
  63219. UNSIGNED_INT_24_8: number;
  63220. DEPTH24_STENCIL8: number;
  63221. MIN: number;
  63222. MAX: number;
  63223. /* Multiple Render Targets */
  63224. drawBuffers(buffers: number[]): void;
  63225. readBuffer(src: number): void;
  63226. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63227. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63228. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63229. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63230. // Occlusion Query
  63231. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63232. ANY_SAMPLES_PASSED: number;
  63233. QUERY_RESULT_AVAILABLE: number;
  63234. QUERY_RESULT: number;
  63235. }
  63236. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63237. }
  63238. interface EXT_disjoint_timer_query {
  63239. QUERY_COUNTER_BITS_EXT: number;
  63240. TIME_ELAPSED_EXT: number;
  63241. TIMESTAMP_EXT: number;
  63242. GPU_DISJOINT_EXT: number;
  63243. QUERY_RESULT_EXT: number;
  63244. QUERY_RESULT_AVAILABLE_EXT: number;
  63245. queryCounterEXT(query: WebGLQuery, target: number): void;
  63246. createQueryEXT(): WebGLQuery;
  63247. beginQueryEXT(target: number, query: WebGLQuery): void;
  63248. endQueryEXT(target: number): void;
  63249. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63250. deleteQueryEXT(query: WebGLQuery): void;
  63251. }
  63252. interface WebGLUniformLocation { private _currentState: any;
  63253. }
  63254. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63255. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63256. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63257. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63258. interface WebGLRenderingContext {
  63259. readonly RASTERIZER_DISCARD: number;
  63260. readonly DEPTH_COMPONENT24: number;
  63261. readonly TEXTURE_3D: number;
  63262. readonly TEXTURE_2D_ARRAY: number;
  63263. readonly TEXTURE_COMPARE_FUNC: number;
  63264. readonly TEXTURE_COMPARE_MODE: number;
  63265. readonly COMPARE_REF_TO_TEXTURE: number;
  63266. readonly TEXTURE_WRAP_R: number;
  63267. readonly HALF_FLOAT: number;
  63268. readonly RGB8: number;
  63269. readonly RED_INTEGER: number;
  63270. readonly RG_INTEGER: number;
  63271. readonly RGB_INTEGER: number;
  63272. readonly RGBA_INTEGER: number;
  63273. readonly R8_SNORM: number;
  63274. readonly RG8_SNORM: number;
  63275. readonly RGB8_SNORM: number;
  63276. readonly RGBA8_SNORM: number;
  63277. readonly R8I: number;
  63278. readonly RG8I: number;
  63279. readonly RGB8I: number;
  63280. readonly RGBA8I: number;
  63281. readonly R8UI: number;
  63282. readonly RG8UI: number;
  63283. readonly RGB8UI: number;
  63284. readonly RGBA8UI: number;
  63285. readonly R16I: number;
  63286. readonly RG16I: number;
  63287. readonly RGB16I: number;
  63288. readonly RGBA16I: number;
  63289. readonly R16UI: number;
  63290. readonly RG16UI: number;
  63291. readonly RGB16UI: number;
  63292. readonly RGBA16UI: number;
  63293. readonly R32I: number;
  63294. readonly RG32I: number;
  63295. readonly RGB32I: number;
  63296. readonly RGBA32I: number;
  63297. readonly R32UI: number;
  63298. readonly RG32UI: number;
  63299. readonly RGB32UI: number;
  63300. readonly RGBA32UI: number;
  63301. readonly RGB10_A2UI: number;
  63302. readonly R11F_G11F_B10F: number;
  63303. readonly RGB9_E5: number;
  63304. readonly RGB10_A2: number;
  63305. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63306. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63307. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63308. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63309. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63310. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63311. 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;
  63312. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63313. readonly TRANSFORM_FEEDBACK: number;
  63314. readonly INTERLEAVED_ATTRIBS: number;
  63315. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63316. createTransformFeedback(): WebGLTransformFeedback;
  63317. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63318. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63319. beginTransformFeedback(primitiveMode: number): void;
  63320. endTransformFeedback(): void;
  63321. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63322. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63323. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63324. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63325. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63326. }
  63327. interface ImageBitmap {
  63328. readonly width: number;
  63329. readonly height: number;
  63330. close(): void;
  63331. }
  63332. interface WebGLQuery extends WebGLObject {
  63333. }
  63334. declare var WebGLQuery: {
  63335. prototype: WebGLQuery;
  63336. new(): WebGLQuery;
  63337. };
  63338. interface WebGLSampler extends WebGLObject {
  63339. }
  63340. declare var WebGLSampler: {
  63341. prototype: WebGLSampler;
  63342. new(): WebGLSampler;
  63343. };
  63344. interface WebGLSync extends WebGLObject {
  63345. }
  63346. declare var WebGLSync: {
  63347. prototype: WebGLSync;
  63348. new(): WebGLSync;
  63349. };
  63350. interface WebGLTransformFeedback extends WebGLObject {
  63351. }
  63352. declare var WebGLTransformFeedback: {
  63353. prototype: WebGLTransformFeedback;
  63354. new(): WebGLTransformFeedback;
  63355. };
  63356. interface WebGLVertexArrayObject extends WebGLObject {
  63357. }
  63358. declare var WebGLVertexArrayObject: {
  63359. prototype: WebGLVertexArrayObject;
  63360. new(): WebGLVertexArrayObject;
  63361. };
  63362. // Type definitions for WebVR API
  63363. // Project: https://w3c.github.io/webvr/
  63364. // Definitions by: six a <https://github.com/lostfictions>
  63365. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63366. interface VRDisplay extends EventTarget {
  63367. /**
  63368. * Dictionary of capabilities describing the VRDisplay.
  63369. */
  63370. readonly capabilities: VRDisplayCapabilities;
  63371. /**
  63372. * z-depth defining the far plane of the eye view frustum
  63373. * enables mapping of values in the render target depth
  63374. * attachment to scene coordinates. Initially set to 10000.0.
  63375. */
  63376. depthFar: number;
  63377. /**
  63378. * z-depth defining the near plane of the eye view frustum
  63379. * enables mapping of values in the render target depth
  63380. * attachment to scene coordinates. Initially set to 0.01.
  63381. */
  63382. depthNear: number;
  63383. /**
  63384. * An identifier for this distinct VRDisplay. Used as an
  63385. * association point in the Gamepad API.
  63386. */
  63387. readonly displayId: number;
  63388. /**
  63389. * A display name, a user-readable name identifying it.
  63390. */
  63391. readonly displayName: string;
  63392. readonly isConnected: boolean;
  63393. readonly isPresenting: boolean;
  63394. /**
  63395. * If this VRDisplay supports room-scale experiences, the optional
  63396. * stage attribute contains details on the room-scale parameters.
  63397. */
  63398. readonly stageParameters: VRStageParameters | null;
  63399. /**
  63400. * Passing the value returned by `requestAnimationFrame` to
  63401. * `cancelAnimationFrame` will unregister the callback.
  63402. * @param handle Define the hanle of the request to cancel
  63403. */
  63404. cancelAnimationFrame(handle: number): void;
  63405. /**
  63406. * Stops presenting to the VRDisplay.
  63407. * @returns a promise to know when it stopped
  63408. */
  63409. exitPresent(): Promise<void>;
  63410. /**
  63411. * Return the current VREyeParameters for the given eye.
  63412. * @param whichEye Define the eye we want the parameter for
  63413. * @returns the eye parameters
  63414. */
  63415. getEyeParameters(whichEye: string): VREyeParameters;
  63416. /**
  63417. * Populates the passed VRFrameData with the information required to render
  63418. * the current frame.
  63419. * @param frameData Define the data structure to populate
  63420. * @returns true if ok otherwise false
  63421. */
  63422. getFrameData(frameData: VRFrameData): boolean;
  63423. /**
  63424. * Get the layers currently being presented.
  63425. * @returns the list of VR layers
  63426. */
  63427. getLayers(): VRLayer[];
  63428. /**
  63429. * Return a VRPose containing the future predicted pose of the VRDisplay
  63430. * when the current frame will be presented. The value returned will not
  63431. * change until JavaScript has returned control to the browser.
  63432. *
  63433. * The VRPose will contain the position, orientation, velocity,
  63434. * and acceleration of each of these properties.
  63435. * @returns the pose object
  63436. */
  63437. getPose(): VRPose;
  63438. /**
  63439. * Return the current instantaneous pose of the VRDisplay, with no
  63440. * prediction applied.
  63441. * @returns the current instantaneous pose
  63442. */
  63443. getImmediatePose(): VRPose;
  63444. /**
  63445. * The callback passed to `requestAnimationFrame` will be called
  63446. * any time a new frame should be rendered. When the VRDisplay is
  63447. * presenting the callback will be called at the native refresh
  63448. * rate of the HMD. When not presenting this function acts
  63449. * identically to how window.requestAnimationFrame acts. Content should
  63450. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63451. * asynchronously from other displays and at differing refresh rates.
  63452. * @param callback Define the eaction to run next frame
  63453. * @returns the request handle it
  63454. */
  63455. requestAnimationFrame(callback: FrameRequestCallback): number;
  63456. /**
  63457. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63458. * Repeat calls while already presenting will update the VRLayers being displayed.
  63459. * @param layers Define the list of layer to present
  63460. * @returns a promise to know when the request has been fulfilled
  63461. */
  63462. requestPresent(layers: VRLayer[]): Promise<void>;
  63463. /**
  63464. * Reset the pose for this display, treating its current position and
  63465. * orientation as the "origin/zero" values. VRPose.position,
  63466. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63467. * updated when calling resetPose(). This should be called in only
  63468. * sitting-space experiences.
  63469. */
  63470. resetPose(): void;
  63471. /**
  63472. * The VRLayer provided to the VRDisplay will be captured and presented
  63473. * in the HMD. Calling this function has the same effect on the source
  63474. * canvas as any other operation that uses its source image, and canvases
  63475. * created without preserveDrawingBuffer set to true will be cleared.
  63476. * @param pose Define the pose to submit
  63477. */
  63478. submitFrame(pose?: VRPose): void;
  63479. }
  63480. declare var VRDisplay: {
  63481. prototype: VRDisplay;
  63482. new(): VRDisplay;
  63483. };
  63484. interface VRLayer {
  63485. leftBounds?: number[] | Float32Array | null;
  63486. rightBounds?: number[] | Float32Array | null;
  63487. source?: HTMLCanvasElement | null;
  63488. }
  63489. interface VRDisplayCapabilities {
  63490. readonly canPresent: boolean;
  63491. readonly hasExternalDisplay: boolean;
  63492. readonly hasOrientation: boolean;
  63493. readonly hasPosition: boolean;
  63494. readonly maxLayers: number;
  63495. }
  63496. interface VREyeParameters {
  63497. /** @deprecated */
  63498. readonly fieldOfView: VRFieldOfView;
  63499. readonly offset: Float32Array;
  63500. readonly renderHeight: number;
  63501. readonly renderWidth: number;
  63502. }
  63503. interface VRFieldOfView {
  63504. readonly downDegrees: number;
  63505. readonly leftDegrees: number;
  63506. readonly rightDegrees: number;
  63507. readonly upDegrees: number;
  63508. }
  63509. interface VRFrameData {
  63510. readonly leftProjectionMatrix: Float32Array;
  63511. readonly leftViewMatrix: Float32Array;
  63512. readonly pose: VRPose;
  63513. readonly rightProjectionMatrix: Float32Array;
  63514. readonly rightViewMatrix: Float32Array;
  63515. readonly timestamp: number;
  63516. }
  63517. interface VRPose {
  63518. readonly angularAcceleration: Float32Array | null;
  63519. readonly angularVelocity: Float32Array | null;
  63520. readonly linearAcceleration: Float32Array | null;
  63521. readonly linearVelocity: Float32Array | null;
  63522. readonly orientation: Float32Array | null;
  63523. readonly position: Float32Array | null;
  63524. readonly timestamp: number;
  63525. }
  63526. interface VRStageParameters {
  63527. sittingToStandingTransform?: Float32Array;
  63528. sizeX?: number;
  63529. sizeY?: number;
  63530. }
  63531. interface Navigator {
  63532. getVRDisplays(): Promise<VRDisplay[]>;
  63533. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63534. }
  63535. interface Window {
  63536. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63537. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63538. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63539. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63540. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63541. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63542. }
  63543. interface Gamepad {
  63544. readonly displayId: number;
  63545. }
  63546. type XRSessionMode =
  63547. | "inline"
  63548. | "immersive-vr"
  63549. | "immersive-ar";
  63550. type XRReferenceSpaceType =
  63551. | "viewer"
  63552. | "local"
  63553. | "local-floor"
  63554. | "bounded-floor"
  63555. | "unbounded";
  63556. type XREnvironmentBlendMode =
  63557. | "opaque"
  63558. | "additive"
  63559. | "alpha-blend";
  63560. type XRVisibilityState =
  63561. | "visible"
  63562. | "visible-blurred"
  63563. | "hidden";
  63564. type XRHandedness =
  63565. | "none"
  63566. | "left"
  63567. | "right";
  63568. type XRTargetRayMode =
  63569. | "gaze"
  63570. | "tracked-pointer"
  63571. | "screen";
  63572. type XREye =
  63573. | "none"
  63574. | "left"
  63575. | "right";
  63576. interface XRSpace extends EventTarget {
  63577. }
  63578. interface XRRenderState {
  63579. depthNear?: number;
  63580. depthFar?: number;
  63581. inlineVerticalFieldOfView?: number;
  63582. baseLayer?: XRWebGLLayer;
  63583. }
  63584. interface XRInputSource {
  63585. handedness: XRHandedness;
  63586. targetRayMode: XRTargetRayMode;
  63587. targetRaySpace: XRSpace;
  63588. gripSpace: XRSpace | undefined;
  63589. gamepad: Gamepad | undefined;
  63590. profiles: Array<string>;
  63591. }
  63592. interface XRSession {
  63593. addEventListener: Function;
  63594. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63595. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63596. requestAnimationFrame: Function;
  63597. end(): Promise<void>;
  63598. renderState: XRRenderState;
  63599. inputSources: Array<XRInputSource>;
  63600. }
  63601. interface XRReferenceSpace extends XRSpace {
  63602. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63603. onreset: any;
  63604. }
  63605. interface XRFrame {
  63606. session: XRSession;
  63607. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63608. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63609. }
  63610. interface XRViewerPose extends XRPose {
  63611. views: Array<XRView>;
  63612. }
  63613. interface XRPose {
  63614. transform: XRRigidTransform;
  63615. emulatedPosition: boolean;
  63616. }
  63617. declare var XRWebGLLayer: {
  63618. prototype: XRWebGLLayer;
  63619. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63620. };
  63621. interface XRWebGLLayer {
  63622. framebuffer: WebGLFramebuffer;
  63623. framebufferWidth: number;
  63624. framebufferHeight: number;
  63625. getViewport: Function;
  63626. }
  63627. interface XRRigidTransform {
  63628. position: DOMPointReadOnly;
  63629. orientation: DOMPointReadOnly;
  63630. matrix: Float32Array;
  63631. inverse: XRRigidTransform;
  63632. }
  63633. interface XRView {
  63634. eye: XREye;
  63635. projectionMatrix: Float32Array;
  63636. transform: XRRigidTransform;
  63637. }
  63638. interface XRInputSourceChangeEvent {
  63639. session: XRSession;
  63640. removed: Array<XRInputSource>;
  63641. added: Array<XRInputSource>;
  63642. }
  63643. /**
  63644. * @ignore
  63645. */
  63646. declare module BABYLON.GLTF2.Exporter {
  63647. }
  63648. /**
  63649. * @ignore
  63650. */
  63651. declare module BABYLON.GLTF1 {
  63652. }
  63653. declare module BABYLON.GUI {
  63654. /**
  63655. * Class used to specific a value and its associated unit
  63656. */
  63657. export class ValueAndUnit {
  63658. /** defines the unit to store */
  63659. unit: number;
  63660. /** defines a boolean indicating if the value can be negative */
  63661. negativeValueAllowed: boolean;
  63662. private _value;
  63663. private _originalUnit;
  63664. /**
  63665. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63666. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63667. */
  63668. ignoreAdaptiveScaling: boolean;
  63669. /**
  63670. * Creates a new ValueAndUnit
  63671. * @param value defines the value to store
  63672. * @param unit defines the unit to store
  63673. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63674. */
  63675. constructor(value: number,
  63676. /** defines the unit to store */
  63677. unit?: number,
  63678. /** defines a boolean indicating if the value can be negative */
  63679. negativeValueAllowed?: boolean);
  63680. /** Gets a boolean indicating if the value is a percentage */
  63681. readonly isPercentage: boolean;
  63682. /** Gets a boolean indicating if the value is store as pixel */
  63683. readonly isPixel: boolean;
  63684. /** Gets direct internal value */
  63685. readonly internalValue: number;
  63686. /**
  63687. * Gets value as pixel
  63688. * @param host defines the root host
  63689. * @param refValue defines the reference value for percentages
  63690. * @returns the value as pixel
  63691. */
  63692. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63693. /**
  63694. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63695. * @param value defines the value to store
  63696. * @param unit defines the unit to store
  63697. * @returns the current ValueAndUnit
  63698. */
  63699. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63700. /**
  63701. * Gets the value accordingly to its unit
  63702. * @param host defines the root host
  63703. * @returns the value
  63704. */
  63705. getValue(host: AdvancedDynamicTexture): number;
  63706. /**
  63707. * Gets a string representation of the value
  63708. * @param host defines the root host
  63709. * @param decimals defines an optional number of decimals to display
  63710. * @returns a string
  63711. */
  63712. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63713. /**
  63714. * Store a value parsed from a string
  63715. * @param source defines the source string
  63716. * @returns true if the value was successfully parsed
  63717. */
  63718. fromString(source: string | number): boolean;
  63719. private static _Regex;
  63720. private static _UNITMODE_PERCENTAGE;
  63721. private static _UNITMODE_PIXEL;
  63722. /** UNITMODE_PERCENTAGE */
  63723. static readonly UNITMODE_PERCENTAGE: number;
  63724. /** UNITMODE_PIXEL */
  63725. static readonly UNITMODE_PIXEL: number;
  63726. }
  63727. }
  63728. declare module BABYLON.GUI {
  63729. /**
  63730. * Define a style used by control to automatically setup properties based on a template.
  63731. * Only support font related properties so far
  63732. */
  63733. export class Style implements BABYLON.IDisposable {
  63734. private _fontFamily;
  63735. private _fontStyle;
  63736. private _fontWeight;
  63737. /** @hidden */ private _host: AdvancedDynamicTexture;
  63738. /** @hidden */ private _fontSize: ValueAndUnit;
  63739. /**
  63740. * BABYLON.Observable raised when the style values are changed
  63741. */
  63742. onChangedObservable: BABYLON.Observable<Style>;
  63743. /**
  63744. * Creates a new style object
  63745. * @param host defines the AdvancedDynamicTexture which hosts this style
  63746. */
  63747. constructor(host: AdvancedDynamicTexture);
  63748. /**
  63749. * Gets or sets the font size
  63750. */
  63751. fontSize: string | number;
  63752. /**
  63753. * Gets or sets the font family
  63754. */
  63755. fontFamily: string;
  63756. /**
  63757. * Gets or sets the font style
  63758. */
  63759. fontStyle: string;
  63760. /** Gets or sets font weight */
  63761. fontWeight: string;
  63762. /** Dispose all associated resources */
  63763. dispose(): void;
  63764. }
  63765. }
  63766. declare module BABYLON.GUI {
  63767. /**
  63768. * Class used to transport BABYLON.Vector2 information for pointer events
  63769. */
  63770. export class Vector2WithInfo extends BABYLON.Vector2 {
  63771. /** defines the current mouse button index */
  63772. buttonIndex: number;
  63773. /**
  63774. * Creates a new Vector2WithInfo
  63775. * @param source defines the vector2 data to transport
  63776. * @param buttonIndex defines the current mouse button index
  63777. */
  63778. constructor(source: BABYLON.Vector2,
  63779. /** defines the current mouse button index */
  63780. buttonIndex?: number);
  63781. }
  63782. /** Class used to provide 2D matrix features */
  63783. export class Matrix2D {
  63784. /** Gets the internal array of 6 floats used to store matrix data */
  63785. m: Float32Array;
  63786. /**
  63787. * Creates a new matrix
  63788. * @param m00 defines value for (0, 0)
  63789. * @param m01 defines value for (0, 1)
  63790. * @param m10 defines value for (1, 0)
  63791. * @param m11 defines value for (1, 1)
  63792. * @param m20 defines value for (2, 0)
  63793. * @param m21 defines value for (2, 1)
  63794. */
  63795. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63796. /**
  63797. * Fills the matrix from direct values
  63798. * @param m00 defines value for (0, 0)
  63799. * @param m01 defines value for (0, 1)
  63800. * @param m10 defines value for (1, 0)
  63801. * @param m11 defines value for (1, 1)
  63802. * @param m20 defines value for (2, 0)
  63803. * @param m21 defines value for (2, 1)
  63804. * @returns the current modified matrix
  63805. */
  63806. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63807. /**
  63808. * Gets matrix determinant
  63809. * @returns the determinant
  63810. */
  63811. determinant(): number;
  63812. /**
  63813. * Inverses the matrix and stores it in a target matrix
  63814. * @param result defines the target matrix
  63815. * @returns the current matrix
  63816. */
  63817. invertToRef(result: Matrix2D): Matrix2D;
  63818. /**
  63819. * Multiplies the current matrix with another one
  63820. * @param other defines the second operand
  63821. * @param result defines the target matrix
  63822. * @returns the current matrix
  63823. */
  63824. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63825. /**
  63826. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63827. * @param x defines the x coordinate to transform
  63828. * @param y defines the x coordinate to transform
  63829. * @param result defines the target vector2
  63830. * @returns the current matrix
  63831. */
  63832. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63833. /**
  63834. * Creates an identity matrix
  63835. * @returns a new matrix
  63836. */
  63837. static Identity(): Matrix2D;
  63838. /**
  63839. * Creates a translation matrix and stores it in a target matrix
  63840. * @param x defines the x coordinate of the translation
  63841. * @param y defines the y coordinate of the translation
  63842. * @param result defines the target matrix
  63843. */
  63844. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63845. /**
  63846. * Creates a scaling matrix and stores it in a target matrix
  63847. * @param x defines the x coordinate of the scaling
  63848. * @param y defines the y coordinate of the scaling
  63849. * @param result defines the target matrix
  63850. */
  63851. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63852. /**
  63853. * Creates a rotation matrix and stores it in a target matrix
  63854. * @param angle defines the rotation angle
  63855. * @param result defines the target matrix
  63856. */
  63857. static RotationToRef(angle: number, result: Matrix2D): void;
  63858. private static _TempPreTranslationMatrix;
  63859. private static _TempPostTranslationMatrix;
  63860. private static _TempRotationMatrix;
  63861. private static _TempScalingMatrix;
  63862. private static _TempCompose0;
  63863. private static _TempCompose1;
  63864. private static _TempCompose2;
  63865. /**
  63866. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63867. * @param tx defines the x coordinate of the translation
  63868. * @param ty defines the y coordinate of the translation
  63869. * @param angle defines the rotation angle
  63870. * @param scaleX defines the x coordinate of the scaling
  63871. * @param scaleY defines the y coordinate of the scaling
  63872. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63873. * @param result defines the target matrix
  63874. */
  63875. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63876. }
  63877. }
  63878. declare module BABYLON.GUI {
  63879. /**
  63880. * Class used to store 2D control sizes
  63881. */
  63882. export class Measure {
  63883. /** defines left coordinate */
  63884. left: number;
  63885. /** defines top coordinate */
  63886. top: number;
  63887. /** defines width dimension */
  63888. width: number;
  63889. /** defines height dimension */
  63890. height: number;
  63891. /**
  63892. * Creates a new measure
  63893. * @param left defines left coordinate
  63894. * @param top defines top coordinate
  63895. * @param width defines width dimension
  63896. * @param height defines height dimension
  63897. */
  63898. constructor(
  63899. /** defines left coordinate */
  63900. left: number,
  63901. /** defines top coordinate */
  63902. top: number,
  63903. /** defines width dimension */
  63904. width: number,
  63905. /** defines height dimension */
  63906. height: number);
  63907. /**
  63908. * Copy from another measure
  63909. * @param other defines the other measure to copy from
  63910. */
  63911. copyFrom(other: Measure): void;
  63912. /**
  63913. * Copy from a group of 4 floats
  63914. * @param left defines left coordinate
  63915. * @param top defines top coordinate
  63916. * @param width defines width dimension
  63917. * @param height defines height dimension
  63918. */
  63919. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63920. /**
  63921. * Computes the axis aligned bounding box measure for two given measures
  63922. * @param a Input measure
  63923. * @param b Input measure
  63924. * @param result the resulting bounding measure
  63925. */
  63926. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63927. /**
  63928. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63929. * @param transform the matrix to transform the measure before computing the AABB
  63930. * @param result the resulting AABB
  63931. */
  63932. transformToRef(transform: Matrix2D, result: Measure): void;
  63933. /**
  63934. * Check equality between this measure and another one
  63935. * @param other defines the other measures
  63936. * @returns true if both measures are equals
  63937. */
  63938. isEqualsTo(other: Measure): boolean;
  63939. /**
  63940. * Creates an empty measure
  63941. * @returns a new measure
  63942. */
  63943. static Empty(): Measure;
  63944. }
  63945. }
  63946. declare module BABYLON.GUI {
  63947. /**
  63948. * Interface used to define a control that can receive focus
  63949. */
  63950. export interface IFocusableControl {
  63951. /**
  63952. * Function called when the control receives the focus
  63953. */
  63954. onFocus(): void;
  63955. /**
  63956. * Function called when the control loses the focus
  63957. */
  63958. onBlur(): void;
  63959. /**
  63960. * Function called to let the control handle keyboard events
  63961. * @param evt defines the current keyboard event
  63962. */
  63963. processKeyboard(evt: KeyboardEvent): void;
  63964. /**
  63965. * Function called to get the list of controls that should not steal the focus from this control
  63966. * @returns an array of controls
  63967. */
  63968. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63969. }
  63970. /**
  63971. * Class used to create texture to support 2D GUI elements
  63972. * @see http://doc.babylonjs.com/how_to/gui
  63973. */
  63974. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63975. private _isDirty;
  63976. private _renderObserver;
  63977. private _resizeObserver;
  63978. private _preKeyboardObserver;
  63979. private _pointerMoveObserver;
  63980. private _pointerObserver;
  63981. private _canvasPointerOutObserver;
  63982. private _background;
  63983. /** @hidden */ private _rootContainer: Container;
  63984. /** @hidden */ private _lastPickedControl: Control;
  63985. /** @hidden */ private _lastControlOver: {
  63986. [pointerId: number]: Control;
  63987. };
  63988. /** @hidden */ private _lastControlDown: {
  63989. [pointerId: number]: Control;
  63990. };
  63991. /** @hidden */ private _capturingControl: {
  63992. [pointerId: number]: Control;
  63993. };
  63994. /** @hidden */ private _shouldBlockPointer: boolean;
  63995. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63996. /** @hidden */ private _linkedControls: Control[];
  63997. private _isFullscreen;
  63998. private _fullscreenViewport;
  63999. private _idealWidth;
  64000. private _idealHeight;
  64001. private _useSmallestIdeal;
  64002. private _renderAtIdealSize;
  64003. private _focusedControl;
  64004. private _blockNextFocusCheck;
  64005. private _renderScale;
  64006. private _rootCanvas;
  64007. private _cursorChanged;
  64008. /**
  64009. * Define type to string to ensure compatibility across browsers
  64010. * Safari doesn't support DataTransfer constructor
  64011. */
  64012. private _clipboardData;
  64013. /**
  64014. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64015. */
  64016. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64017. /**
  64018. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64019. */
  64020. onControlPickedObservable: BABYLON.Observable<Control>;
  64021. /**
  64022. * BABYLON.Observable event triggered before layout is evaluated
  64023. */
  64024. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64025. /**
  64026. * BABYLON.Observable event triggered after the layout was evaluated
  64027. */
  64028. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64029. /**
  64030. * BABYLON.Observable event triggered before the texture is rendered
  64031. */
  64032. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64033. /**
  64034. * BABYLON.Observable event triggered after the texture was rendered
  64035. */
  64036. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64037. /**
  64038. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64039. */
  64040. premulAlpha: boolean;
  64041. /**
  64042. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64043. * Useful when you want more antialiasing
  64044. */
  64045. renderScale: number;
  64046. /** Gets or sets the background color */
  64047. background: string;
  64048. /**
  64049. * Gets or sets the ideal width used to design controls.
  64050. * The GUI will then rescale everything accordingly
  64051. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64052. */
  64053. idealWidth: number;
  64054. /**
  64055. * Gets or sets the ideal height used to design controls.
  64056. * The GUI will then rescale everything accordingly
  64057. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64058. */
  64059. idealHeight: number;
  64060. /**
  64061. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64062. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64063. */
  64064. useSmallestIdeal: boolean;
  64065. /**
  64066. * Gets or sets a boolean indicating if adaptive scaling must be used
  64067. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64068. */
  64069. renderAtIdealSize: boolean;
  64070. /**
  64071. * Gets the underlying layer used to render the texture when in fullscreen mode
  64072. */
  64073. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64074. /**
  64075. * Gets the root container control
  64076. */
  64077. readonly rootContainer: Container;
  64078. /**
  64079. * Returns an array containing the root container.
  64080. * This is mostly used to let the Inspector introspects the ADT
  64081. * @returns an array containing the rootContainer
  64082. */
  64083. getChildren(): Array<Container>;
  64084. /**
  64085. * Will return all controls that are inside this texture
  64086. * @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
  64087. * @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
  64088. * @return all child controls
  64089. */
  64090. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64091. /**
  64092. * Gets or sets the current focused control
  64093. */
  64094. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64095. /**
  64096. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64097. */
  64098. isForeground: boolean;
  64099. /**
  64100. * Gets or set information about clipboardData
  64101. */
  64102. clipboardData: string;
  64103. /**
  64104. * Creates a new AdvancedDynamicTexture
  64105. * @param name defines the name of the texture
  64106. * @param width defines the width of the texture
  64107. * @param height defines the height of the texture
  64108. * @param scene defines the hosting scene
  64109. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64110. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64111. */
  64112. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64113. /**
  64114. * Get the current class name of the texture useful for serialization or dynamic coding.
  64115. * @returns "AdvancedDynamicTexture"
  64116. */
  64117. getClassName(): string;
  64118. /**
  64119. * Function used to execute a function on all controls
  64120. * @param func defines the function to execute
  64121. * @param container defines the container where controls belong. If null the root container will be used
  64122. */
  64123. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64124. private _useInvalidateRectOptimization;
  64125. /**
  64126. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64127. */
  64128. useInvalidateRectOptimization: boolean;
  64129. private _invalidatedRectangle;
  64130. /**
  64131. * Invalidates a rectangle area on the gui texture
  64132. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64133. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64134. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64135. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64136. */
  64137. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64138. /**
  64139. * Marks the texture as dirty forcing a complete update
  64140. */
  64141. markAsDirty(): void;
  64142. /**
  64143. * Helper function used to create a new style
  64144. * @returns a new style
  64145. * @see http://doc.babylonjs.com/how_to/gui#styles
  64146. */
  64147. createStyle(): Style;
  64148. /**
  64149. * Adds a new control to the root container
  64150. * @param control defines the control to add
  64151. * @returns the current texture
  64152. */
  64153. addControl(control: Control): AdvancedDynamicTexture;
  64154. /**
  64155. * Removes a control from the root container
  64156. * @param control defines the control to remove
  64157. * @returns the current texture
  64158. */
  64159. removeControl(control: Control): AdvancedDynamicTexture;
  64160. /**
  64161. * Release all resources
  64162. */
  64163. dispose(): void;
  64164. private _onResize;
  64165. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64166. /**
  64167. * Get screen coordinates for a vector3
  64168. * @param position defines the position to project
  64169. * @param worldMatrix defines the world matrix to use
  64170. * @returns the projected position
  64171. */
  64172. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64173. private _checkUpdate;
  64174. private _clearMeasure;
  64175. private _render;
  64176. /** @hidden */ private _changeCursor(cursor: string): void;
  64177. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  64178. private _doPicking;
  64179. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  64180. [pointerId: number]: Control;
  64181. }, control: Control): void;
  64182. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  64183. /** Attach to all scene events required to support pointer events */
  64184. attach(): void;
  64185. /** @hidden */
  64186. private onClipboardCopy;
  64187. /** @hidden */
  64188. private onClipboardCut;
  64189. /** @hidden */
  64190. private onClipboardPaste;
  64191. /**
  64192. * Register the clipboard Events onto the canvas
  64193. */
  64194. registerClipboardEvents(): void;
  64195. /**
  64196. * Unregister the clipboard Events from the canvas
  64197. */
  64198. unRegisterClipboardEvents(): void;
  64199. /**
  64200. * Connect the texture to a hosting mesh to enable interactions
  64201. * @param mesh defines the mesh to attach to
  64202. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64203. */
  64204. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64205. /**
  64206. * Move the focus to a specific control
  64207. * @param control defines the control which will receive the focus
  64208. */
  64209. moveFocusToControl(control: IFocusableControl): void;
  64210. private _manageFocus;
  64211. private _attachToOnPointerOut;
  64212. /**
  64213. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64214. * @param mesh defines the mesh which will receive the texture
  64215. * @param width defines the texture width (1024 by default)
  64216. * @param height defines the texture height (1024 by default)
  64217. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64218. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64219. * @returns a new AdvancedDynamicTexture
  64220. */
  64221. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64222. /**
  64223. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64224. * In this mode the texture will rely on a layer for its rendering.
  64225. * This allows it to be treated like any other layer.
  64226. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64227. * LayerMask is set through advancedTexture.layer.layerMask
  64228. * @param name defines name for the texture
  64229. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64230. * @param scene defines the hsoting scene
  64231. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64232. * @returns a new AdvancedDynamicTexture
  64233. */
  64234. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64235. }
  64236. }
  64237. declare module BABYLON.GUI {
  64238. /**
  64239. * Root class used for all 2D controls
  64240. * @see http://doc.babylonjs.com/how_to/gui#controls
  64241. */
  64242. export class Control {
  64243. /** defines the name of the control */
  64244. name?: string | undefined;
  64245. /**
  64246. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64247. */
  64248. static AllowAlphaInheritance: boolean;
  64249. private _alpha;
  64250. private _alphaSet;
  64251. private _zIndex;
  64252. /** @hidden */ private _host: AdvancedDynamicTexture;
  64253. /** Gets or sets the control parent */
  64254. parent: BABYLON.Nullable<Container>;
  64255. /** @hidden */ private _currentMeasure: Measure;
  64256. private _fontFamily;
  64257. private _fontStyle;
  64258. private _fontWeight;
  64259. private _fontSize;
  64260. private _font;
  64261. /** @hidden */ private _width: ValueAndUnit;
  64262. /** @hidden */ private _height: ValueAndUnit;
  64263. /** @hidden */
  64264. protected _fontOffset: {
  64265. ascent: number;
  64266. height: number;
  64267. descent: number;
  64268. };
  64269. private _color;
  64270. private _style;
  64271. private _styleObserver;
  64272. /** @hidden */
  64273. protected _horizontalAlignment: number;
  64274. /** @hidden */
  64275. protected _verticalAlignment: number;
  64276. /** @hidden */
  64277. protected _isDirty: boolean;
  64278. /** @hidden */
  64279. protected _wasDirty: boolean;
  64280. /** @hidden */ private _tempParentMeasure: Measure;
  64281. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64282. /** @hidden */
  64283. protected _cachedParentMeasure: Measure;
  64284. private _paddingLeft;
  64285. private _paddingRight;
  64286. private _paddingTop;
  64287. private _paddingBottom;
  64288. /** @hidden */ private _left: ValueAndUnit;
  64289. /** @hidden */ private _top: ValueAndUnit;
  64290. private _scaleX;
  64291. private _scaleY;
  64292. private _rotation;
  64293. private _transformCenterX;
  64294. private _transformCenterY;
  64295. /** @hidden */ private _transformMatrix: Matrix2D;
  64296. /** @hidden */
  64297. protected _invertTransformMatrix: Matrix2D;
  64298. /** @hidden */
  64299. protected _transformedPosition: BABYLON.Vector2;
  64300. private _isMatrixDirty;
  64301. private _cachedOffsetX;
  64302. private _cachedOffsetY;
  64303. private _isVisible;
  64304. private _isHighlighted;
  64305. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64306. private _fontSet;
  64307. private _dummyVector2;
  64308. private _downCount;
  64309. private _enterCount;
  64310. private _doNotRender;
  64311. private _downPointerIds;
  64312. protected _isEnabled: boolean;
  64313. protected _disabledColor: string;
  64314. /** @hidden */
  64315. protected _rebuildLayout: boolean;
  64316. /** @hidden */ private _isClipped: boolean;
  64317. /** @hidden */ private _tag: any;
  64318. /**
  64319. * 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
  64320. */
  64321. uniqueId: number;
  64322. /**
  64323. * Gets or sets an object used to store user defined information for the node
  64324. */
  64325. metadata: any;
  64326. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64327. isHitTestVisible: boolean;
  64328. /** Gets or sets a boolean indicating if the control can block pointer events */
  64329. isPointerBlocker: boolean;
  64330. /** Gets or sets a boolean indicating if the control can be focusable */
  64331. isFocusInvisible: boolean;
  64332. /**
  64333. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64334. * 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
  64335. */
  64336. clipChildren: boolean;
  64337. /**
  64338. * Gets or sets a boolean indicating that control content must be clipped
  64339. * 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
  64340. */
  64341. clipContent: boolean;
  64342. /**
  64343. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64344. */
  64345. useBitmapCache: boolean;
  64346. private _cacheData;
  64347. private _shadowOffsetX;
  64348. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64349. shadowOffsetX: number;
  64350. private _shadowOffsetY;
  64351. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64352. shadowOffsetY: number;
  64353. private _shadowBlur;
  64354. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64355. shadowBlur: number;
  64356. private _shadowColor;
  64357. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64358. shadowColor: string;
  64359. /** Gets or sets the cursor to use when the control is hovered */
  64360. hoverCursor: string;
  64361. /** @hidden */
  64362. protected _linkOffsetX: ValueAndUnit;
  64363. /** @hidden */
  64364. protected _linkOffsetY: ValueAndUnit;
  64365. /** Gets the control type name */
  64366. readonly typeName: string;
  64367. /**
  64368. * Get the current class name of the control.
  64369. * @returns current class name
  64370. */
  64371. getClassName(): string;
  64372. /**
  64373. * An event triggered when the pointer move over the control.
  64374. */
  64375. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64376. /**
  64377. * An event triggered when the pointer move out of the control.
  64378. */
  64379. onPointerOutObservable: BABYLON.Observable<Control>;
  64380. /**
  64381. * An event triggered when the pointer taps the control
  64382. */
  64383. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64384. /**
  64385. * An event triggered when pointer up
  64386. */
  64387. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64388. /**
  64389. * An event triggered when a control is clicked on
  64390. */
  64391. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64392. /**
  64393. * An event triggered when pointer enters the control
  64394. */
  64395. onPointerEnterObservable: BABYLON.Observable<Control>;
  64396. /**
  64397. * An event triggered when the control is marked as dirty
  64398. */
  64399. onDirtyObservable: BABYLON.Observable<Control>;
  64400. /**
  64401. * An event triggered before drawing the control
  64402. */
  64403. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64404. /**
  64405. * An event triggered after the control was drawn
  64406. */
  64407. onAfterDrawObservable: BABYLON.Observable<Control>;
  64408. /**
  64409. * Get the hosting AdvancedDynamicTexture
  64410. */
  64411. readonly host: AdvancedDynamicTexture;
  64412. /** Gets or set information about font offsets (used to render and align text) */
  64413. fontOffset: {
  64414. ascent: number;
  64415. height: number;
  64416. descent: number;
  64417. };
  64418. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64419. alpha: number;
  64420. /**
  64421. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64422. */
  64423. isHighlighted: boolean;
  64424. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64425. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64426. */
  64427. scaleX: number;
  64428. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64429. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64430. */
  64431. scaleY: number;
  64432. /** Gets or sets the rotation angle (0 by default)
  64433. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64434. */
  64435. rotation: number;
  64436. /** Gets or sets the transformation center on Y axis (0 by default)
  64437. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64438. */
  64439. transformCenterY: number;
  64440. /** Gets or sets the transformation center on X axis (0 by default)
  64441. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64442. */
  64443. transformCenterX: number;
  64444. /**
  64445. * Gets or sets the horizontal alignment
  64446. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64447. */
  64448. horizontalAlignment: number;
  64449. /**
  64450. * Gets or sets the vertical alignment
  64451. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64452. */
  64453. verticalAlignment: number;
  64454. /**
  64455. * Gets or sets control width
  64456. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64457. */
  64458. width: string | number;
  64459. /**
  64460. * Gets or sets the control width in pixel
  64461. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64462. */
  64463. widthInPixels: number;
  64464. /**
  64465. * Gets or sets control height
  64466. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64467. */
  64468. height: string | number;
  64469. /**
  64470. * Gets or sets control height in pixel
  64471. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64472. */
  64473. heightInPixels: number;
  64474. /** Gets or set font family */
  64475. fontFamily: string;
  64476. /** Gets or sets font style */
  64477. fontStyle: string;
  64478. /** Gets or sets font weight */
  64479. fontWeight: string;
  64480. /**
  64481. * Gets or sets style
  64482. * @see http://doc.babylonjs.com/how_to/gui#styles
  64483. */
  64484. style: BABYLON.Nullable<Style>;
  64485. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  64486. /** Gets or sets font size in pixels */
  64487. fontSizeInPixels: number;
  64488. /** Gets or sets font size */
  64489. fontSize: string | number;
  64490. /** Gets or sets foreground color */
  64491. color: string;
  64492. /** Gets or sets z index which is used to reorder controls on the z axis */
  64493. zIndex: number;
  64494. /** Gets or sets a boolean indicating if the control can be rendered */
  64495. notRenderable: boolean;
  64496. /** Gets or sets a boolean indicating if the control is visible */
  64497. isVisible: boolean;
  64498. /** Gets a boolean indicating that the control needs to update its rendering */
  64499. readonly isDirty: boolean;
  64500. /**
  64501. * Gets the current linked mesh (or null if none)
  64502. */
  64503. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64504. /**
  64505. * Gets or sets a value indicating the padding to use on the left of the control
  64506. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64507. */
  64508. paddingLeft: string | number;
  64509. /**
  64510. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64511. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64512. */
  64513. paddingLeftInPixels: number;
  64514. /**
  64515. * Gets or sets a value indicating the padding to use on the right of the control
  64516. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64517. */
  64518. paddingRight: string | number;
  64519. /**
  64520. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64521. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64522. */
  64523. paddingRightInPixels: number;
  64524. /**
  64525. * Gets or sets a value indicating the padding to use on the top of the control
  64526. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64527. */
  64528. paddingTop: string | number;
  64529. /**
  64530. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64531. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64532. */
  64533. paddingTopInPixels: number;
  64534. /**
  64535. * Gets or sets a value indicating the padding to use on the bottom of the control
  64536. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64537. */
  64538. paddingBottom: string | number;
  64539. /**
  64540. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64541. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64542. */
  64543. paddingBottomInPixels: number;
  64544. /**
  64545. * Gets or sets a value indicating the left coordinate of the control
  64546. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64547. */
  64548. left: string | number;
  64549. /**
  64550. * Gets or sets a value indicating the left coordinate in pixels of the control
  64551. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64552. */
  64553. leftInPixels: number;
  64554. /**
  64555. * Gets or sets a value indicating the top coordinate of the control
  64556. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64557. */
  64558. top: string | number;
  64559. /**
  64560. * Gets or sets a value indicating the top coordinate in pixels of the control
  64561. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64562. */
  64563. topInPixels: number;
  64564. /**
  64565. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64566. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64567. */
  64568. linkOffsetX: string | number;
  64569. /**
  64570. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64571. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64572. */
  64573. linkOffsetXInPixels: number;
  64574. /**
  64575. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64576. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64577. */
  64578. linkOffsetY: string | number;
  64579. /**
  64580. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64581. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64582. */
  64583. linkOffsetYInPixels: number;
  64584. /** Gets the center coordinate on X axis */
  64585. readonly centerX: number;
  64586. /** Gets the center coordinate on Y axis */
  64587. readonly centerY: number;
  64588. /** Gets or sets if control is Enabled*/
  64589. isEnabled: boolean;
  64590. /** Gets or sets background color of control if it's disabled*/
  64591. disabledColor: string;
  64592. /**
  64593. * Creates a new control
  64594. * @param name defines the name of the control
  64595. */
  64596. constructor(
  64597. /** defines the name of the control */
  64598. name?: string | undefined);
  64599. /** @hidden */
  64600. protected _getTypeName(): string;
  64601. /**
  64602. * Gets the first ascendant in the hierarchy of the given type
  64603. * @param className defines the required type
  64604. * @returns the ascendant or null if not found
  64605. */
  64606. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64607. /** @hidden */ private _resetFontCache(): void;
  64608. /**
  64609. * Determines if a container is an ascendant of the current control
  64610. * @param container defines the container to look for
  64611. * @returns true if the container is one of the ascendant of the control
  64612. */
  64613. isAscendant(container: Control): boolean;
  64614. /**
  64615. * Gets coordinates in local control space
  64616. * @param globalCoordinates defines the coordinates to transform
  64617. * @returns the new coordinates in local space
  64618. */
  64619. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64620. /**
  64621. * Gets coordinates in local control space
  64622. * @param globalCoordinates defines the coordinates to transform
  64623. * @param result defines the target vector2 where to store the result
  64624. * @returns the current control
  64625. */
  64626. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64627. /**
  64628. * Gets coordinates in parent local control space
  64629. * @param globalCoordinates defines the coordinates to transform
  64630. * @returns the new coordinates in parent local space
  64631. */
  64632. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64633. /**
  64634. * Move the current control to a vector3 position projected onto the screen.
  64635. * @param position defines the target position
  64636. * @param scene defines the hosting scene
  64637. */
  64638. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64639. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64640. /**
  64641. * Will return all controls that have this control as ascendant
  64642. * @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
  64643. * @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
  64644. * @return all child controls
  64645. */
  64646. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64647. /**
  64648. * Link current control with a target mesh
  64649. * @param mesh defines the mesh to link with
  64650. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64651. */
  64652. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64653. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64654. /** @hidden */ private _offsetLeft(offset: number): void;
  64655. /** @hidden */ private _offsetTop(offset: number): void;
  64656. /** @hidden */ private _markMatrixAsDirty(): void;
  64657. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  64658. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  64659. /** @hidden */
  64660. protected invalidateRect(): void;
  64661. /** @hidden */ private _markAsDirty(force?: boolean): void;
  64662. /** @hidden */ private _markAllAsDirty(): void;
  64663. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64664. /** @hidden */
  64665. protected _transform(context?: CanvasRenderingContext2D): void;
  64666. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  64667. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64668. /** @hidden */
  64669. protected _applyStates(context: CanvasRenderingContext2D): void;
  64670. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64671. /** @hidden */
  64672. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64673. protected _evaluateClippingState(parentMeasure: Measure): void;
  64674. /** @hidden */ private _measure(): void;
  64675. /** @hidden */
  64676. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64677. /** @hidden */
  64678. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64679. /** @hidden */
  64680. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64681. /** @hidden */
  64682. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64683. private static _ClipMeasure;
  64684. private _tmpMeasureA;
  64685. private _clip;
  64686. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64687. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64688. /**
  64689. * Tests if a given coordinates belong to the current control
  64690. * @param x defines x coordinate to test
  64691. * @param y defines y coordinate to test
  64692. * @returns true if the coordinates are inside the control
  64693. */
  64694. contains(x: number, y: number): boolean;
  64695. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64696. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64697. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  64698. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  64699. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64700. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64701. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64702. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64703. private _prepareFont;
  64704. /** Releases associated resources */
  64705. dispose(): void;
  64706. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64707. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64708. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64709. private static _VERTICAL_ALIGNMENT_TOP;
  64710. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64711. private static _VERTICAL_ALIGNMENT_CENTER;
  64712. /** HORIZONTAL_ALIGNMENT_LEFT */
  64713. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64714. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64715. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64716. /** HORIZONTAL_ALIGNMENT_CENTER */
  64717. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64718. /** VERTICAL_ALIGNMENT_TOP */
  64719. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64720. /** VERTICAL_ALIGNMENT_BOTTOM */
  64721. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64722. /** VERTICAL_ALIGNMENT_CENTER */
  64723. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64724. private static _FontHeightSizes;
  64725. /** @hidden */ private static _GetFontOffset(font: string): {
  64726. ascent: number;
  64727. height: number;
  64728. descent: number;
  64729. };
  64730. /**
  64731. * Creates a stack panel that can be used to render headers
  64732. * @param control defines the control to associate with the header
  64733. * @param text defines the text of the header
  64734. * @param size defines the size of the header
  64735. * @param options defines options used to configure the header
  64736. * @returns a new StackPanel
  64737. * @ignore
  64738. * @hidden
  64739. */
  64740. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64741. isHorizontal: boolean;
  64742. controlFirst: boolean;
  64743. }) => any;
  64744. /** @hidden */
  64745. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64746. }
  64747. }
  64748. declare module BABYLON.GUI {
  64749. /**
  64750. * Root class for 2D containers
  64751. * @see http://doc.babylonjs.com/how_to/gui#containers
  64752. */
  64753. export class Container extends Control {
  64754. name?: string | undefined;
  64755. /** @hidden */
  64756. protected _children: Control[];
  64757. /** @hidden */
  64758. protected _measureForChildren: Measure;
  64759. /** @hidden */
  64760. protected _background: string;
  64761. /** @hidden */
  64762. protected _adaptWidthToChildren: boolean;
  64763. /** @hidden */
  64764. protected _adaptHeightToChildren: boolean;
  64765. /**
  64766. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64767. */
  64768. logLayoutCycleErrors: boolean;
  64769. /**
  64770. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64771. */
  64772. maxLayoutCycle: number;
  64773. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64774. adaptHeightToChildren: boolean;
  64775. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64776. adaptWidthToChildren: boolean;
  64777. /** Gets or sets background color */
  64778. background: string;
  64779. /** Gets the list of children */
  64780. readonly children: Control[];
  64781. /**
  64782. * Creates a new Container
  64783. * @param name defines the name of the container
  64784. */
  64785. constructor(name?: string | undefined);
  64786. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  64787. /**
  64788. * Gets a child using its name
  64789. * @param name defines the child name to look for
  64790. * @returns the child control if found
  64791. */
  64792. getChildByName(name: string): BABYLON.Nullable<Control>;
  64793. /**
  64794. * Gets a child using its type and its name
  64795. * @param name defines the child name to look for
  64796. * @param type defines the child type to look for
  64797. * @returns the child control if found
  64798. */
  64799. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64800. /**
  64801. * Search for a specific control in children
  64802. * @param control defines the control to look for
  64803. * @returns true if the control is in child list
  64804. */
  64805. containsControl(control: Control): boolean;
  64806. /**
  64807. * Adds a new control to the current container
  64808. * @param control defines the control to add
  64809. * @returns the current container
  64810. */
  64811. addControl(control: BABYLON.Nullable<Control>): Container;
  64812. /**
  64813. * Removes all controls from the current container
  64814. * @returns the current container
  64815. */
  64816. clearControls(): Container;
  64817. /**
  64818. * Removes a control from the current container
  64819. * @param control defines the control to remove
  64820. * @returns the current container
  64821. */
  64822. removeControl(control: Control): Container;
  64823. /** @hidden */ private _reOrderControl(control: Control): void;
  64824. /** @hidden */ private _offsetLeft(offset: number): void;
  64825. /** @hidden */ private _offsetTop(offset: number): void;
  64826. /** @hidden */ private _markAllAsDirty(): void;
  64827. /** @hidden */
  64828. protected _localDraw(context: CanvasRenderingContext2D): void;
  64829. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64830. /** @hidden */
  64831. protected _beforeLayout(): void;
  64832. /** @hidden */
  64833. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64834. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64835. protected _postMeasure(): void;
  64836. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64837. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64838. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64839. /** @hidden */
  64840. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64841. /** Releases associated resources */
  64842. dispose(): void;
  64843. }
  64844. }
  64845. declare module BABYLON.GUI {
  64846. /** Class used to create rectangle container */
  64847. export class Rectangle extends Container {
  64848. name?: string | undefined;
  64849. private _thickness;
  64850. private _cornerRadius;
  64851. /** Gets or sets border thickness */
  64852. thickness: number;
  64853. /** Gets or sets the corner radius angle */
  64854. cornerRadius: number;
  64855. /**
  64856. * Creates a new Rectangle
  64857. * @param name defines the control name
  64858. */
  64859. constructor(name?: string | undefined);
  64860. protected _getTypeName(): string;
  64861. protected _localDraw(context: CanvasRenderingContext2D): void;
  64862. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64863. private _drawRoundedRect;
  64864. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64865. }
  64866. }
  64867. declare module BABYLON.GUI {
  64868. /**
  64869. * Enum that determines the text-wrapping mode to use.
  64870. */
  64871. export enum TextWrapping {
  64872. /**
  64873. * Clip the text when it's larger than Control.width; this is the default mode.
  64874. */
  64875. Clip = 0,
  64876. /**
  64877. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64878. */
  64879. WordWrap = 1,
  64880. /**
  64881. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64882. */
  64883. Ellipsis = 2
  64884. }
  64885. /**
  64886. * Class used to create text block control
  64887. */
  64888. export class TextBlock extends Control {
  64889. /**
  64890. * Defines the name of the control
  64891. */
  64892. name?: string | undefined;
  64893. private _text;
  64894. private _textWrapping;
  64895. private _textHorizontalAlignment;
  64896. private _textVerticalAlignment;
  64897. private _lines;
  64898. private _resizeToFit;
  64899. private _lineSpacing;
  64900. private _outlineWidth;
  64901. private _outlineColor;
  64902. /**
  64903. * An event triggered after the text is changed
  64904. */
  64905. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64906. /**
  64907. * An event triggered after the text was broken up into lines
  64908. */
  64909. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64910. /**
  64911. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64912. */
  64913. readonly lines: any[];
  64914. /**
  64915. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64916. */
  64917. /**
  64918. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64919. */
  64920. resizeToFit: boolean;
  64921. /**
  64922. * Gets or sets a boolean indicating if text must be wrapped
  64923. */
  64924. /**
  64925. * Gets or sets a boolean indicating if text must be wrapped
  64926. */
  64927. textWrapping: TextWrapping | boolean;
  64928. /**
  64929. * Gets or sets text to display
  64930. */
  64931. /**
  64932. * Gets or sets text to display
  64933. */
  64934. text: string;
  64935. /**
  64936. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64937. */
  64938. /**
  64939. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64940. */
  64941. textHorizontalAlignment: number;
  64942. /**
  64943. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64944. */
  64945. /**
  64946. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64947. */
  64948. textVerticalAlignment: number;
  64949. /**
  64950. * Gets or sets line spacing value
  64951. */
  64952. /**
  64953. * Gets or sets line spacing value
  64954. */
  64955. lineSpacing: string | number;
  64956. /**
  64957. * Gets or sets outlineWidth of the text to display
  64958. */
  64959. /**
  64960. * Gets or sets outlineWidth of the text to display
  64961. */
  64962. outlineWidth: number;
  64963. /**
  64964. * Gets or sets outlineColor of the text to display
  64965. */
  64966. /**
  64967. * Gets or sets outlineColor of the text to display
  64968. */
  64969. outlineColor: string;
  64970. /**
  64971. * Creates a new TextBlock object
  64972. * @param name defines the name of the control
  64973. * @param text defines the text to display (emptry string by default)
  64974. */
  64975. constructor(
  64976. /**
  64977. * Defines the name of the control
  64978. */
  64979. name?: string | undefined, text?: string);
  64980. protected _getTypeName(): string;
  64981. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64982. private _drawText;
  64983. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64984. protected _applyStates(context: CanvasRenderingContext2D): void;
  64985. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64986. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64987. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64988. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64989. protected _renderLines(context: CanvasRenderingContext2D): void;
  64990. /**
  64991. * Given a width constraint applied on the text block, find the expected height
  64992. * @returns expected height
  64993. */
  64994. computeExpectedHeight(): number;
  64995. dispose(): void;
  64996. }
  64997. }
  64998. declare module BABYLON.GUI {
  64999. /**
  65000. * Class used to create 2D images
  65001. */
  65002. export class Image extends Control {
  65003. name?: string | undefined;
  65004. private static _WorkingCanvas;
  65005. private _domImage;
  65006. private _imageWidth;
  65007. private _imageHeight;
  65008. private _loaded;
  65009. private _stretch;
  65010. private _source;
  65011. private _autoScale;
  65012. private _sourceLeft;
  65013. private _sourceTop;
  65014. private _sourceWidth;
  65015. private _sourceHeight;
  65016. private _cellWidth;
  65017. private _cellHeight;
  65018. private _cellId;
  65019. private _populateNinePatchSlicesFromImage;
  65020. private _sliceLeft;
  65021. private _sliceRight;
  65022. private _sliceTop;
  65023. private _sliceBottom;
  65024. private _detectPointerOnOpaqueOnly;
  65025. /**
  65026. * BABYLON.Observable notified when the content is loaded
  65027. */
  65028. onImageLoadedObservable: BABYLON.Observable<Image>;
  65029. /**
  65030. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65031. */
  65032. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65033. /**
  65034. * Gets a boolean indicating that the content is loaded
  65035. */
  65036. readonly isLoaded: boolean;
  65037. /**
  65038. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65039. */
  65040. populateNinePatchSlicesFromImage: boolean;
  65041. /**
  65042. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65043. * Beware using this as this will comsume more memory as the image has to be stored twice
  65044. */
  65045. detectPointerOnOpaqueOnly: boolean;
  65046. /**
  65047. * Gets or sets the left value for slicing (9-patch)
  65048. */
  65049. sliceLeft: number;
  65050. /**
  65051. * Gets or sets the right value for slicing (9-patch)
  65052. */
  65053. sliceRight: number;
  65054. /**
  65055. * Gets or sets the top value for slicing (9-patch)
  65056. */
  65057. sliceTop: number;
  65058. /**
  65059. * Gets or sets the bottom value for slicing (9-patch)
  65060. */
  65061. sliceBottom: number;
  65062. /**
  65063. * Gets or sets the left coordinate in the source image
  65064. */
  65065. sourceLeft: number;
  65066. /**
  65067. * Gets or sets the top coordinate in the source image
  65068. */
  65069. sourceTop: number;
  65070. /**
  65071. * Gets or sets the width to capture in the source image
  65072. */
  65073. sourceWidth: number;
  65074. /**
  65075. * Gets or sets the height to capture in the source image
  65076. */
  65077. sourceHeight: number;
  65078. /**
  65079. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65080. * @see http://doc.babylonjs.com/how_to/gui#image
  65081. */
  65082. autoScale: boolean;
  65083. /** Gets or sets the streching mode used by the image */
  65084. stretch: number;
  65085. /**
  65086. * Gets or sets the internal DOM image used to render the control
  65087. */
  65088. domImage: HTMLImageElement;
  65089. private _onImageLoaded;
  65090. private _extractNinePatchSliceDataFromImage;
  65091. /**
  65092. * Gets or sets image source url
  65093. */
  65094. source: BABYLON.Nullable<string>;
  65095. /**
  65096. * Checks for svg document with icon id present
  65097. */
  65098. private _svgCheck;
  65099. /**
  65100. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65101. * given external svg file and icon id
  65102. */
  65103. private _getSVGAttribs;
  65104. /**
  65105. * Gets or sets the cell width to use when animation sheet is enabled
  65106. * @see http://doc.babylonjs.com/how_to/gui#image
  65107. */
  65108. cellWidth: number;
  65109. /**
  65110. * Gets or sets the cell height to use when animation sheet is enabled
  65111. * @see http://doc.babylonjs.com/how_to/gui#image
  65112. */
  65113. cellHeight: number;
  65114. /**
  65115. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65116. * @see http://doc.babylonjs.com/how_to/gui#image
  65117. */
  65118. cellId: number;
  65119. /**
  65120. * Creates a new Image
  65121. * @param name defines the control name
  65122. * @param url defines the image url
  65123. */
  65124. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65125. /**
  65126. * Tests if a given coordinates belong to the current control
  65127. * @param x defines x coordinate to test
  65128. * @param y defines y coordinate to test
  65129. * @returns true if the coordinates are inside the control
  65130. */
  65131. contains(x: number, y: number): boolean;
  65132. protected _getTypeName(): string;
  65133. /** Force the control to synchronize with its content */
  65134. synchronizeSizeWithContent(): void;
  65135. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65136. private _prepareWorkingCanvasForOpaqueDetection;
  65137. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  65138. private _renderCornerPatch;
  65139. private _renderNinePatch;
  65140. dispose(): void;
  65141. /** STRETCH_NONE */
  65142. static readonly STRETCH_NONE: number;
  65143. /** STRETCH_FILL */
  65144. static readonly STRETCH_FILL: number;
  65145. /** STRETCH_UNIFORM */
  65146. static readonly STRETCH_UNIFORM: number;
  65147. /** STRETCH_EXTEND */
  65148. static readonly STRETCH_EXTEND: number;
  65149. /** NINE_PATCH */
  65150. static readonly STRETCH_NINE_PATCH: number;
  65151. }
  65152. }
  65153. declare module BABYLON.GUI {
  65154. /**
  65155. * Class used to create 2D buttons
  65156. */
  65157. export class Button extends Rectangle {
  65158. name?: string | undefined;
  65159. /**
  65160. * Function called to generate a pointer enter animation
  65161. */
  65162. pointerEnterAnimation: () => void;
  65163. /**
  65164. * Function called to generate a pointer out animation
  65165. */
  65166. pointerOutAnimation: () => void;
  65167. /**
  65168. * Function called to generate a pointer down animation
  65169. */
  65170. pointerDownAnimation: () => void;
  65171. /**
  65172. * Function called to generate a pointer up animation
  65173. */
  65174. pointerUpAnimation: () => void;
  65175. /**
  65176. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65177. */
  65178. delegatePickingToChildren: boolean;
  65179. private _image;
  65180. /**
  65181. * Returns the image part of the button (if any)
  65182. */
  65183. readonly image: BABYLON.Nullable<Image>;
  65184. private _textBlock;
  65185. /**
  65186. * Returns the image part of the button (if any)
  65187. */
  65188. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65189. /**
  65190. * Creates a new Button
  65191. * @param name defines the name of the button
  65192. */
  65193. constructor(name?: string | undefined);
  65194. protected _getTypeName(): string;
  65195. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65196. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  65197. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  65198. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65199. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65200. /**
  65201. * Creates a new button made with an image and a text
  65202. * @param name defines the name of the button
  65203. * @param text defines the text of the button
  65204. * @param imageUrl defines the url of the image
  65205. * @returns a new Button
  65206. */
  65207. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65208. /**
  65209. * Creates a new button made with an image
  65210. * @param name defines the name of the button
  65211. * @param imageUrl defines the url of the image
  65212. * @returns a new Button
  65213. */
  65214. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65215. /**
  65216. * Creates a new button made with a text
  65217. * @param name defines the name of the button
  65218. * @param text defines the text of the button
  65219. * @returns a new Button
  65220. */
  65221. static CreateSimpleButton(name: string, text: string): Button;
  65222. /**
  65223. * Creates a new button made with an image and a centered text
  65224. * @param name defines the name of the button
  65225. * @param text defines the text of the button
  65226. * @param imageUrl defines the url of the image
  65227. * @returns a new Button
  65228. */
  65229. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65230. }
  65231. }
  65232. declare module BABYLON.GUI {
  65233. /**
  65234. * Class used to create a 2D stack panel container
  65235. */
  65236. export class StackPanel extends Container {
  65237. name?: string | undefined;
  65238. private _isVertical;
  65239. private _manualWidth;
  65240. private _manualHeight;
  65241. private _doNotTrackManualChanges;
  65242. /**
  65243. * Gets or sets a boolean indicating that layou warnings should be ignored
  65244. */
  65245. ignoreLayoutWarnings: boolean;
  65246. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65247. isVertical: boolean;
  65248. /**
  65249. * Gets or sets panel width.
  65250. * This value should not be set when in horizontal mode as it will be computed automatically
  65251. */
  65252. width: string | number;
  65253. /**
  65254. * Gets or sets panel height.
  65255. * This value should not be set when in vertical mode as it will be computed automatically
  65256. */
  65257. height: string | number;
  65258. /**
  65259. * Creates a new StackPanel
  65260. * @param name defines control name
  65261. */
  65262. constructor(name?: string | undefined);
  65263. protected _getTypeName(): string;
  65264. /** @hidden */
  65265. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65266. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65267. protected _postMeasure(): void;
  65268. }
  65269. }
  65270. declare module BABYLON.GUI {
  65271. /**
  65272. * Class used to represent a 2D checkbox
  65273. */
  65274. export class Checkbox extends Control {
  65275. name?: string | undefined;
  65276. private _isChecked;
  65277. private _background;
  65278. private _checkSizeRatio;
  65279. private _thickness;
  65280. /** Gets or sets border thickness */
  65281. thickness: number;
  65282. /**
  65283. * BABYLON.Observable raised when isChecked property changes
  65284. */
  65285. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65286. /** Gets or sets a value indicating the ratio between overall size and check size */
  65287. checkSizeRatio: number;
  65288. /** Gets or sets background color */
  65289. background: string;
  65290. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65291. isChecked: boolean;
  65292. /**
  65293. * Creates a new CheckBox
  65294. * @param name defines the control name
  65295. */
  65296. constructor(name?: string | undefined);
  65297. protected _getTypeName(): string;
  65298. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65299. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65300. /**
  65301. * Utility function to easily create a checkbox with a header
  65302. * @param title defines the label to use for the header
  65303. * @param onValueChanged defines the callback to call when value changes
  65304. * @returns a StackPanel containing the checkbox and a textBlock
  65305. */
  65306. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65307. }
  65308. }
  65309. declare module BABYLON.GUI {
  65310. /**
  65311. * Class used to store key control properties
  65312. */
  65313. export class KeyPropertySet {
  65314. /** Width */
  65315. width?: string;
  65316. /** Height */
  65317. height?: string;
  65318. /** Left padding */
  65319. paddingLeft?: string;
  65320. /** Right padding */
  65321. paddingRight?: string;
  65322. /** Top padding */
  65323. paddingTop?: string;
  65324. /** Bottom padding */
  65325. paddingBottom?: string;
  65326. /** Foreground color */
  65327. color?: string;
  65328. /** Background color */
  65329. background?: string;
  65330. }
  65331. /**
  65332. * Class used to create virtual keyboard
  65333. */
  65334. export class VirtualKeyboard extends StackPanel {
  65335. /** BABYLON.Observable raised when a key is pressed */
  65336. onKeyPressObservable: BABYLON.Observable<string>;
  65337. /** Gets or sets default key button width */
  65338. defaultButtonWidth: string;
  65339. /** Gets or sets default key button height */
  65340. defaultButtonHeight: string;
  65341. /** Gets or sets default key button left padding */
  65342. defaultButtonPaddingLeft: string;
  65343. /** Gets or sets default key button right padding */
  65344. defaultButtonPaddingRight: string;
  65345. /** Gets or sets default key button top padding */
  65346. defaultButtonPaddingTop: string;
  65347. /** Gets or sets default key button bottom padding */
  65348. defaultButtonPaddingBottom: string;
  65349. /** Gets or sets default key button foreground color */
  65350. defaultButtonColor: string;
  65351. /** Gets or sets default key button background color */
  65352. defaultButtonBackground: string;
  65353. /** Gets or sets shift button foreground color */
  65354. shiftButtonColor: string;
  65355. /** Gets or sets shift button thickness*/
  65356. selectedShiftThickness: number;
  65357. /** Gets shift key state */
  65358. shiftState: number;
  65359. protected _getTypeName(): string;
  65360. private _createKey;
  65361. /**
  65362. * Adds a new row of keys
  65363. * @param keys defines the list of keys to add
  65364. * @param propertySets defines the associated property sets
  65365. */
  65366. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65367. /**
  65368. * Set the shift key to a specific state
  65369. * @param shiftState defines the new shift state
  65370. */
  65371. applyShiftState(shiftState: number): void;
  65372. private _currentlyConnectedInputText;
  65373. private _connectedInputTexts;
  65374. private _onKeyPressObserver;
  65375. /** Gets the input text control currently attached to the keyboard */
  65376. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65377. /**
  65378. * Connects the keyboard with an input text control
  65379. *
  65380. * @param input defines the target control
  65381. */
  65382. connect(input: InputText): void;
  65383. /**
  65384. * Disconnects the keyboard from connected InputText controls
  65385. *
  65386. * @param input optionally defines a target control, otherwise all are disconnected
  65387. */
  65388. disconnect(input?: InputText): void;
  65389. private _removeConnectedInputObservables;
  65390. /**
  65391. * Release all resources
  65392. */
  65393. dispose(): void;
  65394. /**
  65395. * Creates a new keyboard using a default layout
  65396. *
  65397. * @param name defines control name
  65398. * @returns a new VirtualKeyboard
  65399. */
  65400. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65401. }
  65402. }
  65403. declare module BABYLON.GUI {
  65404. /**
  65405. * Class used to create input text control
  65406. */
  65407. export class InputText extends Control implements IFocusableControl {
  65408. name?: string | undefined;
  65409. private _text;
  65410. private _placeholderText;
  65411. private _background;
  65412. private _focusedBackground;
  65413. private _focusedColor;
  65414. private _placeholderColor;
  65415. private _thickness;
  65416. private _margin;
  65417. private _autoStretchWidth;
  65418. private _maxWidth;
  65419. private _isFocused;
  65420. private _blinkTimeout;
  65421. private _blinkIsEven;
  65422. private _cursorOffset;
  65423. private _scrollLeft;
  65424. private _textWidth;
  65425. private _clickedCoordinate;
  65426. private _deadKey;
  65427. private _addKey;
  65428. private _currentKey;
  65429. private _isTextHighlightOn;
  65430. private _textHighlightColor;
  65431. private _highligherOpacity;
  65432. private _highlightedText;
  65433. private _startHighlightIndex;
  65434. private _endHighlightIndex;
  65435. private _cursorIndex;
  65436. private _onFocusSelectAll;
  65437. private _isPointerDown;
  65438. private _onClipboardObserver;
  65439. private _onPointerDblTapObserver;
  65440. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65441. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65442. promptMessage: string;
  65443. /** Force disable prompt on mobile device */
  65444. disableMobilePrompt: boolean;
  65445. /** BABYLON.Observable raised when the text changes */
  65446. onTextChangedObservable: BABYLON.Observable<InputText>;
  65447. /** BABYLON.Observable raised just before an entered character is to be added */
  65448. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65449. /** BABYLON.Observable raised when the control gets the focus */
  65450. onFocusObservable: BABYLON.Observable<InputText>;
  65451. /** BABYLON.Observable raised when the control loses the focus */
  65452. onBlurObservable: BABYLON.Observable<InputText>;
  65453. /**Observable raised when the text is highlighted */
  65454. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65455. /**Observable raised when copy event is triggered */
  65456. onTextCopyObservable: BABYLON.Observable<InputText>;
  65457. /** BABYLON.Observable raised when cut event is triggered */
  65458. onTextCutObservable: BABYLON.Observable<InputText>;
  65459. /** BABYLON.Observable raised when paste event is triggered */
  65460. onTextPasteObservable: BABYLON.Observable<InputText>;
  65461. /** BABYLON.Observable raised when a key event was processed */
  65462. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65463. /** Gets or sets the maximum width allowed by the control */
  65464. maxWidth: string | number;
  65465. /** Gets the maximum width allowed by the control in pixels */
  65466. readonly maxWidthInPixels: number;
  65467. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65468. highligherOpacity: number;
  65469. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65470. onFocusSelectAll: boolean;
  65471. /** Gets or sets the text hightlight color */
  65472. textHighlightColor: string;
  65473. /** Gets or sets control margin */
  65474. margin: string;
  65475. /** Gets control margin in pixels */
  65476. readonly marginInPixels: number;
  65477. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65478. autoStretchWidth: boolean;
  65479. /** Gets or sets border thickness */
  65480. thickness: number;
  65481. /** Gets or sets the background color when focused */
  65482. focusedBackground: string;
  65483. /** Gets or sets the background color when focused */
  65484. focusedColor: string;
  65485. /** Gets or sets the background color */
  65486. background: string;
  65487. /** Gets or sets the placeholder color */
  65488. placeholderColor: string;
  65489. /** Gets or sets the text displayed when the control is empty */
  65490. placeholderText: string;
  65491. /** Gets or sets the dead key flag */
  65492. deadKey: boolean;
  65493. /** Gets or sets the highlight text */
  65494. highlightedText: string;
  65495. /** Gets or sets if the current key should be added */
  65496. addKey: boolean;
  65497. /** Gets or sets the value of the current key being entered */
  65498. currentKey: string;
  65499. /** Gets or sets the text displayed in the control */
  65500. text: string;
  65501. /** Gets or sets control width */
  65502. width: string | number;
  65503. /**
  65504. * Creates a new InputText
  65505. * @param name defines the control name
  65506. * @param text defines the text of the control
  65507. */
  65508. constructor(name?: string | undefined, text?: string);
  65509. /** @hidden */
  65510. onBlur(): void;
  65511. /** @hidden */
  65512. onFocus(): void;
  65513. protected _getTypeName(): string;
  65514. /**
  65515. * Function called to get the list of controls that should not steal the focus from this control
  65516. * @returns an array of controls
  65517. */
  65518. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65519. /** @hidden */
  65520. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65521. /** @hidden */
  65522. private _updateValueFromCursorIndex;
  65523. /** @hidden */
  65524. private _processDblClick;
  65525. /** @hidden */
  65526. private _selectAllText;
  65527. /**
  65528. * Handles the keyboard event
  65529. * @param evt Defines the KeyboardEvent
  65530. */
  65531. processKeyboard(evt: KeyboardEvent): void;
  65532. /** @hidden */
  65533. private _onCopyText;
  65534. /** @hidden */
  65535. private _onCutText;
  65536. /** @hidden */
  65537. 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;
  65538. protected _beforeRenderText(text: string): string;
  65539. dispose(): void;
  65540. }
  65541. }
  65542. declare module BABYLON.GUI {
  65543. /**
  65544. * Class used to create a 2D grid container
  65545. */
  65546. export class Grid extends Container {
  65547. name?: string | undefined;
  65548. private _rowDefinitions;
  65549. private _columnDefinitions;
  65550. private _cells;
  65551. private _childControls;
  65552. /**
  65553. * Gets the number of columns
  65554. */
  65555. readonly columnCount: number;
  65556. /**
  65557. * Gets the number of rows
  65558. */
  65559. readonly rowCount: number;
  65560. /** Gets the list of children */
  65561. readonly children: Control[];
  65562. /** Gets the list of cells (e.g. the containers) */
  65563. readonly cells: {
  65564. [key: string]: Container;
  65565. };
  65566. /**
  65567. * Gets the definition of a specific row
  65568. * @param index defines the index of the row
  65569. * @returns the row definition
  65570. */
  65571. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65572. /**
  65573. * Gets the definition of a specific column
  65574. * @param index defines the index of the column
  65575. * @returns the column definition
  65576. */
  65577. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65578. /**
  65579. * Adds a new row to the grid
  65580. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65581. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65582. * @returns the current grid
  65583. */
  65584. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65585. /**
  65586. * Adds a new column to the grid
  65587. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65588. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65589. * @returns the current grid
  65590. */
  65591. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65592. /**
  65593. * Update a row definition
  65594. * @param index defines the index of the row to update
  65595. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65596. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65597. * @returns the current grid
  65598. */
  65599. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65600. /**
  65601. * Update a column definition
  65602. * @param index defines the index of the column to update
  65603. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65604. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65605. * @returns the current grid
  65606. */
  65607. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65608. /**
  65609. * Gets the list of children stored in a specific cell
  65610. * @param row defines the row to check
  65611. * @param column defines the column to check
  65612. * @returns the list of controls
  65613. */
  65614. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65615. /**
  65616. * Gets a string representing the child cell info (row x column)
  65617. * @param child defines the control to get info from
  65618. * @returns a string containing the child cell info (row x column)
  65619. */
  65620. getChildCellInfo(child: Control): string;
  65621. private _removeCell;
  65622. private _offsetCell;
  65623. /**
  65624. * Remove a column definition at specified index
  65625. * @param index defines the index of the column to remove
  65626. * @returns the current grid
  65627. */
  65628. removeColumnDefinition(index: number): Grid;
  65629. /**
  65630. * Remove a row definition at specified index
  65631. * @param index defines the index of the row to remove
  65632. * @returns the current grid
  65633. */
  65634. removeRowDefinition(index: number): Grid;
  65635. /**
  65636. * Adds a new control to the current grid
  65637. * @param control defines the control to add
  65638. * @param row defines the row where to add the control (0 by default)
  65639. * @param column defines the column where to add the control (0 by default)
  65640. * @returns the current grid
  65641. */
  65642. addControl(control: Control, row?: number, column?: number): Grid;
  65643. /**
  65644. * Removes a control from the current container
  65645. * @param control defines the control to remove
  65646. * @returns the current container
  65647. */
  65648. removeControl(control: Control): Container;
  65649. /**
  65650. * Creates a new Grid
  65651. * @param name defines control name
  65652. */
  65653. constructor(name?: string | undefined);
  65654. protected _getTypeName(): string;
  65655. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65656. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65657. /** Releases associated resources */
  65658. dispose(): void;
  65659. }
  65660. }
  65661. declare module BABYLON.GUI {
  65662. /** Class used to create color pickers */
  65663. export class ColorPicker extends Control {
  65664. name?: string | undefined;
  65665. private static _Epsilon;
  65666. private _colorWheelCanvas;
  65667. private _value;
  65668. private _tmpColor;
  65669. private _pointerStartedOnSquare;
  65670. private _pointerStartedOnWheel;
  65671. private _squareLeft;
  65672. private _squareTop;
  65673. private _squareSize;
  65674. private _h;
  65675. private _s;
  65676. private _v;
  65677. private _lastPointerDownID;
  65678. /**
  65679. * BABYLON.Observable raised when the value changes
  65680. */
  65681. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65682. /** Gets or sets the color of the color picker */
  65683. value: BABYLON.Color3;
  65684. /**
  65685. * Gets or sets control width
  65686. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65687. */
  65688. width: string | number;
  65689. /**
  65690. * Gets or sets control height
  65691. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65692. */
  65693. /** Gets or sets control height */
  65694. height: string | number;
  65695. /** Gets or sets control size */
  65696. size: string | number;
  65697. /**
  65698. * Creates a new ColorPicker
  65699. * @param name defines the control name
  65700. */
  65701. constructor(name?: string | undefined);
  65702. protected _getTypeName(): string;
  65703. /** @hidden */
  65704. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65705. private _updateSquareProps;
  65706. private _drawGradientSquare;
  65707. private _drawCircle;
  65708. private _createColorWheelCanvas;
  65709. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65710. private _pointerIsDown;
  65711. private _updateValueFromPointer;
  65712. private _isPointOnSquare;
  65713. 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;
  65714. /**
  65715. * This function expands the color picker by creating a color picker dialog with manual
  65716. * color value input and the ability to save colors into an array to be used later in
  65717. * subsequent launches of the dialogue.
  65718. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65719. * @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.
  65720. * @returns picked color as a hex string and the saved colors array as hex strings.
  65721. */
  65722. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65723. pickerWidth?: string;
  65724. pickerHeight?: string;
  65725. headerHeight?: string;
  65726. lastColor?: string;
  65727. swatchLimit?: number;
  65728. numSwatchesPerLine?: number;
  65729. savedColors?: Array<string>;
  65730. }): Promise<{
  65731. savedColors?: string[];
  65732. pickedColor: string;
  65733. }>;
  65734. }
  65735. }
  65736. declare module BABYLON.GUI {
  65737. /** Class used to create 2D ellipse containers */
  65738. export class Ellipse extends Container {
  65739. name?: string | undefined;
  65740. private _thickness;
  65741. /** Gets or sets border thickness */
  65742. thickness: number;
  65743. /**
  65744. * Creates a new Ellipse
  65745. * @param name defines the control name
  65746. */
  65747. constructor(name?: string | undefined);
  65748. protected _getTypeName(): string;
  65749. protected _localDraw(context: CanvasRenderingContext2D): void;
  65750. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65751. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65752. }
  65753. }
  65754. declare module BABYLON.GUI {
  65755. /**
  65756. * Class used to create a password control
  65757. */
  65758. export class InputPassword extends InputText {
  65759. protected _beforeRenderText(text: string): string;
  65760. }
  65761. }
  65762. declare module BABYLON.GUI {
  65763. /** Class used to render 2D lines */
  65764. export class Line extends Control {
  65765. name?: string | undefined;
  65766. private _lineWidth;
  65767. private _x1;
  65768. private _y1;
  65769. private _x2;
  65770. private _y2;
  65771. private _dash;
  65772. private _connectedControl;
  65773. private _connectedControlDirtyObserver;
  65774. /** Gets or sets the dash pattern */
  65775. dash: Array<number>;
  65776. /** Gets or sets the control connected with the line end */
  65777. connectedControl: Control;
  65778. /** Gets or sets start coordinates on X axis */
  65779. x1: string | number;
  65780. /** Gets or sets start coordinates on Y axis */
  65781. y1: string | number;
  65782. /** Gets or sets end coordinates on X axis */
  65783. x2: string | number;
  65784. /** Gets or sets end coordinates on Y axis */
  65785. y2: string | number;
  65786. /** Gets or sets line width */
  65787. lineWidth: number;
  65788. /** Gets or sets horizontal alignment */
  65789. horizontalAlignment: number;
  65790. /** Gets or sets vertical alignment */
  65791. verticalAlignment: number;
  65792. private readonly _effectiveX2;
  65793. private readonly _effectiveY2;
  65794. /**
  65795. * Creates a new Line
  65796. * @param name defines the control name
  65797. */
  65798. constructor(name?: string | undefined);
  65799. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  65800. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65801. /**
  65802. * Move one end of the line given 3D cartesian coordinates.
  65803. * @param position Targeted world position
  65804. * @param scene BABYLON.Scene
  65805. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65806. */
  65807. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65808. /**
  65809. * Move one end of the line to a position in screen absolute space.
  65810. * @param projectedPosition Position in screen absolute space (X, Y)
  65811. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65812. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65813. }
  65814. }
  65815. declare module BABYLON.GUI {
  65816. /**
  65817. * Class used to store a point for a MultiLine object.
  65818. * The point can be pure 2D coordinates, a mesh or a control
  65819. */
  65820. export class MultiLinePoint {
  65821. private _multiLine;
  65822. private _x;
  65823. private _y;
  65824. private _control;
  65825. private _mesh;
  65826. private _controlObserver;
  65827. private _meshObserver;
  65828. /** @hidden */ private _point: BABYLON.Vector2;
  65829. /**
  65830. * Creates a new MultiLinePoint
  65831. * @param multiLine defines the source MultiLine object
  65832. */
  65833. constructor(multiLine: MultiLine);
  65834. /** Gets or sets x coordinate */
  65835. x: string | number;
  65836. /** Gets or sets y coordinate */
  65837. y: string | number;
  65838. /** Gets or sets the control associated with this point */
  65839. control: BABYLON.Nullable<Control>;
  65840. /** Gets or sets the mesh associated with this point */
  65841. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65842. /** Resets links */
  65843. resetLinks(): void;
  65844. /**
  65845. * Gets a translation vector
  65846. * @returns the translation vector
  65847. */
  65848. translate(): BABYLON.Vector2;
  65849. private _translatePoint;
  65850. /** Release associated resources */
  65851. dispose(): void;
  65852. }
  65853. }
  65854. declare module BABYLON.GUI {
  65855. /**
  65856. * Class used to create multi line control
  65857. */
  65858. export class MultiLine extends Control {
  65859. name?: string | undefined;
  65860. private _lineWidth;
  65861. private _dash;
  65862. private _points;
  65863. private _minX;
  65864. private _minY;
  65865. private _maxX;
  65866. private _maxY;
  65867. /**
  65868. * Creates a new MultiLine
  65869. * @param name defines the control name
  65870. */
  65871. constructor(name?: string | undefined);
  65872. /** Gets or sets dash pattern */
  65873. dash: Array<number>;
  65874. /**
  65875. * Gets point stored at specified index
  65876. * @param index defines the index to look for
  65877. * @returns the requested point if found
  65878. */
  65879. getAt(index: number): MultiLinePoint;
  65880. /** Function called when a point is updated */
  65881. onPointUpdate: () => void;
  65882. /**
  65883. * Adds new points to the point collection
  65884. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65885. * @returns the list of created MultiLinePoint
  65886. */
  65887. add(...items: (AbstractMesh | Control | {
  65888. x: string | number;
  65889. y: string | number;
  65890. })[]): MultiLinePoint[];
  65891. /**
  65892. * Adds a new point to the point collection
  65893. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65894. * @returns the created MultiLinePoint
  65895. */
  65896. push(item?: (AbstractMesh | Control | {
  65897. x: string | number;
  65898. y: string | number;
  65899. })): MultiLinePoint;
  65900. /**
  65901. * Remove a specific value or point from the active point collection
  65902. * @param value defines the value or point to remove
  65903. */
  65904. remove(value: number | MultiLinePoint): void;
  65905. /**
  65906. * Resets this object to initial state (no point)
  65907. */
  65908. reset(): void;
  65909. /**
  65910. * Resets all links
  65911. */
  65912. resetLinks(): void;
  65913. /** Gets or sets line width */
  65914. lineWidth: number;
  65915. horizontalAlignment: number;
  65916. verticalAlignment: number;
  65917. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65918. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  65919. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65920. dispose(): void;
  65921. }
  65922. }
  65923. declare module BABYLON.GUI {
  65924. /**
  65925. * Class used to create radio button controls
  65926. */
  65927. export class RadioButton extends Control {
  65928. name?: string | undefined;
  65929. private _isChecked;
  65930. private _background;
  65931. private _checkSizeRatio;
  65932. private _thickness;
  65933. /** Gets or sets border thickness */
  65934. thickness: number;
  65935. /** Gets or sets group name */
  65936. group: string;
  65937. /** BABYLON.Observable raised when isChecked is changed */
  65938. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65939. /** Gets or sets a value indicating the ratio between overall size and check size */
  65940. checkSizeRatio: number;
  65941. /** Gets or sets background color */
  65942. background: string;
  65943. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65944. isChecked: boolean;
  65945. /**
  65946. * Creates a new RadioButton
  65947. * @param name defines the control name
  65948. */
  65949. constructor(name?: string | undefined);
  65950. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65951. /**
  65952. * Utility function to easily create a radio button with a header
  65953. * @param title defines the label to use for the header
  65954. * @param group defines the group to use for the radio button
  65955. * @param isChecked defines the initial state of the radio button
  65956. * @param onValueChanged defines the callback to call when value changes
  65957. * @returns a StackPanel containing the radio button and a textBlock
  65958. */
  65959. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65960. }
  65961. }
  65962. declare module BABYLON.GUI {
  65963. /**
  65964. * Class used to create slider controls
  65965. */
  65966. export class BaseSlider extends Control {
  65967. name?: string | undefined;
  65968. protected _thumbWidth: ValueAndUnit;
  65969. private _minimum;
  65970. private _maximum;
  65971. private _value;
  65972. private _isVertical;
  65973. protected _barOffset: ValueAndUnit;
  65974. private _isThumbClamped;
  65975. protected _displayThumb: boolean;
  65976. private _step;
  65977. private _lastPointerDownID;
  65978. protected _effectiveBarOffset: number;
  65979. protected _renderLeft: number;
  65980. protected _renderTop: number;
  65981. protected _renderWidth: number;
  65982. protected _renderHeight: number;
  65983. protected _backgroundBoxLength: number;
  65984. protected _backgroundBoxThickness: number;
  65985. protected _effectiveThumbThickness: number;
  65986. /** BABYLON.Observable raised when the sldier value changes */
  65987. onValueChangedObservable: BABYLON.Observable<number>;
  65988. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65989. displayThumb: boolean;
  65990. /** Gets or sets a step to apply to values (0 by default) */
  65991. step: number;
  65992. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65993. barOffset: string | number;
  65994. /** Gets main bar offset in pixels*/
  65995. readonly barOffsetInPixels: number;
  65996. /** Gets or sets thumb width */
  65997. thumbWidth: string | number;
  65998. /** Gets thumb width in pixels */
  65999. readonly thumbWidthInPixels: number;
  66000. /** Gets or sets minimum value */
  66001. minimum: number;
  66002. /** Gets or sets maximum value */
  66003. maximum: number;
  66004. /** Gets or sets current value */
  66005. value: number;
  66006. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66007. isVertical: boolean;
  66008. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66009. isThumbClamped: boolean;
  66010. /**
  66011. * Creates a new BaseSlider
  66012. * @param name defines the control name
  66013. */
  66014. constructor(name?: string | undefined);
  66015. protected _getTypeName(): string;
  66016. protected _getThumbPosition(): number;
  66017. protected _getThumbThickness(type: string): number;
  66018. protected _prepareRenderingData(type: string): void;
  66019. private _pointerIsDown;
  66020. /** @hidden */
  66021. 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;
  66022. }
  66023. }
  66024. declare module BABYLON.GUI {
  66025. /**
  66026. * Class used to create slider controls
  66027. */
  66028. export class Slider extends BaseSlider {
  66029. name?: string | undefined;
  66030. private _background;
  66031. private _borderColor;
  66032. private _isThumbCircle;
  66033. protected _displayValueBar: boolean;
  66034. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66035. displayValueBar: boolean;
  66036. /** Gets or sets border color */
  66037. borderColor: string;
  66038. /** Gets or sets background color */
  66039. background: string;
  66040. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66041. isThumbCircle: boolean;
  66042. /**
  66043. * Creates a new Slider
  66044. * @param name defines the control name
  66045. */
  66046. constructor(name?: string | undefined);
  66047. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66048. }
  66049. }
  66050. declare module BABYLON.GUI {
  66051. /** Class used to create a RadioGroup
  66052. * which contains groups of radio buttons
  66053. */
  66054. export class SelectorGroup {
  66055. /** name of SelectorGroup */
  66056. name: string;
  66057. private _groupPanel;
  66058. private _selectors;
  66059. private _groupHeader;
  66060. /**
  66061. * Creates a new SelectorGroup
  66062. * @param name of group, used as a group heading
  66063. */
  66064. constructor(
  66065. /** name of SelectorGroup */
  66066. name: string);
  66067. /** Gets the groupPanel of the SelectorGroup */
  66068. readonly groupPanel: StackPanel;
  66069. /** Gets the selectors array */
  66070. readonly selectors: StackPanel[];
  66071. /** Gets and sets the group header */
  66072. header: string;
  66073. /** @hidden */
  66074. private _addGroupHeader;
  66075. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  66076. /** Removes the selector at the given position
  66077. * @param selectorNb the position of the selector within the group
  66078. */
  66079. removeSelector(selectorNb: number): void;
  66080. }
  66081. /** Class used to create a CheckboxGroup
  66082. * which contains groups of checkbox buttons
  66083. */
  66084. export class CheckboxGroup extends SelectorGroup {
  66085. /** Adds a checkbox as a control
  66086. * @param text is the label for the selector
  66087. * @param func is the function called when the Selector is checked
  66088. * @param checked is true when Selector is checked
  66089. */
  66090. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66091. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66092. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66093. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66094. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66095. }
  66096. /** Class used to create a RadioGroup
  66097. * which contains groups of radio buttons
  66098. */
  66099. export class RadioGroup extends SelectorGroup {
  66100. private _selectNb;
  66101. /** Adds a radio button as a control
  66102. * @param label is the label for the selector
  66103. * @param func is the function called when the Selector is checked
  66104. * @param checked is true when Selector is checked
  66105. */
  66106. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66107. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66108. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66109. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66110. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66111. }
  66112. /** Class used to create a SliderGroup
  66113. * which contains groups of slider buttons
  66114. */
  66115. export class SliderGroup extends SelectorGroup {
  66116. /**
  66117. * Adds a slider to the SelectorGroup
  66118. * @param label is the label for the SliderBar
  66119. * @param func is the function called when the Slider moves
  66120. * @param unit is a string describing the units used, eg degrees or metres
  66121. * @param min is the minimum value for the Slider
  66122. * @param max is the maximum value for the Slider
  66123. * @param value is the start value for the Slider between min and max
  66124. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66125. */
  66126. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66127. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66128. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66129. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66130. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66131. }
  66132. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66133. * @see http://doc.babylonjs.com/how_to/selector
  66134. */
  66135. export class SelectionPanel extends Rectangle {
  66136. /** name of SelectionPanel */
  66137. name: string;
  66138. /** an array of SelectionGroups */
  66139. groups: SelectorGroup[];
  66140. private _panel;
  66141. private _buttonColor;
  66142. private _buttonBackground;
  66143. private _headerColor;
  66144. private _barColor;
  66145. private _barHeight;
  66146. private _spacerHeight;
  66147. private _labelColor;
  66148. private _groups;
  66149. private _bars;
  66150. /**
  66151. * Creates a new SelectionPanel
  66152. * @param name of SelectionPanel
  66153. * @param groups is an array of SelectionGroups
  66154. */
  66155. constructor(
  66156. /** name of SelectionPanel */
  66157. name: string,
  66158. /** an array of SelectionGroups */
  66159. groups?: SelectorGroup[]);
  66160. protected _getTypeName(): string;
  66161. /** Gets or sets the headerColor */
  66162. headerColor: string;
  66163. private _setHeaderColor;
  66164. /** Gets or sets the button color */
  66165. buttonColor: string;
  66166. private _setbuttonColor;
  66167. /** Gets or sets the label color */
  66168. labelColor: string;
  66169. private _setLabelColor;
  66170. /** Gets or sets the button background */
  66171. buttonBackground: string;
  66172. private _setButtonBackground;
  66173. /** Gets or sets the color of separator bar */
  66174. barColor: string;
  66175. private _setBarColor;
  66176. /** Gets or sets the height of separator bar */
  66177. barHeight: string;
  66178. private _setBarHeight;
  66179. /** Gets or sets the height of spacers*/
  66180. spacerHeight: string;
  66181. private _setSpacerHeight;
  66182. /** Adds a bar between groups */
  66183. private _addSpacer;
  66184. /** Add a group to the selection panel
  66185. * @param group is the selector group to add
  66186. */
  66187. addGroup(group: SelectorGroup): void;
  66188. /** Remove the group from the given position
  66189. * @param groupNb is the position of the group in the list
  66190. */
  66191. removeGroup(groupNb: number): void;
  66192. /** Change a group header label
  66193. * @param label is the new group header label
  66194. * @param groupNb is the number of the group to relabel
  66195. * */
  66196. setHeaderName(label: string, groupNb: number): void;
  66197. /** Change selector label to the one given
  66198. * @param label is the new selector label
  66199. * @param groupNb is the number of the groupcontaining the selector
  66200. * @param selectorNb is the number of the selector within a group to relabel
  66201. * */
  66202. relabel(label: string, groupNb: number, selectorNb: number): void;
  66203. /** For a given group position remove the selector at the given position
  66204. * @param groupNb is the number of the group to remove the selector from
  66205. * @param selectorNb is the number of the selector within the group
  66206. */
  66207. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66208. /** For a given group position of correct type add a checkbox button
  66209. * @param groupNb is the number of the group to remove the selector from
  66210. * @param label is the label for the selector
  66211. * @param func is the function called when the Selector is checked
  66212. * @param checked is true when Selector is checked
  66213. */
  66214. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66215. /** For a given group position of correct type add a radio button
  66216. * @param groupNb is the number of the group to remove the selector from
  66217. * @param label is the label for the selector
  66218. * @param func is the function called when the Selector is checked
  66219. * @param checked is true when Selector is checked
  66220. */
  66221. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66222. /**
  66223. * For a given slider group add a slider
  66224. * @param groupNb is the number of the group to add the slider to
  66225. * @param label is the label for the Slider
  66226. * @param func is the function called when the Slider moves
  66227. * @param unit is a string describing the units used, eg degrees or metres
  66228. * @param min is the minimum value for the Slider
  66229. * @param max is the maximum value for the Slider
  66230. * @param value is the start value for the Slider between min and max
  66231. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66232. */
  66233. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66234. }
  66235. }
  66236. declare module BABYLON.GUI {
  66237. /**
  66238. * Class used to hold a the container for ScrollViewer
  66239. * @hidden
  66240. */
  66241. export class _ScrollViewerWindow extends Container {
  66242. parentClientWidth: number;
  66243. parentClientHeight: number;
  66244. /**
  66245. * Creates a new ScrollViewerWindow
  66246. * @param name of ScrollViewerWindow
  66247. */
  66248. constructor(name?: string);
  66249. protected _getTypeName(): string;
  66250. /** @hidden */
  66251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66252. protected _postMeasure(): void;
  66253. }
  66254. }
  66255. declare module BABYLON.GUI {
  66256. /**
  66257. * Class used to create slider controls
  66258. */
  66259. export class ScrollBar extends BaseSlider {
  66260. name?: string | undefined;
  66261. private _background;
  66262. private _borderColor;
  66263. private _thumbMeasure;
  66264. /** Gets or sets border color */
  66265. borderColor: string;
  66266. /** Gets or sets background color */
  66267. background: string;
  66268. /**
  66269. * Creates a new Slider
  66270. * @param name defines the control name
  66271. */
  66272. constructor(name?: string | undefined);
  66273. protected _getTypeName(): string;
  66274. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  66275. private _first;
  66276. private _originX;
  66277. private _originY;
  66278. /** @hidden */
  66279. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66280. }
  66281. }
  66282. declare module BABYLON.GUI {
  66283. /**
  66284. * Class used to hold a viewer window and sliders in a grid
  66285. */
  66286. export class ScrollViewer extends Rectangle {
  66287. private _grid;
  66288. private _horizontalBarSpace;
  66289. private _verticalBarSpace;
  66290. private _dragSpace;
  66291. private _horizontalBar;
  66292. private _verticalBar;
  66293. private _barColor;
  66294. private _barBackground;
  66295. private _barSize;
  66296. private _endLeft;
  66297. private _endTop;
  66298. private _window;
  66299. private _pointerIsOver;
  66300. private _wheelPrecision;
  66301. private _onPointerObserver;
  66302. private _clientWidth;
  66303. private _clientHeight;
  66304. /**
  66305. * Gets the horizontal scrollbar
  66306. */
  66307. readonly horizontalBar: ScrollBar;
  66308. /**
  66309. * Gets the vertical scrollbar
  66310. */
  66311. readonly verticalBar: ScrollBar;
  66312. /**
  66313. * Adds a new control to the current container
  66314. * @param control defines the control to add
  66315. * @returns the current container
  66316. */
  66317. addControl(control: BABYLON.Nullable<Control>): Container;
  66318. /**
  66319. * Removes a control from the current container
  66320. * @param control defines the control to remove
  66321. * @returns the current container
  66322. */
  66323. removeControl(control: Control): Container;
  66324. /** Gets the list of children */
  66325. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  66326. /**
  66327. * Creates a new ScrollViewer
  66328. * @param name of ScrollViewer
  66329. */
  66330. constructor(name?: string);
  66331. /** Reset the scroll viewer window to initial size */
  66332. resetWindow(): void;
  66333. protected _getTypeName(): string;
  66334. private _buildClientSizes;
  66335. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66336. protected _postMeasure(): void;
  66337. /**
  66338. * Gets or sets the mouse wheel precision
  66339. * from 0 to 1 with a default value of 0.05
  66340. * */
  66341. wheelPrecision: number;
  66342. /** Gets or sets the bar color */
  66343. barColor: string;
  66344. /** Gets or sets the size of the bar */
  66345. barSize: number;
  66346. /** Gets or sets the bar background */
  66347. barBackground: string;
  66348. /** @hidden */
  66349. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  66350. /** @hidden */
  66351. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66352. /** Releases associated resources */
  66353. dispose(): void;
  66354. }
  66355. }
  66356. declare module BABYLON.GUI {
  66357. /** Class used to render a grid */
  66358. export class DisplayGrid extends Control {
  66359. name?: string | undefined;
  66360. private _cellWidth;
  66361. private _cellHeight;
  66362. private _minorLineTickness;
  66363. private _minorLineColor;
  66364. private _majorLineTickness;
  66365. private _majorLineColor;
  66366. private _majorLineFrequency;
  66367. private _background;
  66368. private _displayMajorLines;
  66369. private _displayMinorLines;
  66370. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66371. displayMinorLines: boolean;
  66372. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66373. displayMajorLines: boolean;
  66374. /** Gets or sets background color (Black by default) */
  66375. background: string;
  66376. /** Gets or sets the width of each cell (20 by default) */
  66377. cellWidth: number;
  66378. /** Gets or sets the height of each cell (20 by default) */
  66379. cellHeight: number;
  66380. /** Gets or sets the tickness of minor lines (1 by default) */
  66381. minorLineTickness: number;
  66382. /** Gets or sets the color of minor lines (DarkGray by default) */
  66383. minorLineColor: string;
  66384. /** Gets or sets the tickness of major lines (2 by default) */
  66385. majorLineTickness: number;
  66386. /** Gets or sets the color of major lines (White by default) */
  66387. majorLineColor: string;
  66388. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66389. majorLineFrequency: number;
  66390. /**
  66391. * Creates a new GridDisplayRectangle
  66392. * @param name defines the control name
  66393. */
  66394. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  66395. protected _getTypeName(): string;
  66396. }
  66397. }
  66398. declare module BABYLON.GUI {
  66399. /**
  66400. * Class used to create slider controls based on images
  66401. */
  66402. export class ImageBasedSlider extends BaseSlider {
  66403. name?: string | undefined;
  66404. private _backgroundImage;
  66405. private _thumbImage;
  66406. private _valueBarImage;
  66407. private _tempMeasure;
  66408. displayThumb: boolean;
  66409. /**
  66410. * Gets or sets the image used to render the background
  66411. */
  66412. backgroundImage: Image;
  66413. /**
  66414. * Gets or sets the image used to render the value bar
  66415. */
  66416. valueBarImage: Image;
  66417. /**
  66418. * Gets or sets the image used to render the thumb
  66419. */
  66420. thumbImage: Image;
  66421. /**
  66422. * Creates a new ImageBasedSlider
  66423. * @param name defines the control name
  66424. */
  66425. constructor(name?: string | undefined);
  66426. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66427. }
  66428. }
  66429. declare module BABYLON.GUI {
  66430. /**
  66431. * Forcing an export so that this code will execute
  66432. * @hidden
  66433. */
  66434. const name = "Statics";
  66435. }
  66436. declare module BABYLON.GUI {
  66437. /**
  66438. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66439. */
  66440. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66441. /**
  66442. * Define the instrumented AdvancedDynamicTexture.
  66443. */
  66444. texture: AdvancedDynamicTexture;
  66445. private _captureRenderTime;
  66446. private _renderTime;
  66447. private _captureLayoutTime;
  66448. private _layoutTime;
  66449. private _onBeginRenderObserver;
  66450. private _onEndRenderObserver;
  66451. private _onBeginLayoutObserver;
  66452. private _onEndLayoutObserver;
  66453. /**
  66454. * Gets the perf counter used to capture render time
  66455. */
  66456. readonly renderTimeCounter: BABYLON.PerfCounter;
  66457. /**
  66458. * Gets the perf counter used to capture layout time
  66459. */
  66460. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66461. /**
  66462. * Enable or disable the render time capture
  66463. */
  66464. captureRenderTime: boolean;
  66465. /**
  66466. * Enable or disable the layout time capture
  66467. */
  66468. captureLayoutTime: boolean;
  66469. /**
  66470. * Instantiates a new advanced dynamic texture instrumentation.
  66471. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66472. * @param texture Defines the AdvancedDynamicTexture to instrument
  66473. */
  66474. constructor(
  66475. /**
  66476. * Define the instrumented AdvancedDynamicTexture.
  66477. */
  66478. texture: AdvancedDynamicTexture);
  66479. /**
  66480. * Dispose and release associated resources.
  66481. */
  66482. dispose(): void;
  66483. }
  66484. }
  66485. declare module BABYLON.GUI {
  66486. /**
  66487. * Class used to load GUI via XML.
  66488. */
  66489. export class XmlLoader {
  66490. private _nodes;
  66491. private _nodeTypes;
  66492. private _isLoaded;
  66493. private _objectAttributes;
  66494. private _parentClass;
  66495. /**
  66496. * Create a new xml loader
  66497. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66498. */
  66499. constructor(parentClass?: null);
  66500. private _getChainElement;
  66501. private _getClassAttribute;
  66502. private _createGuiElement;
  66503. private _parseGrid;
  66504. private _parseElement;
  66505. private _prepareSourceElement;
  66506. private _parseElementsFromSource;
  66507. private _parseXml;
  66508. /**
  66509. * Gets if the loading has finished.
  66510. * @returns whether the loading has finished or not
  66511. */
  66512. isLoaded(): boolean;
  66513. /**
  66514. * Gets a loaded node / control by id.
  66515. * @param id the Controls id set in the xml
  66516. * @returns element of type Control
  66517. */
  66518. getNodeById(id: string): any;
  66519. /**
  66520. * Gets all loaded nodes / controls
  66521. * @returns Array of controls
  66522. */
  66523. getNodes(): any;
  66524. /**
  66525. * Initiates the xml layout loading
  66526. * @param xmlFile defines the xml layout to load
  66527. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66528. * @param callback defines the callback called on layout load.
  66529. */
  66530. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66531. }
  66532. }
  66533. declare module BABYLON.GUI {
  66534. /**
  66535. * Class used to create containers for controls
  66536. */
  66537. export class Container3D extends Control3D {
  66538. private _blockLayout;
  66539. /**
  66540. * Gets the list of child controls
  66541. */
  66542. protected _children: Control3D[];
  66543. /**
  66544. * Gets the list of child controls
  66545. */
  66546. readonly children: Array<Control3D>;
  66547. /**
  66548. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66549. * This is helpful to optimize layout operation when adding multiple children in a row
  66550. */
  66551. blockLayout: boolean;
  66552. /**
  66553. * Creates a new container
  66554. * @param name defines the container name
  66555. */
  66556. constructor(name?: string);
  66557. /**
  66558. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66559. * @returns the current container
  66560. */
  66561. updateLayout(): Container3D;
  66562. /**
  66563. * Gets a boolean indicating if the given control is in the children of this control
  66564. * @param control defines the control to check
  66565. * @returns true if the control is in the child list
  66566. */
  66567. containsControl(control: Control3D): boolean;
  66568. /**
  66569. * Adds a control to the children of this control
  66570. * @param control defines the control to add
  66571. * @returns the current container
  66572. */
  66573. addControl(control: Control3D): Container3D;
  66574. /**
  66575. * This function will be called everytime a new control is added
  66576. */
  66577. protected _arrangeChildren(): void;
  66578. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66579. /**
  66580. * Removes a control from the children of this control
  66581. * @param control defines the control to remove
  66582. * @returns the current container
  66583. */
  66584. removeControl(control: Control3D): Container3D;
  66585. protected _getTypeName(): string;
  66586. /**
  66587. * Releases all associated resources
  66588. */
  66589. dispose(): void;
  66590. /** Control rotation will remain unchanged */
  66591. static readonly UNSET_ORIENTATION: number;
  66592. /** Control will rotate to make it look at sphere central axis */
  66593. static readonly FACEORIGIN_ORIENTATION: number;
  66594. /** Control will rotate to make it look back at sphere central axis */
  66595. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66596. /** Control will rotate to look at z axis (0, 0, 1) */
  66597. static readonly FACEFORWARD_ORIENTATION: number;
  66598. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66599. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66600. }
  66601. }
  66602. declare module BABYLON.GUI {
  66603. /**
  66604. * Class used to manage 3D user interface
  66605. * @see http://doc.babylonjs.com/how_to/gui3d
  66606. */
  66607. export class GUI3DManager implements BABYLON.IDisposable {
  66608. private _scene;
  66609. private _sceneDisposeObserver;
  66610. private _utilityLayer;
  66611. private _rootContainer;
  66612. private _pointerObserver;
  66613. private _pointerOutObserver;
  66614. /** @hidden */ private _lastPickedControl: Control3D;
  66615. /** @hidden */ private _lastControlOver: {
  66616. [pointerId: number]: Control3D;
  66617. };
  66618. /** @hidden */ private _lastControlDown: {
  66619. [pointerId: number]: Control3D;
  66620. };
  66621. /**
  66622. * BABYLON.Observable raised when the point picked by the pointer events changed
  66623. */
  66624. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66625. /** @hidden */ private _sharedMaterials: {
  66626. [key: string]: BABYLON.Material;
  66627. };
  66628. /** Gets the hosting scene */
  66629. readonly scene: BABYLON.Scene;
  66630. /** Gets associated utility layer */
  66631. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66632. /**
  66633. * Creates a new GUI3DManager
  66634. * @param scene
  66635. */
  66636. constructor(scene?: BABYLON.Scene);
  66637. private _handlePointerOut;
  66638. private _doPicking;
  66639. /**
  66640. * Gets the root container
  66641. */
  66642. readonly rootContainer: Container3D;
  66643. /**
  66644. * Gets a boolean indicating if the given control is in the root child list
  66645. * @param control defines the control to check
  66646. * @returns true if the control is in the root child list
  66647. */
  66648. containsControl(control: Control3D): boolean;
  66649. /**
  66650. * Adds a control to the root child list
  66651. * @param control defines the control to add
  66652. * @returns the current manager
  66653. */
  66654. addControl(control: Control3D): GUI3DManager;
  66655. /**
  66656. * Removes a control from the root child list
  66657. * @param control defines the control to remove
  66658. * @returns the current container
  66659. */
  66660. removeControl(control: Control3D): GUI3DManager;
  66661. /**
  66662. * Releases all associated resources
  66663. */
  66664. dispose(): void;
  66665. }
  66666. }
  66667. declare module BABYLON.GUI {
  66668. /**
  66669. * Class used to transport BABYLON.Vector3 information for pointer events
  66670. */
  66671. export class Vector3WithInfo extends BABYLON.Vector3 {
  66672. /** defines the current mouse button index */
  66673. buttonIndex: number;
  66674. /**
  66675. * Creates a new Vector3WithInfo
  66676. * @param source defines the vector3 data to transport
  66677. * @param buttonIndex defines the current mouse button index
  66678. */
  66679. constructor(source: BABYLON.Vector3,
  66680. /** defines the current mouse button index */
  66681. buttonIndex?: number);
  66682. }
  66683. }
  66684. declare module BABYLON.GUI {
  66685. /**
  66686. * Class used as base class for controls
  66687. */
  66688. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66689. /** Defines the control name */
  66690. name?: string | undefined;
  66691. /** @hidden */ private _host: GUI3DManager;
  66692. private _node;
  66693. private _downCount;
  66694. private _enterCount;
  66695. private _downPointerIds;
  66696. private _isVisible;
  66697. /** Gets or sets the control position in world space */
  66698. position: BABYLON.Vector3;
  66699. /** Gets or sets the control scaling in world space */
  66700. scaling: BABYLON.Vector3;
  66701. /** Callback used to start pointer enter animation */
  66702. pointerEnterAnimation: () => void;
  66703. /** Callback used to start pointer out animation */
  66704. pointerOutAnimation: () => void;
  66705. /** Callback used to start pointer down animation */
  66706. pointerDownAnimation: () => void;
  66707. /** Callback used to start pointer up animation */
  66708. pointerUpAnimation: () => void;
  66709. /**
  66710. * An event triggered when the pointer move over the control
  66711. */
  66712. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66713. /**
  66714. * An event triggered when the pointer move out of the control
  66715. */
  66716. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66717. /**
  66718. * An event triggered when the pointer taps the control
  66719. */
  66720. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66721. /**
  66722. * An event triggered when pointer is up
  66723. */
  66724. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66725. /**
  66726. * An event triggered when a control is clicked on (with a mouse)
  66727. */
  66728. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66729. /**
  66730. * An event triggered when pointer enters the control
  66731. */
  66732. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66733. /**
  66734. * Gets or sets the parent container
  66735. */
  66736. parent: BABYLON.Nullable<Container3D>;
  66737. private _behaviors;
  66738. /**
  66739. * Gets the list of attached behaviors
  66740. * @see http://doc.babylonjs.com/features/behaviour
  66741. */
  66742. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66743. /**
  66744. * Attach a behavior to the control
  66745. * @see http://doc.babylonjs.com/features/behaviour
  66746. * @param behavior defines the behavior to attach
  66747. * @returns the current control
  66748. */
  66749. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66750. /**
  66751. * Remove an attached behavior
  66752. * @see http://doc.babylonjs.com/features/behaviour
  66753. * @param behavior defines the behavior to attach
  66754. * @returns the current control
  66755. */
  66756. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66757. /**
  66758. * Gets an attached behavior by name
  66759. * @param name defines the name of the behavior to look for
  66760. * @see http://doc.babylonjs.com/features/behaviour
  66761. * @returns null if behavior was not found else the requested behavior
  66762. */
  66763. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66764. /** Gets or sets a boolean indicating if the control is visible */
  66765. isVisible: boolean;
  66766. /**
  66767. * Creates a new control
  66768. * @param name defines the control name
  66769. */
  66770. constructor(
  66771. /** Defines the control name */
  66772. name?: string | undefined);
  66773. /**
  66774. * Gets a string representing the class name
  66775. */
  66776. readonly typeName: string;
  66777. /**
  66778. * Get the current class name of the control.
  66779. * @returns current class name
  66780. */
  66781. getClassName(): string;
  66782. protected _getTypeName(): string;
  66783. /**
  66784. * Gets the transform node used by this control
  66785. */
  66786. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66787. /**
  66788. * Gets the mesh used to render this control
  66789. */
  66790. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66791. /**
  66792. * Link the control as child of the given node
  66793. * @param node defines the node to link to. Use null to unlink the control
  66794. * @returns the current control
  66795. */
  66796. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66797. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  66798. /**
  66799. * Node creation.
  66800. * Can be overriden by children
  66801. * @param scene defines the scene where the node must be attached
  66802. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66803. */
  66804. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66805. /**
  66806. * Affect a material to the given mesh
  66807. * @param mesh defines the mesh which will represent the control
  66808. */
  66809. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66810. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66811. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  66812. /** @hidden */ private _onPointerOut(target: Control3D): void;
  66813. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66814. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66815. /** @hidden */
  66816. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66817. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66818. /** @hidden */ private _disposeNode(): void;
  66819. /**
  66820. * Releases all associated resources
  66821. */
  66822. dispose(): void;
  66823. }
  66824. }
  66825. declare module BABYLON.GUI {
  66826. /**
  66827. * Class used as a root to all buttons
  66828. */
  66829. export class AbstractButton3D extends Control3D {
  66830. /**
  66831. * Creates a new button
  66832. * @param name defines the control name
  66833. */
  66834. constructor(name?: string);
  66835. protected _getTypeName(): string;
  66836. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66837. }
  66838. }
  66839. declare module BABYLON.GUI {
  66840. /**
  66841. * Class used to create a button in 3D
  66842. */
  66843. export class Button3D extends AbstractButton3D {
  66844. /** @hidden */
  66845. protected _currentMaterial: BABYLON.Material;
  66846. private _facadeTexture;
  66847. private _content;
  66848. private _contentResolution;
  66849. private _contentScaleRatio;
  66850. /**
  66851. * Gets or sets the texture resolution used to render content (512 by default)
  66852. */
  66853. contentResolution: BABYLON.int;
  66854. /**
  66855. * Gets or sets the texture scale ratio used to render content (2 by default)
  66856. */
  66857. contentScaleRatio: number;
  66858. protected _disposeFacadeTexture(): void;
  66859. protected _resetContent(): void;
  66860. /**
  66861. * Creates a new button
  66862. * @param name defines the control name
  66863. */
  66864. constructor(name?: string);
  66865. /**
  66866. * Gets or sets the GUI 2D content used to display the button's facade
  66867. */
  66868. content: Control;
  66869. /**
  66870. * Apply the facade texture (created from the content property).
  66871. * This function can be overloaded by child classes
  66872. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66873. */
  66874. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66875. protected _getTypeName(): string;
  66876. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66877. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66878. /**
  66879. * Releases all associated resources
  66880. */
  66881. dispose(): void;
  66882. }
  66883. }
  66884. declare module BABYLON.GUI {
  66885. /**
  66886. * Abstract class used to create a container panel deployed on the surface of a volume
  66887. */
  66888. export abstract class VolumeBasedPanel extends Container3D {
  66889. private _columns;
  66890. private _rows;
  66891. private _rowThenColum;
  66892. private _orientation;
  66893. protected _cellWidth: number;
  66894. protected _cellHeight: number;
  66895. /**
  66896. * Gets or sets the distance between elements
  66897. */
  66898. margin: number;
  66899. /**
  66900. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66901. * | Value | Type | Description |
  66902. * | ----- | ----------------------------------- | ----------- |
  66903. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66904. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66905. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66906. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66907. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66908. */
  66909. orientation: number;
  66910. /**
  66911. * Gets or sets the number of columns requested (10 by default).
  66912. * The panel will automatically compute the number of rows based on number of child controls.
  66913. */
  66914. columns: BABYLON.int;
  66915. /**
  66916. * Gets or sets a the number of rows requested.
  66917. * The panel will automatically compute the number of columns based on number of child controls.
  66918. */
  66919. rows: BABYLON.int;
  66920. /**
  66921. * Creates new VolumeBasedPanel
  66922. */
  66923. constructor();
  66924. protected _arrangeChildren(): void;
  66925. /** Child classes must implement this function to provide correct control positioning */
  66926. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66927. /** Child classes can implement this function to provide additional processing */
  66928. protected _finalProcessing(): void;
  66929. }
  66930. }
  66931. declare module BABYLON.GUI {
  66932. /**
  66933. * Class used to create a container panel deployed on the surface of a cylinder
  66934. */
  66935. export class CylinderPanel extends VolumeBasedPanel {
  66936. private _radius;
  66937. /**
  66938. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66939. */
  66940. radius: BABYLON.float;
  66941. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66942. private _cylindricalMapping;
  66943. }
  66944. }
  66945. declare module BABYLON.GUI {
  66946. /** @hidden */
  66947. export var fluentVertexShader: {
  66948. name: string;
  66949. shader: string;
  66950. };
  66951. }
  66952. declare module BABYLON.GUI {
  66953. /** @hidden */
  66954. export var fluentPixelShader: {
  66955. name: string;
  66956. shader: string;
  66957. };
  66958. }
  66959. declare module BABYLON.GUI {
  66960. /** @hidden */
  66961. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66962. INNERGLOW: boolean;
  66963. BORDER: boolean;
  66964. HOVERLIGHT: boolean;
  66965. TEXTURE: boolean;
  66966. constructor();
  66967. }
  66968. /**
  66969. * Class used to render controls with fluent desgin
  66970. */
  66971. export class FluentMaterial extends BABYLON.PushMaterial {
  66972. /**
  66973. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66974. */
  66975. innerGlowColorIntensity: number;
  66976. /**
  66977. * Gets or sets the inner glow color (white by default)
  66978. */
  66979. innerGlowColor: BABYLON.Color3;
  66980. /**
  66981. * Gets or sets alpha value (default is 1.0)
  66982. */
  66983. alpha: number;
  66984. /**
  66985. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66986. */
  66987. albedoColor: BABYLON.Color3;
  66988. /**
  66989. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66990. */
  66991. renderBorders: boolean;
  66992. /**
  66993. * Gets or sets border width (default is 0.5)
  66994. */
  66995. borderWidth: number;
  66996. /**
  66997. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66998. */
  66999. edgeSmoothingValue: number;
  67000. /**
  67001. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67002. */
  67003. borderMinValue: number;
  67004. /**
  67005. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67006. */
  67007. renderHoverLight: boolean;
  67008. /**
  67009. * Gets or sets the radius used to render the hover light (default is 1.0)
  67010. */
  67011. hoverRadius: number;
  67012. /**
  67013. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67014. */
  67015. hoverColor: BABYLON.Color4;
  67016. /**
  67017. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67018. */
  67019. hoverPosition: BABYLON.Vector3;
  67020. private _albedoTexture;
  67021. /** Gets or sets the texture to use for albedo color */
  67022. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67023. /**
  67024. * Creates a new Fluent material
  67025. * @param name defines the name of the material
  67026. * @param scene defines the hosting scene
  67027. */
  67028. constructor(name: string, scene: BABYLON.Scene);
  67029. needAlphaBlending(): boolean;
  67030. needAlphaTesting(): boolean;
  67031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67033. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67034. getActiveTextures(): BABYLON.BaseTexture[];
  67035. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67036. dispose(forceDisposeEffect?: boolean): void;
  67037. clone(name: string): FluentMaterial;
  67038. serialize(): any;
  67039. getClassName(): string;
  67040. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67041. }
  67042. }
  67043. declare module BABYLON.GUI {
  67044. /**
  67045. * Class used to create a holographic button in 3D
  67046. */
  67047. export class HolographicButton extends Button3D {
  67048. private _backPlate;
  67049. private _textPlate;
  67050. private _frontPlate;
  67051. private _text;
  67052. private _imageUrl;
  67053. private _shareMaterials;
  67054. private _frontMaterial;
  67055. private _backMaterial;
  67056. private _plateMaterial;
  67057. private _pickedPointObserver;
  67058. private _tooltipFade;
  67059. private _tooltipTextBlock;
  67060. private _tooltipTexture;
  67061. private _tooltipMesh;
  67062. private _tooltipHoverObserver;
  67063. private _tooltipOutObserver;
  67064. private _disposeTooltip;
  67065. /**
  67066. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67067. */
  67068. tooltipText: BABYLON.Nullable<string>;
  67069. /**
  67070. * Gets or sets text for the button
  67071. */
  67072. text: string;
  67073. /**
  67074. * Gets or sets the image url for the button
  67075. */
  67076. imageUrl: string;
  67077. /**
  67078. * Gets the back material used by this button
  67079. */
  67080. readonly backMaterial: FluentMaterial;
  67081. /**
  67082. * Gets the front material used by this button
  67083. */
  67084. readonly frontMaterial: FluentMaterial;
  67085. /**
  67086. * Gets the plate material used by this button
  67087. */
  67088. readonly plateMaterial: BABYLON.StandardMaterial;
  67089. /**
  67090. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67091. */
  67092. readonly shareMaterials: boolean;
  67093. /**
  67094. * Creates a new button
  67095. * @param name defines the control name
  67096. */
  67097. constructor(name?: string, shareMaterials?: boolean);
  67098. protected _getTypeName(): string;
  67099. private _rebuildContent;
  67100. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67101. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67102. private _createBackMaterial;
  67103. private _createFrontMaterial;
  67104. private _createPlateMaterial;
  67105. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67106. /**
  67107. * Releases all associated resources
  67108. */
  67109. dispose(): void;
  67110. }
  67111. }
  67112. declare module BABYLON.GUI {
  67113. /**
  67114. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67115. */
  67116. export class MeshButton3D extends Button3D {
  67117. /** @hidden */
  67118. protected _currentMesh: BABYLON.Mesh;
  67119. /**
  67120. * Creates a new 3D button based on a mesh
  67121. * @param mesh mesh to become a 3D button
  67122. * @param name defines the control name
  67123. */
  67124. constructor(mesh: BABYLON.Mesh, name?: string);
  67125. protected _getTypeName(): string;
  67126. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67127. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67128. }
  67129. }
  67130. declare module BABYLON.GUI {
  67131. /**
  67132. * Class used to create a container panel deployed on the surface of a plane
  67133. */
  67134. export class PlanePanel extends VolumeBasedPanel {
  67135. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67136. }
  67137. }
  67138. declare module BABYLON.GUI {
  67139. /**
  67140. * Class used to create a container panel where items get randomized planar mapping
  67141. */
  67142. export class ScatterPanel extends VolumeBasedPanel {
  67143. private _iteration;
  67144. /**
  67145. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67146. */
  67147. iteration: BABYLON.float;
  67148. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67149. private _scatterMapping;
  67150. protected _finalProcessing(): void;
  67151. }
  67152. }
  67153. declare module BABYLON.GUI {
  67154. /**
  67155. * Class used to create a container panel deployed on the surface of a sphere
  67156. */
  67157. export class SpherePanel extends VolumeBasedPanel {
  67158. private _radius;
  67159. /**
  67160. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67161. */
  67162. radius: BABYLON.float;
  67163. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67164. private _sphericalMapping;
  67165. }
  67166. }
  67167. declare module BABYLON.GUI {
  67168. /**
  67169. * Class used to create a stack panel in 3D on XY plane
  67170. */
  67171. export class StackPanel3D extends Container3D {
  67172. private _isVertical;
  67173. /**
  67174. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67175. */
  67176. isVertical: boolean;
  67177. /**
  67178. * Gets or sets the distance between elements
  67179. */
  67180. margin: number;
  67181. /**
  67182. * Creates new StackPanel
  67183. * @param isVertical
  67184. */
  67185. constructor(isVertical?: boolean);
  67186. protected _arrangeChildren(): void;
  67187. }
  67188. }
  67189. declare module BABYLON {
  67190. /**
  67191. * Mode that determines the coordinate system to use.
  67192. */
  67193. export enum GLTFLoaderCoordinateSystemMode {
  67194. /**
  67195. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67196. */
  67197. AUTO = 0,
  67198. /**
  67199. * Sets the useRightHandedSystem flag on the scene.
  67200. */
  67201. FORCE_RIGHT_HANDED = 1
  67202. }
  67203. /**
  67204. * Mode that determines what animations will start.
  67205. */
  67206. export enum GLTFLoaderAnimationStartMode {
  67207. /**
  67208. * No animation will start.
  67209. */
  67210. NONE = 0,
  67211. /**
  67212. * The first animation will start.
  67213. */
  67214. FIRST = 1,
  67215. /**
  67216. * All animations will start.
  67217. */
  67218. ALL = 2
  67219. }
  67220. /**
  67221. * Interface that contains the data for the glTF asset.
  67222. */
  67223. export interface IGLTFLoaderData {
  67224. /**
  67225. * The object that represents the glTF JSON.
  67226. */
  67227. json: Object;
  67228. /**
  67229. * The BIN chunk of a binary glTF.
  67230. */
  67231. bin: Nullable<IDataBuffer>;
  67232. }
  67233. /**
  67234. * Interface for extending the loader.
  67235. */
  67236. export interface IGLTFLoaderExtension {
  67237. /**
  67238. * The name of this extension.
  67239. */
  67240. readonly name: string;
  67241. /**
  67242. * Defines whether this extension is enabled.
  67243. */
  67244. enabled: boolean;
  67245. /**
  67246. * Defines the order of this extension.
  67247. * The loader sorts the extensions using these values when loading.
  67248. */
  67249. order?: number;
  67250. }
  67251. /**
  67252. * Loader state.
  67253. */
  67254. export enum GLTFLoaderState {
  67255. /**
  67256. * The asset is loading.
  67257. */
  67258. LOADING = 0,
  67259. /**
  67260. * The asset is ready for rendering.
  67261. */
  67262. READY = 1,
  67263. /**
  67264. * The asset is completely loaded.
  67265. */
  67266. COMPLETE = 2
  67267. }
  67268. /** @hidden */
  67269. export interface IGLTFLoader extends IDisposable {
  67270. readonly state: Nullable<GLTFLoaderState>;
  67271. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67272. meshes: AbstractMesh[];
  67273. particleSystems: IParticleSystem[];
  67274. skeletons: Skeleton[];
  67275. animationGroups: AnimationGroup[];
  67276. }>;
  67277. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67278. }
  67279. /**
  67280. * File loader for loading glTF files into a scene.
  67281. */
  67282. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67283. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67284. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67285. /**
  67286. * Raised when the asset has been parsed
  67287. */
  67288. onParsedObservable: Observable<IGLTFLoaderData>;
  67289. private _onParsedObserver;
  67290. /**
  67291. * Raised when the asset has been parsed
  67292. */
  67293. onParsed: (loaderData: IGLTFLoaderData) => void;
  67294. /**
  67295. * 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.
  67296. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67297. * Defaults to true.
  67298. * @hidden
  67299. */
  67300. static IncrementalLoading: boolean;
  67301. /**
  67302. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67303. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67304. * @hidden
  67305. */
  67306. static HomogeneousCoordinates: boolean;
  67307. /**
  67308. * The coordinate system mode. Defaults to AUTO.
  67309. */
  67310. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67311. /**
  67312. * The animation start mode. Defaults to FIRST.
  67313. */
  67314. animationStartMode: GLTFLoaderAnimationStartMode;
  67315. /**
  67316. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67317. */
  67318. compileMaterials: boolean;
  67319. /**
  67320. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67321. */
  67322. useClipPlane: boolean;
  67323. /**
  67324. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67325. */
  67326. compileShadowGenerators: boolean;
  67327. /**
  67328. * Defines if the Alpha blended materials are only applied as coverage.
  67329. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67330. * If true, no extra effects are applied to transparent pixels.
  67331. */
  67332. transparencyAsCoverage: boolean;
  67333. /**
  67334. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  67335. * Enabling will disable offline support and glTF validator.
  67336. * Defaults to false.
  67337. */
  67338. useRangeRequests: boolean;
  67339. /**
  67340. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  67341. */
  67342. createInstances: boolean;
  67343. /**
  67344. * Function called before loading a url referenced by the asset.
  67345. */
  67346. preprocessUrlAsync: (url: string) => Promise<string>;
  67347. /**
  67348. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67349. */
  67350. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67351. private _onMeshLoadedObserver;
  67352. /**
  67353. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67354. */
  67355. onMeshLoaded: (mesh: AbstractMesh) => void;
  67356. /**
  67357. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67358. */
  67359. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67360. private _onTextureLoadedObserver;
  67361. /**
  67362. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67363. */
  67364. onTextureLoaded: (texture: BaseTexture) => void;
  67365. /**
  67366. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67367. */
  67368. readonly onMaterialLoadedObservable: Observable<Material>;
  67369. private _onMaterialLoadedObserver;
  67370. /**
  67371. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67372. */
  67373. onMaterialLoaded: (material: Material) => void;
  67374. /**
  67375. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67376. */
  67377. readonly onCameraLoadedObservable: Observable<Camera>;
  67378. private _onCameraLoadedObserver;
  67379. /**
  67380. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67381. */
  67382. onCameraLoaded: (camera: Camera) => void;
  67383. /**
  67384. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67385. * For assets with LODs, raised when all of the LODs are complete.
  67386. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67387. */
  67388. readonly onCompleteObservable: Observable<void>;
  67389. private _onCompleteObserver;
  67390. /**
  67391. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67392. * For assets with LODs, raised when all of the LODs are complete.
  67393. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67394. */
  67395. onComplete: () => void;
  67396. /**
  67397. * Observable raised when an error occurs.
  67398. */
  67399. readonly onErrorObservable: Observable<any>;
  67400. private _onErrorObserver;
  67401. /**
  67402. * Callback raised when an error occurs.
  67403. */
  67404. onError: (reason: any) => void;
  67405. /**
  67406. * Observable raised after the loader is disposed.
  67407. */
  67408. readonly onDisposeObservable: Observable<void>;
  67409. private _onDisposeObserver;
  67410. /**
  67411. * Callback raised after the loader is disposed.
  67412. */
  67413. onDispose: () => void;
  67414. /**
  67415. * Observable raised after a loader extension is created.
  67416. * Set additional options for a loader extension in this event.
  67417. */
  67418. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67419. private _onExtensionLoadedObserver;
  67420. /**
  67421. * Callback raised after a loader extension is created.
  67422. */
  67423. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67424. /**
  67425. * Defines if the loader logging is enabled.
  67426. */
  67427. loggingEnabled: boolean;
  67428. /**
  67429. * Defines if the loader should capture performance counters.
  67430. */
  67431. capturePerformanceCounters: boolean;
  67432. /**
  67433. * Defines if the loader should validate the asset.
  67434. */
  67435. validate: boolean;
  67436. /**
  67437. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67438. */
  67439. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67440. private _onValidatedObserver;
  67441. /**
  67442. * Callback raised after a loader extension is created.
  67443. */
  67444. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67445. private _loader;
  67446. /**
  67447. * Name of the loader ("gltf")
  67448. */
  67449. name: string;
  67450. /** @hidden */
  67451. extensions: ISceneLoaderPluginExtensions;
  67452. /**
  67453. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67454. */
  67455. dispose(): void;
  67456. /** @hidden */ private _clear(): void;
  67457. /** @hidden */
  67458. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  67459. /** @hidden */
  67460. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  67461. /** @hidden */
  67462. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67463. meshes: AbstractMesh[];
  67464. particleSystems: IParticleSystem[];
  67465. skeletons: Skeleton[];
  67466. animationGroups: AnimationGroup[];
  67467. }>;
  67468. /** @hidden */
  67469. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67470. /** @hidden */
  67471. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67472. /** @hidden */
  67473. canDirectLoad(data: string): boolean;
  67474. /** @hidden */
  67475. directLoad(scene: Scene, data: string): any;
  67476. /**
  67477. * The callback that allows custom handling of the root url based on the response url.
  67478. * @param rootUrl the original root url
  67479. * @param responseURL the response url if available
  67480. * @returns the new root url
  67481. */
  67482. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  67483. /** @hidden */
  67484. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67485. /**
  67486. * The loader state or null if the loader is not active.
  67487. */
  67488. readonly loaderState: Nullable<GLTFLoaderState>;
  67489. /**
  67490. * Returns a promise that resolves when the asset is completely loaded.
  67491. * @returns a promise that resolves when the asset is completely loaded.
  67492. */
  67493. whenCompleteAsync(): Promise<void>;
  67494. private _validateAsync;
  67495. private _getLoader;
  67496. private _parseJson;
  67497. private _unpackBinaryAsync;
  67498. private _unpackBinaryV1Async;
  67499. private _unpackBinaryV2Async;
  67500. private static _parseVersion;
  67501. private static _compareVersion;
  67502. private static readonly _logSpaces;
  67503. private _logIndentLevel;
  67504. private _loggingEnabled;
  67505. /** @hidden */ private _log: (message: string) => void;
  67506. /** @hidden */ private _logOpen(message: string): void;
  67507. /** @hidden */ private _logClose(): void;
  67508. private _logEnabled;
  67509. private _logDisabled;
  67510. private _capturePerformanceCounters;
  67511. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  67512. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  67513. private _startPerformanceCounterEnabled;
  67514. private _startPerformanceCounterDisabled;
  67515. private _endPerformanceCounterEnabled;
  67516. private _endPerformanceCounterDisabled;
  67517. }
  67518. }
  67519. declare module BABYLON.GLTF1 {
  67520. /**
  67521. * Enums
  67522. * @hidden
  67523. */
  67524. export enum EComponentType {
  67525. BYTE = 5120,
  67526. UNSIGNED_BYTE = 5121,
  67527. SHORT = 5122,
  67528. UNSIGNED_SHORT = 5123,
  67529. FLOAT = 5126
  67530. }
  67531. /** @hidden */
  67532. export enum EShaderType {
  67533. FRAGMENT = 35632,
  67534. VERTEX = 35633
  67535. }
  67536. /** @hidden */
  67537. export enum EParameterType {
  67538. BYTE = 5120,
  67539. UNSIGNED_BYTE = 5121,
  67540. SHORT = 5122,
  67541. UNSIGNED_SHORT = 5123,
  67542. INT = 5124,
  67543. UNSIGNED_INT = 5125,
  67544. FLOAT = 5126,
  67545. FLOAT_VEC2 = 35664,
  67546. FLOAT_VEC3 = 35665,
  67547. FLOAT_VEC4 = 35666,
  67548. INT_VEC2 = 35667,
  67549. INT_VEC3 = 35668,
  67550. INT_VEC4 = 35669,
  67551. BOOL = 35670,
  67552. BOOL_VEC2 = 35671,
  67553. BOOL_VEC3 = 35672,
  67554. BOOL_VEC4 = 35673,
  67555. FLOAT_MAT2 = 35674,
  67556. FLOAT_MAT3 = 35675,
  67557. FLOAT_MAT4 = 35676,
  67558. SAMPLER_2D = 35678
  67559. }
  67560. /** @hidden */
  67561. export enum ETextureWrapMode {
  67562. CLAMP_TO_EDGE = 33071,
  67563. MIRRORED_REPEAT = 33648,
  67564. REPEAT = 10497
  67565. }
  67566. /** @hidden */
  67567. export enum ETextureFilterType {
  67568. NEAREST = 9728,
  67569. LINEAR = 9728,
  67570. NEAREST_MIPMAP_NEAREST = 9984,
  67571. LINEAR_MIPMAP_NEAREST = 9985,
  67572. NEAREST_MIPMAP_LINEAR = 9986,
  67573. LINEAR_MIPMAP_LINEAR = 9987
  67574. }
  67575. /** @hidden */
  67576. export enum ETextureFormat {
  67577. ALPHA = 6406,
  67578. RGB = 6407,
  67579. RGBA = 6408,
  67580. LUMINANCE = 6409,
  67581. LUMINANCE_ALPHA = 6410
  67582. }
  67583. /** @hidden */
  67584. export enum ECullingType {
  67585. FRONT = 1028,
  67586. BACK = 1029,
  67587. FRONT_AND_BACK = 1032
  67588. }
  67589. /** @hidden */
  67590. export enum EBlendingFunction {
  67591. ZERO = 0,
  67592. ONE = 1,
  67593. SRC_COLOR = 768,
  67594. ONE_MINUS_SRC_COLOR = 769,
  67595. DST_COLOR = 774,
  67596. ONE_MINUS_DST_COLOR = 775,
  67597. SRC_ALPHA = 770,
  67598. ONE_MINUS_SRC_ALPHA = 771,
  67599. DST_ALPHA = 772,
  67600. ONE_MINUS_DST_ALPHA = 773,
  67601. CONSTANT_COLOR = 32769,
  67602. ONE_MINUS_CONSTANT_COLOR = 32770,
  67603. CONSTANT_ALPHA = 32771,
  67604. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67605. SRC_ALPHA_SATURATE = 776
  67606. }
  67607. /** @hidden */
  67608. export interface IGLTFProperty {
  67609. extensions?: {
  67610. [key: string]: any;
  67611. };
  67612. extras?: Object;
  67613. }
  67614. /** @hidden */
  67615. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67616. name?: string;
  67617. }
  67618. /** @hidden */
  67619. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67620. bufferView: string;
  67621. byteOffset: number;
  67622. byteStride: number;
  67623. count: number;
  67624. type: string;
  67625. componentType: EComponentType;
  67626. max?: number[];
  67627. min?: number[];
  67628. name?: string;
  67629. }
  67630. /** @hidden */
  67631. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67632. buffer: string;
  67633. byteOffset: number;
  67634. byteLength: number;
  67635. byteStride: number;
  67636. target?: number;
  67637. }
  67638. /** @hidden */
  67639. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67640. uri: string;
  67641. byteLength?: number;
  67642. type?: string;
  67643. }
  67644. /** @hidden */
  67645. export interface IGLTFShader extends IGLTFChildRootProperty {
  67646. uri: string;
  67647. type: EShaderType;
  67648. }
  67649. /** @hidden */
  67650. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67651. attributes: string[];
  67652. fragmentShader: string;
  67653. vertexShader: string;
  67654. }
  67655. /** @hidden */
  67656. export interface IGLTFTechniqueParameter {
  67657. type: number;
  67658. count?: number;
  67659. semantic?: string;
  67660. node?: string;
  67661. value?: number | boolean | string | Array<any>;
  67662. source?: string;
  67663. babylonValue?: any;
  67664. }
  67665. /** @hidden */
  67666. export interface IGLTFTechniqueCommonProfile {
  67667. lightingModel: string;
  67668. texcoordBindings: Object;
  67669. parameters?: Array<any>;
  67670. }
  67671. /** @hidden */
  67672. export interface IGLTFTechniqueStatesFunctions {
  67673. blendColor?: number[];
  67674. blendEquationSeparate?: number[];
  67675. blendFuncSeparate?: number[];
  67676. colorMask: boolean[];
  67677. cullFace: number[];
  67678. }
  67679. /** @hidden */
  67680. export interface IGLTFTechniqueStates {
  67681. enable: number[];
  67682. functions: IGLTFTechniqueStatesFunctions;
  67683. }
  67684. /** @hidden */
  67685. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67686. parameters: {
  67687. [key: string]: IGLTFTechniqueParameter;
  67688. };
  67689. program: string;
  67690. attributes: {
  67691. [key: string]: string;
  67692. };
  67693. uniforms: {
  67694. [key: string]: string;
  67695. };
  67696. states: IGLTFTechniqueStates;
  67697. }
  67698. /** @hidden */
  67699. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67700. technique?: string;
  67701. values: string[];
  67702. }
  67703. /** @hidden */
  67704. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67705. attributes: {
  67706. [key: string]: string;
  67707. };
  67708. indices: string;
  67709. material: string;
  67710. mode?: number;
  67711. }
  67712. /** @hidden */
  67713. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67714. primitives: IGLTFMeshPrimitive[];
  67715. }
  67716. /** @hidden */
  67717. export interface IGLTFImage extends IGLTFChildRootProperty {
  67718. uri: string;
  67719. }
  67720. /** @hidden */
  67721. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67722. magFilter?: number;
  67723. minFilter?: number;
  67724. wrapS?: number;
  67725. wrapT?: number;
  67726. }
  67727. /** @hidden */
  67728. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67729. sampler: string;
  67730. source: string;
  67731. format?: ETextureFormat;
  67732. internalFormat?: ETextureFormat;
  67733. target?: number;
  67734. type?: number;
  67735. babylonTexture?: Texture;
  67736. }
  67737. /** @hidden */
  67738. export interface IGLTFAmbienLight {
  67739. color?: number[];
  67740. }
  67741. /** @hidden */
  67742. export interface IGLTFDirectionalLight {
  67743. color?: number[];
  67744. }
  67745. /** @hidden */
  67746. export interface IGLTFPointLight {
  67747. color?: number[];
  67748. constantAttenuation?: number;
  67749. linearAttenuation?: number;
  67750. quadraticAttenuation?: number;
  67751. }
  67752. /** @hidden */
  67753. export interface IGLTFSpotLight {
  67754. color?: number[];
  67755. constantAttenuation?: number;
  67756. fallOfAngle?: number;
  67757. fallOffExponent?: number;
  67758. linearAttenuation?: number;
  67759. quadraticAttenuation?: number;
  67760. }
  67761. /** @hidden */
  67762. export interface IGLTFLight extends IGLTFChildRootProperty {
  67763. type: string;
  67764. }
  67765. /** @hidden */
  67766. export interface IGLTFCameraOrthographic {
  67767. xmag: number;
  67768. ymag: number;
  67769. zfar: number;
  67770. znear: number;
  67771. }
  67772. /** @hidden */
  67773. export interface IGLTFCameraPerspective {
  67774. aspectRatio: number;
  67775. yfov: number;
  67776. zfar: number;
  67777. znear: number;
  67778. }
  67779. /** @hidden */
  67780. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67781. type: string;
  67782. }
  67783. /** @hidden */
  67784. export interface IGLTFAnimationChannelTarget {
  67785. id: string;
  67786. path: string;
  67787. }
  67788. /** @hidden */
  67789. export interface IGLTFAnimationChannel {
  67790. sampler: string;
  67791. target: IGLTFAnimationChannelTarget;
  67792. }
  67793. /** @hidden */
  67794. export interface IGLTFAnimationSampler {
  67795. input: string;
  67796. output: string;
  67797. interpolation?: string;
  67798. }
  67799. /** @hidden */
  67800. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67801. channels?: IGLTFAnimationChannel[];
  67802. parameters?: {
  67803. [key: string]: string;
  67804. };
  67805. samplers?: {
  67806. [key: string]: IGLTFAnimationSampler;
  67807. };
  67808. }
  67809. /** @hidden */
  67810. export interface IGLTFNodeInstanceSkin {
  67811. skeletons: string[];
  67812. skin: string;
  67813. meshes: string[];
  67814. }
  67815. /** @hidden */
  67816. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67817. bindShapeMatrix: number[];
  67818. inverseBindMatrices: string;
  67819. jointNames: string[];
  67820. babylonSkeleton?: Skeleton;
  67821. }
  67822. /** @hidden */
  67823. export interface IGLTFNode extends IGLTFChildRootProperty {
  67824. camera?: string;
  67825. children: string[];
  67826. skin?: string;
  67827. jointName?: string;
  67828. light?: string;
  67829. matrix: number[];
  67830. mesh?: string;
  67831. meshes?: string[];
  67832. rotation?: number[];
  67833. scale?: number[];
  67834. translation?: number[];
  67835. babylonNode?: Node;
  67836. }
  67837. /** @hidden */
  67838. export interface IGLTFScene extends IGLTFChildRootProperty {
  67839. nodes: string[];
  67840. }
  67841. /** @hidden */
  67842. export interface IGLTFRuntime {
  67843. extensions: {
  67844. [key: string]: any;
  67845. };
  67846. accessors: {
  67847. [key: string]: IGLTFAccessor;
  67848. };
  67849. buffers: {
  67850. [key: string]: IGLTFBuffer;
  67851. };
  67852. bufferViews: {
  67853. [key: string]: IGLTFBufferView;
  67854. };
  67855. meshes: {
  67856. [key: string]: IGLTFMesh;
  67857. };
  67858. lights: {
  67859. [key: string]: IGLTFLight;
  67860. };
  67861. cameras: {
  67862. [key: string]: IGLTFCamera;
  67863. };
  67864. nodes: {
  67865. [key: string]: IGLTFNode;
  67866. };
  67867. images: {
  67868. [key: string]: IGLTFImage;
  67869. };
  67870. textures: {
  67871. [key: string]: IGLTFTexture;
  67872. };
  67873. shaders: {
  67874. [key: string]: IGLTFShader;
  67875. };
  67876. programs: {
  67877. [key: string]: IGLTFProgram;
  67878. };
  67879. samplers: {
  67880. [key: string]: IGLTFSampler;
  67881. };
  67882. techniques: {
  67883. [key: string]: IGLTFTechnique;
  67884. };
  67885. materials: {
  67886. [key: string]: IGLTFMaterial;
  67887. };
  67888. animations: {
  67889. [key: string]: IGLTFAnimation;
  67890. };
  67891. skins: {
  67892. [key: string]: IGLTFSkins;
  67893. };
  67894. currentScene?: Object;
  67895. scenes: {
  67896. [key: string]: IGLTFScene;
  67897. };
  67898. extensionsUsed: string[];
  67899. extensionsRequired?: string[];
  67900. buffersCount: number;
  67901. shaderscount: number;
  67902. scene: Scene;
  67903. rootUrl: string;
  67904. loadedBufferCount: number;
  67905. loadedBufferViews: {
  67906. [name: string]: ArrayBufferView;
  67907. };
  67908. loadedShaderCount: number;
  67909. importOnlyMeshes: boolean;
  67910. importMeshesNames?: string[];
  67911. dummyNodes: Node[];
  67912. }
  67913. /** @hidden */
  67914. export interface INodeToRoot {
  67915. bone: Bone;
  67916. node: IGLTFNode;
  67917. id: string;
  67918. }
  67919. /** @hidden */
  67920. export interface IJointNode {
  67921. node: IGLTFNode;
  67922. id: string;
  67923. }
  67924. }
  67925. declare module BABYLON.GLTF1 {
  67926. /**
  67927. * Utils functions for GLTF
  67928. * @hidden
  67929. */
  67930. export class GLTFUtils {
  67931. /**
  67932. * Sets the given "parameter" matrix
  67933. * @param scene: the Scene object
  67934. * @param source: the source node where to pick the matrix
  67935. * @param parameter: the GLTF technique parameter
  67936. * @param uniformName: the name of the shader's uniform
  67937. * @param shaderMaterial: the shader material
  67938. */
  67939. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67940. /**
  67941. * Sets the given "parameter" matrix
  67942. * @param shaderMaterial: the shader material
  67943. * @param uniform: the name of the shader's uniform
  67944. * @param value: the value of the uniform
  67945. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67946. */
  67947. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67948. /**
  67949. * Returns the wrap mode of the texture
  67950. * @param mode: the mode value
  67951. */
  67952. static GetWrapMode(mode: number): number;
  67953. /**
  67954. * Returns the byte stride giving an accessor
  67955. * @param accessor: the GLTF accessor objet
  67956. */
  67957. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67958. /**
  67959. * Returns the texture filter mode giving a mode value
  67960. * @param mode: the filter mode value
  67961. */
  67962. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67963. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67964. /**
  67965. * Returns a buffer from its accessor
  67966. * @param gltfRuntime: the GLTF runtime
  67967. * @param accessor: the GLTF accessor
  67968. */
  67969. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67970. /**
  67971. * Decodes a buffer view into a string
  67972. * @param view: the buffer view
  67973. */
  67974. static DecodeBufferToText(view: ArrayBufferView): string;
  67975. /**
  67976. * Returns the default material of gltf. Related to
  67977. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67978. * @param scene: the Babylon.js scene
  67979. */
  67980. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67981. private static _DefaultMaterial;
  67982. }
  67983. }
  67984. declare module BABYLON.GLTF1 {
  67985. /**
  67986. * Implementation of the base glTF spec
  67987. * @hidden
  67988. */
  67989. export class GLTFLoaderBase {
  67990. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67991. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67992. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67993. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67994. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67995. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67996. }
  67997. /**
  67998. * glTF V1 Loader
  67999. * @hidden
  68000. */
  68001. export class GLTFLoader implements IGLTFLoader {
  68002. static Extensions: {
  68003. [name: string]: GLTFLoaderExtension;
  68004. };
  68005. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68006. state: Nullable<GLTFLoaderState>;
  68007. dispose(): void;
  68008. private _importMeshAsync;
  68009. /**
  68010. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68011. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68012. * @param scene the scene the meshes should be added to
  68013. * @param data gltf data containing information of the meshes in a loaded file
  68014. * @param rootUrl root url to load from
  68015. * @param onProgress event that fires when loading progress has occured
  68016. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68017. */
  68018. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68019. meshes: AbstractMesh[];
  68020. particleSystems: IParticleSystem[];
  68021. skeletons: Skeleton[];
  68022. animationGroups: AnimationGroup[];
  68023. }>;
  68024. private _loadAsync;
  68025. /**
  68026. * Imports all objects from a loaded gltf file and adds them to the scene
  68027. * @param scene the scene the objects should be added to
  68028. * @param data gltf data containing information of the meshes in a loaded file
  68029. * @param rootUrl root url to load from
  68030. * @param onProgress event that fires when loading progress has occured
  68031. * @returns a promise which completes when objects have been loaded to the scene
  68032. */
  68033. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68034. private _loadShadersAsync;
  68035. private _loadBuffersAsync;
  68036. private _createNodes;
  68037. }
  68038. /** @hidden */
  68039. export abstract class GLTFLoaderExtension {
  68040. private _name;
  68041. constructor(name: string);
  68042. readonly name: string;
  68043. /**
  68044. * Defines an override for loading the runtime
  68045. * Return true to stop further extensions from loading the runtime
  68046. */
  68047. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68048. /**
  68049. * Defines an onverride for creating gltf runtime
  68050. * Return true to stop further extensions from creating the runtime
  68051. */
  68052. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68053. /**
  68054. * Defines an override for loading buffers
  68055. * Return true to stop further extensions from loading this buffer
  68056. */
  68057. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68058. /**
  68059. * Defines an override for loading texture buffers
  68060. * Return true to stop further extensions from loading this texture data
  68061. */
  68062. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68063. /**
  68064. * Defines an override for creating textures
  68065. * Return true to stop further extensions from loading this texture
  68066. */
  68067. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68068. /**
  68069. * Defines an override for loading shader strings
  68070. * Return true to stop further extensions from loading this shader data
  68071. */
  68072. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68073. /**
  68074. * Defines an override for loading materials
  68075. * Return true to stop further extensions from loading this material
  68076. */
  68077. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68078. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68079. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68080. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68081. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68082. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68083. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68084. private static LoadTextureBufferAsync;
  68085. private static CreateTextureAsync;
  68086. private static ApplyExtensions;
  68087. }
  68088. }
  68089. declare module BABYLON.GLTF1 {
  68090. /** @hidden */
  68091. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68092. private _bin;
  68093. constructor();
  68094. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68095. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68096. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68097. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68098. }
  68099. }
  68100. declare module BABYLON.GLTF1 {
  68101. /** @hidden */
  68102. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68103. constructor();
  68104. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68105. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68106. private _loadTexture;
  68107. }
  68108. }
  68109. declare module BABYLON.GLTF2.Loader {
  68110. /**
  68111. * Loader interface with an index field.
  68112. */
  68113. export interface IArrayItem {
  68114. /**
  68115. * The index of this item in the array.
  68116. */
  68117. index: number;
  68118. }
  68119. /**
  68120. * Loader interface with additional members.
  68121. */
  68122. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68123. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68124. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  68125. }
  68126. /**
  68127. * Loader interface with additional members.
  68128. */
  68129. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68130. }
  68131. /** @hidden */
  68132. export interface _IAnimationSamplerData {
  68133. input: Float32Array;
  68134. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68135. output: Float32Array;
  68136. }
  68137. /**
  68138. * Loader interface with additional members.
  68139. */
  68140. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68141. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  68142. }
  68143. /**
  68144. * Loader interface with additional members.
  68145. */
  68146. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68147. channels: IAnimationChannel[];
  68148. samplers: IAnimationSampler[];
  68149. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  68150. }
  68151. /**
  68152. * Loader interface with additional members.
  68153. */
  68154. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68155. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68156. }
  68157. /**
  68158. * Loader interface with additional members.
  68159. */
  68160. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68161. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68162. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  68163. }
  68164. /**
  68165. * Loader interface with additional members.
  68166. */
  68167. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68168. }
  68169. /**
  68170. * Loader interface with additional members.
  68171. */
  68172. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68173. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68174. }
  68175. /**
  68176. * Loader interface with additional members.
  68177. */
  68178. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68179. }
  68180. /**
  68181. * Loader interface with additional members.
  68182. */
  68183. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68184. }
  68185. /**
  68186. * Loader interface with additional members.
  68187. */
  68188. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68189. baseColorTexture?: ITextureInfo;
  68190. metallicRoughnessTexture?: ITextureInfo;
  68191. }
  68192. /**
  68193. * Loader interface with additional members.
  68194. */
  68195. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68196. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68197. normalTexture?: IMaterialNormalTextureInfo;
  68198. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68199. emissiveTexture?: ITextureInfo;
  68200. /** @hidden */ private _data?: {
  68201. [babylonDrawMode: number]: {
  68202. babylonMaterial: Material;
  68203. babylonMeshes: AbstractMesh[];
  68204. promise: Promise<void>;
  68205. };
  68206. };
  68207. }
  68208. /**
  68209. * Loader interface with additional members.
  68210. */
  68211. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68212. primitives: IMeshPrimitive[];
  68213. }
  68214. /**
  68215. * Loader interface with additional members.
  68216. */
  68217. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68218. /** @hidden */ private _instanceData?: {
  68219. babylonSourceMesh: Mesh;
  68220. promise: Promise<any>;
  68221. };
  68222. }
  68223. /**
  68224. * Loader interface with additional members.
  68225. */
  68226. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68227. /**
  68228. * The parent glTF node.
  68229. */
  68230. parent?: INode;
  68231. /** @hidden */ private _babylonTransformNode?: TransformNode;
  68232. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  68233. /** @hidden */ private _babylonBones?: Bone[];
  68234. /** @hidden */ private _numMorphTargets?: number;
  68235. }
  68236. /** @hidden */
  68237. export interface _ISamplerData {
  68238. noMipMaps: boolean;
  68239. samplingMode: number;
  68240. wrapU: number;
  68241. wrapV: number;
  68242. }
  68243. /**
  68244. * Loader interface with additional members.
  68245. */
  68246. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68247. /** @hidden */ private _data?: _ISamplerData;
  68248. }
  68249. /**
  68250. * Loader interface with additional members.
  68251. */
  68252. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68253. }
  68254. /**
  68255. * Loader interface with additional members.
  68256. */
  68257. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68258. /** @hidden */ private _data?: {
  68259. babylonSkeleton: Skeleton;
  68260. promise: Promise<void>;
  68261. };
  68262. }
  68263. /**
  68264. * Loader interface with additional members.
  68265. */
  68266. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68267. }
  68268. /**
  68269. * Loader interface with additional members.
  68270. */
  68271. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68272. }
  68273. /**
  68274. * Loader interface with additional members.
  68275. */
  68276. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68277. accessors?: IAccessor[];
  68278. animations?: IAnimation[];
  68279. buffers?: IBuffer[];
  68280. bufferViews?: IBufferView[];
  68281. cameras?: ICamera[];
  68282. images?: IImage[];
  68283. materials?: IMaterial[];
  68284. meshes?: IMesh[];
  68285. nodes?: INode[];
  68286. samplers?: ISampler[];
  68287. scenes?: IScene[];
  68288. skins?: ISkin[];
  68289. textures?: ITexture[];
  68290. }
  68291. }
  68292. declare module BABYLON.GLTF2 {
  68293. /**
  68294. * Interface for a glTF loader extension.
  68295. */
  68296. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68297. /**
  68298. * Called after the loader state changes to LOADING.
  68299. */
  68300. onLoading?(): void;
  68301. /**
  68302. * Called after the loader state changes to READY.
  68303. */
  68304. onReady?(): void;
  68305. /**
  68306. * Define this method to modify the default behavior when loading scenes.
  68307. * @param context The context when loading the asset
  68308. * @param scene The glTF scene property
  68309. * @returns A promise that resolves when the load is complete or null if not handled
  68310. */
  68311. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68312. /**
  68313. * Define this method to modify the default behavior when loading nodes.
  68314. * @param context The context when loading the asset
  68315. * @param node The glTF node property
  68316. * @param assign A function called synchronously after parsing the glTF properties
  68317. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68318. */
  68319. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68320. /**
  68321. * Define this method to modify the default behavior when loading cameras.
  68322. * @param context The context when loading the asset
  68323. * @param camera The glTF camera property
  68324. * @param assign A function called synchronously after parsing the glTF properties
  68325. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68326. */
  68327. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68328. /**
  68329. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68330. * @param context The context when loading the asset
  68331. * @param primitive The glTF mesh primitive property
  68332. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68333. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68334. /**
  68335. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68336. * @param context The context when loading the asset
  68337. * @param name The mesh name when loading the asset
  68338. * @param node The glTF node when loading the asset
  68339. * @param mesh The glTF mesh when loading the asset
  68340. * @param primitive The glTF mesh primitive property
  68341. * @param assign A function called synchronously after parsing the glTF properties
  68342. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68343. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68344. /**
  68345. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68346. * @param context The context when loading the asset
  68347. * @param material The glTF material property
  68348. * @param assign A function called synchronously after parsing the glTF properties
  68349. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68350. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68351. /**
  68352. * Define this method to modify the default behavior when creating materials.
  68353. * @param context The context when loading the asset
  68354. * @param material The glTF material property
  68355. * @param babylonDrawMode The draw mode for the Babylon material
  68356. * @returns The Babylon material or null if not handled
  68357. */
  68358. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68359. /**
  68360. * Define this method to modify the default behavior when loading material properties.
  68361. * @param context The context when loading the asset
  68362. * @param material The glTF material property
  68363. * @param babylonMaterial The Babylon material
  68364. * @returns A promise that resolves when the load is complete or null if not handled
  68365. */
  68366. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68367. /**
  68368. * Define this method to modify the default behavior when loading texture infos.
  68369. * @param context The context when loading the asset
  68370. * @param textureInfo The glTF texture info property
  68371. * @param assign A function called synchronously after parsing the glTF properties
  68372. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68373. */
  68374. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68375. /**
  68376. * Define this method to modify the default behavior when loading animations.
  68377. * @param context The context when loading the asset
  68378. * @param animation The glTF animation property
  68379. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68380. */
  68381. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68382. /**
  68383. * @hidden Define this method to modify the default behavior when loading skins.
  68384. * @param context The context when loading the asset
  68385. * @param node The glTF node property
  68386. * @param skin The glTF skin property
  68387. * @returns A promise that resolves when the load is complete or null if not handled
  68388. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68389. /**
  68390. * @hidden Define this method to modify the default behavior when loading uris.
  68391. * @param context The context when loading the asset
  68392. * @param property The glTF property associated with the uri
  68393. * @param uri The uri to load
  68394. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68395. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68396. /**
  68397. * Define this method to modify the default behavior when loading buffer views.
  68398. * @param context The context when loading the asset
  68399. * @param bufferView The glTF buffer view property
  68400. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68401. */
  68402. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  68403. /**
  68404. * Define this method to modify the default behavior when loading buffers.
  68405. * @param context The context when loading the asset
  68406. * @param buffer The glTF buffer property
  68407. * @param byteOffset The byte offset to load
  68408. * @param byteLength The byte length to load
  68409. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68410. */
  68411. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  68412. }
  68413. }
  68414. declare module BABYLON.GLTF2 {
  68415. /**
  68416. * Helper class for working with arrays when loading the glTF asset
  68417. */
  68418. export class ArrayItem {
  68419. /**
  68420. * Gets an item from the given array.
  68421. * @param context The context when loading the asset
  68422. * @param array The array to get the item from
  68423. * @param index The index to the array
  68424. * @returns The array item
  68425. */
  68426. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68427. /**
  68428. * Assign an `index` field to each item of the given array.
  68429. * @param array The array of items
  68430. */
  68431. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68432. }
  68433. /**
  68434. * The glTF 2.0 loader
  68435. */
  68436. export class GLTFLoader implements IGLTFLoader {
  68437. /** @hidden */ private _completePromises: Promise<any>[];
  68438. private _disposed;
  68439. private _parent;
  68440. private _state;
  68441. private _extensions;
  68442. private _rootUrl;
  68443. private _fileName;
  68444. private _uniqueRootUrl;
  68445. private _gltf;
  68446. private _bin;
  68447. private _babylonScene;
  68448. private _rootBabylonMesh;
  68449. private _defaultBabylonMaterialData;
  68450. private _progressCallback?;
  68451. private _requests;
  68452. private static readonly _DefaultSampler;
  68453. private static _RegisteredExtensions;
  68454. /**
  68455. * Registers a loader extension.
  68456. * @param name The name of the loader extension.
  68457. * @param factory The factory function that creates the loader extension.
  68458. */
  68459. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68460. /**
  68461. * Unregisters a loader extension.
  68462. * @param name The name of the loader extension.
  68463. * @returns A boolean indicating whether the extension has been unregistered
  68464. */
  68465. static UnregisterExtension(name: string): boolean;
  68466. /**
  68467. * Gets the loader state.
  68468. */
  68469. readonly state: Nullable<GLTFLoaderState>;
  68470. /**
  68471. * The object that represents the glTF JSON.
  68472. */
  68473. readonly gltf: IGLTF;
  68474. /**
  68475. * The BIN chunk of a binary glTF.
  68476. */
  68477. readonly bin: Nullable<IDataBuffer>;
  68478. /**
  68479. * The parent file loader.
  68480. */
  68481. readonly parent: GLTFFileLoader;
  68482. /**
  68483. * The Babylon scene when loading the asset.
  68484. */
  68485. readonly babylonScene: Scene;
  68486. /**
  68487. * The root Babylon mesh when loading the asset.
  68488. */
  68489. readonly rootBabylonMesh: Mesh;
  68490. /** @hidden */
  68491. constructor(parent: GLTFFileLoader);
  68492. /** @hidden */
  68493. dispose(): void;
  68494. /** @hidden */
  68495. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68496. meshes: AbstractMesh[];
  68497. particleSystems: IParticleSystem[];
  68498. skeletons: Skeleton[];
  68499. animationGroups: AnimationGroup[];
  68500. }>;
  68501. /** @hidden */
  68502. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68503. private _loadAsync;
  68504. private _loadData;
  68505. private _setupData;
  68506. private _loadExtensions;
  68507. private _checkExtensions;
  68508. private _setState;
  68509. private _createRootNode;
  68510. /**
  68511. * Loads a glTF scene.
  68512. * @param context The context when loading the asset
  68513. * @param scene The glTF scene property
  68514. * @returns A promise that resolves when the load is complete
  68515. */
  68516. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68517. private _forEachPrimitive;
  68518. private _getMeshes;
  68519. private _getSkeletons;
  68520. private _getAnimationGroups;
  68521. private _startAnimations;
  68522. /**
  68523. * Loads a glTF node.
  68524. * @param context The context when loading the asset
  68525. * @param node The glTF node property
  68526. * @param assign A function called synchronously after parsing the glTF properties
  68527. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68528. */
  68529. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68530. private _loadMeshAsync;
  68531. /**
  68532. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68533. * @param context The context when loading the asset
  68534. * @param name The mesh name when loading the asset
  68535. * @param node The glTF node when loading the asset
  68536. * @param mesh The glTF mesh when loading the asset
  68537. * @param primitive The glTF mesh primitive property
  68538. * @param assign A function called synchronously after parsing the glTF properties
  68539. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68540. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68541. private _loadVertexDataAsync;
  68542. private _createMorphTargets;
  68543. private _loadMorphTargetsAsync;
  68544. private _loadMorphTargetVertexDataAsync;
  68545. private static _LoadTransform;
  68546. private _loadSkinAsync;
  68547. private _loadBones;
  68548. private _loadBone;
  68549. private _loadSkinInverseBindMatricesDataAsync;
  68550. private _updateBoneMatrices;
  68551. private _getNodeMatrix;
  68552. /**
  68553. * Loads a glTF camera.
  68554. * @param context The context when loading the asset
  68555. * @param camera The glTF camera property
  68556. * @param assign A function called synchronously after parsing the glTF properties
  68557. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68558. */
  68559. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68560. private _loadAnimationsAsync;
  68561. /**
  68562. * Loads a glTF animation.
  68563. * @param context The context when loading the asset
  68564. * @param animation The glTF animation property
  68565. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68566. */
  68567. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68568. /**
  68569. * @hidden Loads a glTF animation channel.
  68570. * @param context The context when loading the asset
  68571. * @param animationContext The context of the animation when loading the asset
  68572. * @param animation The glTF animation property
  68573. * @param channel The glTF animation channel property
  68574. * @param babylonAnimationGroup The babylon animation group property
  68575. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68576. * @returns A void promise when the channel load is complete
  68577. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68578. private _loadAnimationSamplerAsync;
  68579. private _loadBufferAsync;
  68580. /**
  68581. * Loads a glTF buffer view.
  68582. * @param context The context when loading the asset
  68583. * @param bufferView The glTF buffer view property
  68584. * @returns A promise that resolves with the loaded data when the load is complete
  68585. */
  68586. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68587. private _loadAccessorAsync;
  68588. private _loadFloatAccessorAsync;
  68589. private _loadIndicesAccessorAsync;
  68590. private _loadVertexBufferViewAsync;
  68591. private _loadVertexAccessorAsync;
  68592. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68593. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68594. private _createDefaultMaterial;
  68595. /**
  68596. * Creates a Babylon material from a glTF material.
  68597. * @param context The context when loading the asset
  68598. * @param material The glTF material property
  68599. * @param babylonDrawMode The draw mode for the Babylon material
  68600. * @returns The Babylon material
  68601. */
  68602. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68603. /**
  68604. * Loads properties from a glTF material into a Babylon material.
  68605. * @param context The context when loading the asset
  68606. * @param material The glTF material property
  68607. * @param babylonMaterial The Babylon material
  68608. * @returns A promise that resolves when the load is complete
  68609. */
  68610. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68611. /**
  68612. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68613. * @param context The context when loading the asset
  68614. * @param material The glTF material property
  68615. * @param babylonMaterial The Babylon material
  68616. * @returns A promise that resolves when the load is complete
  68617. */
  68618. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68619. /**
  68620. * Loads the alpha properties from a glTF material into a Babylon material.
  68621. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68622. * @param context The context when loading the asset
  68623. * @param material The glTF material property
  68624. * @param babylonMaterial The Babylon material
  68625. */
  68626. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68627. /**
  68628. * Loads a glTF texture info.
  68629. * @param context The context when loading the asset
  68630. * @param textureInfo The glTF texture info property
  68631. * @param assign A function called synchronously after parsing the glTF properties
  68632. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68633. */
  68634. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68635. private _loadTextureAsync;
  68636. private _loadSampler;
  68637. /**
  68638. * Loads a glTF image.
  68639. * @param context The context when loading the asset
  68640. * @param image The glTF image property
  68641. * @returns A promise that resolves with the loaded data when the load is complete
  68642. */
  68643. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68644. /**
  68645. * Loads a glTF uri.
  68646. * @param context The context when loading the asset
  68647. * @param property The glTF property associated with the uri
  68648. * @param uri The base64 or relative uri
  68649. * @returns A promise that resolves with the loaded data when the load is complete
  68650. */
  68651. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68652. private _onProgress;
  68653. /**
  68654. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68655. * @param babylonObject the Babylon object with metadata
  68656. * @param pointer the JSON pointer
  68657. */
  68658. static AddPointerMetadata(babylonObject: {
  68659. metadata: any;
  68660. }, pointer: string): void;
  68661. private static _GetTextureWrapMode;
  68662. private static _GetTextureSamplingMode;
  68663. private static _GetTypedArrayConstructor;
  68664. private static _GetTypedArray;
  68665. private static _GetNumComponents;
  68666. private static _ValidateUri;
  68667. private static _GetDrawMode;
  68668. private _compileMaterialsAsync;
  68669. private _compileShadowGeneratorsAsync;
  68670. private _forEachExtensions;
  68671. private _applyExtensions;
  68672. private _extensionsOnLoading;
  68673. private _extensionsOnReady;
  68674. private _extensionsLoadSceneAsync;
  68675. private _extensionsLoadNodeAsync;
  68676. private _extensionsLoadCameraAsync;
  68677. private _extensionsLoadVertexDataAsync;
  68678. private _extensionsLoadMeshPrimitiveAsync;
  68679. private _extensionsLoadMaterialAsync;
  68680. private _extensionsCreateMaterial;
  68681. private _extensionsLoadMaterialPropertiesAsync;
  68682. private _extensionsLoadTextureInfoAsync;
  68683. private _extensionsLoadAnimationAsync;
  68684. private _extensionsLoadSkinAsync;
  68685. private _extensionsLoadUriAsync;
  68686. private _extensionsLoadBufferViewAsync;
  68687. private _extensionsLoadBufferAsync;
  68688. /**
  68689. * Helper method called by a loader extension to load an glTF extension.
  68690. * @param context The context when loading the asset
  68691. * @param property The glTF property to load the extension from
  68692. * @param extensionName The name of the extension to load
  68693. * @param actionAsync The action to run
  68694. * @returns The promise returned by actionAsync or null if the extension does not exist
  68695. */
  68696. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68697. /**
  68698. * Helper method called by a loader extension to load a glTF extra.
  68699. * @param context The context when loading the asset
  68700. * @param property The glTF property to load the extra from
  68701. * @param extensionName The name of the extension to load
  68702. * @param actionAsync The action to run
  68703. * @returns The promise returned by actionAsync or null if the extra does not exist
  68704. */
  68705. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68706. /**
  68707. * Checks for presence of an extension.
  68708. * @param name The name of the extension to check
  68709. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  68710. */
  68711. isExtensionUsed(name: string): boolean;
  68712. /**
  68713. * Increments the indentation level and logs a message.
  68714. * @param message The message to log
  68715. */
  68716. logOpen(message: string): void;
  68717. /**
  68718. * Decrements the indentation level.
  68719. */
  68720. logClose(): void;
  68721. /**
  68722. * Logs a message
  68723. * @param message The message to log
  68724. */
  68725. log(message: string): void;
  68726. /**
  68727. * Starts a performance counter.
  68728. * @param counterName The name of the performance counter
  68729. */
  68730. startPerformanceCounter(counterName: string): void;
  68731. /**
  68732. * Ends a performance counter.
  68733. * @param counterName The name of the performance counter
  68734. */
  68735. endPerformanceCounter(counterName: string): void;
  68736. }
  68737. }
  68738. declare module BABYLON.GLTF2.Loader.Extensions {
  68739. /**
  68740. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  68741. */
  68742. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68743. /**
  68744. * The name of this extension.
  68745. */
  68746. readonly name: string;
  68747. /**
  68748. * Defines whether this extension is enabled.
  68749. */
  68750. enabled: boolean;
  68751. private _loader;
  68752. private _lights?;
  68753. /** @hidden */
  68754. constructor(loader: GLTFLoader);
  68755. /** @hidden */
  68756. dispose(): void;
  68757. /** @hidden */
  68758. onLoading(): void;
  68759. /** @hidden */
  68760. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68761. private _loadLightAsync;
  68762. }
  68763. }
  68764. declare module BABYLON.GLTF2.Loader.Extensions {
  68765. /**
  68766. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68767. */
  68768. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68769. /**
  68770. * The name of this extension.
  68771. */
  68772. readonly name: string;
  68773. /**
  68774. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  68775. */
  68776. dracoCompression?: DracoCompression;
  68777. /**
  68778. * Defines whether this extension is enabled.
  68779. */
  68780. enabled: boolean;
  68781. private _loader;
  68782. /** @hidden */
  68783. constructor(loader: GLTFLoader);
  68784. /** @hidden */
  68785. dispose(): void;
  68786. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68787. }
  68788. }
  68789. declare module BABYLON.GLTF2.Loader.Extensions {
  68790. /**
  68791. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68792. */
  68793. export class KHR_lights implements IGLTFLoaderExtension {
  68794. /**
  68795. * The name of this extension.
  68796. */
  68797. readonly name: string;
  68798. /**
  68799. * Defines whether this extension is enabled.
  68800. */
  68801. enabled: boolean;
  68802. private _loader;
  68803. private _lights?;
  68804. /** @hidden */
  68805. constructor(loader: GLTFLoader);
  68806. /** @hidden */
  68807. dispose(): void;
  68808. /** @hidden */
  68809. onLoading(): void;
  68810. /** @hidden */
  68811. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68812. }
  68813. }
  68814. declare module BABYLON.GLTF2.Loader.Extensions {
  68815. /**
  68816. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68817. */
  68818. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68819. /**
  68820. * The name of this extension.
  68821. */
  68822. readonly name: string;
  68823. /**
  68824. * Defines whether this extension is enabled.
  68825. */
  68826. enabled: boolean;
  68827. /**
  68828. * Defines a number that determines the order the extensions are applied.
  68829. */
  68830. order: number;
  68831. private _loader;
  68832. /** @hidden */
  68833. constructor(loader: GLTFLoader);
  68834. /** @hidden */
  68835. dispose(): void;
  68836. /** @hidden */
  68837. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68838. private _loadSpecularGlossinessPropertiesAsync;
  68839. }
  68840. }
  68841. declare module BABYLON.GLTF2.Loader.Extensions {
  68842. /**
  68843. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68844. */
  68845. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68846. /**
  68847. * The name of this extension.
  68848. */
  68849. readonly name: string;
  68850. /**
  68851. * Defines whether this extension is enabled.
  68852. */
  68853. enabled: boolean;
  68854. /**
  68855. * Defines a number that determines the order the extensions are applied.
  68856. */
  68857. order: number;
  68858. private _loader;
  68859. /** @hidden */
  68860. constructor(loader: GLTFLoader);
  68861. /** @hidden */
  68862. dispose(): void;
  68863. /** @hidden */
  68864. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68865. private _loadUnlitPropertiesAsync;
  68866. }
  68867. }
  68868. declare module BABYLON.GLTF2.Loader.Extensions {
  68869. /**
  68870. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68871. */
  68872. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68873. /**
  68874. * The name of this extension.
  68875. */
  68876. readonly name: string;
  68877. /**
  68878. * Defines whether this extension is enabled.
  68879. */
  68880. enabled: boolean;
  68881. private _loader;
  68882. /** @hidden */
  68883. constructor(loader: GLTFLoader);
  68884. /** @hidden */
  68885. dispose(): void;
  68886. /** @hidden */
  68887. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68888. }
  68889. }
  68890. declare module BABYLON.GLTF2.Loader.Extensions {
  68891. /**
  68892. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68893. */
  68894. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68895. /**
  68896. * The name of this extension.
  68897. */
  68898. readonly name: string;
  68899. /**
  68900. * Defines whether this extension is enabled.
  68901. */
  68902. enabled: boolean;
  68903. private _loader;
  68904. private _clips;
  68905. private _emitters;
  68906. /** @hidden */
  68907. constructor(loader: GLTFLoader);
  68908. /** @hidden */
  68909. dispose(): void;
  68910. /** @hidden */
  68911. onLoading(): void;
  68912. /** @hidden */
  68913. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68914. /** @hidden */
  68915. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68916. /** @hidden */
  68917. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68918. private _loadClipAsync;
  68919. private _loadEmitterAsync;
  68920. private _getEventAction;
  68921. private _loadAnimationEventAsync;
  68922. }
  68923. }
  68924. declare module BABYLON.GLTF2.Loader.Extensions {
  68925. /**
  68926. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68927. */
  68928. export class MSFT_lod implements IGLTFLoaderExtension {
  68929. /**
  68930. * The name of this extension.
  68931. */
  68932. readonly name: string;
  68933. /**
  68934. * Defines whether this extension is enabled.
  68935. */
  68936. enabled: boolean;
  68937. /**
  68938. * Defines a number that determines the order the extensions are applied.
  68939. */
  68940. order: number;
  68941. /**
  68942. * Maximum number of LODs to load, starting from the lowest LOD.
  68943. */
  68944. maxLODsToLoad: number;
  68945. /**
  68946. * Observable raised when all node LODs of one level are loaded.
  68947. * The event data is the index of the loaded LOD starting from zero.
  68948. * Dispose the loader to cancel the loading of the next level of LODs.
  68949. */
  68950. onNodeLODsLoadedObservable: Observable<number>;
  68951. /**
  68952. * Observable raised when all material LODs of one level are loaded.
  68953. * The event data is the index of the loaded LOD starting from zero.
  68954. * Dispose the loader to cancel the loading of the next level of LODs.
  68955. */
  68956. onMaterialLODsLoadedObservable: Observable<number>;
  68957. private _loader;
  68958. private _nodeIndexLOD;
  68959. private _nodeSignalLODs;
  68960. private _nodePromiseLODs;
  68961. private _materialIndexLOD;
  68962. private _materialSignalLODs;
  68963. private _materialPromiseLODs;
  68964. private _indexLOD;
  68965. private _bufferLODs;
  68966. /** @hidden */
  68967. constructor(loader: GLTFLoader);
  68968. /** @hidden */
  68969. dispose(): void;
  68970. /** @hidden */
  68971. onReady(): void;
  68972. /** @hidden */
  68973. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68974. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68975. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68976. /** @hidden */
  68977. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  68978. private _loadBufferLOD;
  68979. /**
  68980. * Gets an array of LOD properties from lowest to highest.
  68981. */
  68982. private _getLODs;
  68983. private _disposeUnusedMaterials;
  68984. }
  68985. }
  68986. declare module BABYLON.GLTF2.Loader.Extensions {
  68987. /** @hidden */
  68988. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68989. readonly name: string;
  68990. enabled: boolean;
  68991. private _loader;
  68992. constructor(loader: GLTFLoader);
  68993. dispose(): void;
  68994. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68995. }
  68996. }
  68997. declare module BABYLON.GLTF2.Loader.Extensions {
  68998. /** @hidden */
  68999. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69000. readonly name: string;
  69001. enabled: boolean;
  69002. private _loader;
  69003. constructor(loader: GLTFLoader);
  69004. dispose(): void;
  69005. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69006. }
  69007. }
  69008. declare module BABYLON.GLTF2.Loader.Extensions {
  69009. /**
  69010. * Store glTF extras (if present) in BJS objects' metadata
  69011. */
  69012. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69013. /**
  69014. * The name of this extension.
  69015. */
  69016. readonly name: string;
  69017. /**
  69018. * Defines whether this extension is enabled.
  69019. */
  69020. enabled: boolean;
  69021. private _loader;
  69022. private _assignExtras;
  69023. /** @hidden */
  69024. constructor(loader: GLTFLoader);
  69025. /** @hidden */
  69026. dispose(): void;
  69027. /** @hidden */
  69028. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69029. /** @hidden */
  69030. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69031. /** @hidden */
  69032. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69033. }
  69034. }
  69035. declare module BABYLON {
  69036. /**
  69037. * Class reading and parsing the MTL file bundled with the obj file.
  69038. */
  69039. export class MTLFileLoader {
  69040. /**
  69041. * All material loaded from the mtl will be set here
  69042. */
  69043. materials: StandardMaterial[];
  69044. /**
  69045. * This function will read the mtl file and create each material described inside
  69046. * This function could be improve by adding :
  69047. * -some component missing (Ni, Tf...)
  69048. * -including the specific options available
  69049. *
  69050. * @param scene defines the scene the material will be created in
  69051. * @param data defines the mtl data to parse
  69052. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69053. */
  69054. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69055. /**
  69056. * Gets the texture for the material.
  69057. *
  69058. * If the material is imported from input file,
  69059. * We sanitize the url to ensure it takes the textre from aside the material.
  69060. *
  69061. * @param rootUrl The root url to load from
  69062. * @param value The value stored in the mtl
  69063. * @return The Texture
  69064. */
  69065. private static _getTexture;
  69066. }
  69067. /**
  69068. * Options for loading OBJ/MTL files
  69069. */
  69070. type MeshLoadOptions = {
  69071. /**
  69072. * Defines if UVs are optimized by default during load.
  69073. */
  69074. OptimizeWithUV: boolean;
  69075. /**
  69076. * Defines custom scaling of UV coordinates of loaded meshes.
  69077. */
  69078. UVScaling: Vector2;
  69079. /**
  69080. * Invert model on y-axis (does a model scaling inversion)
  69081. */
  69082. InvertY: boolean;
  69083. /**
  69084. * Invert Y-Axis of referenced textures on load
  69085. */
  69086. InvertTextureY: boolean;
  69087. /**
  69088. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69089. */
  69090. ImportVertexColors: boolean;
  69091. /**
  69092. * Compute the normals for the model, even if normals are present in the file.
  69093. */
  69094. ComputeNormals: boolean;
  69095. /**
  69096. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69097. */
  69098. SkipMaterials: boolean;
  69099. /**
  69100. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69101. */
  69102. MaterialLoadingFailsSilently: boolean;
  69103. };
  69104. /**
  69105. * OBJ file type loader.
  69106. * This is a babylon scene loader plugin.
  69107. */
  69108. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69109. /**
  69110. * Defines if UVs are optimized by default during load.
  69111. */
  69112. static OPTIMIZE_WITH_UV: boolean;
  69113. /**
  69114. * Invert model on y-axis (does a model scaling inversion)
  69115. */
  69116. static INVERT_Y: boolean;
  69117. /**
  69118. * Invert Y-Axis of referenced textures on load
  69119. */
  69120. static INVERT_TEXTURE_Y: boolean;
  69121. /**
  69122. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69123. */
  69124. static IMPORT_VERTEX_COLORS: boolean;
  69125. /**
  69126. * Compute the normals for the model, even if normals are present in the file.
  69127. */
  69128. static COMPUTE_NORMALS: boolean;
  69129. /**
  69130. * Defines custom scaling of UV coordinates of loaded meshes.
  69131. */
  69132. static UV_SCALING: Vector2;
  69133. /**
  69134. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69135. */
  69136. static SKIP_MATERIALS: boolean;
  69137. /**
  69138. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69139. *
  69140. * Defaults to true for backwards compatibility.
  69141. */
  69142. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69143. /**
  69144. * Defines the name of the plugin.
  69145. */
  69146. name: string;
  69147. /**
  69148. * Defines the extension the plugin is able to load.
  69149. */
  69150. extensions: string;
  69151. /** @hidden */
  69152. obj: RegExp;
  69153. /** @hidden */
  69154. group: RegExp;
  69155. /** @hidden */
  69156. mtllib: RegExp;
  69157. /** @hidden */
  69158. usemtl: RegExp;
  69159. /** @hidden */
  69160. smooth: RegExp;
  69161. /** @hidden */
  69162. vertexPattern: RegExp;
  69163. /** @hidden */
  69164. normalPattern: RegExp;
  69165. /** @hidden */
  69166. uvPattern: RegExp;
  69167. /** @hidden */
  69168. facePattern1: RegExp;
  69169. /** @hidden */
  69170. facePattern2: RegExp;
  69171. /** @hidden */
  69172. facePattern3: RegExp;
  69173. /** @hidden */
  69174. facePattern4: RegExp;
  69175. /** @hidden */
  69176. facePattern5: RegExp;
  69177. private _meshLoadOptions;
  69178. /**
  69179. * Creates loader for .OBJ files
  69180. *
  69181. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69182. */
  69183. constructor(meshLoadOptions?: MeshLoadOptions);
  69184. private static readonly currentMeshLoadOptions;
  69185. /**
  69186. * Calls synchronously the MTL file attached to this obj.
  69187. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69188. * Without this function materials are not displayed in the first frame (but displayed after).
  69189. * In consequence it is impossible to get material information in your HTML file
  69190. *
  69191. * @param url The URL of the MTL file
  69192. * @param rootUrl
  69193. * @param onSuccess Callback function to be called when the MTL file is loaded
  69194. * @private
  69195. */
  69196. private _loadMTL;
  69197. /**
  69198. * Instantiates a OBJ file loader plugin.
  69199. * @returns the created plugin
  69200. */
  69201. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69202. /**
  69203. * If the data string can be loaded directly.
  69204. *
  69205. * @param data string containing the file data
  69206. * @returns if the data can be loaded directly
  69207. */
  69208. canDirectLoad(data: string): boolean;
  69209. /**
  69210. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69211. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69212. * @param scene the scene the meshes should be added to
  69213. * @param data the OBJ data to load
  69214. * @param rootUrl root url to load from
  69215. * @param onProgress event that fires when loading progress has occured
  69216. * @param fileName Defines the name of the file to load
  69217. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69218. */
  69219. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69220. meshes: AbstractMesh[];
  69221. particleSystems: IParticleSystem[];
  69222. skeletons: Skeleton[];
  69223. animationGroups: AnimationGroup[];
  69224. }>;
  69225. /**
  69226. * Imports all objects from the loaded OBJ data and adds them to the scene
  69227. * @param scene the scene the objects should be added to
  69228. * @param data the OBJ data to load
  69229. * @param rootUrl root url to load from
  69230. * @param onProgress event that fires when loading progress has occured
  69231. * @param fileName Defines the name of the file to load
  69232. * @returns a promise which completes when objects have been loaded to the scene
  69233. */
  69234. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69235. /**
  69236. * Load into an asset container.
  69237. * @param scene The scene to load into
  69238. * @param data The data to import
  69239. * @param rootUrl The root url for scene and resources
  69240. * @param onProgress The callback when the load progresses
  69241. * @param fileName Defines the name of the file to load
  69242. * @returns The loaded asset container
  69243. */
  69244. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69245. /**
  69246. * Read the OBJ file and create an Array of meshes.
  69247. * Each mesh contains all information given by the OBJ and the MTL file.
  69248. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69249. *
  69250. * @param meshesNames
  69251. * @param scene Scene The scene where are displayed the data
  69252. * @param data String The content of the obj file
  69253. * @param rootUrl String The path to the folder
  69254. * @returns Array<AbstractMesh>
  69255. * @private
  69256. */
  69257. private _parseSolid;
  69258. }
  69259. }
  69260. declare module BABYLON {
  69261. /**
  69262. * STL file type loader.
  69263. * This is a babylon scene loader plugin.
  69264. */
  69265. export class STLFileLoader implements ISceneLoaderPlugin {
  69266. /** @hidden */
  69267. solidPattern: RegExp;
  69268. /** @hidden */
  69269. facetsPattern: RegExp;
  69270. /** @hidden */
  69271. normalPattern: RegExp;
  69272. /** @hidden */
  69273. vertexPattern: RegExp;
  69274. /**
  69275. * Defines the name of the plugin.
  69276. */
  69277. name: string;
  69278. /**
  69279. * Defines the extensions the stl loader is able to load.
  69280. * force data to come in as an ArrayBuffer
  69281. * we'll convert to string if it looks like it's an ASCII .stl
  69282. */
  69283. extensions: ISceneLoaderPluginExtensions;
  69284. /**
  69285. * Import meshes into a scene.
  69286. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69287. * @param scene The scene to import into
  69288. * @param data The data to import
  69289. * @param rootUrl The root url for scene and resources
  69290. * @param meshes The meshes array to import into
  69291. * @param particleSystems The particle systems array to import into
  69292. * @param skeletons The skeletons array to import into
  69293. * @param onError The callback when import fails
  69294. * @returns True if successful or false otherwise
  69295. */
  69296. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69297. /**
  69298. * Load into a scene.
  69299. * @param scene The scene to load into
  69300. * @param data The data to import
  69301. * @param rootUrl The root url for scene and resources
  69302. * @param onError The callback when import fails
  69303. * @returns true if successful or false otherwise
  69304. */
  69305. load(scene: Scene, data: any, rootUrl: string): boolean;
  69306. /**
  69307. * Load into an asset container.
  69308. * @param scene The scene to load into
  69309. * @param data The data to import
  69310. * @param rootUrl The root url for scene and resources
  69311. * @param onError The callback when import fails
  69312. * @returns The loaded asset container
  69313. */
  69314. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69315. private _isBinary;
  69316. private _parseBinary;
  69317. private _parseASCII;
  69318. }
  69319. }
  69320. declare module BABYLON {
  69321. /**
  69322. * Class for generating OBJ data from a Babylon scene.
  69323. */
  69324. export class OBJExport {
  69325. /**
  69326. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69327. * @param mesh defines the list of meshes to serialize
  69328. * @param materials defines if materials should be exported
  69329. * @param matlibname defines the name of the associated mtl file
  69330. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69331. * @returns the OBJ content
  69332. */
  69333. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69334. /**
  69335. * Exports the material(s) of a mesh in .MTL file format (text)
  69336. * @param mesh defines the mesh to extract the material from
  69337. * @returns the mtl content
  69338. */
  69339. static MTL(mesh: Mesh): string;
  69340. }
  69341. }
  69342. declare module BABYLON {
  69343. /** @hidden */
  69344. export var __IGLTFExporterExtension: number;
  69345. /**
  69346. * Interface for extending the exporter
  69347. * @hidden
  69348. */
  69349. export interface IGLTFExporterExtension {
  69350. /**
  69351. * The name of this extension
  69352. */
  69353. readonly name: string;
  69354. /**
  69355. * Defines whether this extension is enabled
  69356. */
  69357. enabled: boolean;
  69358. /**
  69359. * Defines whether this extension is required
  69360. */
  69361. required: boolean;
  69362. }
  69363. }
  69364. declare module BABYLON.GLTF2.Exporter {
  69365. /** @hidden */
  69366. export var __IGLTFExporterExtensionV2: number;
  69367. /**
  69368. * Interface for a glTF exporter extension
  69369. * @hidden
  69370. */
  69371. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69372. /**
  69373. * Define this method to modify the default behavior before exporting a texture
  69374. * @param context The context when loading the asset
  69375. * @param babylonTexture The glTF texture info property
  69376. * @param mimeType The mime-type of the generated image
  69377. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69378. */
  69379. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69380. /**
  69381. * Define this method to modify the default behavior when exporting texture info
  69382. * @param context The context when loading the asset
  69383. * @param meshPrimitive glTF mesh primitive
  69384. * @param babylonSubMesh Babylon submesh
  69385. * @param binaryWriter glTF serializer binary writer instance
  69386. * @returns nullable IMeshPrimitive promise
  69387. */
  69388. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69389. /**
  69390. * Define this method to modify the default behavior when exporting a node
  69391. * @param context The context when exporting the node
  69392. * @param node glTF node
  69393. * @param babylonNode BabylonJS node
  69394. * @returns nullable INode promise
  69395. */
  69396. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69397. /**
  69398. * Called after the exporter state changes to EXPORTING
  69399. */
  69400. onExporting?(): void;
  69401. }
  69402. }
  69403. declare module BABYLON.GLTF2.Exporter {
  69404. /**
  69405. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69406. * @hidden
  69407. */
  69408. export class _GLTFMaterialExporter {
  69409. /**
  69410. * Represents the dielectric specular values for R, G and B
  69411. */
  69412. private static readonly _DielectricSpecular;
  69413. /**
  69414. * Allows the maximum specular power to be defined for material calculations
  69415. */
  69416. private static readonly _MaxSpecularPower;
  69417. /**
  69418. * Mapping to store textures
  69419. */
  69420. private _textureMap;
  69421. /**
  69422. * Numeric tolerance value
  69423. */
  69424. private static readonly _Epsilon;
  69425. /**
  69426. * Reference to the glTF Exporter
  69427. */
  69428. private _exporter;
  69429. constructor(exporter: _Exporter);
  69430. /**
  69431. * Specifies if two colors are approximately equal in value
  69432. * @param color1 first color to compare to
  69433. * @param color2 second color to compare to
  69434. * @param epsilon threshold value
  69435. */
  69436. private static FuzzyEquals;
  69437. /**
  69438. * Gets the materials from a Babylon scene and converts them to glTF materials
  69439. * @param scene babylonjs scene
  69440. * @param mimeType texture mime type
  69441. * @param images array of images
  69442. * @param textures array of textures
  69443. * @param materials array of materials
  69444. * @param imageData mapping of texture names to base64 textures
  69445. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69446. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69447. /**
  69448. * Makes a copy of the glTF material without the texture parameters
  69449. * @param originalMaterial original glTF material
  69450. * @returns glTF material without texture parameters
  69451. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69452. /**
  69453. * Specifies if the material has any texture parameters present
  69454. * @param material glTF Material
  69455. * @returns boolean specifying if texture parameters are present
  69456. */ private _hasTexturesPresent(material: IMaterial): boolean;
  69457. /**
  69458. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69459. * @param babylonStandardMaterial
  69460. * @returns glTF Metallic Roughness Material representation
  69461. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69462. /**
  69463. * Computes the metallic factor
  69464. * @param diffuse diffused value
  69465. * @param specular specular value
  69466. * @param oneMinusSpecularStrength one minus the specular strength
  69467. * @returns metallic value
  69468. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69469. /**
  69470. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69471. * @param glTFMaterial glTF material
  69472. * @param babylonMaterial Babylon material
  69473. */
  69474. private static _SetAlphaMode;
  69475. /**
  69476. * Converts a Babylon Standard Material to a glTF Material
  69477. * @param babylonStandardMaterial BJS Standard Material
  69478. * @param mimeType mime type to use for the textures
  69479. * @param images array of glTF image interfaces
  69480. * @param textures array of glTF texture interfaces
  69481. * @param materials array of glTF material interfaces
  69482. * @param imageData map of image file name to data
  69483. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69484. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69485. /**
  69486. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69487. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69488. * @param mimeType mime type to use for the textures
  69489. * @param images array of glTF image interfaces
  69490. * @param textures array of glTF texture interfaces
  69491. * @param materials array of glTF material interfaces
  69492. * @param imageData map of image file name to data
  69493. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69494. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69495. /**
  69496. * Converts an image typed array buffer to a base64 image
  69497. * @param buffer typed array buffer
  69498. * @param width width of the image
  69499. * @param height height of the image
  69500. * @param mimeType mimetype of the image
  69501. * @returns base64 image string
  69502. */
  69503. private _createBase64FromCanvasAsync;
  69504. /**
  69505. * Generates a white texture based on the specified width and height
  69506. * @param width width of the texture in pixels
  69507. * @param height height of the texture in pixels
  69508. * @param scene babylonjs scene
  69509. * @returns white texture
  69510. */
  69511. private _createWhiteTexture;
  69512. /**
  69513. * 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
  69514. * @param texture1 first texture to resize
  69515. * @param texture2 second texture to resize
  69516. * @param scene babylonjs scene
  69517. * @returns resized textures or null
  69518. */
  69519. private _resizeTexturesToSameDimensions;
  69520. /**
  69521. * Converts an array of pixels to a Float32Array
  69522. * Throws an error if the pixel format is not supported
  69523. * @param pixels - array buffer containing pixel values
  69524. * @returns Float32 of pixels
  69525. */
  69526. private _convertPixelArrayToFloat32;
  69527. /**
  69528. * Convert Specular Glossiness Textures to Metallic Roughness
  69529. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69530. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69531. * @param diffuseTexture texture used to store diffuse information
  69532. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69533. * @param factors specular glossiness material factors
  69534. * @param mimeType the mime type to use for the texture
  69535. * @returns pbr metallic roughness interface or null
  69536. */
  69537. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69538. /**
  69539. * Converts specular glossiness material properties to metallic roughness
  69540. * @param specularGlossiness interface with specular glossiness material properties
  69541. * @returns interface with metallic roughness material properties
  69542. */
  69543. private _convertSpecularGlossinessToMetallicRoughness;
  69544. /**
  69545. * Calculates the surface reflectance, independent of lighting conditions
  69546. * @param color Color source to calculate brightness from
  69547. * @returns number representing the perceived brightness, or zero if color is undefined
  69548. */
  69549. private _getPerceivedBrightness;
  69550. /**
  69551. * Returns the maximum color component value
  69552. * @param color
  69553. * @returns maximum color component value, or zero if color is null or undefined
  69554. */
  69555. private _getMaxComponent;
  69556. /**
  69557. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69558. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69559. * @param mimeType mime type to use for the textures
  69560. * @param images array of glTF image interfaces
  69561. * @param textures array of glTF texture interfaces
  69562. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69563. * @param imageData map of image file name to data
  69564. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69565. * @returns glTF PBR Metallic Roughness factors
  69566. */
  69567. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69568. private _getGLTFTextureSampler;
  69569. private _getGLTFTextureWrapMode;
  69570. private _getGLTFTextureWrapModesSampler;
  69571. /**
  69572. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69573. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69574. * @param mimeType mime type to use for the textures
  69575. * @param images array of glTF image interfaces
  69576. * @param textures array of glTF texture interfaces
  69577. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69578. * @param imageData map of image file name to data
  69579. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69580. * @returns glTF PBR Metallic Roughness factors
  69581. */
  69582. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69583. /**
  69584. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69585. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69586. * @param mimeType mime type to use for the textures
  69587. * @param images array of glTF image interfaces
  69588. * @param textures array of glTF texture interfaces
  69589. * @param materials array of glTF material interfaces
  69590. * @param imageData map of image file name to data
  69591. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69592. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69593. private setMetallicRoughnessPbrMaterial;
  69594. private getPixelsFromTexture;
  69595. /**
  69596. * Extracts a texture from a Babylon texture into file data and glTF data
  69597. * @param babylonTexture Babylon texture to extract
  69598. * @param mimeType Mime Type of the babylonTexture
  69599. * @return glTF texture info, or null if the texture format is not supported
  69600. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69601. /**
  69602. * Builds a texture from base64 string
  69603. * @param base64Texture base64 texture string
  69604. * @param baseTextureName Name to use for the texture
  69605. * @param mimeType image mime type for the texture
  69606. * @param images array of images
  69607. * @param textures array of textures
  69608. * @param imageData map of image data
  69609. * @returns glTF texture info, or null if the texture format is not supported
  69610. */
  69611. private _getTextureInfoFromBase64;
  69612. }
  69613. }
  69614. declare module BABYLON {
  69615. /**
  69616. * Class for holding and downloading glTF file data
  69617. */
  69618. export class GLTFData {
  69619. /**
  69620. * Object which contains the file name as the key and its data as the value
  69621. */
  69622. glTFFiles: {
  69623. [fileName: string]: string | Blob;
  69624. };
  69625. /**
  69626. * Initializes the glTF file object
  69627. */
  69628. constructor();
  69629. /**
  69630. * Downloads the glTF data as files based on their names and data
  69631. */
  69632. downloadFiles(): void;
  69633. }
  69634. }
  69635. declare module BABYLON {
  69636. /**
  69637. * Holds a collection of exporter options and parameters
  69638. */
  69639. export interface IExportOptions {
  69640. /**
  69641. * Function which indicates whether a babylon node should be exported or not
  69642. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69643. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69644. */
  69645. shouldExportNode?(node: Node): boolean;
  69646. /**
  69647. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69648. * @param metadata source metadata to read from
  69649. * @returns the data to store to glTF node extras
  69650. */
  69651. metadataSelector?(metadata: any): any;
  69652. /**
  69653. * The sample rate to bake animation curves
  69654. */
  69655. animationSampleRate?: number;
  69656. /**
  69657. * Begin serialization without waiting for the scene to be ready
  69658. */
  69659. exportWithoutWaitingForScene?: boolean;
  69660. }
  69661. /**
  69662. * Class for generating glTF data from a Babylon scene.
  69663. */
  69664. export class GLTF2Export {
  69665. /**
  69666. * Exports the geometry of the scene to .gltf file format asynchronously
  69667. * @param scene Babylon scene with scene hierarchy information
  69668. * @param filePrefix File prefix to use when generating the glTF file
  69669. * @param options Exporter options
  69670. * @returns Returns an object with a .gltf file and associates texture names
  69671. * as keys and their data and paths as values
  69672. */
  69673. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69674. private static _PreExportAsync;
  69675. private static _PostExportAsync;
  69676. /**
  69677. * Exports the geometry of the scene to .glb file format asychronously
  69678. * @param scene Babylon scene with scene hierarchy information
  69679. * @param filePrefix File prefix to use when generating glb file
  69680. * @param options Exporter options
  69681. * @returns Returns an object with a .glb filename as key and data as value
  69682. */
  69683. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69684. }
  69685. }
  69686. declare module BABYLON.GLTF2.Exporter {
  69687. /**
  69688. * @hidden
  69689. */
  69690. export class _GLTFUtilities {
  69691. /**
  69692. * Creates a buffer view based on the supplied arguments
  69693. * @param bufferIndex index value of the specified buffer
  69694. * @param byteOffset byte offset value
  69695. * @param byteLength byte length of the bufferView
  69696. * @param byteStride byte distance between conequential elements
  69697. * @param name name of the buffer view
  69698. * @returns bufferView for glTF
  69699. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69700. /**
  69701. * Creates an accessor based on the supplied arguments
  69702. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69703. * @param name The name of the accessor
  69704. * @param type The type of the accessor
  69705. * @param componentType The datatype of components in the attribute
  69706. * @param count The number of attributes referenced by this accessor
  69707. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69708. * @param min Minimum value of each component in this attribute
  69709. * @param max Maximum value of each component in this attribute
  69710. * @returns accessor for glTF
  69711. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69712. /**
  69713. * Calculates the minimum and maximum values of an array of position floats
  69714. * @param positions Positions array of a mesh
  69715. * @param vertexStart Starting vertex offset to calculate min and max values
  69716. * @param vertexCount Number of vertices to check for min and max values
  69717. * @returns min number array and max number array
  69718. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69719. min: number[];
  69720. max: number[];
  69721. };
  69722. /**
  69723. * Converts a new right-handed Vector3
  69724. * @param vector vector3 array
  69725. * @returns right-handed Vector3
  69726. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69727. /**
  69728. * Converts a Vector3 to right-handed
  69729. * @param vector Vector3 to convert to right-handed
  69730. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69731. /**
  69732. * Converts a three element number array to right-handed
  69733. * @param vector number array to convert to right-handed
  69734. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69735. /**
  69736. * Converts a new right-handed Vector3
  69737. * @param vector vector3 array
  69738. * @returns right-handed Vector3
  69739. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69740. /**
  69741. * Converts a Vector3 to right-handed
  69742. * @param vector Vector3 to convert to right-handed
  69743. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69744. /**
  69745. * Converts a three element number array to right-handed
  69746. * @param vector number array to convert to right-handed
  69747. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69748. /**
  69749. * Converts a Vector4 to right-handed
  69750. * @param vector Vector4 to convert to right-handed
  69751. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69752. /**
  69753. * Converts a Vector4 to right-handed
  69754. * @param vector Vector4 to convert to right-handed
  69755. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  69756. /**
  69757. * Converts a Quaternion to right-handed
  69758. * @param quaternion Source quaternion to convert to right-handed
  69759. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69760. /**
  69761. * Converts a Quaternion to right-handed
  69762. * @param quaternion Source quaternion to convert to right-handed
  69763. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  69764. }
  69765. }
  69766. declare module BABYLON.GLTF2.Exporter {
  69767. /**
  69768. * Converts Babylon Scene into glTF 2.0.
  69769. * @hidden
  69770. */
  69771. export class _Exporter {
  69772. /**
  69773. * Stores the glTF to export
  69774. */ private _glTF: IGLTF;
  69775. /**
  69776. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69777. */ private _bufferViews: IBufferView[];
  69778. /**
  69779. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69780. */ private _accessors: IAccessor[];
  69781. /**
  69782. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69783. */
  69784. private _nodes;
  69785. /**
  69786. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69787. */
  69788. private _scenes;
  69789. /**
  69790. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69791. */
  69792. private _meshes;
  69793. /**
  69794. * Stores all the generated material information, which represents the appearance of each primitive
  69795. */ private _materials: IMaterial[]; private _materialMap: {
  69796. [materialID: number]: number;
  69797. };
  69798. /**
  69799. * Stores all the generated texture information, which is referenced by glTF materials
  69800. */ private _textures: ITexture[];
  69801. /**
  69802. * Stores all the generated image information, which is referenced by glTF textures
  69803. */ private _images: IImage[];
  69804. /**
  69805. * Stores all the texture samplers
  69806. */ private _samplers: ISampler[];
  69807. /**
  69808. * Stores all the generated animation samplers, which is referenced by glTF animations
  69809. */
  69810. /**
  69811. * Stores the animations for glTF models
  69812. */
  69813. private _animations;
  69814. /**
  69815. * Stores the total amount of bytes stored in the glTF buffer
  69816. */
  69817. private _totalByteLength;
  69818. /**
  69819. * Stores a reference to the Babylon scene containing the source geometry and material information
  69820. */ private _babylonScene: Scene;
  69821. /**
  69822. * Stores a map of the image data, where the key is the file name and the value
  69823. * is the image data
  69824. */ private _imageData: {
  69825. [fileName: string]: {
  69826. data: Uint8Array;
  69827. mimeType: ImageMimeType;
  69828. };
  69829. };
  69830. /**
  69831. * Stores a map of the unique id of a node to its index in the node array
  69832. */
  69833. private _nodeMap;
  69834. /**
  69835. * Specifies if the Babylon scene should be converted to right-handed on export
  69836. */ private _convertToRightHandedSystem: boolean;
  69837. /**
  69838. * Baked animation sample rate
  69839. */
  69840. private _animationSampleRate;
  69841. private _options;
  69842. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  69843. private _extensions;
  69844. private static _ExtensionNames;
  69845. private static _ExtensionFactories;
  69846. 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>>;
  69847. private _forEachExtensions;
  69848. private _extensionsOnExporting;
  69849. /**
  69850. * Load glTF serializer extensions
  69851. */
  69852. private _loadExtensions;
  69853. /**
  69854. * Creates a glTF Exporter instance, which can accept optional exporter options
  69855. * @param babylonScene Babylon scene object
  69856. * @param options Options to modify the behavior of the exporter
  69857. */
  69858. constructor(babylonScene: Scene, options?: IExportOptions);
  69859. /**
  69860. * Registers a glTF exporter extension
  69861. * @param name Name of the extension to export
  69862. * @param factory The factory function that creates the exporter extension
  69863. */
  69864. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69865. /**
  69866. * Un-registers an exporter extension
  69867. * @param name The name fo the exporter extension
  69868. * @returns A boolean indicating whether the extension has been un-registered
  69869. */
  69870. static UnregisterExtension(name: string): boolean;
  69871. /**
  69872. * Lazy load a local engine with premultiplied alpha set to false
  69873. */ private _getLocalEngine(): Engine;
  69874. private reorderIndicesBasedOnPrimitiveMode;
  69875. /**
  69876. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69877. * clock-wise during export to glTF
  69878. * @param submesh BabylonJS submesh
  69879. * @param primitiveMode Primitive mode of the mesh
  69880. * @param sideOrientation the winding order of the submesh
  69881. * @param vertexBufferKind The type of vertex attribute
  69882. * @param meshAttributeArray The vertex attribute data
  69883. * @param byteOffset The offset to the binary data
  69884. * @param binaryWriter The binary data for the glTF file
  69885. */
  69886. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69887. /**
  69888. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69889. * clock-wise during export to glTF
  69890. * @param submesh BabylonJS submesh
  69891. * @param primitiveMode Primitive mode of the mesh
  69892. * @param sideOrientation the winding order of the submesh
  69893. * @param vertexBufferKind The type of vertex attribute
  69894. * @param meshAttributeArray The vertex attribute data
  69895. * @param byteOffset The offset to the binary data
  69896. * @param binaryWriter The binary data for the glTF file
  69897. */
  69898. private reorderTriangleFillMode;
  69899. /**
  69900. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69901. * clock-wise during export to glTF
  69902. * @param submesh BabylonJS submesh
  69903. * @param primitiveMode Primitive mode of the mesh
  69904. * @param sideOrientation the winding order of the submesh
  69905. * @param vertexBufferKind The type of vertex attribute
  69906. * @param meshAttributeArray The vertex attribute data
  69907. * @param byteOffset The offset to the binary data
  69908. * @param binaryWriter The binary data for the glTF file
  69909. */
  69910. private reorderTriangleStripDrawMode;
  69911. /**
  69912. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69913. * clock-wise during export to glTF
  69914. * @param submesh BabylonJS submesh
  69915. * @param primitiveMode Primitive mode of the mesh
  69916. * @param sideOrientation the winding order of the submesh
  69917. * @param vertexBufferKind The type of vertex attribute
  69918. * @param meshAttributeArray The vertex attribute data
  69919. * @param byteOffset The offset to the binary data
  69920. * @param binaryWriter The binary data for the glTF file
  69921. */
  69922. private reorderTriangleFanMode;
  69923. /**
  69924. * Writes the vertex attribute data to binary
  69925. * @param vertices The vertices to write to the binary writer
  69926. * @param byteOffset The offset into the binary writer to overwrite binary data
  69927. * @param vertexAttributeKind The vertex attribute type
  69928. * @param meshAttributeArray The vertex attribute data
  69929. * @param binaryWriter The writer containing the binary data
  69930. */
  69931. private writeVertexAttributeData;
  69932. /**
  69933. * Writes mesh attribute data to a data buffer
  69934. * Returns the bytelength of the data
  69935. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69936. * @param meshAttributeArray Array containing the attribute data
  69937. * @param binaryWriter The buffer to write the binary data to
  69938. * @param indices Used to specify the order of the vertex data
  69939. */
  69940. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69941. /**
  69942. * Generates glTF json data
  69943. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69944. * @param glTFPrefix Text to use when prefixing a glTF file
  69945. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69946. * @returns json data as string
  69947. */
  69948. private generateJSON;
  69949. /**
  69950. * Generates data for .gltf and .bin files based on the glTF prefix string
  69951. * @param glTFPrefix Text to use when prefixing a glTF file
  69952. * @returns GLTFData with glTF file data
  69953. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69954. /**
  69955. * Creates a binary buffer for glTF
  69956. * @returns array buffer for binary data
  69957. */
  69958. private _generateBinaryAsync;
  69959. /**
  69960. * Pads the number to a multiple of 4
  69961. * @param num number to pad
  69962. * @returns padded number
  69963. */
  69964. private _getPadding;
  69965. /**
  69966. * Generates a glb file from the json and binary data
  69967. * Returns an object with the glb file name as the key and data as the value
  69968. * @param glTFPrefix
  69969. * @returns object with glb filename as key and data as value
  69970. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69971. /**
  69972. * Sets the TRS for each node
  69973. * @param node glTF Node for storing the transformation data
  69974. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69975. */
  69976. private setNodeTransformation;
  69977. private getVertexBufferFromMesh;
  69978. /**
  69979. * Creates a bufferview based on the vertices type for the Babylon mesh
  69980. * @param kind Indicates the type of vertices data
  69981. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69982. * @param binaryWriter The buffer to write the bufferview data to
  69983. */
  69984. private createBufferViewKind;
  69985. /**
  69986. * The primitive mode of the Babylon mesh
  69987. * @param babylonMesh The BabylonJS mesh
  69988. */
  69989. private getMeshPrimitiveMode;
  69990. /**
  69991. * Sets the primitive mode of the glTF mesh primitive
  69992. * @param meshPrimitive glTF mesh primitive
  69993. * @param primitiveMode The primitive mode
  69994. */
  69995. private setPrimitiveMode;
  69996. /**
  69997. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69998. * @param meshPrimitive glTF mesh primitive
  69999. * @param attributeKind vertex attribute
  70000. * @returns boolean specifying if uv coordinates are present
  70001. */
  70002. private setAttributeKind;
  70003. /**
  70004. * Sets data for the primitive attributes of each submesh
  70005. * @param mesh glTF Mesh object to store the primitive attribute information
  70006. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70007. * @param binaryWriter Buffer to write the attribute data to
  70008. */
  70009. private setPrimitiveAttributesAsync;
  70010. /**
  70011. * Creates a glTF scene based on the array of meshes
  70012. * Returns the the total byte offset
  70013. * @param babylonScene Babylon scene to get the mesh data from
  70014. * @param binaryWriter Buffer to write binary data to
  70015. */
  70016. private createSceneAsync;
  70017. /**
  70018. * Creates a mapping of Node unique id to node index and handles animations
  70019. * @param babylonScene Babylon Scene
  70020. * @param nodes Babylon transform nodes
  70021. * @param binaryWriter Buffer to write binary data to
  70022. * @returns Node mapping of unique id to index
  70023. */
  70024. private createNodeMapAndAnimationsAsync;
  70025. /**
  70026. * Creates a glTF node from a Babylon mesh
  70027. * @param babylonMesh Source Babylon mesh
  70028. * @param binaryWriter Buffer for storing geometry data
  70029. * @returns glTF node
  70030. */
  70031. private createNodeAsync;
  70032. }
  70033. /**
  70034. * @hidden
  70035. *
  70036. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70037. */
  70038. export class _BinaryWriter {
  70039. /**
  70040. * Array buffer which stores all binary data
  70041. */
  70042. private _arrayBuffer;
  70043. /**
  70044. * View of the array buffer
  70045. */
  70046. private _dataView;
  70047. /**
  70048. * byte offset of data in array buffer
  70049. */
  70050. private _byteOffset;
  70051. /**
  70052. * Initialize binary writer with an initial byte length
  70053. * @param byteLength Initial byte length of the array buffer
  70054. */
  70055. constructor(byteLength: number);
  70056. /**
  70057. * Resize the array buffer to the specified byte length
  70058. * @param byteLength
  70059. */
  70060. private resizeBuffer;
  70061. /**
  70062. * Get an array buffer with the length of the byte offset
  70063. * @returns ArrayBuffer resized to the byte offset
  70064. */
  70065. getArrayBuffer(): ArrayBuffer;
  70066. /**
  70067. * Get the byte offset of the array buffer
  70068. * @returns byte offset
  70069. */
  70070. getByteOffset(): number;
  70071. /**
  70072. * Stores an UInt8 in the array buffer
  70073. * @param entry
  70074. * @param byteOffset If defined, specifies where to set the value as an offset.
  70075. */
  70076. setUInt8(entry: number, byteOffset?: number): void;
  70077. /**
  70078. * Gets an UInt32 in the array buffer
  70079. * @param entry
  70080. * @param byteOffset If defined, specifies where to set the value as an offset.
  70081. */
  70082. getUInt32(byteOffset: number): number;
  70083. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70084. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70085. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70086. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70087. /**
  70088. * Stores a Float32 in the array buffer
  70089. * @param entry
  70090. */
  70091. setFloat32(entry: number, byteOffset?: number): void;
  70092. /**
  70093. * Stores an UInt32 in the array buffer
  70094. * @param entry
  70095. * @param byteOffset If defined, specifies where to set the value as an offset.
  70096. */
  70097. setUInt32(entry: number, byteOffset?: number): void;
  70098. }
  70099. }
  70100. declare module BABYLON.GLTF2.Exporter {
  70101. /**
  70102. * @hidden
  70103. * Interface to store animation data.
  70104. */
  70105. export interface _IAnimationData {
  70106. /**
  70107. * Keyframe data.
  70108. */
  70109. inputs: number[];
  70110. /**
  70111. * Value data.
  70112. */
  70113. outputs: number[][];
  70114. /**
  70115. * Animation interpolation data.
  70116. */
  70117. samplerInterpolation: AnimationSamplerInterpolation;
  70118. /**
  70119. * Minimum keyframe value.
  70120. */
  70121. inputsMin: number;
  70122. /**
  70123. * Maximum keyframe value.
  70124. */
  70125. inputsMax: number;
  70126. }
  70127. /**
  70128. * @hidden
  70129. */
  70130. export interface _IAnimationInfo {
  70131. /**
  70132. * The target channel for the animation
  70133. */
  70134. animationChannelTargetPath: AnimationChannelTargetPath;
  70135. /**
  70136. * The glTF accessor type for the data.
  70137. */
  70138. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70139. /**
  70140. * Specifies if quaternions should be used.
  70141. */
  70142. useQuaternion: boolean;
  70143. }
  70144. /**
  70145. * @hidden
  70146. * Utility class for generating glTF animation data from BabylonJS.
  70147. */
  70148. export class _GLTFAnimation {
  70149. /**
  70150. * @ignore
  70151. *
  70152. * Creates glTF channel animation from BabylonJS animation.
  70153. * @param babylonTransformNode - BabylonJS mesh.
  70154. * @param animation - animation.
  70155. * @param animationChannelTargetPath - The target animation channel.
  70156. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70157. * @param useQuaternion - Specifies if quaternions are used.
  70158. * @returns nullable IAnimationData
  70159. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70160. private static _DeduceAnimationInfo;
  70161. /**
  70162. * @ignore
  70163. * Create node animations from the transform node animations
  70164. * @param babylonNode
  70165. * @param runtimeGLTFAnimation
  70166. * @param idleGLTFAnimations
  70167. * @param nodeMap
  70168. * @param nodes
  70169. * @param binaryWriter
  70170. * @param bufferViews
  70171. * @param accessors
  70172. * @param convertToRightHandedSystem
  70173. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70174. [key: number]: number;
  70175. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70176. /**
  70177. * @ignore
  70178. * Create node animations from the animation groups
  70179. * @param babylonScene
  70180. * @param glTFAnimations
  70181. * @param nodeMap
  70182. * @param nodes
  70183. * @param binaryWriter
  70184. * @param bufferViews
  70185. * @param accessors
  70186. * @param convertToRightHandedSystem
  70187. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70188. [key: number]: number;
  70189. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70190. private static AddAnimation;
  70191. /**
  70192. * Create a baked animation
  70193. * @param babylonTransformNode BabylonJS mesh
  70194. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70195. * @param animationChannelTargetPath animation target channel
  70196. * @param minFrame minimum animation frame
  70197. * @param maxFrame maximum animation frame
  70198. * @param fps frames per second of the animation
  70199. * @param inputs input key frames of the animation
  70200. * @param outputs output key frame data of the animation
  70201. * @param convertToRightHandedSystem converts the values to right-handed
  70202. * @param useQuaternion specifies if quaternions should be used
  70203. */
  70204. private static _CreateBakedAnimation;
  70205. private static _ConvertFactorToVector3OrQuaternion;
  70206. private static _SetInterpolatedValue;
  70207. /**
  70208. * Creates linear animation from the animation key frames
  70209. * @param babylonTransformNode BabylonJS mesh
  70210. * @param animation BabylonJS animation
  70211. * @param animationChannelTargetPath The target animation channel
  70212. * @param frameDelta The difference between the last and first frame of the animation
  70213. * @param inputs Array to store the key frame times
  70214. * @param outputs Array to store the key frame data
  70215. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70216. * @param useQuaternion Specifies if quaternions are used in the animation
  70217. */
  70218. private static _CreateLinearOrStepAnimation;
  70219. /**
  70220. * Creates cubic spline animation from the animation key frames
  70221. * @param babylonTransformNode BabylonJS mesh
  70222. * @param animation BabylonJS animation
  70223. * @param animationChannelTargetPath The target animation channel
  70224. * @param frameDelta The difference between the last and first frame of the animation
  70225. * @param inputs Array to store the key frame times
  70226. * @param outputs Array to store the key frame data
  70227. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70228. * @param useQuaternion Specifies if quaternions are used in the animation
  70229. */
  70230. private static _CreateCubicSplineAnimation;
  70231. private static _GetBasePositionRotationOrScale;
  70232. /**
  70233. * Adds a key frame value
  70234. * @param keyFrame
  70235. * @param animation
  70236. * @param outputs
  70237. * @param animationChannelTargetPath
  70238. * @param basePositionRotationOrScale
  70239. * @param convertToRightHandedSystem
  70240. * @param useQuaternion
  70241. */
  70242. private static _AddKeyframeValue;
  70243. /**
  70244. * Determine the interpolation based on the key frames
  70245. * @param keyFrames
  70246. * @param animationChannelTargetPath
  70247. * @param useQuaternion
  70248. */
  70249. private static _DeduceInterpolation;
  70250. /**
  70251. * Adds an input tangent or output tangent to the output data
  70252. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70253. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70254. * @param outputs The animation data by keyframe
  70255. * @param animationChannelTargetPath The target animation channel
  70256. * @param interpolation The interpolation type
  70257. * @param keyFrame The key frame with the animation data
  70258. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70259. * @param useQuaternion Specifies if quaternions are used
  70260. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70261. */
  70262. private static AddSplineTangent;
  70263. /**
  70264. * Get the minimum and maximum key frames' frame values
  70265. * @param keyFrames animation key frames
  70266. * @returns the minimum and maximum key frame value
  70267. */
  70268. private static calculateMinMaxKeyFrames;
  70269. }
  70270. }
  70271. declare module BABYLON.GLTF2.Exporter {
  70272. /** @hidden */
  70273. export var textureTransformPixelShader: {
  70274. name: string;
  70275. shader: string;
  70276. };
  70277. }
  70278. declare module BABYLON.GLTF2.Exporter.Extensions {
  70279. /**
  70280. * @hidden
  70281. */
  70282. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70283. /** Name of this extension */
  70284. readonly name: string;
  70285. /** Defines whether this extension is enabled */
  70286. enabled: boolean;
  70287. /** Defines whether this extension is required */
  70288. required: boolean;
  70289. /** Reference to the glTF exporter */
  70290. private _exporter;
  70291. constructor(exporter: _Exporter);
  70292. dispose(): void;
  70293. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70294. /**
  70295. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70296. * @param babylonTexture
  70297. * @param offset
  70298. * @param rotation
  70299. * @param scale
  70300. * @param scene
  70301. */
  70302. private _textureTransformTextureAsync;
  70303. }
  70304. }
  70305. declare module BABYLON.GLTF2.Exporter.Extensions {
  70306. /**
  70307. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70308. */
  70309. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70310. /** The name of this extension. */
  70311. readonly name: string;
  70312. /** Defines whether this extension is enabled. */
  70313. enabled: boolean;
  70314. /** Defines whether this extension is required */
  70315. required: boolean;
  70316. /** Reference to the glTF exporter */
  70317. private _exporter;
  70318. private _lights;
  70319. /** @hidden */
  70320. constructor(exporter: _Exporter);
  70321. /** @hidden */
  70322. dispose(): void;
  70323. /** @hidden */
  70324. onExporting(): void;
  70325. /**
  70326. * Define this method to modify the default behavior when exporting a node
  70327. * @param context The context when exporting the node
  70328. * @param node glTF node
  70329. * @param babylonNode BabylonJS node
  70330. * @returns nullable INode promise
  70331. */
  70332. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70333. }
  70334. }
  70335. declare module BABYLON {
  70336. /**
  70337. * Class for generating STL data from a Babylon scene.
  70338. */
  70339. export class STLExport {
  70340. /**
  70341. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70342. * @param meshes list defines the mesh to serialize
  70343. * @param download triggers the automatic download of the file.
  70344. * @param fileName changes the downloads fileName.
  70345. * @param binary changes the STL to a binary type.
  70346. * @param isLittleEndian toggle for binary type exporter.
  70347. * @returns the STL as UTF8 string
  70348. */
  70349. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70350. }
  70351. }
  70352. declare module "babylonjs-gltf2interface" {
  70353. export = BABYLON.GLTF2;
  70354. }
  70355. /**
  70356. * Module for glTF 2.0 Interface
  70357. */
  70358. declare module BABYLON.GLTF2 {
  70359. /**
  70360. * The datatype of the components in the attribute
  70361. */
  70362. const enum AccessorComponentType {
  70363. /**
  70364. * Byte
  70365. */
  70366. BYTE = 5120,
  70367. /**
  70368. * Unsigned Byte
  70369. */
  70370. UNSIGNED_BYTE = 5121,
  70371. /**
  70372. * Short
  70373. */
  70374. SHORT = 5122,
  70375. /**
  70376. * Unsigned Short
  70377. */
  70378. UNSIGNED_SHORT = 5123,
  70379. /**
  70380. * Unsigned Int
  70381. */
  70382. UNSIGNED_INT = 5125,
  70383. /**
  70384. * Float
  70385. */
  70386. FLOAT = 5126,
  70387. }
  70388. /**
  70389. * Specifies if the attirbute is a scalar, vector, or matrix
  70390. */
  70391. const enum AccessorType {
  70392. /**
  70393. * Scalar
  70394. */
  70395. SCALAR = "SCALAR",
  70396. /**
  70397. * Vector2
  70398. */
  70399. VEC2 = "VEC2",
  70400. /**
  70401. * Vector3
  70402. */
  70403. VEC3 = "VEC3",
  70404. /**
  70405. * Vector4
  70406. */
  70407. VEC4 = "VEC4",
  70408. /**
  70409. * Matrix2x2
  70410. */
  70411. MAT2 = "MAT2",
  70412. /**
  70413. * Matrix3x3
  70414. */
  70415. MAT3 = "MAT3",
  70416. /**
  70417. * Matrix4x4
  70418. */
  70419. MAT4 = "MAT4",
  70420. }
  70421. /**
  70422. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70423. */
  70424. const enum AnimationChannelTargetPath {
  70425. /**
  70426. * Translation
  70427. */
  70428. TRANSLATION = "translation",
  70429. /**
  70430. * Rotation
  70431. */
  70432. ROTATION = "rotation",
  70433. /**
  70434. * Scale
  70435. */
  70436. SCALE = "scale",
  70437. /**
  70438. * Weights
  70439. */
  70440. WEIGHTS = "weights",
  70441. }
  70442. /**
  70443. * Interpolation algorithm
  70444. */
  70445. const enum AnimationSamplerInterpolation {
  70446. /**
  70447. * The animated values are linearly interpolated between keyframes
  70448. */
  70449. LINEAR = "LINEAR",
  70450. /**
  70451. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70452. */
  70453. STEP = "STEP",
  70454. /**
  70455. * The animation's interpolation is computed using a cubic spline with specified tangents
  70456. */
  70457. CUBICSPLINE = "CUBICSPLINE",
  70458. }
  70459. /**
  70460. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70461. */
  70462. const enum CameraType {
  70463. /**
  70464. * A perspective camera containing properties to create a perspective projection matrix
  70465. */
  70466. PERSPECTIVE = "perspective",
  70467. /**
  70468. * An orthographic camera containing properties to create an orthographic projection matrix
  70469. */
  70470. ORTHOGRAPHIC = "orthographic",
  70471. }
  70472. /**
  70473. * The mime-type of the image
  70474. */
  70475. const enum ImageMimeType {
  70476. /**
  70477. * JPEG Mime-type
  70478. */
  70479. JPEG = "image/jpeg",
  70480. /**
  70481. * PNG Mime-type
  70482. */
  70483. PNG = "image/png",
  70484. }
  70485. /**
  70486. * The alpha rendering mode of the material
  70487. */
  70488. const enum MaterialAlphaMode {
  70489. /**
  70490. * The alpha value is ignored and the rendered output is fully opaque
  70491. */
  70492. OPAQUE = "OPAQUE",
  70493. /**
  70494. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70495. */
  70496. MASK = "MASK",
  70497. /**
  70498. * 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)
  70499. */
  70500. BLEND = "BLEND",
  70501. }
  70502. /**
  70503. * The type of the primitives to render
  70504. */
  70505. const enum MeshPrimitiveMode {
  70506. /**
  70507. * Points
  70508. */
  70509. POINTS = 0,
  70510. /**
  70511. * Lines
  70512. */
  70513. LINES = 1,
  70514. /**
  70515. * Line Loop
  70516. */
  70517. LINE_LOOP = 2,
  70518. /**
  70519. * Line Strip
  70520. */
  70521. LINE_STRIP = 3,
  70522. /**
  70523. * Triangles
  70524. */
  70525. TRIANGLES = 4,
  70526. /**
  70527. * Triangle Strip
  70528. */
  70529. TRIANGLE_STRIP = 5,
  70530. /**
  70531. * Triangle Fan
  70532. */
  70533. TRIANGLE_FAN = 6,
  70534. }
  70535. /**
  70536. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70537. */
  70538. const enum TextureMagFilter {
  70539. /**
  70540. * Nearest
  70541. */
  70542. NEAREST = 9728,
  70543. /**
  70544. * Linear
  70545. */
  70546. LINEAR = 9729,
  70547. }
  70548. /**
  70549. * Minification filter. All valid values correspond to WebGL enums
  70550. */
  70551. const enum TextureMinFilter {
  70552. /**
  70553. * Nearest
  70554. */
  70555. NEAREST = 9728,
  70556. /**
  70557. * Linear
  70558. */
  70559. LINEAR = 9729,
  70560. /**
  70561. * Nearest Mip-Map Nearest
  70562. */
  70563. NEAREST_MIPMAP_NEAREST = 9984,
  70564. /**
  70565. * Linear Mipmap Nearest
  70566. */
  70567. LINEAR_MIPMAP_NEAREST = 9985,
  70568. /**
  70569. * Nearest Mipmap Linear
  70570. */
  70571. NEAREST_MIPMAP_LINEAR = 9986,
  70572. /**
  70573. * Linear Mipmap Linear
  70574. */
  70575. LINEAR_MIPMAP_LINEAR = 9987,
  70576. }
  70577. /**
  70578. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70579. */
  70580. const enum TextureWrapMode {
  70581. /**
  70582. * Clamp to Edge
  70583. */
  70584. CLAMP_TO_EDGE = 33071,
  70585. /**
  70586. * Mirrored Repeat
  70587. */
  70588. MIRRORED_REPEAT = 33648,
  70589. /**
  70590. * Repeat
  70591. */
  70592. REPEAT = 10497,
  70593. }
  70594. /**
  70595. * glTF Property
  70596. */
  70597. interface IProperty {
  70598. /**
  70599. * Dictionary object with extension-specific objects
  70600. */
  70601. extensions?: {
  70602. [key: string]: any;
  70603. };
  70604. /**
  70605. * Application-Specific data
  70606. */
  70607. extras?: any;
  70608. }
  70609. /**
  70610. * glTF Child of Root Property
  70611. */
  70612. interface IChildRootProperty extends IProperty {
  70613. /**
  70614. * The user-defined name of this object
  70615. */
  70616. name?: string;
  70617. }
  70618. /**
  70619. * Indices of those attributes that deviate from their initialization value
  70620. */
  70621. interface IAccessorSparseIndices extends IProperty {
  70622. /**
  70623. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70624. */
  70625. bufferView: number;
  70626. /**
  70627. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70628. */
  70629. byteOffset?: number;
  70630. /**
  70631. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70632. */
  70633. componentType: AccessorComponentType;
  70634. }
  70635. /**
  70636. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70637. */
  70638. interface IAccessorSparseValues extends IProperty {
  70639. /**
  70640. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70641. */
  70642. bufferView: number;
  70643. /**
  70644. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70645. */
  70646. byteOffset?: number;
  70647. }
  70648. /**
  70649. * Sparse storage of attributes that deviate from their initialization value
  70650. */
  70651. interface IAccessorSparse extends IProperty {
  70652. /**
  70653. * The number of attributes encoded in this sparse accessor
  70654. */
  70655. count: number;
  70656. /**
  70657. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70658. */
  70659. indices: IAccessorSparseIndices;
  70660. /**
  70661. * 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
  70662. */
  70663. values: IAccessorSparseValues;
  70664. }
  70665. /**
  70666. * 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
  70667. */
  70668. interface IAccessor extends IChildRootProperty {
  70669. /**
  70670. * The index of the bufferview
  70671. */
  70672. bufferView?: number;
  70673. /**
  70674. * The offset relative to the start of the bufferView in bytes
  70675. */
  70676. byteOffset?: number;
  70677. /**
  70678. * The datatype of components in the attribute
  70679. */
  70680. componentType: AccessorComponentType;
  70681. /**
  70682. * Specifies whether integer data values should be normalized
  70683. */
  70684. normalized?: boolean;
  70685. /**
  70686. * The number of attributes referenced by this accessor
  70687. */
  70688. count: number;
  70689. /**
  70690. * Specifies if the attribute is a scalar, vector, or matrix
  70691. */
  70692. type: AccessorType;
  70693. /**
  70694. * Maximum value of each component in this attribute
  70695. */
  70696. max?: number[];
  70697. /**
  70698. * Minimum value of each component in this attribute
  70699. */
  70700. min?: number[];
  70701. /**
  70702. * Sparse storage of attributes that deviate from their initialization value
  70703. */
  70704. sparse?: IAccessorSparse;
  70705. }
  70706. /**
  70707. * Targets an animation's sampler at a node's property
  70708. */
  70709. interface IAnimationChannel extends IProperty {
  70710. /**
  70711. * The index of a sampler in this animation used to compute the value for the target
  70712. */
  70713. sampler: number;
  70714. /**
  70715. * The index of the node and TRS property to target
  70716. */
  70717. target: IAnimationChannelTarget;
  70718. }
  70719. /**
  70720. * The index of the node and TRS property that an animation channel targets
  70721. */
  70722. interface IAnimationChannelTarget extends IProperty {
  70723. /**
  70724. * The index of the node to target
  70725. */
  70726. node: number;
  70727. /**
  70728. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70729. */
  70730. path: AnimationChannelTargetPath;
  70731. }
  70732. /**
  70733. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70734. */
  70735. interface IAnimationSampler extends IProperty {
  70736. /**
  70737. * The index of an accessor containing keyframe input values, e.g., time
  70738. */
  70739. input: number;
  70740. /**
  70741. * Interpolation algorithm
  70742. */
  70743. interpolation?: AnimationSamplerInterpolation;
  70744. /**
  70745. * The index of an accessor, containing keyframe output values
  70746. */
  70747. output: number;
  70748. }
  70749. /**
  70750. * A keyframe animation
  70751. */
  70752. interface IAnimation extends IChildRootProperty {
  70753. /**
  70754. * An array of channels, each of which targets an animation's sampler at a node's property
  70755. */
  70756. channels: IAnimationChannel[];
  70757. /**
  70758. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70759. */
  70760. samplers: IAnimationSampler[];
  70761. }
  70762. /**
  70763. * Metadata about the glTF asset
  70764. */
  70765. interface IAsset extends IChildRootProperty {
  70766. /**
  70767. * A copyright message suitable for display to credit the content creator
  70768. */
  70769. copyright?: string;
  70770. /**
  70771. * Tool that generated this glTF model. Useful for debugging
  70772. */
  70773. generator?: string;
  70774. /**
  70775. * The glTF version that this asset targets
  70776. */
  70777. version: string;
  70778. /**
  70779. * The minimum glTF version that this asset targets
  70780. */
  70781. minVersion?: string;
  70782. }
  70783. /**
  70784. * A buffer points to binary geometry, animation, or skins
  70785. */
  70786. interface IBuffer extends IChildRootProperty {
  70787. /**
  70788. * 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
  70789. */
  70790. uri?: string;
  70791. /**
  70792. * The length of the buffer in bytes
  70793. */
  70794. byteLength: number;
  70795. }
  70796. /**
  70797. * A view into a buffer generally representing a subset of the buffer
  70798. */
  70799. interface IBufferView extends IChildRootProperty {
  70800. /**
  70801. * The index of the buffer
  70802. */
  70803. buffer: number;
  70804. /**
  70805. * The offset into the buffer in bytes
  70806. */
  70807. byteOffset?: number;
  70808. /**
  70809. * The lenth of the bufferView in bytes
  70810. */
  70811. byteLength: number;
  70812. /**
  70813. * The stride, in bytes
  70814. */
  70815. byteStride?: number;
  70816. }
  70817. /**
  70818. * An orthographic camera containing properties to create an orthographic projection matrix
  70819. */
  70820. interface ICameraOrthographic extends IProperty {
  70821. /**
  70822. * The floating-point horizontal magnification of the view. Must not be zero
  70823. */
  70824. xmag: number;
  70825. /**
  70826. * The floating-point vertical magnification of the view. Must not be zero
  70827. */
  70828. ymag: number;
  70829. /**
  70830. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70831. */
  70832. zfar: number;
  70833. /**
  70834. * The floating-point distance to the near clipping plane
  70835. */
  70836. znear: number;
  70837. }
  70838. /**
  70839. * A perspective camera containing properties to create a perspective projection matrix
  70840. */
  70841. interface ICameraPerspective extends IProperty {
  70842. /**
  70843. * The floating-point aspect ratio of the field of view
  70844. */
  70845. aspectRatio?: number;
  70846. /**
  70847. * The floating-point vertical field of view in radians
  70848. */
  70849. yfov: number;
  70850. /**
  70851. * The floating-point distance to the far clipping plane
  70852. */
  70853. zfar?: number;
  70854. /**
  70855. * The floating-point distance to the near clipping plane
  70856. */
  70857. znear: number;
  70858. }
  70859. /**
  70860. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70861. */
  70862. interface ICamera extends IChildRootProperty {
  70863. /**
  70864. * An orthographic camera containing properties to create an orthographic projection matrix
  70865. */
  70866. orthographic?: ICameraOrthographic;
  70867. /**
  70868. * A perspective camera containing properties to create a perspective projection matrix
  70869. */
  70870. perspective?: ICameraPerspective;
  70871. /**
  70872. * Specifies if the camera uses a perspective or orthographic projection
  70873. */
  70874. type: CameraType;
  70875. }
  70876. /**
  70877. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70878. */
  70879. interface IImage extends IChildRootProperty {
  70880. /**
  70881. * 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
  70882. */
  70883. uri?: string;
  70884. /**
  70885. * The image's MIME type
  70886. */
  70887. mimeType?: ImageMimeType;
  70888. /**
  70889. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70890. */
  70891. bufferView?: number;
  70892. }
  70893. /**
  70894. * Material Normal Texture Info
  70895. */
  70896. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70897. /**
  70898. * The scalar multiplier applied to each normal vector of the normal texture
  70899. */
  70900. scale?: number;
  70901. }
  70902. /**
  70903. * Material Occlusion Texture Info
  70904. */
  70905. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70906. /**
  70907. * A scalar multiplier controlling the amount of occlusion applied
  70908. */
  70909. strength?: number;
  70910. }
  70911. /**
  70912. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70913. */
  70914. interface IMaterialPbrMetallicRoughness {
  70915. /**
  70916. * The material's base color factor
  70917. */
  70918. baseColorFactor?: number[];
  70919. /**
  70920. * The base color texture
  70921. */
  70922. baseColorTexture?: ITextureInfo;
  70923. /**
  70924. * The metalness of the material
  70925. */
  70926. metallicFactor?: number;
  70927. /**
  70928. * The roughness of the material
  70929. */
  70930. roughnessFactor?: number;
  70931. /**
  70932. * The metallic-roughness texture
  70933. */
  70934. metallicRoughnessTexture?: ITextureInfo;
  70935. }
  70936. /**
  70937. * The material appearance of a primitive
  70938. */
  70939. interface IMaterial extends IChildRootProperty {
  70940. /**
  70941. * 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
  70942. */
  70943. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70944. /**
  70945. * The normal map texture
  70946. */
  70947. normalTexture?: IMaterialNormalTextureInfo;
  70948. /**
  70949. * The occlusion map texture
  70950. */
  70951. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70952. /**
  70953. * The emissive map texture
  70954. */
  70955. emissiveTexture?: ITextureInfo;
  70956. /**
  70957. * 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
  70958. */
  70959. emissiveFactor?: number[];
  70960. /**
  70961. * The alpha rendering mode of the material
  70962. */
  70963. alphaMode?: MaterialAlphaMode;
  70964. /**
  70965. * The alpha cutoff value of the material
  70966. */
  70967. alphaCutoff?: number;
  70968. /**
  70969. * Specifies whether the material is double sided
  70970. */
  70971. doubleSided?: boolean;
  70972. }
  70973. /**
  70974. * Geometry to be rendered with the given material
  70975. */
  70976. interface IMeshPrimitive extends IProperty {
  70977. /**
  70978. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70979. */
  70980. attributes: {
  70981. [name: string]: number;
  70982. };
  70983. /**
  70984. * The index of the accessor that contains the indices
  70985. */
  70986. indices?: number;
  70987. /**
  70988. * The index of the material to apply to this primitive when rendering
  70989. */
  70990. material?: number;
  70991. /**
  70992. * The type of primitives to render. All valid values correspond to WebGL enums
  70993. */
  70994. mode?: MeshPrimitiveMode;
  70995. /**
  70996. * 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
  70997. */
  70998. targets?: {
  70999. [name: string]: number;
  71000. }[];
  71001. }
  71002. /**
  71003. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71004. */
  71005. interface IMesh extends IChildRootProperty {
  71006. /**
  71007. * An array of primitives, each defining geometry to be rendered with a material
  71008. */
  71009. primitives: IMeshPrimitive[];
  71010. /**
  71011. * Array of weights to be applied to the Morph Targets
  71012. */
  71013. weights?: number[];
  71014. }
  71015. /**
  71016. * A node in the node hierarchy
  71017. */
  71018. interface INode extends IChildRootProperty {
  71019. /**
  71020. * The index of the camera referenced by this node
  71021. */
  71022. camera?: number;
  71023. /**
  71024. * The indices of this node's children
  71025. */
  71026. children?: number[];
  71027. /**
  71028. * The index of the skin referenced by this node
  71029. */
  71030. skin?: number;
  71031. /**
  71032. * A floating-point 4x4 transformation matrix stored in column-major order
  71033. */
  71034. matrix?: number[];
  71035. /**
  71036. * The index of the mesh in this node
  71037. */
  71038. mesh?: number;
  71039. /**
  71040. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71041. */
  71042. rotation?: number[];
  71043. /**
  71044. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71045. */
  71046. scale?: number[];
  71047. /**
  71048. * The node's translation along the x, y, and z axes
  71049. */
  71050. translation?: number[];
  71051. /**
  71052. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71053. */
  71054. weights?: number[];
  71055. }
  71056. /**
  71057. * Texture sampler properties for filtering and wrapping modes
  71058. */
  71059. interface ISampler extends IChildRootProperty {
  71060. /**
  71061. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71062. */
  71063. magFilter?: TextureMagFilter;
  71064. /**
  71065. * Minification filter. All valid values correspond to WebGL enums
  71066. */
  71067. minFilter?: TextureMinFilter;
  71068. /**
  71069. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71070. */
  71071. wrapS?: TextureWrapMode;
  71072. /**
  71073. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71074. */
  71075. wrapT?: TextureWrapMode;
  71076. }
  71077. /**
  71078. * The root nodes of a scene
  71079. */
  71080. interface IScene extends IChildRootProperty {
  71081. /**
  71082. * The indices of each root node
  71083. */
  71084. nodes: number[];
  71085. }
  71086. /**
  71087. * Joints and matrices defining a skin
  71088. */
  71089. interface ISkin extends IChildRootProperty {
  71090. /**
  71091. * 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
  71092. */
  71093. inverseBindMatrices?: number;
  71094. /**
  71095. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71096. */
  71097. skeleton?: number;
  71098. /**
  71099. * 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)
  71100. */
  71101. joints: number[];
  71102. }
  71103. /**
  71104. * A texture and its sampler
  71105. */
  71106. interface ITexture extends IChildRootProperty {
  71107. /**
  71108. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71109. */
  71110. sampler?: number;
  71111. /**
  71112. * The index of the image used by this texture
  71113. */
  71114. source: number;
  71115. }
  71116. /**
  71117. * Reference to a texture
  71118. */
  71119. interface ITextureInfo extends IProperty {
  71120. /**
  71121. * The index of the texture
  71122. */
  71123. index: number;
  71124. /**
  71125. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71126. */
  71127. texCoord?: number;
  71128. }
  71129. /**
  71130. * The root object for a glTF asset
  71131. */
  71132. interface IGLTF extends IProperty {
  71133. /**
  71134. * An array of accessors. An accessor is a typed view into a bufferView
  71135. */
  71136. accessors?: IAccessor[];
  71137. /**
  71138. * An array of keyframe animations
  71139. */
  71140. animations?: IAnimation[];
  71141. /**
  71142. * Metadata about the glTF asset
  71143. */
  71144. asset: IAsset;
  71145. /**
  71146. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71147. */
  71148. buffers?: IBuffer[];
  71149. /**
  71150. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71151. */
  71152. bufferViews?: IBufferView[];
  71153. /**
  71154. * An array of cameras
  71155. */
  71156. cameras?: ICamera[];
  71157. /**
  71158. * Names of glTF extensions used somewhere in this asset
  71159. */
  71160. extensionsUsed?: string[];
  71161. /**
  71162. * Names of glTF extensions required to properly load this asset
  71163. */
  71164. extensionsRequired?: string[];
  71165. /**
  71166. * An array of images. An image defines data used to create a texture
  71167. */
  71168. images?: IImage[];
  71169. /**
  71170. * An array of materials. A material defines the appearance of a primitive
  71171. */
  71172. materials?: IMaterial[];
  71173. /**
  71174. * An array of meshes. A mesh is a set of primitives to be rendered
  71175. */
  71176. meshes?: IMesh[];
  71177. /**
  71178. * An array of nodes
  71179. */
  71180. nodes?: INode[];
  71181. /**
  71182. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71183. */
  71184. samplers?: ISampler[];
  71185. /**
  71186. * The index of the default scene
  71187. */
  71188. scene?: number;
  71189. /**
  71190. * An array of scenes
  71191. */
  71192. scenes?: IScene[];
  71193. /**
  71194. * An array of skins. A skin is defined by joints and matrices
  71195. */
  71196. skins?: ISkin[];
  71197. /**
  71198. * An array of textures
  71199. */
  71200. textures?: ITexture[];
  71201. }
  71202. /**
  71203. * The glTF validation results
  71204. * @ignore
  71205. */
  71206. interface IGLTFValidationResults {
  71207. info: {
  71208. generator: string;
  71209. hasAnimations: boolean;
  71210. hasDefaultScene: boolean;
  71211. hasMaterials: boolean;
  71212. hasMorphTargets: boolean;
  71213. hasSkins: boolean;
  71214. hasTextures: boolean;
  71215. maxAttributesUsed: number;
  71216. primitivesCount: number
  71217. };
  71218. issues: {
  71219. messages: Array<string>;
  71220. numErrors: number;
  71221. numHints: number;
  71222. numInfos: number;
  71223. numWarnings: number;
  71224. truncated: boolean
  71225. };
  71226. mimeType: string;
  71227. uri: string;
  71228. validatedAt: string;
  71229. validatorVersion: string;
  71230. }
  71231. /**
  71232. * The glTF validation options
  71233. */
  71234. interface IGLTFValidationOptions {
  71235. /** Uri to use */
  71236. uri?: string;
  71237. /** Function used to load external resources */
  71238. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71239. /** Boolean indicating that we need to validate accessor data */
  71240. validateAccessorData?: boolean;
  71241. /** max number of issues allowed */
  71242. maxIssues?: number;
  71243. /** Ignored issues */
  71244. ignoredIssues?: Array<string>;
  71245. /** Value to override severy settings */
  71246. severityOverrides?: Object;
  71247. }
  71248. /**
  71249. * The glTF validator object
  71250. * @ignore
  71251. */
  71252. interface IGLTFValidator {
  71253. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71254. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71255. }
  71256. }
  71257. declare module BABYLON {
  71258. /** @hidden */
  71259. export var cellPixelShader: {
  71260. name: string;
  71261. shader: string;
  71262. };
  71263. }
  71264. declare module BABYLON {
  71265. /** @hidden */
  71266. export var cellVertexShader: {
  71267. name: string;
  71268. shader: string;
  71269. };
  71270. }
  71271. declare module BABYLON {
  71272. export class CellMaterial extends BABYLON.PushMaterial {
  71273. private _diffuseTexture;
  71274. diffuseTexture: BABYLON.BaseTexture;
  71275. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  71276. computeHighLevel: boolean;
  71277. private _disableLighting;
  71278. disableLighting: boolean;
  71279. private _maxSimultaneousLights;
  71280. maxSimultaneousLights: number;
  71281. private _renderId;
  71282. constructor(name: string, scene: BABYLON.Scene);
  71283. needAlphaBlending(): boolean;
  71284. needAlphaTesting(): boolean;
  71285. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71286. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71287. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71288. getAnimatables(): BABYLON.IAnimatable[];
  71289. getActiveTextures(): BABYLON.BaseTexture[];
  71290. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71291. dispose(forceDisposeEffect?: boolean): void;
  71292. getClassName(): string;
  71293. clone(name: string): CellMaterial;
  71294. serialize(): any;
  71295. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71296. }
  71297. }
  71298. declare module BABYLON {
  71299. export class CustomShaderStructure {
  71300. FragmentStore: string;
  71301. VertexStore: string;
  71302. constructor();
  71303. }
  71304. export class ShaderSpecialParts {
  71305. constructor();
  71306. Fragment_Begin: string;
  71307. Fragment_Definitions: string;
  71308. Fragment_MainBegin: string;
  71309. Fragment_Custom_Diffuse: string;
  71310. Fragment_Before_Lights: string;
  71311. Fragment_Before_Fog: string;
  71312. Fragment_Custom_Alpha: string;
  71313. Fragment_Before_FragColor: string;
  71314. Vertex_Begin: string;
  71315. Vertex_Definitions: string;
  71316. Vertex_MainBegin: string;
  71317. Vertex_Before_PositionUpdated: string;
  71318. Vertex_Before_NormalUpdated: string;
  71319. Vertex_MainEnd: string;
  71320. }
  71321. export class CustomMaterial extends BABYLON.StandardMaterial {
  71322. static ShaderIndexer: number;
  71323. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71324. FragmentShader: string;
  71325. VertexShader: string;
  71326. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71327. ReviewUniform(name: string, arr: string[]): string[];
  71328. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71329. constructor(name: string, scene: BABYLON.Scene);
  71330. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71331. Fragment_Begin(shaderPart: string): CustomMaterial;
  71332. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71333. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71334. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71335. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71336. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71337. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71338. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71339. Vertex_Begin(shaderPart: string): CustomMaterial;
  71340. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71341. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71342. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71343. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71344. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71345. }
  71346. }
  71347. declare module BABYLON {
  71348. export class ShaderAlebdoParts {
  71349. constructor();
  71350. Fragment_Begin: string;
  71351. Fragment_Definitions: string;
  71352. Fragment_MainBegin: string;
  71353. Fragment_Custom_Albedo: string;
  71354. Fragment_Before_Lights: string;
  71355. Fragment_Custom_MetallicRoughness: string;
  71356. Fragment_Custom_MicroSurface: string;
  71357. Fragment_Before_Fog: string;
  71358. Fragment_Custom_Alpha: string;
  71359. Fragment_Before_FragColor: string;
  71360. Vertex_Begin: string;
  71361. Vertex_Definitions: string;
  71362. Vertex_MainBegin: string;
  71363. Vertex_Before_PositionUpdated: string;
  71364. Vertex_Before_NormalUpdated: string;
  71365. Vertex_MainEnd: string;
  71366. }
  71367. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71368. static ShaderIndexer: number;
  71369. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71370. FragmentShader: string;
  71371. VertexShader: string;
  71372. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71373. ReviewUniform(name: string, arr: string[]): string[];
  71374. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71375. constructor(name: string, scene: BABYLON.Scene);
  71376. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71377. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71378. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71379. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71380. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71381. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71382. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71383. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71384. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71385. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71386. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71387. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71388. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71389. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71390. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71391. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71392. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71393. }
  71394. }
  71395. declare module BABYLON {
  71396. /** @hidden */
  71397. export var firePixelShader: {
  71398. name: string;
  71399. shader: string;
  71400. };
  71401. }
  71402. declare module BABYLON {
  71403. /** @hidden */
  71404. export var fireVertexShader: {
  71405. name: string;
  71406. shader: string;
  71407. };
  71408. }
  71409. declare module BABYLON {
  71410. export class FireMaterial extends BABYLON.PushMaterial {
  71411. private _diffuseTexture;
  71412. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71413. private _distortionTexture;
  71414. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71415. private _opacityTexture;
  71416. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71417. diffuseColor: BABYLON.Color3;
  71418. speed: number;
  71419. private _scaledDiffuse;
  71420. private _renderId;
  71421. private _lastTime;
  71422. constructor(name: string, scene: BABYLON.Scene);
  71423. needAlphaBlending(): boolean;
  71424. needAlphaTesting(): boolean;
  71425. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71426. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71427. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71428. getAnimatables(): BABYLON.IAnimatable[];
  71429. getActiveTextures(): BABYLON.BaseTexture[];
  71430. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71431. getClassName(): string;
  71432. dispose(forceDisposeEffect?: boolean): void;
  71433. clone(name: string): FireMaterial;
  71434. serialize(): any;
  71435. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71436. }
  71437. }
  71438. declare module BABYLON {
  71439. /** @hidden */
  71440. export var furPixelShader: {
  71441. name: string;
  71442. shader: string;
  71443. };
  71444. }
  71445. declare module BABYLON {
  71446. /** @hidden */
  71447. export var furVertexShader: {
  71448. name: string;
  71449. shader: string;
  71450. };
  71451. }
  71452. declare module BABYLON {
  71453. export class FurMaterial extends BABYLON.PushMaterial {
  71454. private _diffuseTexture;
  71455. diffuseTexture: BABYLON.BaseTexture;
  71456. private _heightTexture;
  71457. heightTexture: BABYLON.BaseTexture;
  71458. diffuseColor: BABYLON.Color3;
  71459. furLength: number;
  71460. furAngle: number;
  71461. furColor: BABYLON.Color3;
  71462. furOffset: number;
  71463. furSpacing: number;
  71464. furGravity: BABYLON.Vector3;
  71465. furSpeed: number;
  71466. furDensity: number;
  71467. furOcclusion: number;
  71468. furTexture: BABYLON.DynamicTexture;
  71469. private _disableLighting;
  71470. disableLighting: boolean;
  71471. private _maxSimultaneousLights;
  71472. maxSimultaneousLights: number;
  71473. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  71474. private _renderId;
  71475. private _furTime;
  71476. constructor(name: string, scene: BABYLON.Scene);
  71477. furTime: number;
  71478. needAlphaBlending(): boolean;
  71479. needAlphaTesting(): boolean;
  71480. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71481. updateFur(): void;
  71482. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71483. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71484. getAnimatables(): BABYLON.IAnimatable[];
  71485. getActiveTextures(): BABYLON.BaseTexture[];
  71486. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71487. dispose(forceDisposeEffect?: boolean): void;
  71488. clone(name: string): FurMaterial;
  71489. serialize(): any;
  71490. getClassName(): string;
  71491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71492. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71493. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71494. }
  71495. }
  71496. declare module BABYLON {
  71497. /** @hidden */
  71498. export var gradientPixelShader: {
  71499. name: string;
  71500. shader: string;
  71501. };
  71502. }
  71503. declare module BABYLON {
  71504. /** @hidden */
  71505. export var gradientVertexShader: {
  71506. name: string;
  71507. shader: string;
  71508. };
  71509. }
  71510. declare module BABYLON {
  71511. export class GradientMaterial extends BABYLON.PushMaterial {
  71512. private _maxSimultaneousLights;
  71513. maxSimultaneousLights: number;
  71514. topColor: BABYLON.Color3;
  71515. topColorAlpha: number;
  71516. bottomColor: BABYLON.Color3;
  71517. bottomColorAlpha: number;
  71518. offset: number;
  71519. scale: number;
  71520. smoothness: number;
  71521. private _disableLighting;
  71522. disableLighting: boolean;
  71523. private _renderId;
  71524. constructor(name: string, scene: BABYLON.Scene);
  71525. needAlphaBlending(): boolean;
  71526. needAlphaTesting(): boolean;
  71527. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71528. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71529. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71530. getAnimatables(): BABYLON.IAnimatable[];
  71531. dispose(forceDisposeEffect?: boolean): void;
  71532. clone(name: string): GradientMaterial;
  71533. serialize(): any;
  71534. getClassName(): string;
  71535. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71536. }
  71537. }
  71538. declare module BABYLON {
  71539. /** @hidden */
  71540. export var gridPixelShader: {
  71541. name: string;
  71542. shader: string;
  71543. };
  71544. }
  71545. declare module BABYLON {
  71546. /** @hidden */
  71547. export var gridVertexShader: {
  71548. name: string;
  71549. shader: string;
  71550. };
  71551. }
  71552. declare module BABYLON {
  71553. /**
  71554. * The grid materials allows you to wrap any shape with a grid.
  71555. * Colors are customizable.
  71556. */
  71557. export class GridMaterial extends BABYLON.PushMaterial {
  71558. /**
  71559. * Main color of the grid (e.g. between lines)
  71560. */
  71561. mainColor: BABYLON.Color3;
  71562. /**
  71563. * Color of the grid lines.
  71564. */
  71565. lineColor: BABYLON.Color3;
  71566. /**
  71567. * The scale of the grid compared to unit.
  71568. */
  71569. gridRatio: number;
  71570. /**
  71571. * Allows setting an offset for the grid lines.
  71572. */
  71573. gridOffset: BABYLON.Vector3;
  71574. /**
  71575. * The frequency of thicker lines.
  71576. */
  71577. majorUnitFrequency: number;
  71578. /**
  71579. * The visibility of minor units in the grid.
  71580. */
  71581. minorUnitVisibility: number;
  71582. /**
  71583. * The grid opacity outside of the lines.
  71584. */
  71585. opacity: number;
  71586. /**
  71587. * Determine RBG output is premultiplied by alpha value.
  71588. */
  71589. preMultiplyAlpha: boolean;
  71590. private _opacityTexture;
  71591. opacityTexture: BABYLON.BaseTexture;
  71592. private _gridControl;
  71593. private _renderId;
  71594. /**
  71595. * constructor
  71596. * @param name The name given to the material in order to identify it afterwards.
  71597. * @param scene The scene the material is used in.
  71598. */
  71599. constructor(name: string, scene: BABYLON.Scene);
  71600. /**
  71601. * Returns wehter or not the grid requires alpha blending.
  71602. */
  71603. needAlphaBlending(): boolean;
  71604. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71605. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71606. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71607. /**
  71608. * Dispose the material and its associated resources.
  71609. * @param forceDisposeEffect will also dispose the used effect when true
  71610. */
  71611. dispose(forceDisposeEffect?: boolean): void;
  71612. clone(name: string): GridMaterial;
  71613. serialize(): any;
  71614. getClassName(): string;
  71615. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71616. }
  71617. }
  71618. declare module BABYLON {
  71619. /** @hidden */
  71620. export var lavaPixelShader: {
  71621. name: string;
  71622. shader: string;
  71623. };
  71624. }
  71625. declare module BABYLON {
  71626. /** @hidden */
  71627. export var lavaVertexShader: {
  71628. name: string;
  71629. shader: string;
  71630. };
  71631. }
  71632. declare module BABYLON {
  71633. export class LavaMaterial extends BABYLON.PushMaterial {
  71634. private _diffuseTexture;
  71635. diffuseTexture: BABYLON.BaseTexture;
  71636. noiseTexture: BABYLON.BaseTexture;
  71637. fogColor: BABYLON.Color3;
  71638. speed: number;
  71639. movingSpeed: number;
  71640. lowFrequencySpeed: number;
  71641. fogDensity: number;
  71642. private _lastTime;
  71643. diffuseColor: BABYLON.Color3;
  71644. private _disableLighting;
  71645. disableLighting: boolean;
  71646. private _unlit;
  71647. unlit: boolean;
  71648. private _maxSimultaneousLights;
  71649. maxSimultaneousLights: number;
  71650. private _scaledDiffuse;
  71651. private _renderId;
  71652. constructor(name: string, scene: BABYLON.Scene);
  71653. needAlphaBlending(): boolean;
  71654. needAlphaTesting(): boolean;
  71655. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71656. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71657. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71658. getAnimatables(): BABYLON.IAnimatable[];
  71659. getActiveTextures(): BABYLON.BaseTexture[];
  71660. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71661. dispose(forceDisposeEffect?: boolean): void;
  71662. clone(name: string): LavaMaterial;
  71663. serialize(): any;
  71664. getClassName(): string;
  71665. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71666. }
  71667. }
  71668. declare module BABYLON {
  71669. /** @hidden */
  71670. export var mixPixelShader: {
  71671. name: string;
  71672. shader: string;
  71673. };
  71674. }
  71675. declare module BABYLON {
  71676. /** @hidden */
  71677. export var mixVertexShader: {
  71678. name: string;
  71679. shader: string;
  71680. };
  71681. }
  71682. declare module BABYLON {
  71683. export class MixMaterial extends BABYLON.PushMaterial {
  71684. /**
  71685. * Mix textures
  71686. */
  71687. private _mixTexture1;
  71688. mixTexture1: BABYLON.BaseTexture;
  71689. private _mixTexture2;
  71690. mixTexture2: BABYLON.BaseTexture;
  71691. /**
  71692. * Diffuse textures
  71693. */
  71694. private _diffuseTexture1;
  71695. diffuseTexture1: BABYLON.Texture;
  71696. private _diffuseTexture2;
  71697. diffuseTexture2: BABYLON.Texture;
  71698. private _diffuseTexture3;
  71699. diffuseTexture3: BABYLON.Texture;
  71700. private _diffuseTexture4;
  71701. diffuseTexture4: BABYLON.Texture;
  71702. private _diffuseTexture5;
  71703. diffuseTexture5: BABYLON.Texture;
  71704. private _diffuseTexture6;
  71705. diffuseTexture6: BABYLON.Texture;
  71706. private _diffuseTexture7;
  71707. diffuseTexture7: BABYLON.Texture;
  71708. private _diffuseTexture8;
  71709. diffuseTexture8: BABYLON.Texture;
  71710. /**
  71711. * Uniforms
  71712. */
  71713. diffuseColor: BABYLON.Color3;
  71714. specularColor: BABYLON.Color3;
  71715. specularPower: number;
  71716. private _disableLighting;
  71717. disableLighting: boolean;
  71718. private _maxSimultaneousLights;
  71719. maxSimultaneousLights: number;
  71720. private _renderId;
  71721. constructor(name: string, scene: BABYLON.Scene);
  71722. needAlphaBlending(): boolean;
  71723. needAlphaTesting(): boolean;
  71724. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71725. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71726. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71727. getAnimatables(): BABYLON.IAnimatable[];
  71728. getActiveTextures(): BABYLON.BaseTexture[];
  71729. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71730. dispose(forceDisposeEffect?: boolean): void;
  71731. clone(name: string): MixMaterial;
  71732. serialize(): any;
  71733. getClassName(): string;
  71734. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71735. }
  71736. }
  71737. declare module BABYLON {
  71738. /** @hidden */
  71739. export var normalPixelShader: {
  71740. name: string;
  71741. shader: string;
  71742. };
  71743. }
  71744. declare module BABYLON {
  71745. /** @hidden */
  71746. export var normalVertexShader: {
  71747. name: string;
  71748. shader: string;
  71749. };
  71750. }
  71751. declare module BABYLON {
  71752. export class NormalMaterial extends BABYLON.PushMaterial {
  71753. private _diffuseTexture;
  71754. diffuseTexture: BABYLON.BaseTexture;
  71755. diffuseColor: BABYLON.Color3;
  71756. private _disableLighting;
  71757. disableLighting: boolean;
  71758. private _maxSimultaneousLights;
  71759. maxSimultaneousLights: number;
  71760. private _renderId;
  71761. constructor(name: string, scene: BABYLON.Scene);
  71762. needAlphaBlending(): boolean;
  71763. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71764. needAlphaTesting(): boolean;
  71765. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71766. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71767. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71768. getAnimatables(): BABYLON.IAnimatable[];
  71769. getActiveTextures(): BABYLON.BaseTexture[];
  71770. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71771. dispose(forceDisposeEffect?: boolean): void;
  71772. clone(name: string): NormalMaterial;
  71773. serialize(): any;
  71774. getClassName(): string;
  71775. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71776. }
  71777. }
  71778. declare module BABYLON {
  71779. /** @hidden */
  71780. export var shadowOnlyPixelShader: {
  71781. name: string;
  71782. shader: string;
  71783. };
  71784. }
  71785. declare module BABYLON {
  71786. /** @hidden */
  71787. export var shadowOnlyVertexShader: {
  71788. name: string;
  71789. shader: string;
  71790. };
  71791. }
  71792. declare module BABYLON {
  71793. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71794. private _renderId;
  71795. private _activeLight;
  71796. constructor(name: string, scene: BABYLON.Scene);
  71797. shadowColor: BABYLON.Color3;
  71798. needAlphaBlending(): boolean;
  71799. needAlphaTesting(): boolean;
  71800. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71801. activeLight: BABYLON.IShadowLight;
  71802. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71803. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71804. clone(name: string): ShadowOnlyMaterial;
  71805. serialize(): any;
  71806. getClassName(): string;
  71807. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71808. }
  71809. }
  71810. declare module BABYLON {
  71811. /** @hidden */
  71812. export var simplePixelShader: {
  71813. name: string;
  71814. shader: string;
  71815. };
  71816. }
  71817. declare module BABYLON {
  71818. /** @hidden */
  71819. export var simpleVertexShader: {
  71820. name: string;
  71821. shader: string;
  71822. };
  71823. }
  71824. declare module BABYLON {
  71825. export class SimpleMaterial extends BABYLON.PushMaterial {
  71826. private _diffuseTexture;
  71827. diffuseTexture: BABYLON.BaseTexture;
  71828. diffuseColor: BABYLON.Color3;
  71829. private _disableLighting;
  71830. disableLighting: boolean;
  71831. private _maxSimultaneousLights;
  71832. maxSimultaneousLights: number;
  71833. private _renderId;
  71834. constructor(name: string, scene: BABYLON.Scene);
  71835. needAlphaBlending(): boolean;
  71836. needAlphaTesting(): boolean;
  71837. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71838. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71839. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71840. getAnimatables(): BABYLON.IAnimatable[];
  71841. getActiveTextures(): BABYLON.BaseTexture[];
  71842. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71843. dispose(forceDisposeEffect?: boolean): void;
  71844. clone(name: string): SimpleMaterial;
  71845. serialize(): any;
  71846. getClassName(): string;
  71847. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71848. }
  71849. }
  71850. declare module BABYLON {
  71851. /** @hidden */
  71852. export var skyPixelShader: {
  71853. name: string;
  71854. shader: string;
  71855. };
  71856. }
  71857. declare module BABYLON {
  71858. /** @hidden */
  71859. export var skyVertexShader: {
  71860. name: string;
  71861. shader: string;
  71862. };
  71863. }
  71864. declare module BABYLON {
  71865. /**
  71866. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71867. * @see https://doc.babylonjs.com/extensions/sky
  71868. */
  71869. export class SkyMaterial extends BABYLON.PushMaterial {
  71870. /**
  71871. * Defines the overall luminance of sky in interval ]0, 1[.
  71872. */
  71873. luminance: number;
  71874. /**
  71875. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71876. */
  71877. turbidity: number;
  71878. /**
  71879. * Defines the sky appearance (light intensity).
  71880. */
  71881. rayleigh: number;
  71882. /**
  71883. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71884. */
  71885. mieCoefficient: number;
  71886. /**
  71887. * Defines the amount of haze particles following the Mie scattering theory.
  71888. */
  71889. mieDirectionalG: number;
  71890. /**
  71891. * Defines the distance of the sun according to the active scene camera.
  71892. */
  71893. distance: number;
  71894. /**
  71895. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71896. * "inclined".
  71897. */
  71898. inclination: number;
  71899. /**
  71900. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71901. * an object direction and a reference direction.
  71902. */
  71903. azimuth: number;
  71904. /**
  71905. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71906. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71907. */
  71908. sunPosition: BABYLON.Vector3;
  71909. /**
  71910. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71911. * .sunPosition property.
  71912. */
  71913. useSunPosition: boolean;
  71914. /**
  71915. * Defines an offset vector used to get a horizon offset.
  71916. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71917. */
  71918. cameraOffset: BABYLON.Vector3;
  71919. private _cameraPosition;
  71920. private _renderId;
  71921. /**
  71922. * Instantiates a new sky material.
  71923. * This material allows to create dynamic and texture free
  71924. * effects for skyboxes by taking care of the atmosphere state.
  71925. * @see https://doc.babylonjs.com/extensions/sky
  71926. * @param name Define the name of the material in the scene
  71927. * @param scene Define the scene the material belong to
  71928. */
  71929. constructor(name: string, scene: BABYLON.Scene);
  71930. /**
  71931. * Specifies if the material will require alpha blending
  71932. * @returns a boolean specifying if alpha blending is needed
  71933. */
  71934. needAlphaBlending(): boolean;
  71935. /**
  71936. * Specifies if this material should be rendered in alpha test mode
  71937. * @returns false as the sky material doesn't need alpha testing.
  71938. */
  71939. needAlphaTesting(): boolean;
  71940. /**
  71941. * Get the texture used for alpha test purpose.
  71942. * @returns null as the sky material has no texture.
  71943. */
  71944. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71945. /**
  71946. * Get if the submesh is ready to be used and all its information available.
  71947. * Child classes can use it to update shaders
  71948. * @param mesh defines the mesh to check
  71949. * @param subMesh defines which submesh to check
  71950. * @param useInstances specifies that instances should be used
  71951. * @returns a boolean indicating that the submesh is ready or not
  71952. */
  71953. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71954. /**
  71955. * Binds the submesh to this material by preparing the effect and shader to draw
  71956. * @param world defines the world transformation matrix
  71957. * @param mesh defines the mesh containing the submesh
  71958. * @param subMesh defines the submesh to bind the material to
  71959. */
  71960. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71961. /**
  71962. * Get the list of animatables in the material.
  71963. * @returns the list of animatables object used in the material
  71964. */
  71965. getAnimatables(): BABYLON.IAnimatable[];
  71966. /**
  71967. * Disposes the material
  71968. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71969. */
  71970. dispose(forceDisposeEffect?: boolean): void;
  71971. /**
  71972. * Makes a duplicate of the material, and gives it a new name
  71973. * @param name defines the new name for the duplicated material
  71974. * @returns the cloned material
  71975. */
  71976. clone(name: string): SkyMaterial;
  71977. /**
  71978. * Serializes this material in a JSON representation
  71979. * @returns the serialized material object
  71980. */
  71981. serialize(): any;
  71982. /**
  71983. * Gets the current class name of the material e.g. "SkyMaterial"
  71984. * Mainly use in serialization.
  71985. * @returns the class name
  71986. */
  71987. getClassName(): string;
  71988. /**
  71989. * Creates a sky material from parsed material data
  71990. * @param source defines the JSON representation of the material
  71991. * @param scene defines the hosting scene
  71992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71993. * @returns a new sky material
  71994. */
  71995. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71996. }
  71997. }
  71998. declare module BABYLON {
  71999. /** @hidden */
  72000. export var terrainPixelShader: {
  72001. name: string;
  72002. shader: string;
  72003. };
  72004. }
  72005. declare module BABYLON {
  72006. /** @hidden */
  72007. export var terrainVertexShader: {
  72008. name: string;
  72009. shader: string;
  72010. };
  72011. }
  72012. declare module BABYLON {
  72013. export class TerrainMaterial extends BABYLON.PushMaterial {
  72014. private _mixTexture;
  72015. mixTexture: BABYLON.BaseTexture;
  72016. private _diffuseTexture1;
  72017. diffuseTexture1: BABYLON.Texture;
  72018. private _diffuseTexture2;
  72019. diffuseTexture2: BABYLON.Texture;
  72020. private _diffuseTexture3;
  72021. diffuseTexture3: BABYLON.Texture;
  72022. private _bumpTexture1;
  72023. bumpTexture1: BABYLON.Texture;
  72024. private _bumpTexture2;
  72025. bumpTexture2: BABYLON.Texture;
  72026. private _bumpTexture3;
  72027. bumpTexture3: BABYLON.Texture;
  72028. diffuseColor: BABYLON.Color3;
  72029. specularColor: BABYLON.Color3;
  72030. specularPower: number;
  72031. private _disableLighting;
  72032. disableLighting: boolean;
  72033. private _maxSimultaneousLights;
  72034. maxSimultaneousLights: number;
  72035. private _renderId;
  72036. constructor(name: string, scene: BABYLON.Scene);
  72037. needAlphaBlending(): boolean;
  72038. needAlphaTesting(): boolean;
  72039. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72040. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72041. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72042. getAnimatables(): BABYLON.IAnimatable[];
  72043. getActiveTextures(): BABYLON.BaseTexture[];
  72044. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72045. dispose(forceDisposeEffect?: boolean): void;
  72046. clone(name: string): TerrainMaterial;
  72047. serialize(): any;
  72048. getClassName(): string;
  72049. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72050. }
  72051. }
  72052. declare module BABYLON {
  72053. /** @hidden */
  72054. export var triplanarPixelShader: {
  72055. name: string;
  72056. shader: string;
  72057. };
  72058. }
  72059. declare module BABYLON {
  72060. /** @hidden */
  72061. export var triplanarVertexShader: {
  72062. name: string;
  72063. shader: string;
  72064. };
  72065. }
  72066. declare module BABYLON {
  72067. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72068. mixTexture: BABYLON.BaseTexture;
  72069. private _diffuseTextureX;
  72070. diffuseTextureX: BABYLON.BaseTexture;
  72071. private _diffuseTextureY;
  72072. diffuseTextureY: BABYLON.BaseTexture;
  72073. private _diffuseTextureZ;
  72074. diffuseTextureZ: BABYLON.BaseTexture;
  72075. private _normalTextureX;
  72076. normalTextureX: BABYLON.BaseTexture;
  72077. private _normalTextureY;
  72078. normalTextureY: BABYLON.BaseTexture;
  72079. private _normalTextureZ;
  72080. normalTextureZ: BABYLON.BaseTexture;
  72081. tileSize: number;
  72082. diffuseColor: BABYLON.Color3;
  72083. specularColor: BABYLON.Color3;
  72084. specularPower: number;
  72085. private _disableLighting;
  72086. disableLighting: boolean;
  72087. private _maxSimultaneousLights;
  72088. maxSimultaneousLights: number;
  72089. private _renderId;
  72090. constructor(name: string, scene: BABYLON.Scene);
  72091. needAlphaBlending(): boolean;
  72092. needAlphaTesting(): boolean;
  72093. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72094. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72095. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72096. getAnimatables(): BABYLON.IAnimatable[];
  72097. getActiveTextures(): BABYLON.BaseTexture[];
  72098. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72099. dispose(forceDisposeEffect?: boolean): void;
  72100. clone(name: string): TriPlanarMaterial;
  72101. serialize(): any;
  72102. getClassName(): string;
  72103. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72104. }
  72105. }
  72106. declare module BABYLON {
  72107. /** @hidden */
  72108. export var waterPixelShader: {
  72109. name: string;
  72110. shader: string;
  72111. };
  72112. }
  72113. declare module BABYLON {
  72114. /** @hidden */
  72115. export var waterVertexShader: {
  72116. name: string;
  72117. shader: string;
  72118. };
  72119. }
  72120. declare module BABYLON {
  72121. export class WaterMaterial extends BABYLON.PushMaterial {
  72122. renderTargetSize: BABYLON.Vector2;
  72123. private _bumpTexture;
  72124. bumpTexture: BABYLON.BaseTexture;
  72125. diffuseColor: BABYLON.Color3;
  72126. specularColor: BABYLON.Color3;
  72127. specularPower: number;
  72128. private _disableLighting;
  72129. disableLighting: boolean;
  72130. private _maxSimultaneousLights;
  72131. maxSimultaneousLights: number;
  72132. /**
  72133. * @param {number}: Represents the wind force
  72134. */
  72135. windForce: number;
  72136. /**
  72137. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72138. */
  72139. windDirection: BABYLON.Vector2;
  72140. /**
  72141. * @param {number}: Wave height, represents the height of the waves
  72142. */
  72143. waveHeight: number;
  72144. /**
  72145. * @param {number}: Bump height, represents the bump height related to the bump map
  72146. */
  72147. bumpHeight: number;
  72148. /**
  72149. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72150. */
  72151. private _bumpSuperimpose;
  72152. bumpSuperimpose: boolean;
  72153. /**
  72154. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72155. */
  72156. private _fresnelSeparate;
  72157. fresnelSeparate: boolean;
  72158. /**
  72159. * @param {boolean}: bump Waves modify the reflection.
  72160. */
  72161. private _bumpAffectsReflection;
  72162. bumpAffectsReflection: boolean;
  72163. /**
  72164. * @param {number}: The water color blended with the refraction (near)
  72165. */
  72166. waterColor: BABYLON.Color3;
  72167. /**
  72168. * @param {number}: The blend factor related to the water color
  72169. */
  72170. colorBlendFactor: number;
  72171. /**
  72172. * @param {number}: The water color blended with the reflection (far)
  72173. */
  72174. waterColor2: BABYLON.Color3;
  72175. /**
  72176. * @param {number}: The blend factor related to the water color (reflection, far)
  72177. */
  72178. colorBlendFactor2: number;
  72179. /**
  72180. * @param {number}: Represents the maximum length of a wave
  72181. */
  72182. waveLength: number;
  72183. /**
  72184. * @param {number}: Defines the waves speed
  72185. */
  72186. waveSpeed: number;
  72187. /**
  72188. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72189. * will avoid calculating useless pixels in the pixel shader of the water material.
  72190. */
  72191. disableClipPlane: boolean;
  72192. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72193. private _mesh;
  72194. private _refractionRTT;
  72195. private _reflectionRTT;
  72196. private _reflectionTransform;
  72197. private _lastTime;
  72198. private _lastDeltaTime;
  72199. private _renderId;
  72200. private _useLogarithmicDepth;
  72201. private _waitingRenderList;
  72202. private _imageProcessingConfiguration;
  72203. private _imageProcessingObserver;
  72204. /**
  72205. * Gets a boolean indicating that current material needs to register RTT
  72206. */
  72207. readonly hasRenderTargetTextures: boolean;
  72208. /**
  72209. * Constructor
  72210. */
  72211. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72212. useLogarithmicDepth: boolean;
  72213. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72214. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72215. addToRenderList(node: any): void;
  72216. enableRenderTargets(enable: boolean): void;
  72217. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72218. readonly renderTargetsEnabled: boolean;
  72219. needAlphaBlending(): boolean;
  72220. needAlphaTesting(): boolean;
  72221. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72222. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72223. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72224. private _createRenderTargets;
  72225. getAnimatables(): BABYLON.IAnimatable[];
  72226. getActiveTextures(): BABYLON.BaseTexture[];
  72227. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72228. dispose(forceDisposeEffect?: boolean): void;
  72229. clone(name: string): WaterMaterial;
  72230. serialize(): any;
  72231. getClassName(): string;
  72232. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72233. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72234. }
  72235. }
  72236. declare module BABYLON {
  72237. /** @hidden */
  72238. export var asciiartPixelShader: {
  72239. name: string;
  72240. shader: string;
  72241. };
  72242. }
  72243. declare module BABYLON {
  72244. /**
  72245. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72246. *
  72247. * It basically takes care rendering the font front the given font size to a texture.
  72248. * This is used later on in the postprocess.
  72249. */
  72250. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72251. private _font;
  72252. private _text;
  72253. private _charSize;
  72254. /**
  72255. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72256. */
  72257. readonly charSize: number;
  72258. /**
  72259. * Create a new instance of the Ascii Art FontTexture class
  72260. * @param name the name of the texture
  72261. * @param font the font to use, use the W3C CSS notation
  72262. * @param text the caracter set to use in the rendering.
  72263. * @param scene the scene that owns the texture
  72264. */
  72265. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72266. /**
  72267. * Gets the max char width of a font.
  72268. * @param font the font to use, use the W3C CSS notation
  72269. * @return the max char width
  72270. */
  72271. private getFontWidth;
  72272. /**
  72273. * Gets the max char height of a font.
  72274. * @param font the font to use, use the W3C CSS notation
  72275. * @return the max char height
  72276. */
  72277. private getFontHeight;
  72278. /**
  72279. * Clones the current AsciiArtTexture.
  72280. * @return the clone of the texture.
  72281. */
  72282. clone(): AsciiArtFontTexture;
  72283. /**
  72284. * Parses a json object representing the texture and returns an instance of it.
  72285. * @param source the source JSON representation
  72286. * @param scene the scene to create the texture for
  72287. * @return the parsed texture
  72288. */
  72289. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72290. }
  72291. /**
  72292. * Option available in the Ascii Art Post Process.
  72293. */
  72294. export interface IAsciiArtPostProcessOptions {
  72295. /**
  72296. * The font to use following the w3c font definition.
  72297. */
  72298. font?: string;
  72299. /**
  72300. * The character set to use in the postprocess.
  72301. */
  72302. characterSet?: string;
  72303. /**
  72304. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72305. * This number is defined between 0 and 1;
  72306. */
  72307. mixToTile?: number;
  72308. /**
  72309. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72310. * This number is defined between 0 and 1;
  72311. */
  72312. mixToNormal?: number;
  72313. }
  72314. /**
  72315. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72316. *
  72317. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72318. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72319. */
  72320. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72321. /**
  72322. * The font texture used to render the char in the post process.
  72323. */
  72324. private _asciiArtFontTexture;
  72325. /**
  72326. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72327. * This number is defined between 0 and 1;
  72328. */
  72329. mixToTile: number;
  72330. /**
  72331. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72332. * This number is defined between 0 and 1;
  72333. */
  72334. mixToNormal: number;
  72335. /**
  72336. * Instantiates a new Ascii Art Post Process.
  72337. * @param name the name to give to the postprocess
  72338. * @camera the camera to apply the post process to.
  72339. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72340. */
  72341. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72342. }
  72343. }
  72344. declare module BABYLON {
  72345. /** @hidden */
  72346. export var digitalrainPixelShader: {
  72347. name: string;
  72348. shader: string;
  72349. };
  72350. }
  72351. declare module BABYLON {
  72352. /**
  72353. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72354. *
  72355. * It basically takes care rendering the font front the given font size to a texture.
  72356. * This is used later on in the postprocess.
  72357. */
  72358. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72359. private _font;
  72360. private _text;
  72361. private _charSize;
  72362. /**
  72363. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72364. */
  72365. readonly charSize: number;
  72366. /**
  72367. * Create a new instance of the Digital Rain FontTexture class
  72368. * @param name the name of the texture
  72369. * @param font the font to use, use the W3C CSS notation
  72370. * @param text the caracter set to use in the rendering.
  72371. * @param scene the scene that owns the texture
  72372. */
  72373. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72374. /**
  72375. * Gets the max char width of a font.
  72376. * @param font the font to use, use the W3C CSS notation
  72377. * @return the max char width
  72378. */
  72379. private getFontWidth;
  72380. /**
  72381. * Gets the max char height of a font.
  72382. * @param font the font to use, use the W3C CSS notation
  72383. * @return the max char height
  72384. */
  72385. private getFontHeight;
  72386. /**
  72387. * Clones the current DigitalRainFontTexture.
  72388. * @return the clone of the texture.
  72389. */
  72390. clone(): DigitalRainFontTexture;
  72391. /**
  72392. * Parses a json object representing the texture and returns an instance of it.
  72393. * @param source the source JSON representation
  72394. * @param scene the scene to create the texture for
  72395. * @return the parsed texture
  72396. */
  72397. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72398. }
  72399. /**
  72400. * Option available in the Digital Rain Post Process.
  72401. */
  72402. export interface IDigitalRainPostProcessOptions {
  72403. /**
  72404. * The font to use following the w3c font definition.
  72405. */
  72406. font?: string;
  72407. /**
  72408. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72409. * This number is defined between 0 and 1;
  72410. */
  72411. mixToTile?: number;
  72412. /**
  72413. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72414. * This number is defined between 0 and 1;
  72415. */
  72416. mixToNormal?: number;
  72417. }
  72418. /**
  72419. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72420. *
  72421. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72422. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72423. */
  72424. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72425. /**
  72426. * The font texture used to render the char in the post process.
  72427. */
  72428. private _digitalRainFontTexture;
  72429. /**
  72430. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72431. * This number is defined between 0 and 1;
  72432. */
  72433. mixToTile: number;
  72434. /**
  72435. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72436. * This number is defined between 0 and 1;
  72437. */
  72438. mixToNormal: number;
  72439. /**
  72440. * Instantiates a new Digital Rain Post Process.
  72441. * @param name the name to give to the postprocess
  72442. * @camera the camera to apply the post process to.
  72443. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72444. */
  72445. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72446. }
  72447. }
  72448. declare module BABYLON {
  72449. /** @hidden */
  72450. export var oceanPostProcessPixelShader: {
  72451. name: string;
  72452. shader: string;
  72453. };
  72454. }
  72455. declare module BABYLON {
  72456. /**
  72457. * Option available in the Ocean Post Process.
  72458. */
  72459. export interface IOceanPostProcessOptions {
  72460. /**
  72461. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72462. */
  72463. reflectionSize?: number | {
  72464. width: number;
  72465. height: number;
  72466. } | {
  72467. ratio: number;
  72468. };
  72469. /**
  72470. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72471. */
  72472. refractionSize?: number | {
  72473. width: number;
  72474. height: number;
  72475. } | {
  72476. ratio: number;
  72477. };
  72478. }
  72479. /**
  72480. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72481. *
  72482. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72483. * Example usage:
  72484. * var pp = new OceanPostProcess("myOcean", camera);
  72485. * pp.reflectionEnabled = true;
  72486. * pp.refractionEnabled = true;
  72487. */
  72488. export class OceanPostProcess extends BABYLON.PostProcess {
  72489. /**
  72490. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72491. */
  72492. /**
  72493. * Sets weither or not the real-time reflection is enabled on the ocean.
  72494. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72495. */
  72496. reflectionEnabled: boolean;
  72497. /**
  72498. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72499. */
  72500. /**
  72501. * Sets weither or not the real-time refraction is enabled on the ocean.
  72502. * Is set to true, the refraction render target texture will be used as refraction texture.
  72503. */
  72504. refractionEnabled: boolean;
  72505. /**
  72506. * Gets wether or not the post-processes is supported by the running hardware.
  72507. * This requires draw buffer supports.
  72508. */
  72509. readonly isSupported: boolean;
  72510. /**
  72511. * This is the reflection mirror texture used to display reflections on the ocean.
  72512. * By default, render list is empty.
  72513. */
  72514. reflectionTexture: BABYLON.MirrorTexture;
  72515. /**
  72516. * This is the refraction render target texture used to display refraction on the ocean.
  72517. * By default, render list is empty.
  72518. */
  72519. refractionTexture: BABYLON.RenderTargetTexture;
  72520. private _time;
  72521. private _cameraRotation;
  72522. private _cameraViewMatrix;
  72523. private _reflectionEnabled;
  72524. private _refractionEnabled;
  72525. private _geometryRenderer;
  72526. /**
  72527. * Instantiates a new Ocean Post Process.
  72528. * @param name the name to give to the postprocess.
  72529. * @camera the camera to apply the post process to.
  72530. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72531. */
  72532. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72533. /**
  72534. * Returns the appropriate defines according to the current configuration.
  72535. */
  72536. private _getDefines;
  72537. /**
  72538. * Computes the current camera rotation as the shader requires a camera rotation.
  72539. */
  72540. private _computeCameraRotation;
  72541. }
  72542. }
  72543. declare module BABYLON {
  72544. /** @hidden */
  72545. export var brickProceduralTexturePixelShader: {
  72546. name: string;
  72547. shader: string;
  72548. };
  72549. }
  72550. declare module BABYLON {
  72551. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72552. private _numberOfBricksHeight;
  72553. private _numberOfBricksWidth;
  72554. private _jointColor;
  72555. private _brickColor;
  72556. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72557. updateShaderUniforms(): void;
  72558. numberOfBricksHeight: number;
  72559. numberOfBricksWidth: number;
  72560. jointColor: BABYLON.Color3;
  72561. brickColor: BABYLON.Color3;
  72562. /**
  72563. * Serializes this brick procedural texture
  72564. * @returns a serialized brick procedural texture object
  72565. */
  72566. serialize(): any;
  72567. /**
  72568. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72569. * @param parsedTexture defines parsed texture data
  72570. * @param scene defines the current scene
  72571. * @param rootUrl defines the root URL containing brick procedural texture information
  72572. * @returns a parsed Brick Procedural BABYLON.Texture
  72573. */
  72574. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72575. }
  72576. }
  72577. declare module BABYLON {
  72578. /** @hidden */
  72579. export var cloudProceduralTexturePixelShader: {
  72580. name: string;
  72581. shader: string;
  72582. };
  72583. }
  72584. declare module BABYLON {
  72585. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72586. private _skyColor;
  72587. private _cloudColor;
  72588. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72589. updateShaderUniforms(): void;
  72590. skyColor: BABYLON.Color4;
  72591. cloudColor: BABYLON.Color4;
  72592. /**
  72593. * Serializes this cloud procedural texture
  72594. * @returns a serialized cloud procedural texture object
  72595. */
  72596. serialize(): any;
  72597. /**
  72598. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72599. * @param parsedTexture defines parsed texture data
  72600. * @param scene defines the current scene
  72601. * @param rootUrl defines the root URL containing cloud procedural texture information
  72602. * @returns a parsed Cloud Procedural BABYLON.Texture
  72603. */
  72604. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72605. }
  72606. }
  72607. declare module BABYLON {
  72608. /** @hidden */
  72609. export var fireProceduralTexturePixelShader: {
  72610. name: string;
  72611. shader: string;
  72612. };
  72613. }
  72614. declare module BABYLON {
  72615. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72616. private _time;
  72617. private _speed;
  72618. private _autoGenerateTime;
  72619. private _fireColors;
  72620. private _alphaThreshold;
  72621. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72622. updateShaderUniforms(): void;
  72623. render(useCameraPostProcess?: boolean): void;
  72624. static readonly PurpleFireColors: BABYLON.Color3[];
  72625. static readonly GreenFireColors: BABYLON.Color3[];
  72626. static readonly RedFireColors: BABYLON.Color3[];
  72627. static readonly BlueFireColors: BABYLON.Color3[];
  72628. autoGenerateTime: boolean;
  72629. fireColors: BABYLON.Color3[];
  72630. time: number;
  72631. speed: BABYLON.Vector2;
  72632. alphaThreshold: number;
  72633. /**
  72634. * Serializes this fire procedural texture
  72635. * @returns a serialized fire procedural texture object
  72636. */
  72637. serialize(): any;
  72638. /**
  72639. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72640. * @param parsedTexture defines parsed texture data
  72641. * @param scene defines the current scene
  72642. * @param rootUrl defines the root URL containing fire procedural texture information
  72643. * @returns a parsed Fire Procedural BABYLON.Texture
  72644. */
  72645. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. /** @hidden */
  72650. export var grassProceduralTexturePixelShader: {
  72651. name: string;
  72652. shader: string;
  72653. };
  72654. }
  72655. declare module BABYLON {
  72656. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72657. private _grassColors;
  72658. private _groundColor;
  72659. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72660. updateShaderUniforms(): void;
  72661. grassColors: BABYLON.Color3[];
  72662. groundColor: BABYLON.Color3;
  72663. /**
  72664. * Serializes this grass procedural texture
  72665. * @returns a serialized grass procedural texture object
  72666. */
  72667. serialize(): any;
  72668. /**
  72669. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72670. * @param parsedTexture defines parsed texture data
  72671. * @param scene defines the current scene
  72672. * @param rootUrl defines the root URL containing grass procedural texture information
  72673. * @returns a parsed Grass Procedural BABYLON.Texture
  72674. */
  72675. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72676. }
  72677. }
  72678. declare module BABYLON {
  72679. /** @hidden */
  72680. export var marbleProceduralTexturePixelShader: {
  72681. name: string;
  72682. shader: string;
  72683. };
  72684. }
  72685. declare module BABYLON {
  72686. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72687. private _numberOfTilesHeight;
  72688. private _numberOfTilesWidth;
  72689. private _amplitude;
  72690. private _jointColor;
  72691. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72692. updateShaderUniforms(): void;
  72693. numberOfTilesHeight: number;
  72694. amplitude: number;
  72695. numberOfTilesWidth: number;
  72696. jointColor: BABYLON.Color3;
  72697. /**
  72698. * Serializes this marble procedural texture
  72699. * @returns a serialized marble procedural texture object
  72700. */
  72701. serialize(): any;
  72702. /**
  72703. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72704. * @param parsedTexture defines parsed texture data
  72705. * @param scene defines the current scene
  72706. * @param rootUrl defines the root URL containing marble procedural texture information
  72707. * @returns a parsed Marble Procedural BABYLON.Texture
  72708. */
  72709. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72710. }
  72711. }
  72712. declare module BABYLON {
  72713. /** @hidden */
  72714. export var normalMapProceduralTexturePixelShader: {
  72715. name: string;
  72716. shader: string;
  72717. };
  72718. }
  72719. declare module BABYLON {
  72720. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72721. private _baseTexture;
  72722. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72723. updateShaderUniforms(): void;
  72724. render(useCameraPostProcess?: boolean): void;
  72725. resize(size: any, generateMipMaps: any): void;
  72726. baseTexture: BABYLON.Texture;
  72727. /**
  72728. * Serializes this normal map procedural texture
  72729. * @returns a serialized normal map procedural texture object
  72730. */
  72731. serialize(): any;
  72732. /**
  72733. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72734. * @param parsedTexture defines parsed texture data
  72735. * @param scene defines the current scene
  72736. * @param rootUrl defines the root URL containing normal map procedural texture information
  72737. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72738. */
  72739. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72740. }
  72741. }
  72742. declare module BABYLON {
  72743. /** @hidden */
  72744. export var perlinNoiseProceduralTexturePixelShader: {
  72745. name: string;
  72746. shader: string;
  72747. };
  72748. }
  72749. declare module BABYLON {
  72750. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72751. time: number;
  72752. timeScale: number;
  72753. translationSpeed: number;
  72754. private _currentTranslation;
  72755. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72756. updateShaderUniforms(): void;
  72757. render(useCameraPostProcess?: boolean): void;
  72758. resize(size: any, generateMipMaps: any): void;
  72759. /**
  72760. * Serializes this perlin noise procedural texture
  72761. * @returns a serialized perlin noise procedural texture object
  72762. */
  72763. serialize(): any;
  72764. /**
  72765. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72766. * @param parsedTexture defines parsed texture data
  72767. * @param scene defines the current scene
  72768. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72769. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72770. */
  72771. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72772. }
  72773. }
  72774. declare module BABYLON {
  72775. /** @hidden */
  72776. export var roadProceduralTexturePixelShader: {
  72777. name: string;
  72778. shader: string;
  72779. };
  72780. }
  72781. declare module BABYLON {
  72782. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72783. private _roadColor;
  72784. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72785. updateShaderUniforms(): void;
  72786. roadColor: BABYLON.Color3;
  72787. /**
  72788. * Serializes this road procedural texture
  72789. * @returns a serialized road procedural texture object
  72790. */
  72791. serialize(): any;
  72792. /**
  72793. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72794. * @param parsedTexture defines parsed texture data
  72795. * @param scene defines the current scene
  72796. * @param rootUrl defines the root URL containing road procedural texture information
  72797. * @returns a parsed Road Procedural BABYLON.Texture
  72798. */
  72799. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72800. }
  72801. }
  72802. declare module BABYLON {
  72803. /** @hidden */
  72804. export var starfieldProceduralTexturePixelShader: {
  72805. name: string;
  72806. shader: string;
  72807. };
  72808. }
  72809. declare module BABYLON {
  72810. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72811. private _time;
  72812. private _alpha;
  72813. private _beta;
  72814. private _zoom;
  72815. private _formuparam;
  72816. private _stepsize;
  72817. private _tile;
  72818. private _brightness;
  72819. private _darkmatter;
  72820. private _distfading;
  72821. private _saturation;
  72822. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72823. updateShaderUniforms(): void;
  72824. time: number;
  72825. alpha: number;
  72826. beta: number;
  72827. formuparam: number;
  72828. stepsize: number;
  72829. zoom: number;
  72830. tile: number;
  72831. brightness: number;
  72832. darkmatter: number;
  72833. distfading: number;
  72834. saturation: number;
  72835. /**
  72836. * Serializes this starfield procedural texture
  72837. * @returns a serialized starfield procedural texture object
  72838. */
  72839. serialize(): any;
  72840. /**
  72841. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72842. * @param parsedTexture defines parsed texture data
  72843. * @param scene defines the current scene
  72844. * @param rootUrl defines the root URL containing startfield procedural texture information
  72845. * @returns a parsed Starfield Procedural BABYLON.Texture
  72846. */
  72847. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72848. }
  72849. }
  72850. declare module BABYLON {
  72851. /** @hidden */
  72852. export var woodProceduralTexturePixelShader: {
  72853. name: string;
  72854. shader: string;
  72855. };
  72856. }
  72857. declare module BABYLON {
  72858. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72859. private _ampScale;
  72860. private _woodColor;
  72861. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72862. updateShaderUniforms(): void;
  72863. ampScale: number;
  72864. woodColor: BABYLON.Color3;
  72865. /**
  72866. * Serializes this wood procedural texture
  72867. * @returns a serialized wood procedural texture object
  72868. */
  72869. serialize(): any;
  72870. /**
  72871. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72872. * @param parsedTexture defines parsed texture data
  72873. * @param scene defines the current scene
  72874. * @param rootUrl defines the root URL containing wood procedural texture information
  72875. * @returns a parsed Wood Procedural BABYLON.Texture
  72876. */
  72877. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72878. }
  72879. }